[gobject-introspection] Don't include machine-dependent integral types in the typelib
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Don't include machine-dependent integral types in the typelib
- Date: Fri, 9 Jul 2010 18:17:20 +0000 (UTC)
commit 5cb925b20739c04e18e94a03a3e4e68041894b03
Author: Colin Walters <walters verbum org>
Date: Wed Jul 7 14:07:17 2010 -0400
Don't include machine-dependent integral types in the typelib
Previously we had both e.g. GI_TYPE_TAG_LONG and GI_TYPE_TAG_INT64,
but in fact the typelib is already machine-specific, so it makes sense
to just encode this as a fixed type. The .gir remains abstract.
We also remove size_t from the typelib; one would never want to treat
it differently than an integer.
time_t is removed as well; while bindings like gjs had special handling
to turn it into e.g. a JS Date object, I don't think we should encourage
people to use these POSIX types in their API. Use GTimeVal or the like
instead.
Because the typelib is now really machine-specific, we need to remove
the -expected.tgirs from git. (We could potentially add a check
which wasn't just a literal diff later)
https://bugzilla.gnome.org/show_bug.cgi?id=623774
configure.ac | 7 +-
gir/Everything-1.0-expected.gir | 27 +-
gir/GIMarshallingTests-1.0-expected.gir | 32 +-
girepository/giconstantinfo.c | 21 -
girepository/gifieldinfo.c | 60 ---
girepository/girepository.c | 18 -
girepository/girffi.c | 29 --
girepository/girnode.c | 27 -
girepository/girparser.c | 69 +++-
girepository/girwriter.c | 18 -
girepository/gitypelib.c | 11 +-
girepository/gitypes.h | 50 +--
giscanner/ast.py | 16 +-
tests/scanner/BarApp-1.0-expected.tgir | 38 --
tests/scanner/GtkFrob-1.0-expected.tgir | 15 -
tests/scanner/Makefile.am | 32 +-
tests/scanner/annotation-1.0-expected.gir | 6 +-
tests/scanner/annotation-1.0-expected.tgir | 563 ---------------------
tests/scanner/drawable-1.0-expected.tgir | 72 ---
tests/scanner/foo-1.0-expected.gir | 2 +-
tests/scanner/foo-1.0-expected.tgir | 735 ----------------------------
tests/scanner/utility-1.0-expected.gir | 2 +-
tests/scanner/utility-1.0-expected.tgir | 123 -----
23 files changed, 136 insertions(+), 1837 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a63979..5f724d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -180,11 +180,14 @@ AC_SUBST(FFI_PC_CFLAGS)
AC_SUBST(FFI_PC_LIBS)
AC_SUBST(FFI_PC_PACKAGES)
-AC_CHECK_SIZEOF(time_t, [], [#include <time.h>])
+AC_CHECK_SIZEOF(char)
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
PKG_CHECK_MODULES(GIREPO, [glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0])
-# if we ever remove manual check for ffi and require .pc file, then
+# if we ever remove manual check for ffi and require .pc file, then
# just put libffi in the PKG_CHECK_MODULES(GIREPO) deps
GIREPO_LIBS="$GIREPO_LIBS $GCOV_LIBS $FFI_LIBS"
GIREPO_CFLAGS="$GIREPO_CFLAGS $FFI_CFLAGS"
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index 023f0bb..aa7de3b 100644
--- a/gir/Everything-1.0-expected.gir
+++ b/gir/Everything-1.0-expected.gir
@@ -1888,21 +1888,21 @@ call and can be released on return.</doc>
</function>
<function name="test_size" c:identifier="test_size">
<return-value transfer-ownership="none">
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</parameter>
</parameters>
</function>
<function name="test_ssize" c:identifier="test_ssize">
<return-value transfer-ownership="none">
- <type name="ssize_t" c:type="gssize"/>
+ <type name="gssize" c:type="gssize"/>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="ssize_t" c:type="gssize"/>
+ <type name="gssize" c:type="gssize"/>
</parameter>
</parameters>
</function>
@@ -1977,11 +1977,11 @@ call and can be released on return.</doc>
</function>
<function name="test_timet" c:identifier="test_timet">
<return-value transfer-ownership="none">
- <type name="time_t" c:type="time_t"/>
+ <type name="long" c:type="time_t"/>
</return-value>
<parameters>
<parameter name="in" transfer-ownership="none">
- <type name="time_t" c:type="time_t"/>
+ <type name="long" c:type="time_t"/>
</parameter>
</parameters>
</function>
@@ -2321,5 +2321,20 @@ call and can be released on return.</doc>
</parameter>
</parameters>
</function>
+ <function name="test_value_set_fundamental_object"
+ c:identifier="test_value_set_fundamental_object"
+ introspectable="0">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="value" transfer-ownership="none">
+ <type name="GObject.Value" c:type="GValue*"/>
+ </parameter>
+ <parameter name="fundamental_object" transfer-ownership="none">
+ <type name="TestFundamentalObject" c:type="TestFundamentalObject*"/>
+ </parameter>
+ </parameters>
+ </function>
</namespace>
</repository>
diff --git a/gir/GIMarshallingTests-1.0-expected.gir b/gir/GIMarshallingTests-1.0-expected.gir
index 798ecc7..164f7f1 100644
--- a/gir/GIMarshallingTests-1.0-expected.gir
+++ b/gir/GIMarshallingTests-1.0-expected.gir
@@ -2940,7 +2940,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="size" transfer-ownership="none">
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</parameter>
</parameters>
</function>
@@ -2954,7 +2954,7 @@ and/or use gtk-doc annotations. -->
direction="inout"
caller-allocates="0"
transfer-ownership="full">
- <type name="size_t" c:type="gsize*"/>
+ <type name="gsize" c:type="gsize*"/>
</parameter>
</parameters>
</function>
@@ -2967,14 +2967,14 @@ and/or use gtk-doc annotations. -->
direction="out"
caller-allocates="0"
transfer-ownership="full">
- <type name="size_t" c:type="gsize*"/>
+ <type name="gsize" c:type="gsize*"/>
</parameter>
</parameters>
</function>
<function name="size_return"
c:identifier="g_i_marshalling_tests_size_return">
<return-value transfer-ownership="none">
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</return-value>
</function>
<function name="ssize_in_max"
@@ -2984,7 +2984,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="ssize" transfer-ownership="none">
- <type name="ssize_t" c:type="gssize"/>
+ <type name="gssize" c:type="gssize"/>
</parameter>
</parameters>
</function>
@@ -2995,7 +2995,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="ssize" transfer-ownership="none">
- <type name="ssize_t" c:type="gssize"/>
+ <type name="gssize" c:type="gssize"/>
</parameter>
</parameters>
</function>
@@ -3009,7 +3009,7 @@ and/or use gtk-doc annotations. -->
direction="inout"
caller-allocates="0"
transfer-ownership="full">
- <type name="ssize_t" c:type="gssize*"/>
+ <type name="gssize" c:type="gssize*"/>
</parameter>
</parameters>
</function>
@@ -3023,7 +3023,7 @@ and/or use gtk-doc annotations. -->
direction="inout"
caller-allocates="0"
transfer-ownership="full">
- <type name="ssize_t" c:type="gssize*"/>
+ <type name="gssize" c:type="gssize*"/>
</parameter>
</parameters>
</function>
@@ -3037,7 +3037,7 @@ and/or use gtk-doc annotations. -->
direction="out"
caller-allocates="0"
transfer-ownership="full">
- <type name="ssize_t" c:type="gssize*"/>
+ <type name="gssize" c:type="gssize*"/>
</parameter>
</parameters>
</function>
@@ -3051,20 +3051,20 @@ and/or use gtk-doc annotations. -->
direction="out"
caller-allocates="0"
transfer-ownership="full">
- <type name="ssize_t" c:type="gssize*"/>
+ <type name="gssize" c:type="gssize*"/>
</parameter>
</parameters>
</function>
<function name="ssize_return_max"
c:identifier="g_i_marshalling_tests_ssize_return_max">
<return-value transfer-ownership="none">
- <type name="ssize_t" c:type="gssize"/>
+ <type name="gssize" c:type="gssize"/>
</return-value>
</function>
<function name="ssize_return_min"
c:identifier="g_i_marshalling_tests_ssize_return_min">
<return-value transfer-ownership="none">
- <type name="ssize_t" c:type="gssize"/>
+ <type name="gssize" c:type="gssize"/>
</return-value>
</function>
<function name="test_interface_test_int8_in"
@@ -3087,7 +3087,7 @@ and/or use gtk-doc annotations. -->
</return-value>
<parameters>
<parameter name="time_t_" transfer-ownership="none">
- <type name="time_t" c:type="time_t"/>
+ <type name="long" c:type="time_t"/>
</parameter>
</parameters>
</function>
@@ -3101,7 +3101,7 @@ and/or use gtk-doc annotations. -->
direction="inout"
caller-allocates="0"
transfer-ownership="full">
- <type name="time_t" c:type="time_t*"/>
+ <type name="long" c:type="time_t*"/>
</parameter>
</parameters>
</function>
@@ -3115,14 +3115,14 @@ and/or use gtk-doc annotations. -->
direction="out"
caller-allocates="0"
transfer-ownership="full">
- <type name="time_t" c:type="time_t*"/>
+ <type name="long" c:type="time_t*"/>
</parameter>
</parameters>
</function>
<function name="time_t_return"
c:identifier="g_i_marshalling_tests_time_t_return">
<return-value transfer-ownership="none">
- <type name="time_t" c:type="time_t"/>
+ <type name="long" c:type="time_t"/>
</return-value>
</function>
<function name="uint16_in" c:identifier="g_i_marshalling_tests_uint16_in">
diff --git a/girepository/giconstantinfo.c b/girepository/giconstantinfo.c
index 4a3b838..58b223f 100644
--- a/girepository/giconstantinfo.c
+++ b/girepository/giconstantinfo.c
@@ -129,27 +129,6 @@ g_constant_info_get_value (GIConstantInfo *info,
case GI_TYPE_TAG_DOUBLE:
value->v_double = *(gdouble*)&rinfo->typelib->data[blob->offset];
break;
- case GI_TYPE_TAG_TIME_T:
- value->v_long = *(long*)&rinfo->typelib->data[blob->offset];
- break;
- case GI_TYPE_TAG_SHORT:
- value->v_short = *(gshort*)&rinfo->typelib->data[blob->offset];
- break;
- case GI_TYPE_TAG_USHORT:
- value->v_ushort = *(gushort*)&rinfo->typelib->data[blob->offset];
- break;
- case GI_TYPE_TAG_INT:
- value->v_int = *(gint*)&rinfo->typelib->data[blob->offset];
- break;
- case GI_TYPE_TAG_UINT:
- value->v_uint = *(guint*)&rinfo->typelib->data[blob->offset];
- break;
- case GI_TYPE_TAG_LONG:
- value->v_long = *(glong*)&rinfo->typelib->data[blob->offset];
- break;
- case GI_TYPE_TAG_ULONG:
- value->v_ulong = *(gulong*)&rinfo->typelib->data[blob->offset];
- break;
}
}
}
diff --git a/girepository/gifieldinfo.c b/girepository/gifieldinfo.c
index 14e371f..9862a72 100644
--- a/girepository/gifieldinfo.c
+++ b/girepository/gifieldinfo.c
@@ -215,15 +215,11 @@ g_field_info_get_field (GIFieldInfo *field_info,
break;
case GI_TYPE_TAG_INT16:
case GI_TYPE_TAG_UINT16:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
value->v_uint16 = G_STRUCT_MEMBER (guint16, mem, offset);
result = TRUE;
break;
case GI_TYPE_TAG_INT32:
case GI_TYPE_TAG_UINT32:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
value->v_uint32 = G_STRUCT_MEMBER (guint32, mem, offset);
result = TRUE;
break;
@@ -232,13 +228,6 @@ g_field_info_get_field (GIFieldInfo *field_info,
value->v_uint64 = G_STRUCT_MEMBER (guint64, mem, offset);
result = TRUE;
break;
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- value->v_ulong = G_STRUCT_MEMBER (gulong, mem, offset);
- result = TRUE;
- break;
- case GI_TYPE_TAG_SSIZE:
- case GI_TYPE_TAG_SIZE:
case GI_TYPE_TAG_GTYPE:
value->v_size = G_STRUCT_MEMBER (gsize, mem, offset);
result = TRUE;
@@ -251,16 +240,6 @@ g_field_info_get_field (GIFieldInfo *field_info,
value->v_double = G_STRUCT_MEMBER (gdouble, mem, offset);
result = TRUE;
break;
- case GI_TYPE_TAG_TIME_T:
-#if SIZEOF_TIME_T == 4
- value->v_int32 = G_STRUCT_MEMBER (time_t, mem, offset);
-#elif SIZEOF_TIME_T == 8
- value->v_int64 = G_STRUCT_MEMBER (time_t, mem, offset);
-#else
-# error "Unexpected size for time_t: not 4 or 8"
-#endif
- result = TRUE;
- break;
case GI_TYPE_TAG_UTF8:
case GI_TYPE_TAG_FILENAME:
case GI_TYPE_TAG_ARRAY:
@@ -306,15 +285,11 @@ g_field_info_get_field (GIFieldInfo *field_info,
break;
case GI_TYPE_TAG_INT16:
case GI_TYPE_TAG_UINT16:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
value->v_int = (gint)G_STRUCT_MEMBER (guint16, mem, offset);
result = TRUE;
break;
case GI_TYPE_TAG_INT32:
case GI_TYPE_TAG_UINT32:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
value->v_int = (gint)G_STRUCT_MEMBER (guint32, mem, offset);
result = TRUE;
break;
@@ -323,11 +298,6 @@ g_field_info_get_field (GIFieldInfo *field_info,
value->v_int = (gint)G_STRUCT_MEMBER (guint64, mem, offset);
result = TRUE;
break;
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- value->v_int = (gint)G_STRUCT_MEMBER (gulong, mem, offset);
- result = TRUE;
- break;
default:
g_warning("Field %s: Unexpected enum storage type %s",
g_base_info_get_name ((GIBaseInfo *)field_info),
@@ -424,15 +394,11 @@ g_field_info_set_field (GIFieldInfo *field_info,
break;
case GI_TYPE_TAG_INT16:
case GI_TYPE_TAG_UINT16:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
G_STRUCT_MEMBER (guint16, mem, offset) = value->v_uint16;
result = TRUE;
break;
case GI_TYPE_TAG_INT32:
case GI_TYPE_TAG_UINT32:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
G_STRUCT_MEMBER (guint32, mem, offset) = value->v_uint32;
result = TRUE;
break;
@@ -441,13 +407,6 @@ g_field_info_set_field (GIFieldInfo *field_info,
G_STRUCT_MEMBER (guint64, mem, offset) = value->v_uint64;
result = TRUE;
break;
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- G_STRUCT_MEMBER (gulong, mem, offset)= value->v_ulong;
- result = TRUE;
- break;
- case GI_TYPE_TAG_SSIZE:
- case GI_TYPE_TAG_SIZE:
case GI_TYPE_TAG_GTYPE:
G_STRUCT_MEMBER (gsize, mem, offset) = value->v_size;
result = TRUE;
@@ -460,16 +419,6 @@ g_field_info_set_field (GIFieldInfo *field_info,
G_STRUCT_MEMBER (gdouble, mem, offset)= value->v_double;
result = TRUE;
break;
- case GI_TYPE_TAG_TIME_T:
-#if SIZEOF_TIME_T == 4
- G_STRUCT_MEMBER (time_t, mem, offset) = value->v_int32;
-#elif SIZEOF_TIME_T == 8
- G_STRUCT_MEMBER (time_t, mem, offset) = value->v_int64;
-#else
-# error "Unexpected size for time_t: not 4 or 8"
-#endif
- result = TRUE;
- break;
case GI_TYPE_TAG_UTF8:
case GI_TYPE_TAG_FILENAME:
case GI_TYPE_TAG_ARRAY:
@@ -510,15 +459,11 @@ g_field_info_set_field (GIFieldInfo *field_info,
break;
case GI_TYPE_TAG_INT16:
case GI_TYPE_TAG_UINT16:
- case GI_TYPE_TAG_SHORT:
- case GI_TYPE_TAG_USHORT:
G_STRUCT_MEMBER (guint16, mem, offset) = (guint16)value->v_int;
result = TRUE;
break;
case GI_TYPE_TAG_INT32:
case GI_TYPE_TAG_UINT32:
- case GI_TYPE_TAG_INT:
- case GI_TYPE_TAG_UINT:
G_STRUCT_MEMBER (guint32, mem, offset) = (guint32)value->v_int;
result = TRUE;
break;
@@ -527,11 +472,6 @@ g_field_info_set_field (GIFieldInfo *field_info,
G_STRUCT_MEMBER (guint64, mem, offset) = (guint64)value->v_int;
result = TRUE;
break;
- case GI_TYPE_TAG_LONG:
- case GI_TYPE_TAG_ULONG:
- G_STRUCT_MEMBER (gulong, mem, offset) = (gulong)value->v_int;
- result = TRUE;
- break;
default:
g_warning("Field %s: Unexpected enum storage type %s",
g_base_info_get_name ((GIBaseInfo *)field_info),
diff --git a/girepository/girepository.c b/girepository/girepository.c
index 66a604e..ba6756e 100644
--- a/girepository/girepository.c
+++ b/girepository/girepository.c
@@ -1319,28 +1319,10 @@ g_type_tag_to_string (GITypeTag type)
return "int64";
case GI_TYPE_TAG_UINT64:
return "uint64";
- case GI_TYPE_TAG_SHORT:
- return "short";
- case GI_TYPE_TAG_USHORT:
- return "ushort";
- case GI_TYPE_TAG_INT:
- return "int";
- case GI_TYPE_TAG_UINT:
- return "uint";
- case GI_TYPE_TAG_LONG:
- return "long";
- case GI_TYPE_TAG_ULONG:
- return "ulong";
- case GI_TYPE_TAG_SSIZE:
- return "ssize";
- case GI_TYPE_TAG_SIZE:
- return "size";
case GI_TYPE_TAG_FLOAT:
return "float";
case GI_TYPE_TAG_DOUBLE:
return "double";
- case GI_TYPE_TAG_TIME_T:
- return "time_t";
case GI_TYPE_TAG_GTYPE:
return "GType";
case GI_TYPE_TAG_UTF8:
diff --git a/girepository/girffi.c b/girepository/girffi.c
index 559af25..23b076b 100644
--- a/girepository/girffi.c
+++ b/girepository/girffi.c
@@ -54,25 +54,6 @@ _gi_type_tag_get_ffi_type (GITypeTag tag,
return &ffi_type_sint64;
case GI_TYPE_TAG_UINT64:
return &ffi_type_uint64;
- case GI_TYPE_TAG_SHORT:
- return &ffi_type_sshort;
- case GI_TYPE_TAG_USHORT:
- return &ffi_type_ushort;
- case GI_TYPE_TAG_INT:
- return &ffi_type_sint;
- case GI_TYPE_TAG_UINT:
- return &ffi_type_uint;
- case GI_TYPE_TAG_SSIZE:
-#if GLIB_SIZEOF_SIZE_T == 4
- return &ffi_type_sint32;
-#elif GLIB_SIZEOF_SIZE_T == 8
- return &ffi_type_sint64;
-#else
-# error "Unexpected size for size_t: not 4 or 8"
-#endif
- case GI_TYPE_TAG_LONG:
- return &ffi_type_slong;
- case GI_TYPE_TAG_SIZE:
case GI_TYPE_TAG_GTYPE:
#if GLIB_SIZEOF_SIZE_T == 4
return &ffi_type_uint32;
@@ -81,16 +62,6 @@ _gi_type_tag_get_ffi_type (GITypeTag tag,
#else
# error "Unexpected size for size_t: not 4 or 8"
#endif
- case GI_TYPE_TAG_TIME_T:
-#if SIZEOF_TIME_T == 4
- return &ffi_type_sint32;
-#elif SIZEOF_TIME_T == 8
- return &ffi_type_sint64;
-#else
-# error "Unexpected size for time_t: not 4 or 8"
-#endif
- case GI_TYPE_TAG_ULONG:
- return &ffi_type_ulong;
case GI_TYPE_TAG_FLOAT:
return &ffi_type_float;
case GI_TYPE_TAG_DOUBLE:
diff --git a/girepository/girnode.c b/girepository/girnode.c
index af24161..17b739e 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -2319,33 +2319,6 @@ g_ir_node_build_typelib (GIrNode *node,
blob->size = 8;
DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), guint64);
break;
- case GI_TYPE_TAG_SHORT:
- blob->size = sizeof (gshort);
- *(gshort*)&data[blob->offset] = (gshort) parse_int_value (constant->value);
- break;
- case GI_TYPE_TAG_USHORT:
- blob->size = sizeof (gushort);
- *(gushort*)&data[blob->offset] = (gushort) parse_uint_value (constant->value);
- break;
- case GI_TYPE_TAG_INT:
- blob->size = sizeof (gint);
- *(gint*)&data[blob->offset] = (gint) parse_int_value (constant->value);
- break;
- case GI_TYPE_TAG_UINT:
- blob->size = sizeof (guint);
- *(gint*)&data[blob->offset] = (guint) parse_uint_value (constant->value);
- break;
- case GI_TYPE_TAG_SSIZE: /* FIXME */
- case GI_TYPE_TAG_LONG:
- blob->size = sizeof (glong);
- DO_ALIGNED_COPY(&data[blob->offset], parse_int_value (constant->value), glong);
- break;
- case GI_TYPE_TAG_SIZE: /* FIXME */
- case GI_TYPE_TAG_TIME_T:
- case GI_TYPE_TAG_ULONG:
- blob->size = sizeof (gulong);
- DO_ALIGNED_COPY(&data[blob->offset], parse_uint_value (constant->value), gulong);
- break;
case GI_TYPE_TAG_FLOAT:
blob->size = sizeof (gfloat);
DO_ALIGNED_COPY(&data[blob->offset], parse_float_value (constant->value), gfloat);
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 488d77b..8af0396 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -328,17 +328,36 @@ static GIrNodeType * parse_type_internal (const gchar *str, gchar **next, gboole
typedef struct {
const gchar *str;
+ guint size;
+ guint is_signed : 1;
+} IntegerAliasInfo;
+
+static IntegerAliasInfo integer_aliases[] = {
+ { "char", SIZEOF_CHAR, 0 },
+ { "short", SIZEOF_SHORT, 1 },
+ { "ushort", SIZEOF_SHORT, 0 },
+ { "int", SIZEOF_INT, 1 },
+ { "uint", SIZEOF_INT, 0 },
+ { "long", SIZEOF_LONG, 1 },
+ { "ulong", SIZEOF_LONG, 0 },
+ { "gsize", GLIB_SIZEOF_SIZE_T, 0 },
+ { "gssize", GLIB_SIZEOF_SIZE_T, 1 },
+};
+
+typedef struct {
+ const gchar *str;
gint tag;
gboolean pointer;
} BasicTypeInfo;
+#define BASIC_TYPE_FIXED_OFFSET 3
+
static BasicTypeInfo basic_types[] = {
{ "none", GI_TYPE_TAG_VOID, 0 },
{ "any", GI_TYPE_TAG_VOID, 1 },
{ "bool", GI_TYPE_TAG_BOOLEAN, 0 },
- { "char", GI_TYPE_TAG_INT8, 0 },
- { "int8", GI_TYPE_TAG_INT8, 0 },
+ { "int8", GI_TYPE_TAG_INT8, 0 }, /* Start of BASIC_TYPE_FIXED_OFFSET */
{ "uint8", GI_TYPE_TAG_UINT8, 0 },
{ "int16", GI_TYPE_TAG_INT16, 0 },
{ "uint16", GI_TYPE_TAG_UINT16, 0 },
@@ -346,19 +365,8 @@ static BasicTypeInfo basic_types[] = {
{ "uint32", GI_TYPE_TAG_UINT32, 0 },
{ "int64", GI_TYPE_TAG_INT64, 0 },
{ "uint64", GI_TYPE_TAG_UINT64, 0 },
- { "short", GI_TYPE_TAG_SHORT, 0 },
- { "ushort", GI_TYPE_TAG_USHORT, 0 },
- { "int", GI_TYPE_TAG_INT, 0 },
- { "uint", GI_TYPE_TAG_UINT, 0 },
- { "long", GI_TYPE_TAG_LONG, 0 },
- { "ulong", GI_TYPE_TAG_ULONG, 0 },
- { "ssize_t", GI_TYPE_TAG_SSIZE, 0 },
- { "ssize", GI_TYPE_TAG_SSIZE, 0 },
- { "size_t", GI_TYPE_TAG_SIZE, 0 },
- { "size", GI_TYPE_TAG_SIZE, 0 },
{ "float", GI_TYPE_TAG_FLOAT, 0 },
{ "double", GI_TYPE_TAG_DOUBLE, 0 },
- { "time_t", GI_TYPE_TAG_TIME_T, 0 },
{ "GType", GI_TYPE_TAG_GTYPE, 0 },
{ "utf8", GI_TYPE_TAG_UTF8, 1 },
{ "filename", GI_TYPE_TAG_FILENAME,1 },
@@ -375,6 +383,41 @@ parse_basic (const char *str)
if (g_str_has_prefix (str, basic_types[i].str))
return &(basic_types[i]);
}
+ for (i = 0; i < G_N_ELEMENTS (integer_aliases); i++)
+ {
+ if (g_str_has_prefix (str, integer_aliases[i].str))
+ {
+ switch (integer_aliases[i].size)
+ {
+ case sizeof(guint8):
+ if (integer_aliases[i].is_signed)
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET];
+ else
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+1];
+ break;
+ case sizeof(guint16):
+ if (integer_aliases[i].is_signed)
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+2];
+ else
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+3];
+ break;
+ case sizeof(guint32):
+ if (integer_aliases[i].is_signed)
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+4];
+ else
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+5];
+ break;
+ case sizeof(guint64):
+ if (integer_aliases[i].is_signed)
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+6];
+ else
+ return &basic_types[BASIC_TYPE_FIXED_OFFSET+7];
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ }
+ }
return NULL;
}
diff --git a/girepository/girwriter.c b/girepository/girwriter.c
index 56d61b2..bf7ea9d 100644
--- a/girepository/girwriter.c
+++ b/girepository/girwriter.c
@@ -757,24 +757,6 @@ write_constant_value (const gchar *namespace,
case GI_TYPE_TAG_UINT64:
xml_printf (file, "%" G_GUINT64_FORMAT, value->v_uint64);
break;
- case GI_TYPE_TAG_INT:
- xml_printf (file, "%d", value->v_int);
- break;
- case GI_TYPE_TAG_UINT:
- xml_printf (file, "%d", value->v_uint);
- break;
- case GI_TYPE_TAG_LONG:
- xml_printf (file, "%ld", value->v_long);
- break;
- case GI_TYPE_TAG_ULONG:
- xml_printf (file, "%ld", value->v_ulong);
- break;
- case GI_TYPE_TAG_SSIZE:
- xml_printf (file, "%zd", value->v_ssize);
- break;
- case GI_TYPE_TAG_SIZE:
- xml_printf (file, "%zd", value->v_size);
- break;
case GI_TYPE_TAG_FLOAT:
xml_printf (file, "%f", value->v_float);
break;
diff --git a/girepository/gitypelib.c b/girepository/gitypelib.c
index 06a38d2..0741bcb 100644
--- a/girepository/gitypelib.c
+++ b/girepository/gitypelib.c
@@ -909,17 +909,8 @@ validate_constant_blob (GTypelib *typelib,
4, /* UINT32 */
8, /* INT64 */
8, /* UINT64 */
- sizeof (gshort),
- sizeof (gushort),
- sizeof (gint),
- sizeof (guint),
- sizeof (glong),
- sizeof (gulong),
- sizeof (gssize),
- sizeof (gsize),
sizeof (gfloat),
sizeof (gdouble),
- sizeof (time_t),
0, /* GTYPE */
0, /* UTF8 */
0, /* FILENAME */
@@ -933,6 +924,8 @@ validate_constant_blob (GTypelib *typelib,
ConstantBlob *blob;
SimpleTypeBlob *type;
+ g_assert (G_N_ELEMENTS (value_size) == GI_TYPE_TAG_ERROR + 1);
+
if (typelib->len < offset + sizeof (ConstantBlob))
{
g_set_error (error,
diff --git a/girepository/gitypes.h b/girepository/gitypes.h
index 5ef64ca..eb1c102 100644
--- a/girepository/gitypes.h
+++ b/girepository/gitypes.h
@@ -319,17 +319,8 @@ typedef enum {
* @GI_TYPE_TAG_UINT32: 32-bit unsigned integer
* @GI_TYPE_TAG_INT64: 64-bit signed integer
* @GI_TYPE_TAG_UINT64: 64-bit unsigned integer
- * @GI_TYPE_TAG_SHORT: signed short
- * @GI_TYPE_TAG_USHORT: unsigned hosrt
- * @GI_TYPE_TAG_INT: signed integer
- * @GI_TYPE_TAG_UINT: unsigned integer
- * @GI_TYPE_TAG_LONG: signed long
- * @GI_TYPE_TAG_ULONG: unsigned long
- * @GI_TYPE_TAG_SSIZE: ssize_t
- * @GI_TYPE_TAG_SIZE: size_t
* @GI_TYPE_TAG_FLOAT: float
* @GI_TYPE_TAG_DOUBLE: double floating point
- * @GI_TYPE_TAG_TIME_T: time_t
* @GI_TYPE_TAG_GTYPE: a #GType
* @GI_TYPE_TAG_UTF8: a UTF-8 encoded string
* @GI_TYPE_TAG_FILENAME: a filename, encoded in the same encoding
@@ -355,31 +346,32 @@ typedef enum {
GI_TYPE_TAG_UINT32 = 7,
GI_TYPE_TAG_INT64 = 8,
GI_TYPE_TAG_UINT64 = 9,
- GI_TYPE_TAG_SHORT = 10,
- GI_TYPE_TAG_USHORT = 11,
- GI_TYPE_TAG_INT = 12,
- GI_TYPE_TAG_UINT = 13,
- GI_TYPE_TAG_LONG = 14,
- GI_TYPE_TAG_ULONG = 15,
- GI_TYPE_TAG_SSIZE = 16,
- GI_TYPE_TAG_SIZE = 17,
- GI_TYPE_TAG_FLOAT = 18,
- GI_TYPE_TAG_DOUBLE = 19,
- GI_TYPE_TAG_TIME_T = 20,
- GI_TYPE_TAG_GTYPE = 21,
- GI_TYPE_TAG_UTF8 = 22,
- GI_TYPE_TAG_FILENAME = 23,
+ GI_TYPE_TAG_FLOAT = 10,
+ GI_TYPE_TAG_DOUBLE = 11,
+ GI_TYPE_TAG_GTYPE = 12,
+ GI_TYPE_TAG_UTF8 = 13,
+ GI_TYPE_TAG_FILENAME = 14,
/* Non-basic types */
- GI_TYPE_TAG_ARRAY = 24,
- GI_TYPE_TAG_INTERFACE = 25,
- GI_TYPE_TAG_GLIST = 26,
- GI_TYPE_TAG_GSLIST = 27,
- GI_TYPE_TAG_GHASH = 28,
- GI_TYPE_TAG_ERROR = 29
+ GI_TYPE_TAG_ARRAY = 15,
+ GI_TYPE_TAG_INTERFACE = 16,
+ GI_TYPE_TAG_GLIST = 17,
+ GI_TYPE_TAG_GSLIST = 18,
+ GI_TYPE_TAG_GHASH = 19,
+ GI_TYPE_TAG_ERROR = 20
/* Note - there is only room currently for 32 tags.
* See docs/typelib-format.txt SimpleTypeBlob definition */
} GITypeTag;
+#define GI_TYPE_TAG_N_TYPES (GI_TYPE_TAG_ERROR+1)
+
+/* These were removed and no longer appear in the typelib;
+ * instead, the machine-specific versions like INT32 are
+ * always used.
+ */
+#define GI_TYPE_TAG_SHORT GI_TYPE_TAG_SHORT_WAS_REMOVED
+#define GI_TYPE_TAG_INT GI_TYPE_TAG_INT_WAS_REMOVED
+#define GI_TYPE_TAG_LONG GI_TYPE_TAG_LONG_WAS_REMOVED
+
/**
* GIArrayType:
* @GI_ARRAY_TYPE_C: a C array, char[] for instance
diff --git a/giscanner/ast.py b/giscanner/ast.py
index a70f2d8..3678e8c 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -48,9 +48,8 @@ TYPE_INT64 = 'int64'
TYPE_UINT64 = 'uint64'
TYPE_LONG = 'long'
TYPE_ULONG = 'ulong'
-TYPE_SSIZET = 'ssize_t'
-TYPE_SIZET = 'size_t'
-TYPE_TIMET = 'time_t'
+TYPE_SIZET = 'gsize'
+TYPE_SSIZET = 'gssize'
TYPE_GTYPE = 'GType'
TYPE_FLOAT = 'float'
TYPE_DOUBLE = 'double'
@@ -61,7 +60,7 @@ BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
TYPE_UINT64, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_SSIZET,
- TYPE_SIZET, TYPE_FLOAT, TYPE_DOUBLE, TYPE_TIMET,
+ TYPE_SIZET, TYPE_FLOAT, TYPE_DOUBLE,
TYPE_GTYPE]
GIR_TYPES = [TYPE_NONE, TYPE_ANY]
GIR_TYPES.extend(BASIC_GIR_TYPES)
@@ -117,12 +116,7 @@ type_names['char*'] = TYPE_STRING
type_names['void*'] = TYPE_ANY
type_names['void'] = TYPE_NONE
-# Unix types that we special case here (and that have their own introspection
-# type tag) because of wide use in GLib.
-type_names['size_t'] = TYPE_SIZET
-type_names['ssize_t'] = TYPE_SSIZET
-
-# One off C unix type definitions; note some of these may be GNU Libc
+# Random C unix type definitions; note some of these may be GNU Libc
# specific. If someone is actually bitten by this, feel free to do
# the required configure goop to determine their size and replace
# here.
@@ -133,6 +127,8 @@ type_names['ssize_t'] = TYPE_SSIZET
# methods are added under #ifdefs inside GLib itself. We could just (skip)
# the relevant methods, but on the other hand, since these types are just
# integers it's easy enough to expand them.
+type_names['size_t'] = TYPE_SIZET
+type_names['time_t'] = TYPE_LONG
type_names['off_t'] = TYPE_SIZET
type_names['pid_t'] = TYPE_INT
type_names['uid_t'] = TYPE_UINT
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index 522f8a5..42a7f72 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -29,18 +29,15 @@ if OS_WIN32
AM_LDFLAGS += -no-undefined
endif
-# .gir --[scanner]-> .typelib --[generate]-> .tgir
+# .gir --[scanner]-> .typelib
GIRS =
TYPELIBS = $(GIRS:.gir=.typelib)
CHECKGIRS = $(GIRS:.gir=.gir.check)
EXPECTEDGIRS = $(GIRS:.gir=-expected.gir)
-TGIRS = $(GIRS:.gir=.tgir)
-CHECKTGIRS = $(GIRS:.gir=.tgir.check)
-EXPECTEDTGIRS = $(GIRS:.gir=-expected.tgir)
INTROSPECTION_GIRS = $(GIRS)
CLEANFILES = $(TYPELIBS) $(GIRS)
-BUILT_SOURCES = $(TYPELIBS) $(GIRS) $(TGIRS)
-EXTRA_DIST = $(EXPECTEDGIRS) $(EXPECTEDTGIRS)
+BUILT_SOURCES = $(TYPELIBS) $(GIRS)
+EXTRA_DIST = $(EXPECTEDGIRS)
annotation-1.0.gir: utility-1.0.gir libannotation.la
annotation_1_0_gir_PACKAGES = gobject-2.0
@@ -110,28 +107,7 @@ post-check:
%.gir.check: %.gir
@diff -u -U 10 $(srcdir)/$*-expected.gir $*.gir && echo " TEST $*.gir"
-# stop %.typelib rule from building %-expected.tgir (via %-expected.typelib)
-%-expected.typelib:
- @true
-
-%.tgir: %.typelib $(top_builddir)/tools/g-ir-generate$(EXEEXT) Makefile
- $(AM_V_GEN) $(top_builddir)/tools/g-ir-generate --includedir=. --includedir=$(top_builddir)/gir $< -o $@
-
-%.tgir.check: %.tgir
- @diff -u -U 10 $(srcdir)/$*-expected.tgir $*.tgir; \
- if test "$$?" = "0"; then \
- echo " TEST $*.tgir"; \
- rm -f $*.tgir; \
- else \
- exit 1; \
- fi
-
-distclean-local:
- @if test "$(top_builddir)" != "$(top_srcdir)"; then \
- rm -f $(top_builddir)/tests/scanner/*.tgir; \
- fi
-
check-local: pre-check
-check-local: $(CHECKGIRS) $(CHECKTGIRS) $(TYPELIBS)
+check-local: $(CHECKGIRS) $(TYPELIBS)
check-local: post-check
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index 61003ad..3850668 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -407,7 +407,7 @@ intentionally similar example to gtk_container_get_children</doc>
</parameter>
<parameter name="length" transfer-ownership="none">
<doc xml:whitespace="preserve">Length of the data</doc>
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</parameter>
</parameters>
</method>
@@ -425,7 +425,7 @@ intentionally similar example to gtk_container_get_children</doc>
</parameter>
<parameter name="length" transfer-ownership="none">
<doc xml:whitespace="preserve">Length of the data</doc>
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</parameter>
</parameters>
</method>
@@ -444,7 +444,7 @@ type.</doc>
</parameter>
<parameter name="length" transfer-ownership="none">
<doc xml:whitespace="preserve">Length of the data</doc>
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</parameter>
</parameters>
</method>
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index df14d23..80d11e6 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -405,7 +405,7 @@ uses a C sugar return type.</doc>
</return-value>
<parameters>
<parameter name="time" transfer-ownership="none">
- <type name="time_t" c:type="time_t"/>
+ <type name="long" c:type="time_t"/>
</parameter>
</parameters>
</method>
diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir
index 57ec5db..5f8f96c 100644
--- a/tests/scanner/utility-1.0-expected.gir
+++ b/tests/scanner/utility-1.0-expected.gir
@@ -19,7 +19,7 @@ and/or use gtk-doc annotations. -->
<type name="any" c:type="char*"/>
</field>
<field name="length" writable="1">
- <type name="size_t" c:type="gsize"/>
+ <type name="gsize" c:type="gsize"/>
</field>
</record>
<union name="Byte" c:type="UtilityByte">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]