From 8ef942ed56236380cbc9acc445926bfa534cc58a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 23 Jun 2009 17:51:15 -0400 Subject: Bug 579008 - Don't override element-type for arrays Annotation parser patch from: Tim Horton If an explicit element type is specified, don't override it with guint8. --- giscanner/annotationparser.py | 3 ++- tests/scanner/annotation-1.0-expected.gir | 16 ++++++++++++++++ tests/scanner/annotation-1.0-expected.tgir | 15 +++++++++++++++ tests/scanner/annotation.c | 10 ++++++++++ tests/scanner/annotation.h | 2 ++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index bb74cdc3..d79a46bb 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -601,7 +601,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."> + + + + + + + + + + + + + + + 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 @@ + + + + + + + + + + + + + + + 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 @@ -600,6 +600,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: * 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, -- cgit v1.2.1 From f88185674fbac1cea33855e7e7760021e51eecab Mon Sep 17 00:00:00 2001 From: Simon van der Linden Date: Wed, 24 Jun 2009 17:01:21 +0200 Subject: Add two tests in Everything regarding multiple output arguments Add test_utf8_out_out and test_utf8_out_nonconst_return in Everything to test the return of more than one value in a tuple in dynamic bindings. http://bugzilla.gnome.org/show_bug.cgi?id=585368 --- gir/everything.c | 29 +++++++++++++++++++++++++++++ gir/everything.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/gir/everything.c b/gir/everything.c index 5e5bed80..674a0c22 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"}; diff --git a/gir/everything.h b/gir/everything.h index 88f91f26..a7d23221 100644 --- a/gir/everything.h +++ b/gir/everything.h @@ -36,6 +36,10 @@ 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); -- cgit v1.2.1 From 0561c1e84fa9c8063de5db6b6cde13b3be7fed3d Mon Sep 17 00:00:00 2001 From: Simon van der Linden Date: Wed, 24 Jun 2009 17:16:48 +0200 Subject: Add tests for array as output argument and fixed-size arrays in Everything Add test_array_int_out to test arrays as output argument. Add test_array_fixed_size_int_in, test_array_fixed_size_int_out, and test_array_fixed_size_int_return to test fixed-size arrays as arguments. http://bugzilla.gnome.org/show_bug.cgi?id=585427 --- gir/everything.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gir/everything.h | 4 ++++ 2 files changed, 61 insertions(+) diff --git a/gir/everything.c b/gir/everything.c index 674a0c22..62a80109 100644 --- a/gir/everything.c +++ b/gir/everything.c @@ -306,6 +306,21 @@ test_array_int_in (int n_ints, int *ints) return sum; } +/** + * 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: @@ -468,6 +483,48 @@ test_strv_outarg (char ***retp) *retp = ret; } +/** + * 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: diff --git a/gir/everything.h b/gir/everything.h index a7d23221..8ce29c5a 100644 --- a/gir/everything.h +++ b/gir/everything.h @@ -44,6 +44,7 @@ char *test_utf8_out_nonconst_return (char **out); /* 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); @@ -53,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); -- cgit v1.2.1 From 5fb45ca4c1c2f72f34ff22da7ad7f44183270197 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Wed, 24 Jun 2009 14:12:52 -0400 Subject: Fix 'make check'. Commits 0561c1e84 and f88185674 (for b.g.o 585427 and 585368) broke 'make check' because they forgot to update Everything-1.0-expected.gir when additional tests were added to the Everything library. Add the new methods to the -expected.gir file. --- gir/Everything-1.0-expected.gir | 95 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir index 1dacddef..d762bb55 100644 --- a/gir/Everything-1.0-expected.gir +++ b/gir/Everything-1.0-expected.gir @@ -386,6 +386,46 @@ case."> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -519,6 +559,27 @@ case."> + + + + + + + + + + + + + + + @@ -1325,6 +1386,40 @@ call and can be released on return."> + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1 From 84b0b64b024bb434af6f508e4d4144e39035502a Mon Sep 17 00:00:00 2001 From: Tobias Mueller Date: Wed, 24 Jun 2009 23:52:05 +0200 Subject: Name unions to enable compilation on Solaris Patch by Brian Cameron . Fixes bug 578199. --- girepository/ginfo.c | 34 +++++++++++++++++----------------- girepository/girnode.c | 16 ++++++++-------- girepository/gtypelib.c | 24 ++++++++++++------------ girepository/gtypelib.h | 4 ++-- 4 files changed, 39 insertions(+), 39 deletions(-) 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; -- cgit v1.2.1 From b27fcd5bed2cd3a89c00918a53f2c84a55e96400 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Thu, 25 Jun 2009 17:18:56 -0400 Subject: Bug 586994: Add annotations for g_file_open_tmp()/g_file_replace_contents(). --- gir/gio-2.0.c | 3 +++ gir/glib-2.0.c | 5 +++++ 2 files changed, 8 insertions(+) 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 @@ -4,6 +4,11 @@ * @length: (out) (allow-none): */ +/** + * g_file_open_tmp: + * @name_used: (out): + */ + /** * g_markup_escape_text: * Return value: (transfer full): -- cgit v1.2.1 From e8d99aad1d29f343583792fac41a5182ab7d2ef7 Mon Sep 17 00:00:00 2001 From: Tim Horton Date: Thu, 25 Jun 2009 20:28:30 -0400 Subject: Add xmlTextReaderPtr type to fake libxml2 GIR This is needed in order to get libgweather introspecting. --- gir/libxml2-2.0.gir | 1 + 1 file changed, 1 insertion(+) 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 @@ + -- cgit v1.2.1 From 5f811f2d0d192c3d546b91e12fcf74b341434ca9 Mon Sep 17 00:00:00 2001 From: Andreas Rottmann Date: Fri, 3 Jul 2009 23:14:04 +0200 Subject: Allow annotations on fields Plain fields (i.e. non-callbacks) may have a 'type' annotation now. --- .topdeps | 1 - .topmsg | 2 -- giscanner/annotationparser.py | 20 +++++++++++++++----- tests/scanner/utility-1.0-expected.gir | 8 ++++++++ tests/scanner/utility-1.0-expected.tgir | 8 ++++++++ tests/scanner/utility.c | 6 ++++++ tests/scanner/utility.h | 7 +++++++ 7 files changed, 44 insertions(+), 8 deletions(-) delete mode 100644 .topdeps delete mode 100644 .topmsg 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 -Subject: [PATCH] Everything: add a boxed property to TestObj diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index d79a46bb..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: 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"> + + + + + + + + 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 @@ + + + + + + + + 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; -- cgit v1.2.1 From 11af62358ce600cecceb7af858074281901d5067 Mon Sep 17 00:00:00 2001 From: Simon van der Linden Date: Sun, 28 Jun 2009 16:05:46 +0200 Subject: Add a TestObj subclass in Everything Add an instance method to TestObj. Add a TestObj subclass in Everything, with another constructor, an additional instance method and an overridden instance method. --- gir/Everything-1.0-expected.gir | 38 ++++++++++++++++++++++++++++++++++++++ gir/everything.c | 37 +++++++++++++++++++++++++++++++++++++ gir/everything.h | 25 +++++++++++++++++++++++++ 3 files changed, 100 insertions(+) diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir index d762bb55..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. --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bare); } +int +test_obj_instance_method (TestObj *obj) +{ + return -1; +} + double test_obj_static_method (int x) { @@ -1456,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 8ce29c5a..d566f5f8 100644 --- a/gir/everything.h +++ b/gir/everything.h @@ -249,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); -- cgit v1.2.1