diff options
author | Johan Dahlin <johan@gnome.org> | 2009-11-24 22:18:27 -0200 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2009-12-02 10:31:29 -0200 |
commit | f74823dbcb647dee950c066119876db9f0edc32f (patch) | |
tree | 94d6434eb856fe04182b6252d0102895ca12625d /giscanner | |
parent | 8ebaa58148917ce2b89b68f00aefbdca3eac87fd (diff) | |
download | gobject-introspection-f74823dbcb647dee950c066119876db9f0edc32f.tar.gz |
Better scope in GAsyncReadyCallback/GDestroyNotify
GAsyncReadyCallback should have use the async scope per
default and GDestroyNotify should be notified if the
previous parameters are a callback and user data.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=602862
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/annotationparser.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py index 1cedfb9c..f03c6240 100644 --- a/giscanner/annotationparser.py +++ b/giscanner/annotationparser.py @@ -73,6 +73,9 @@ OPT_ARRAY_FIXED_SIZE = 'fixed-size' OPT_ARRAY_LENGTH = 'length' OPT_ARRAY_ZERO_TERMINATED = 'zero-terminated' +OPT_SCOPE_ASYNC = 'async' +OPT_SCOPE_CALL = 'call' +OPT_SCOPE_NOTIFIED = 'notified' class InvalidAnnotationError(Exception): pass @@ -410,6 +413,16 @@ class AnnotationApplier(object): def _parse_callable(self, callable, block): self._parse_node_common(callable, block) + for i, param in enumerate(callable.parameters): + if param.type.name != 'GLib.DestroyNotify': + continue + if i < 2: + break + callback_param = callable.parameters[i-2] + if callback_param.closure_index != -1: + callback_param.scope = OPT_SCOPE_NOTIFIED + callback_param.transfer = PARAM_TRANSFER_NONE + self._parse_params(callable, callable.parameters, block) self._parse_return(callable, callable.retval, block) if block: @@ -490,11 +503,15 @@ class AnnotationApplier(object): def _parse_param(self, parent, param, tag): options = getattr(tag, 'options', {}) - if isinstance(parent, Function): + if isinstance(parent, Function) and not param.scope: scope = options.get(OPT_SCOPE) if scope: param.scope = scope.one() param.transfer = PARAM_TRANSFER_NONE + elif param.type.name == 'Gio.AsyncReadyCallback': + param.scope = OPT_SCOPE_ASYNC + param.transfer = PARAM_TRANSFER_NONE + destroy = options.get(OPT_DESTROY) if destroy: param.destroy_index = parent.get_parameter_index(destroy.one()) |