diff options
author | Johan Dahlin <johan@gnome.org> | 2009-07-06 11:05:11 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2009-07-06 11:05:11 -0300 |
commit | 62b1395a3650f4445dc28ec8f4ff82f0e7cbddd1 (patch) | |
tree | a9de890262fb0654ccf0a8046bb68964228b9f28 | |
parent | 4fabb3e649b9d359e10454bdf3984a3bdf5bb285 (diff) | |
parent | 11af62358ce600cecceb7af858074281901d5067 (diff) | |
download | gobject-introspection-62b1395a3650f4445dc28ec8f4ff82f0e7cbddd1.tar.gz |
Merge commit 'origin'
-rw-r--r-- | .topdeps | 1 | ||||
-rw-r--r-- | .topmsg | 2 | ||||
-rw-r--r-- | gir/Everything-1.0-expected.gir | 133 | ||||
-rw-r--r-- | gir/everything.c | 123 | ||||
-rw-r--r-- | gir/everything.h | 33 | ||||
-rw-r--r-- | gir/gio-2.0.c | 3 | ||||
-rw-r--r-- | gir/glib-2.0.c | 5 | ||||
-rw-r--r-- | gir/libxml2-2.0.gir | 1 | ||||
-rw-r--r-- | girepository/ginfo.c | 34 | ||||
-rw-r--r-- | girepository/girnode.c | 16 | ||||
-rw-r--r-- | girepository/gtypelib.c | 24 | ||||
-rw-r--r-- | girepository/gtypelib.h | 4 | ||||
-rw-r--r-- | giscanner/annotationparser.py | 23 | ||||
-rw-r--r-- | tests/scanner/annotation-1.0-expected.gir | 16 | ||||
-rw-r--r-- | tests/scanner/annotation-1.0-expected.tgir | 15 | ||||
-rw-r--r-- | tests/scanner/annotation.c | 10 | ||||
-rw-r--r-- | tests/scanner/annotation.h | 2 | ||||
-rw-r--r-- | tests/scanner/utility-1.0-expected.gir | 8 | ||||
-rw-r--r-- | tests/scanner/utility-1.0-expected.tgir | 8 | ||||
-rw-r--r-- | tests/scanner/utility.c | 6 | ||||
-rw-r--r-- | tests/scanner/utility.h | 7 |
21 files changed, 426 insertions, 48 deletions
diff --git a/.topdeps b/.topdeps deleted file mode 100644 index 1f7391f9..00000000 --- a/.topdeps +++ /dev/null @@ -1 +0,0 @@ -master diff --git a/.topmsg b/.topmsg deleted file mode 100644 index 33a72a5f..00000000 --- a/.topmsg +++ /dev/null @@ -1,2 +0,0 @@ -From: Andreas Rottmann <a.rottmann@gmx.at> -Subject: [PATCH] Everything: add a boxed property to TestObj diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir index 1dacddef..35aa7709 100644 --- a/gir/Everything-1.0-expected.gir +++ b/gir/Everything-1.0-expected.gir @@ -159,6 +159,11 @@ and/or use gtk-doc annotations. --> </parameter> </parameters> </method> + <method name="instance_method" c:identifier="test_obj_instance_method"> + <return-value transfer-ownership="none"> + <type name="int" c:type="int"/> + </return-value> + </method> <method name="do_matrix" c:identifier="test_obj_do_matrix" doc="This method is virtual. Notably its name differs from the virtual @@ -332,6 +337,39 @@ case."> <type name="GObject.Object" c:type="GObject*"/> </field> </record> + <class name="TestSubObj" + c:type="TestSubObj" + parent="TestObj" + glib:type-name="TestSubObj" + glib:get-type="test_sub_obj_get_type" + glib:type-struct="TestSubObjClass"> + <constructor name="new" c:identifier="test_sub_obj_new"> + <return-value transfer-ownership="full"> + <type name="TestSubObj" c:type="TestSubObj*"/> + </return-value> + </constructor> + <method name="unset_bare" c:identifier="test_sub_obj_unset_bare"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + </method> + <method name="instance_method" + c:identifier="test_sub_obj_instance_method"> + <return-value transfer-ownership="none"> + <type name="int" c:type="int"/> + </return-value> + </method> + <field name="parent_instance"> + <type name="TestObj" c:type="TestObj"/> + </field> + </class> + <record name="TestSubObjClass" + c:type="TestSubObjClass" + glib:is-gtype-struct-for="TestSubObj"> + <field name="parent_class"> + <type name="TestObjClass" c:type="TestObjClass"/> + </field> + </record> <class name="TestWi8021x" c:type="TestWi8021x" parent="GObject.Object" @@ -386,6 +424,46 @@ case."> <type name="GObject.ObjectClass" c:type="GObjectClass"/> </field> </record> + <function name="test_array_fixed_size_int_in" + c:identifier="test_array_fixed_size_int_in"> + <return-value transfer-ownership="none"> + <type name="int" c:type="int"/> + </return-value> + <parameters> + <parameter name="ints" + transfer-ownership="none" + doc="a list of 5 integers"> + <array c:type="int*" fixed-size="5"> + <type name="int"/> + </array> + </parameter> + </parameters> + </function> + <function name="test_array_fixed_size_int_out" + c:identifier="test_array_fixed_size_int_out"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="ints" + direction="out" + transfer-ownership="full" + doc="a list of 5 integers ranging from 0 to 4"> + <array c:type="int**" fixed-size="5"> + <type name="int"/> + </array> + </parameter> + </parameters> + </function> + <function name="test_array_fixed_size_int_return" + c:identifier="test_array_fixed_size_int_return"> + <return-value transfer-ownership="full" + doc="a list of 5 integers ranging from 0 to 4"> + <array c:type="int*" fixed-size="5"> + <type name="int"/> + </array> + </return-value> + </function> <function name="test_array_gint16_in" c:identifier="test_array_gint16_in"> <return-value transfer-ownership="none"> <type name="int" c:type="int"/> @@ -519,6 +597,27 @@ case."> </parameter> </parameters> </function> + <function name="test_array_int_out" c:identifier="test_array_int_out"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="n_ints" + direction="out" + transfer-ownership="full" + doc="the length of @ints"> + <type name="int" c:type="int*"/> + </parameter> + <parameter name="ints" + direction="out" + transfer-ownership="full" + doc="a list of 5 integers, from 0 to 4 in consecutive order"> + <array length="0" c:type="int**"> + <type name="int"/> + </array> + </parameter> + </parameters> + </function> <function name="test_boolean" c:identifier="test_boolean"> <return-value transfer-ownership="none"> <type name="boolean" c:type="gboolean"/> @@ -1325,6 +1424,40 @@ call and can be released on return."> </parameter> </parameters> </function> + <function name="test_utf8_out_nonconst_return" + c:identifier="test_utf8_out_nonconst_return"> + <return-value transfer-ownership="full" + doc="a copy of "first""> + <type name="utf8" c:type="char*"/> + </return-value> + <parameters> + <parameter name="out" + direction="out" + transfer-ownership="full" + doc="a copy of "second""> + <type name="utf8" c:type="char**"/> + </parameter> + </parameters> + </function> + <function name="test_utf8_out_out" c:identifier="test_utf8_out_out"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="out0" + direction="out" + transfer-ownership="full" + doc="a copy of "first""> + <type name="utf8" c:type="char**"/> + </parameter> + <parameter name="out1" + direction="out" + transfer-ownership="full" + doc="a copy of "second""> + <type name="utf8" c:type="char**"/> + </parameter> + </parameters> + </function> <function name="test_value_return" c:identifier="test_value_return"> <return-value transfer-ownership="none" doc="the int wrapped in a GValue."> diff --git a/gir/everything.c b/gir/everything.c index 5e5bed80..2eedeef0 100644 --- a/gir/everything.c +++ b/gir/everything.c @@ -257,6 +257,35 @@ GSList *test_filename_return (void) return filenames; } + +/* multiple output arguments */ + +/** + * test_utf8_out_out: + * @out0: (out) (transfer full): a copy of "first" + * @out1: (out) (transfer full): a copy of "second" + */ +void +test_utf8_out_out (char **out0, char **out1) +{ + *out0 = g_strdup ("first"); + *out1 = g_strdup ("second"); +} + +/** + * test_utf8_out_nonconst_return: + * @out: (out) (transfer full): a copy of "second" + * + * Returns: (transfer full): a copy of "first" + */ +char * +test_utf8_out_nonconst_return (char **out) +{ + *out = g_strdup ("second"); + return g_strdup ("first"); +} + + /* non-basic-types */ static const char *test_sequence[] = {"1", "2", "3"}; @@ -278,6 +307,21 @@ test_array_int_in (int n_ints, int *ints) } /** + * test_array_int_out: + * @n_ints: (out): the length of @ints + * @ints: (out) (array length=n_ints) (transfer full): a list of 5 integers, from 0 to 4 in consecutive order + */ +void +test_array_int_out (int *n_ints, int **ints) +{ + int i; + *n_ints = 5; + *ints = g_malloc0(sizeof(**ints) * *n_ints); + for (i = 1; i < *n_ints; i++) + (*ints)[i] = (*ints)[i-1] + 1; +} + +/** * test_array_gint8_in: * @n_ints: * @ints: (array length=n_ints): List of ints @@ -440,6 +484,48 @@ test_strv_outarg (char ***retp) } /** + * test_array_fixed_size_int_in: + * @ints: (array fixed-size=5): a list of 5 integers + * + * Returns: the sum of the items in @ints + */ +int +test_array_fixed_size_int_in (int *ints) +{ + int i, sum = 0; + for (i = 0; i < 5; i++) + sum += ints[i]; + return sum; +} + +/** + * test_array_fixed_size_int_out: + * @ints: (out) (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4 + */ +void +test_array_fixed_size_int_out (int **ints) +{ + int i; + *ints = g_malloc0(sizeof(**ints) * 5); + for (i = 1; i < 5; i++) + (*ints)[i] = (*ints)[i-1] + 1; +} + +/** + * test_array_fixed_size_int_return: + * Returns: (array fixed-size=5) (transfer full): a list of 5 integers ranging from 0 to 4 + */ +int * +test_array_fixed_size_int_return (void) +{ + int i, *ints; + ints = g_malloc0(sizeof(*ints) * 5); + for (i = 1; i < 5; i++) + ints[i] = ints[i-1] + 1; + return ints; +} + +/** * test_array_int_in_take: * @n_ints: * @ints: (array length=n_ints) (transfer full): List of ints @@ -1337,6 +1423,12 @@ test_obj_set_bare (TestObj *obj, GObject *bare) g_object_ref (obj->bare); } +int +test_obj_instance_method (TestObj *obj) +{ + return -1; +} + double test_obj_static_method (int x) { @@ -1370,6 +1462,37 @@ struct _CallbackInfo }; +G_DEFINE_TYPE(TestSubObj, test_sub_obj, TEST_TYPE_OBJ); + +static void +test_sub_obj_class_init (TestSubObjClass *klass) +{ +} + +static void +test_sub_obj_init (TestSubObj *obj) +{ +} + +TestSubObj* +test_sub_obj_new () +{ + return g_object_new (TEST_TYPE_SUB_OBJ, NULL); +} + +int +test_sub_obj_instance_method (TestSubObj *obj) +{ + return 0; +} + +void +test_sub_obj_unset_bare (TestSubObj *obj) +{ + test_obj_set_bare(TEST_OBJECT(obj), NULL); +} + + /** * test_callback: * @callback: (scope call): diff --git a/gir/everything.h b/gir/everything.h index 88f91f26..d566f5f8 100644 --- a/gir/everything.h +++ b/gir/everything.h @@ -36,10 +36,15 @@ void test_utf8_out (char **out); void test_utf8_inout (char **inout); GSList *test_filename_return (void); +/* multiple output arguments */ +void test_utf8_out_out (char **out0, char **out1); +char *test_utf8_out_nonconst_return (char **out); + /* non-basic-types */ /* array */ gboolean test_strv_in (char **arr); int test_array_int_in (int n_ints, int *ints); +void test_array_int_out (int *n_ints, int **ints); int test_array_gint8_in (int n_ints, gint8 *ints); int test_array_gint16_in (int n_ints, gint16 *ints); gint32 test_array_gint32_in (int n_ints, gint32 *ints); @@ -49,6 +54,9 @@ char **test_strv_out_container (void); char **test_strv_out (void); const char * const * test_strv_out_c (void); void test_strv_outarg (char ***retp); +int test_array_fixed_size_int_in (int *ints); +void test_array_fixed_size_int_out (int **ints); +int *test_array_fixed_size_int_return (void); /* transfer tests */ int test_array_int_in_take (int n_ints, int *ints); @@ -241,11 +249,36 @@ struct _TestObjClass GType test_obj_get_type (void); TestObj* test_obj_new_from_file (const char *x, GError **error); void test_obj_set_bare (TestObj *obj, GObject *bare); +int test_obj_instance_method (TestObj *obj); double test_obj_static_method (int x); /* virtual */ int test_obj_do_matrix (TestObj *obj, const char *somestr); +/* inheritance */ +#define TEST_TYPE_SUB_OBJ (test_sub_obj_get_type ()) +#define TEST_SUB_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_SUB_OBJ, TestSubObj)) +#define TEST_IS_SUB_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_SUB_OBJ)) +#define TEST_SUB_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SUB_OBJ, TestSubObjClass)) + +typedef struct _TestSubObj TestSubObj; +typedef struct _TestSubObjClass TestSubObjClass; + +struct _TestSubObj +{ + TestObj parent_instance; +}; + +struct _TestSubObjClass +{ + TestObjClass parent_class; +}; + +GType test_sub_obj_get_type (void); +TestSubObj* test_sub_obj_new (void); +void test_sub_obj_unset_bare (TestSubObj *obj); +int test_sub_obj_instance_method (TestSubObj *obj); + /* callback */ typedef int (*TestCallback) (); typedef int (*TestCallbackUserData) (gpointer user_data); diff --git a/gir/gio-2.0.c b/gir/gio-2.0.c index 3a1c8fdc..55eaf2a6 100644 --- a/gir/gio-2.0.c +++ b/gir/gio-2.0.c @@ -390,11 +390,14 @@ /** * g_file_replace_contents: + * @etag: (allow-none): + * @new_etag: (allow-none) (out): * @cancellable: (allow-none): */ /** * g_file_replace_contents_async: + * @etag: (allow-none): * @cancellable: (allow-none): */ diff --git a/gir/glib-2.0.c b/gir/glib-2.0.c index 578ccd8f..2c2a11d2 100644 --- a/gir/glib-2.0.c +++ b/gir/glib-2.0.c @@ -5,6 +5,11 @@ */ /** + * g_file_open_tmp: + * @name_used: (out): + */ + +/** * g_markup_escape_text: * Return value: (transfer full): */ diff --git a/gir/libxml2-2.0.gir b/gir/libxml2-2.0.gir index c110805e..2e75267b 100644 --- a/gir/libxml2-2.0.gir +++ b/gir/libxml2-2.0.gir @@ -10,6 +10,7 @@ <record name="NsPtr" c:type="xmlNsPtr"/> <record name="Char" c:type="xmlChar"/> <record name="TextWriter" c:type="xmlTextWriterPtr"/> + <record name="TextReader" c:type="xmlTextReaderPtr"/> <function name="dummy" c:identifier="dummy"> <return-value transfer-ownership="none"> <type name="none" c:type="void"/> diff --git a/girepository/ginfo.c b/girepository/ginfo.c index 6fbd464f..e7b0b8bd 100644 --- a/girepository/ginfo.c +++ b/girepository/ginfo.c @@ -637,7 +637,7 @@ g_type_info_new (GIBaseInfo *container, SimpleTypeBlob *type = (SimpleTypeBlob *)&typelib->data[offset]; return (GITypeInfo *) g_info_new (GI_INFO_TYPE_TYPE, container, typelib, - (type->reserved == 0 && type->reserved2 == 0) ? offset : type->offset); + (type->flags.reserved == 0 && type->flags.reserved2 == 0) ? offset : type->offset); } /** @@ -852,8 +852,8 @@ g_type_info_is_pointer (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (type->reserved == 0 && type->reserved2 == 0) - return type->pointer; + if (type->flags.reserved == 0 && type->flags.reserved2 == 0) + return type->flags.pointer; else { InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&base->typelib->data[base->offset]; @@ -868,8 +868,8 @@ g_type_info_get_tag (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (type->reserved == 0 && type->reserved2 == 0) - return type->tag; + if (type->flags.reserved == 0 && type->flags.reserved2 == 0) + return type->flags.tag; else { InterfaceTypeBlob *iface = (InterfaceTypeBlob *)&base->typelib->data[base->offset]; @@ -885,7 +885,7 @@ g_type_info_get_param_type (GITypeInfo *info, GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ParamTypeBlob *param = (ParamTypeBlob *)&base->typelib->data[base->offset]; @@ -913,7 +913,7 @@ g_type_info_get_interface (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { InterfaceTypeBlob *blob = (InterfaceTypeBlob *)&base->typelib->data[base->offset]; @@ -930,14 +930,14 @@ g_type_info_get_array_length (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->typelib->data[base->offset]; if (blob->tag == GI_TYPE_TAG_ARRAY) { if (blob->has_length) - return blob->length; + return blob->dimensions.length; } } @@ -950,14 +950,14 @@ g_type_info_get_array_fixed_size (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->typelib->data[base->offset]; if (blob->tag == GI_TYPE_TAG_ARRAY) { if (blob->has_size) - return blob->size; + return blob->dimensions.size; } } @@ -970,7 +970,7 @@ g_type_info_is_zero_terminated (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ArrayTypeBlob *blob = (ArrayTypeBlob *)&base->typelib->data[base->offset]; @@ -987,7 +987,7 @@ g_type_info_get_n_error_domains (GITypeInfo *info) GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->typelib->data[base->offset]; @@ -1005,7 +1005,7 @@ g_type_info_get_error_domain (GITypeInfo *info, GIBaseInfo *base = (GIBaseInfo *)info; SimpleTypeBlob *type = (SimpleTypeBlob *)&base->typelib->data[base->offset]; - if (!(type->reserved == 0 && type->reserved2 == 0)) + if (!(type->flags.reserved == 0 && type->flags.reserved2 == 0)) { ErrorTypeBlob *blob = (ErrorTypeBlob *)&base->typelib->data[base->offset]; @@ -2047,13 +2047,13 @@ g_constant_info_get_value (GIConstantInfo *info, ConstantBlob *blob = (ConstantBlob *)&base->typelib->data[base->offset]; /* FIXME non-basic types ? */ - if (blob->type.reserved == 0 && blob->type.reserved2 == 0) + if (blob->type.flags.reserved == 0 && blob->type.flags.reserved2 == 0) { - if (blob->type.pointer) + if (blob->type.flags.pointer) value->v_pointer = g_memdup (&base->typelib->data[blob->offset], blob->size); else { - switch (blob->type.tag) + switch (blob->type.flags.tag) { case GI_TYPE_TAG_BOOLEAN: value->v_boolean = *(gboolean*)&base->typelib->data[blob->offset]; diff --git a/girepository/girnode.c b/girepository/girnode.c index e4f889a7..bd9be682 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -1437,11 +1437,11 @@ g_ir_node_build_typelib (GIrNode *node, type->tag == GI_TYPE_TAG_UTF8 || type->tag == GI_TYPE_TAG_FILENAME) { - blob->reserved = 0; - blob->reserved2 = 0; - blob->pointer = type->is_pointer; - blob->reserved3 = 0; - blob->tag = type->tag; + blob->flags.reserved = 0; + blob->flags.reserved2 = 0; + blob->flags.pointer = type->is_pointer; + blob->flags.reserved3 = 0; + blob->flags.tag = type->tag; } else { @@ -1481,11 +1481,11 @@ g_ir_node_build_typelib (GIrNode *node, array->has_size = type->has_size; array->reserved2 = 0; if (array->has_length) - array->length = type->length; + array->dimensions.length = type->length; else if (array->has_size) - array->size = type->size; + array->dimensions.size = type->size; else - array->length = -1; + array->dimensions.length = -1; pos = *offset2 + G_STRUCT_OFFSET (ArrayTypeBlob, type); *offset2 += sizeof (ArrayTypeBlob); diff --git a/girepository/gtypelib.c b/girepository/gtypelib.c index 4e26f1e4..92df5393 100644 --- a/girepository/gtypelib.c +++ b/girepository/gtypelib.c @@ -116,13 +116,13 @@ get_type_blob (GTypelib *typelib, return FALSE; } - if (simple->reserved == 0 && simple->reserved2 == 0) + if (simple->flags.reserved == 0 && simple->flags.reserved2 == 0) { g_set_error (error, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID, "Expected non-basic type but got %d", - simple->tag); + simple->flags.tag); return FALSE; } @@ -547,10 +547,10 @@ validate_type_blob (GTypelib *typelib, simple = (SimpleTypeBlob *)&typelib->data[offset]; - if (simple->reserved == 0 && - simple->reserved2 == 0) + if (simple->flags.reserved == 0 && + simple->flags.reserved2 == 0) { - if (simple->tag >= GI_TYPE_TAG_ARRAY) + if (simple->flags.tag >= GI_TYPE_TAG_ARRAY) { g_set_error (error, G_TYPELIB_ERROR, @@ -559,13 +559,13 @@ validate_type_blob (GTypelib *typelib, return FALSE; } - if (simple->tag >= GI_TYPE_TAG_UTF8 && - !simple->pointer) + if (simple->flags.tag >= GI_TYPE_TAG_UTF8 && + !simple->flags.pointer) { g_set_error (error, G_TYPELIB_ERROR, G_TYPELIB_ERROR_INVALID_BLOB, - "Pointer type exected for tag %d", simple->tag); + "Pointer type exected for tag %d", simple->flags.tag); return FALSE; } @@ -965,9 +965,9 @@ validate_constant_blob (GTypelib *typelib, } type = (SimpleTypeBlob *)&typelib->data[offset + G_STRUCT_OFFSET (ConstantBlob, type)]; - if (type->reserved == 0 && type->reserved2 == 0) + if (type->flags.reserved == 0 && type->flags.reserved2 == 0) { - if (type->tag == 0) + if (type->flags.tag == 0) { g_set_error (error, G_TYPELIB_ERROR, @@ -976,8 +976,8 @@ validate_constant_blob (GTypelib *typelib, return FALSE; } - if (value_size[type->tag] != 0 && - blob->size != value_size[type->tag]) + if (value_size[type->flags.tag] != 0 && + blob->size != value_size[type->flags.tag]) { g_set_error (error, G_TYPELIB_ERROR, diff --git a/girepository/gtypelib.h b/girepository/gtypelib.h index aff53d93..2827543a 100644 --- a/girepository/gtypelib.h +++ b/girepository/gtypelib.h @@ -313,7 +313,7 @@ typedef union guint pointer : 1; guint reserved3 : 2; guint tag : 5; - }; + } flags; guint32 offset; } SimpleTypeBlob; @@ -530,7 +530,7 @@ typedef struct { union { guint16 length; guint16 size; - }; + } dimensions; SimpleTypeBlob type; } ArrayTypeBlob; diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index bb74cdc3..79cbfe8a 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -332,7 +332,7 @@ class AnnotationApplier(object): self._parse_node_common(record, block) self._parse_constructors(record.constructors) self._parse_methods(record, record.methods) - self._parse_fields(record, record.fields) + self._parse_fields(record, record.fields, block) if block: record.doc = block.comment @@ -347,7 +347,7 @@ class AnnotationApplier(object): def _parse_union(self, union): block = self._blocks.get(union.name) self._parse_node_common(union, block) - self._parse_fields(union, union.fields) + self._parse_fields(union, union.fields, block) self._parse_constructors(union.constructors) self._parse_methods(union, union.methods) if block: @@ -373,9 +373,9 @@ class AnnotationApplier(object): for ctor in constructors: self._parse_function(ctor) - def _parse_fields(self, parent, fields): + def _parse_fields(self, parent, fields, block=None): for field in fields: - self._parse_field(parent, field) + self._parse_field(parent, field, block) def _parse_properties(self, parent, properties): for prop in properties: @@ -464,9 +464,19 @@ class AnnotationApplier(object): key = '%s::%s' % (parent.type_name, vfunc.name) self._parse_callable(vfunc, self._blocks.get(key)) - def _parse_field(self, parent, field): + def _parse_field(self, parent, field, block=None): if isinstance(field, Callback): self._parse_callback(field) + else: + if not block: + return + tag = block.get(field.name) + if not tag: + return + t = tag.options.get('type') + if not t: + return + field.type.name = self._transformer.resolve_type_name(t.one()) def _parse_params(self, parent, params, block): for param in params: @@ -601,7 +611,8 @@ class AnnotationApplier(object): # is specified. if (isinstance(node, Parameter) and node.type.name == 'utf8' and - self._guess_direction(node) == PARAM_DIRECTION_IN): + self._guess_direction(node) == PARAM_DIRECTION_IN and + element_type is None): # FIXME: unsigned char/guchar should be uint8 container_type.element_type = Type('int8') container_type.size = array_values.get(OPT_ARRAY_FIXED_SIZE) diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 46a30065..3715edca 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -607,6 +607,22 @@ detection, and fixing it via annotations."> </parameter> </parameters> </function> + <function name="string_array_length" + c:identifier="annotation_string_array_length"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="n_properties" transfer-ownership="none"> + <type name="uint" c:type="guint"/> + </parameter> + <parameter name="properties" transfer-ownership="none"> + <array length="0" c:type="gchar*"> + <type name="utf8"/> + </array> + </parameter> + </parameters> + </function> <function name="string_zero_terminated" c:identifier="annotation_string_zero_terminated"> <return-value transfer-ownership="full" doc="The return value"> diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index 9e6fe160..76a20edb 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -452,6 +452,21 @@ </parameter> </parameters> </function> + <function name="string_array_length" c:identifier="annotation_string_array_length"> + <return-value transfer-ownership="none"> + <type name="none"/> + </return-value> + <parameters> + <parameter name="n_properties" transfer-ownership="none"> + <type name="uint"/> + </parameter> + <parameter name="properties" transfer-ownership="none"> + <array length="0"> + <type name="utf8"/> + </array> + </parameter> + </parameters> + </function> <function name="string_zero_terminated" c:identifier="annotation_string_zero_terminated"> <return-value transfer-ownership="full"> <array zero-terminated="1"> diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index 5c5d46d4..058d508a 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -601,6 +601,16 @@ annotation_versioned (void) } /** + * annotation_string_array_length: + * @n_properties: + * @properties: (array length=n_properties) (element-type utf8): + */ +void +annotation_string_array_length (guint n_properties, const gchar * const properties[]) +{ +} + +/** * annotation_object_extra_annos: * * Attributes: (org.foobar testvalue) diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h index 745a94b6..798594b1 100644 --- a/tests/scanner/annotation.h +++ b/tests/scanner/annotation.h @@ -129,6 +129,8 @@ void annotation_versioned (void); char ** annotation_string_zero_terminated (void); void annotation_string_zero_terminated_out (char ***out); +void annotation_string_array_length (guint n_properties, const gchar * const properties[]); + void annotation_object_extra_annos (AnnotationObject *object); void annotation_custom_destroy (AnnotationCallback callback, diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir index 02e29136..8c6a602b 100644 --- a/tests/scanner/utility-1.0-expected.gir +++ b/tests/scanner/utility-1.0-expected.gir @@ -14,6 +14,14 @@ and/or use gtk-doc annotations. --> shared-library="utility" c:prefix="utility"> <alias name="Glyph" target="uint32" c:type="UtilityGlyph"/> + <record name="Buffer" c:type="UtilityBuffer"> + <field name="data" writable="1"> + <type name="any" c:type="char*"/> + </field> + <field name="length" writable="1"> + <type name="size_t" c:type="gsize"/> + </field> + </record> <union name="Byte" c:type="UtilityByte"> <field name="value" writable="1"> <type name="uint8" c:type="guint8"/> diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir index 2a30f850..d25bd59f 100644 --- a/tests/scanner/utility-1.0-expected.tgir +++ b/tests/scanner/utility-1.0-expected.tgir @@ -6,6 +6,14 @@ <include name="GObject" version="2.0"/> <include name="GLib" version="2.0"/> <namespace name="utility" version="1.0" shared-library="utility" c:prefix="utility"> + <record name="Buffer"> + <field name="data" writable="1"> + <type name="any"/> + </field> + <field name="length" writable="1"> + <type name="size"/> + </field> + </record> <union name="Byte"> <field name="value" writable="1"> <type name="uint8"/> diff --git a/tests/scanner/utility.c b/tests/scanner/utility.c index a54afad9..5ae5ed3e 100644 --- a/tests/scanner/utility.c +++ b/tests/scanner/utility.c @@ -6,6 +6,12 @@ G_DEFINE_TYPE (UtilityObject, utility_object, G_TYPE_OBJECT); * UtilityFlagType: (type bitfield) **/ +/** + * UtilityBuffer: + * + * @data: (type pointer): the data + **/ + static void utility_object_class_init (UtilityObjectClass *klass) { diff --git a/tests/scanner/utility.h b/tests/scanner/utility.h index cad93ff5..a3eb3ef8 100644 --- a/tests/scanner/utility.h +++ b/tests/scanner/utility.h @@ -44,6 +44,13 @@ typedef union }; } UtilityByte; +/* This one is similiar to Soup.Buffer */ +typedef struct +{ + const char *data; + gsize length; +} UtilityBuffer; + typedef void (*UtilityFileFunc)(const char *path, gpointer user_data); GType utility_object_get_type (void) G_GNUC_CONST; |