From aa8bf8d82c96d7151017c8b7e721fb4454645597 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 16 Dec 2008 04:20:50 +0000 Subject: Disable array auto-detection for out-annotated parameters If we have a parameter annotated as (out), then having a ctype of 'char **' (or similar) doesn't necessarily indicate an array. * giscanner/transformer.py: Skip array-detection logic for (out)-annotated parameters. * tests/scanner/annotation.h tests/scanner/annotation.c tests/scanner/annotation-1.0-expected.gir tests/scanner/annotation-1.0-expected.tgir: Add a test for an (out) string parameter. http://bugzilla.gnome.org/show_bug.cgi?id=563934 svn path=/trunk/; revision=994 --- ChangeLog | 14 ++++++++++++++ giscanner/transformer.py | 3 ++- tests/scanner/annotation-1.0-expected.gir | 10 ++++++++++ tests/scanner/annotation-1.0-expected.tgir | 10 ++++++++++ tests/scanner/annotation.c | 16 ++++++++++++++++ tests/scanner/annotation.h | 2 ++ 6 files changed, 54 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 389c8200..812f6459 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2008-12-12 Owen Taylor + + Disable array auto-detection for out-annotated parameters (#563934) + + If we have a parameter annotated as (out), then having a ctype of + 'char **' (or similar) doesn't necessarily indicate an array. + + * giscanner/transformer.py: Skip array-detection logic for + (out)-annotated parameters. + * tests/scanner/annotation.h tests/scanner/annotation.c + tests/scanner/annotation-1.0-expected.gir + tests/scanner/annotation-1.0-expected.tgir: Add a test for + an (out) string parameter. + 2008-12-12 Johan Dahlin * giscanner/dumper.py (DumpCompiler._link): Pass in diff --git a/giscanner/transformer.py b/giscanner/transformer.py index f9807eab..bba44f7d 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -462,7 +462,8 @@ class Transformer(object): rettype = Map(derefed_name, ctype, key_type, value_type) - elif ((is_param and canonical_ctype in default_array_types) + elif ((is_param and canonical_ctype in default_array_types + and not 'out' in options) or ('array' in options)): if canonical_ctype[-1] == '*': derefed_name = canonical_ctype[:-1] diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 745bbc3f..88dcdc6a 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -235,6 +235,16 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c index 420a927c..cbb69b72 100644 --- a/tests/scanner/annotation.c +++ b/tests/scanner/annotation.c @@ -291,6 +291,22 @@ annotation_object_parse_args(AnnotationObject *object, } +/** + * annotation_object_string_out: + * @object: a #AnnotationObject + * @str_out: (out) (transfer full): string return value + * + * Test returning a string as an out parameter + * + * Returns: some boolean + **/ +gboolean +annotation_object_string_out(AnnotationObject *object, + char **str_out) +{ + +} + /** * annotation_object_allow_none: * @object: a #GObject diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h index d6d60916..1e83ca23 100644 --- a/tests/scanner/annotation.h +++ b/tests/scanner/annotation.h @@ -73,6 +73,8 @@ void annotation_object_compute_sum_nz(AnnotationObject *object, void annotation_object_parse_args (AnnotationObject *object, int *argc, char ***argv); +gboolean annotation_object_string_out (AnnotationObject *object, + char **str_out); GObject* annotation_object_do_not_use (AnnotationObject *object); -- cgit v1.2.1