From 0aa60a43c4c9679668e15dbf3ef7a39016525150 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 10 Oct 2015 15:43:54 -0400 Subject: maintransformer: Fix regression in callback closure assignment The nullable code needs to search via index lookup of closure_name, which drops the need to (incorrectly) assign closure_name again. https://bugzilla.gnome.org/show_bug.cgi?id=756352 --- giscanner/maintransformer.py | 11 ++++++----- tests/scanner/Regress-1.0-expected.gir | 35 ++++++++++++---------------------- tests/scanner/Utility-1.0-expected.gir | 6 ++---- 3 files changed, 20 insertions(+), 32 deletions(-) diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 5ea1f5b4..b4b39345 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -1451,14 +1451,15 @@ method or constructor of some type.""" param.argname is not None and param.argname.endswith('data')): callback_param.closure_name = param.argname - param.closure_name = param.argname for param in params: # By convention, closure user_data parameters are always nullable. - if param.closure_name is not None and \ - param.closure_name == param.argname and \ - not param.not_nullable: - param.nullable = True + if param.closure_name is not None: + idx = node.get_parameter_index(param.closure_name) + assert idx >= 0 + closure_param = params[idx] + if not closure_param.not_nullable: + closure_param.nullable = True def _pass3_callable_throws(self, node): """Check to see if we have anything that looks like a diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index dfbbd8d5..620a2907 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -387,8 +387,7 @@ are zero-terminated + allow-none="1"> Callback user data @@ -739,8 +738,7 @@ regress_annotation_object_watch_full(). + allow-none="1"> The callback data @@ -770,8 +768,7 @@ regress_annotation_object_watch_full(). + allow-none="1"> The callback data @@ -1868,8 +1865,7 @@ exposed to language bindings. + allow-none="1"> @@ -2927,8 +2923,7 @@ use it should be. + allow-none="1"> @@ -4309,8 +4304,7 @@ detection, and fixing it via annotations. + allow-none="1"> @@ -4507,8 +4501,7 @@ detection, and fixing it via annotations. + allow-none="1"> @@ -4529,8 +4522,7 @@ detection, and fixing it via annotations. + allow-none="1"> @@ -5404,8 +5396,7 @@ libgnome-keyring. + allow-none="1"> @@ -5429,8 +5420,7 @@ is invoked. + allow-none="1"> @@ -5501,7 +5491,7 @@ call and can be released on return. - + @@ -6513,8 +6503,7 @@ https://bugzilla.gnome.org/show_bug.cgi?id=685399 + allow-none="1"> diff --git a/tests/scanner/Utility-1.0-expected.gir b/tests/scanner/Utility-1.0-expected.gir index 38b6a3cb..7eea9f77 100644 --- a/tests/scanner/Utility-1.0-expected.gir +++ b/tests/scanner/Utility-1.0-expected.gir @@ -100,8 +100,7 @@ and/or use gtk-doc annotations. --> + allow-none="1"> @@ -180,8 +179,7 @@ and/or use gtk-doc annotations. --> + allow-none="1"> -- cgit v1.2.1