diff options
author | Corentin Noël <corentin@elementary.io> | 2019-07-31 16:11:18 +0200 |
---|---|---|
committer | Christoph Reiter <reiter.christoph@gmail.com> | 2019-08-07 19:35:08 +0000 |
commit | c0c60dc2ef6210665f1609023ff1a44f8eae2b8c (patch) | |
tree | 95e5080640a8060727040eb549dc06deafc447c5 | |
parent | 99db7d7fb3dbb9f4da416a21282aadf351eb3471 (diff) | |
download | gobject-introspection-c0c60dc2ef6210665f1609023ff1a44f8eae2b8c.tar.gz |
Fix inconsistencies when handling closure and destroy annotations
-rw-r--r-- | giscanner/maintransformer.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 9468751d..e93b40ad 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -774,22 +774,26 @@ class MainTransformer(object): destroy_annotation = annotations.get(ANN_DESTROY) if destroy_annotation: - param.destroy_name = self._get_validate_parameter_name(parent, - destroy_annotation[0], - param) - if param.destroy_name is not None: + destroy_param = parent.get_parameter(destroy_annotation[0]) + if destroy_param: + destroy_param.destroy_name = param.argname param.scope = ast.PARAM_SCOPE_NOTIFIED - destroy_param = parent.get_parameter(param.destroy_name) # This is technically bogus; we're setting the scope on the destroy # itself. But this helps avoid tripping a warning from finaltransformer, # since we don't have a way right now to flag this callback a destroy. destroy_param.scope = ast.PARAM_SCOPE_NOTIFIED + else: + message.warn('%s: unable to find parameter %s' % (param.argname, destroy_annotation[0],), + tag.position) closure_annotation = annotations.get(ANN_CLOSURE) if closure_annotation and len(closure_annotation) == 1: - param.closure_name = self._get_validate_parameter_name(parent, - closure_annotation[0], - param) + closure_param = parent.get_parameter(closure_annotation[0]) + if closure_param: + closure_param.closure_name = param.argname + else: + message.warn('%s: unable to find parameter %s' % (param.argname, closure_annotation[0],), + tag.position) elif isinstance(parent, ast.Callback): if ANN_CLOSURE in annotations: # For callbacks, (closure) appears without an |