From 6531a094d73703c0c16777bdc82252688d1c7d51 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 19 Feb 2009 17:16:17 +0000 Subject: Bug 565147 - Add (type) annotation to override the C type definition We previously supported (type) on signals only, extend it to all cases. This is useful for a few cases where libraries use a superclass like GtkWidget* for C convenience, where the actual type is a subclass. --- diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index f32486c..e94afa3 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -416,6 +416,7 @@ class AnnotationApplier(object): # We're only attempting to name the signal parameters if # the number of parameter tags (@foo) is the same or greater # than the number of signal parameters + resolve = self._transformer.resolve_param_type if block and len(block.tags) > len(signal.parameters): names = block.tags.items() else: @@ -427,7 +428,7 @@ class AnnotationApplier(object): options = getattr(tag, 'options', {}) param_type = options.get(OPT_TYPE) if param_type: - param.type.name = param_type.one() + param.type.name = resolve(param_type.one()) else: tag = None self._parse_param(signal, param, tag) @@ -489,6 +490,10 @@ class AnnotationApplier(object): node.transfer = self._extract_transfer(parent, node, options) if OPT_ALLOW_NONE in options: node.allow_none = True + param_type = options.get(OPT_TYPE) + if param_type: + resolve = self._transformer.resolve_param_type + node.type.name = resolve(param_type.one()) assert node.transfer is not None if tag is not None and tag.comment is not None: diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 1af7271..c37d2d4 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -493,6 +493,11 @@ known by GObject as it's only marked as G_TYPE_POINTER"> + + + + + @@ -529,6 +534,16 @@ known by GObject as it's only marked as G_TYPE_POINTER"> + + + + + + + + + + diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index 2a1426b..99c3d26 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -368,6 +368,11 @@ + + + + + @@ -395,6 +400,16 @@ + + + + + + + + + + diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index 41508e2..3dcc6be 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -575,4 +575,24 @@ annotation_object_extra_annos (AnnotationObject *object) { } +/** + * annotation_get_source_file: + * + * Return value: (type filename): Source file + */ +char * +annotation_get_source_file (void) +{ +} + +/** + * annotation_set_source_file: + * @fname: (type filename): Source file + * + */ +void +annotation_set_source_file (const char *fname) +{ +} + char backslash_parsing_tester_2 = '\\'; diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h index 79a686d..102b571 100644 --- a/tests/scanner/annotation.h +++ b/tests/scanner/annotation.h @@ -115,6 +115,9 @@ void annotation_string_zero_terminated_out (char ***out); void annotation_object_extra_annos (AnnotationObject *object); +char * annotation_get_source_file (void); +void annotation_set_source_file (const char *fname); + /** * AnnotationStruct: * diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir index 086170e..59efffd 100644 --- a/tests/scanner/foo-1.0-expected.gir +++ b/tests/scanner/foo-1.0-expected.gir @@ -290,6 +290,14 @@ and/or use gtk-doc annotations. --> + + + + + diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir index 1d82b6a..e834876 100644 --- a/tests/scanner/foo-1.0-expected.tgir +++ b/tests/scanner/foo-1.0-expected.tgir @@ -206,6 +206,11 @@ + + + + + diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c index 8a9283d..6cb1f3f 100644 --- a/tests/scanner/foo.c +++ b/tests/scanner/foo.c @@ -269,6 +269,20 @@ foo_subobject_init (FooSubobject *object) } +/** + * foo_object_get_default: + * + * This function is intended to match clutter_stage_get_default which + * uses a C sugar return type. + * + * Return value: (type FooSubobject): The global #FooSubobject + */ +FooObject * +foo_object_get_default () +{ + return NULL; +} + int foo_init (void) { return FOO_SUCCESS_INT; diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h index 02f3cfe..e9d00dd 100644 --- a/tests/scanner/foo.h +++ b/tests/scanner/foo.h @@ -135,6 +135,8 @@ struct _FooSubobjectClass GType foo_subobject_get_type (void) G_GNUC_CONST; FooSubobject* foo_subobject_new (); +FooObject * foo_object_get_default (); + GType foo_buffer_get_type (void); void foo_buffer_some_method (FooBuffer *buffer); -- cgit v0.9.1