From b0b4c98b31a23e6885b6c0785df93404b161b4b7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Torsten=20Sch=C3=B6nfeld?= Date: Sat, 18 Aug 2012 00:27:21 +0200 Subject: [PATCH] scanner: methods cannot have an out-arg as their first arg This ensures that if the first argument of a function like gboolean gdk_rgba_parse (GdkRGBA *rgba, const gchar *spec); is annotated as being an out-arg, the result is a class function with two arguments, not a method with one argument. Previously, the (out) annotation was simply ignored. https://bugzilla.gnome.org/show_bug.cgi?id=682124 --- giscanner/maintransformer.py | 6 ++++ tests/scanner/Regress-1.0-expected.gir | 38 ++++++++++++++++++++++++++ tests/scanner/regress.c | 12 ++++++++ tests/scanner/regress.h | 1 + 4 files changed, 57 insertions(+) diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 77a66d21..d4163fae 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -1001,6 +1001,12 @@ method or constructor of some type.""" '%s: Methods must belong to the same namespace as the ' 'class they belong to' % (func.symbol, )) return False + if first.direction == ast.PARAM_DIRECTION_OUT: + if func.is_method: + message.warn_node(func, + '%s: The first argument of methods cannot be an ' + 'out-argument' % (func.symbol, )) + return False # A quick hack here...in the future we should catch C signature/GI signature # mismatches in a general way in finaltransformer diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index e954705b..1d826766 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -1444,6 +1444,24 @@ Use with regress_test_obj_emit_sig_with_obj + + + + + + + the structure that is to be filled + + + + ignored + + + + @@ -3059,6 +3077,26 @@ What we're testing here is that the scanner ignores the @a nested inside XML. + + + + + + + the structure that is to be filled + + + + ignored + + + + diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c index 910f01a5..e72c5aa7 100644 --- a/tests/scanner/regress.c +++ b/tests/scanner/regress.c @@ -1672,6 +1672,18 @@ regress_test_struct_a_clone (RegressTestStructA *a, *a_out = *a; } +/** + * regress_test_struct_a_parse: + * @a_out: (out caller-allocates): the structure that is to be filled + * @string: ignored + */ +void +regress_test_struct_a_parse (RegressTestStructA *a_out, + const gchar *string) +{ + a_out->some_int = 23; +} + /** * regress_test_struct_b_clone: * @b: the structure diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index d6bdacb2..949a3764 100644 --- a/tests/scanner/regress.h +++ b/tests/scanner/regress.h @@ -282,6 +282,7 @@ struct _RegressTestStructA void regress_test_struct_a_clone (RegressTestStructA *a, RegressTestStructA *a_out); +void regress_test_struct_a_parse (RegressTestStructA *a_out, const gchar *string); struct _RegressTestStructB { -- 2.34.1