diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | giscanner/transformer.py | 9 | ||||
-rw-r--r-- | tests/scanner/annotation-1.0-expected.gir | 12 | ||||
-rw-r--r-- | tests/scanner/annotation-1.0-expected.tgir | 12 | ||||
-rw-r--r-- | tests/scanner/annotation.c | 12 | ||||
-rw-r--r-- | tests/scanner/annotation.h | 1 |
6 files changed, 53 insertions, 2 deletions
@@ -1,3 +1,12 @@ +2008-11-21 Johan Dahlin <jdahlin@async.com.br> + + Bug 561617 – Return value array annotations + + * giscanner/transformer.py: + * tests/scanner/annotation.c (annotation_return_array): + * tests/scanner/annotation.h: + Add support for (array) for return value annotations as well. + 2008-11-20 Johan Bilien <jobi@via.ecp.fr> * tests/everything/everything.[ch]: add a test function which calls a diff --git a/giscanner/transformer.py b/giscanner/transformer.py index c60ec622..70a08498 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -249,7 +249,7 @@ class Transformer(object): raise ValueError("Unmatched length parameter name %r"\ % (target_name, )) - def _pair_annotations(self, params): + def _pair_annotations(self, params, return_): names = {} for param in params: if param.name in names: @@ -259,6 +259,9 @@ class Transformer(object): if isinstance(param.type, Array): self._pair_array(params, param) + if isinstance(return_.type, Array): + self._pair_array(params, return_) + # We take the annotations from the parser as strings; here we # want to split them into components, so: # (transfer full) -> {'transfer' : [ 'full' ]} @@ -275,9 +278,9 @@ class Transformer(object): directives = symbol.directives() parameters = list(self._create_parameters( symbol.base_type, directives)) - self._pair_annotations(parameters) return_ = self._create_return(symbol.base_type.base_type, directives.get('return', {})) + self._pair_annotations(parameters, return_) name = self._strip_namespace_func(symbol.ident) func = Function(name, return_, parameters, symbol.ident) self._parse_deprecated(func, directives) @@ -595,6 +598,8 @@ class Transformer(object): if option in ('transfer', 'transfer-inferred', 'element-type', 'out'): pass + elif option.startswith(('element-type', 'array')): + pass else: print 'Unhandled return type annotation option: %r' % ( option, ) diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 286759c1..d3582a11 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -267,5 +267,17 @@ </parameter> </parameters> </function> + <function name="return_array" c:identifier="annotation_return_array"> + <return-value transfer-ownership="none"> + <array length="0" c:type="char**"> + <type name="utf8"/> + </array> + </return-value> + <parameters> + <parameter name="length" direction="out" transfer-ownership="full"> + <type name="int" c:type="int*"/> + </parameter> + </parameters> + </function> </namespace> </repository> diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index 251d0bc9..449286e9 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -250,5 +250,17 @@ </parameter> </parameters> </function> + <function name="return_array" c:identifier="annotation_return_array"> + <return-value transfer-ownership="none"> + <array length="0" zero-terminated="1"> + <type name="utf8"/> + </array> + </return-value> + <parameters> + <parameter name="length" transfer-ownership="full" direction="out"> + <type name="int"/> + </parameter> + </parameters> + </function> </namespace> </repository> diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index fafb2a43..b19b5407 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -338,5 +338,17 @@ annotation_init (int *argc, char ***argv) } +/** + * annotation_return_array: + * @length: (out): Number of return values + * + * Return value: (array length=length zero-terminated=1): The return value + **/ +char ** +annotation_return_array (int *length) +{ + return NULL; +} + static char backslash_parsing_tester_2 = '\\'; diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h index d79c309d..0eecce0b 100644 --- a/tests/scanner/annotation.h +++ b/tests/scanner/annotation.h @@ -78,5 +78,6 @@ GObject* annotation_object_do_not_use (AnnotationObject *object); void annotation_init (int *argc, char ***argv); +char ** annotation_return_array (int *length); #endif /* __ANNOTATION_OBJECT_H__ */ |