diff options
author | Colin Walters <walters@verbum.org> | 2010-11-19 16:59:02 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2010-11-19 16:59:02 -0500 |
commit | 1113955bb6a5276c21771685dd30c51f9ef1661f (patch) | |
tree | 4d024db41c55301bf7e43f077f29405323a1bbce | |
parent | 9f5da945add22bd3a2b72d50ed8f11387e51ce85 (diff) | |
download | gobject-introspection-1113955bb6a5276c21771685dd30c51f9ef1661f.tar.gz |
scanner: Only mark structures and unions as out-caller-allocates
These are the only things for which we expect native values to be
preserved; for e.g. flags and integers, we expect bindings to convert.
The particular rationale for this patch is to avoid flagging flags (sic)
as (out caller-allocates).
-rw-r--r-- | giscanner/maintransformer.py | 5 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 15 | ||||
-rw-r--r-- | tests/scanner/regress.c | 11 | ||||
-rw-r--r-- | tests/scanner/regress.h | 2 |
4 files changed, 32 insertions, 1 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 517ddb2d..4ae55169 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -510,7 +510,10 @@ usage is void (*_gtk_reserved1)(void);""" annotated_direction = ast.PARAM_DIRECTION_OUT if subtype in (None, ''): if node.type.target_giname and node.type.ctype: - caller_allocates = '**' not in node.type.ctype + target = self._transformer.lookup_giname(node.type.target_giname) + has_double_indirection = '**' in node.type.ctype + is_structure_or_union = isinstance(target, (ast.Record, ast.Union)) + caller_allocates = (not has_double_indirection and is_structure_or_union) else: caller_allocates = False elif subtype == OPT_OUT_CALLER_ALLOCATES: diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 515853b4..15fba0d8 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -962,6 +962,21 @@ TpAccount::status-changed</doc> </parameter> </parameters> </function> + <function name="global_get_flags_out" + c:identifier="regress_global_get_flags_out"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="v" + direction="out" + caller-allocates="0" + transfer-ownership="full"> + <doc xml:whitespace="preserve">A flags value</doc> + <type name="TestFlags" c:type="RegressTestFlags*"/> + </parameter> + </parameters> + </function> <function name="random_function_with_skipped_structure" c:identifier="regress_random_function_with_skipped_structure" introspectable="0"> diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 9f225961..cd7e91c5 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1301,6 +1301,17 @@ regress_test_unsigned_enum_param(RegressTestEnumUnsigned e) return ev->value_nick; } +/** + * regress_global_get_flags_out: + * @v: (out): A flags value + * + */ +void +regress_global_get_flags_out (RegressTestFlags *v) +{ + *v = REGRESS_TEST_FLAG1 | REGRESS_TEST_FLAG3; +} + /* structures */ /** diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 9b39bd3c..9daf1798 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -163,6 +163,8 @@ GType regress_test_flags_get_type (void) G_GNUC_CONST; const gchar * regress_test_enum_param(RegressTestEnum e); const gchar * regress_test_unsigned_enum_param(RegressTestEnumUnsigned e); +void regress_global_get_flags_out (RegressTestFlags *v); + /* constants */ #define REGRESS_INT_CONSTANT 4422 |