diff options
author | Ryan Lortie <desrt@desrt.ca> | 2014-04-16 17:16:17 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2014-05-06 08:15:24 -0400 |
commit | 754f1965c08bb01b2e6440d2a6f1ab9edd6e1970 (patch) | |
tree | 9982f806a949d07c274901fab1549fe5bb0aa038 /giscanner/maintransformer.py | |
parent | 289e85c43b0bf5cd19d1c5a282ad2db7c5136c84 (diff) | |
download | gobject-introspection-754f1965c08bb01b2e6440d2a6f1ab9edd6e1970.tar.gz |
giscanner: change some internal field logic
Replace the 'allow_none' field on parameters with two separate fields:
'nullable' and 'optional'.
Currently, we use 'nullable' to mean the same thing as 'allow-none' for
normal (non-out) parameters. For out parameters, we use the 'optional'
field instead.
Note that the special case for GCancellable and GAsyncReadyCallback is
already guarded by a check for being an in parameter, so we always use
'nullable' here.
On the .gir writer side, we decide which variable to consult when
writing the allow-none attribute depending on the parameter direction.
https://bugzilla.gnome.org/show_bug.cgi?id=660879
Diffstat (limited to 'giscanner/maintransformer.py')
-rw-r--r-- | giscanner/maintransformer.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py index 8fad0d70..5f4788a3 100644 --- a/giscanner/maintransformer.py +++ b/giscanner/maintransformer.py @@ -580,12 +580,15 @@ class MainTransformer(object): self._adjust_container_type(parent, node, annotations) if ANN_ALLOW_NONE in annotations: - node.allow_none = True + if node.direction == ast.PARAM_DIRECTION_OUT: + node.optional = True + else: + node.nullable = True if (node.direction == ast.PARAM_DIRECTION_IN and (node.type.target_giname == 'Gio.AsyncReadyCallback' or node.type.target_giname == 'Gio.Cancellable')): - node.allow_none = True + node.nullable = True if tag and tag.description: node.doc = tag.description |