diff options
author | Ryan Lortie <desrt@desrt.ca> | 2014-04-16 11:22:32 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2014-05-06 08:15:24 -0400 |
commit | 89d51bce0feb115a1b73f32b023bfabaeec9fde1 (patch) | |
tree | bfe3ef15f2814d85bdd86cb43ca36224c8eae179 /giscanner | |
parent | 754f1965c08bb01b2e6440d2a6f1ab9edd6e1970 (diff) | |
download | gobject-introspection-89d51bce0feb115a1b73f32b023bfabaeec9fde1.tar.gz |
giscanner: write nullable and optional attributes
Record our internal 'nullable' and 'optional' attributes into the
written .gir file. It is now theoretically possible to express the
concept of an out parameter with a nullable type (although presently
there is no way to do this).
Modify our own internal parser (in the scanner) to understand the
newly-written attributes.
Update the expected output of the 'Regress-1.0.gir' test to account for
the new attributes.
Nothing else understands 'nullable' yet, but the girparser in the
typelib compiler already understands 'optional' and records a bit for it
in the typelib.
https://bugzilla.gnome.org/show_bug.cgi?id=660879
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ast.py | 7 | ||||
-rw-r--r-- | giscanner/girparser.py | 2 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index 35a764a7..12304eb7 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -775,13 +775,14 @@ class Parameter(TypeContainer): """An argument to a function.""" def __init__(self, argname, typenode, direction=None, - transfer=None, allow_none=False, scope=None, + transfer=None, nullable=False, optional=False, + allow_none=False, scope=None, caller_allocates=False): TypeContainer.__init__(self, typenode, transfer) self.argname = argname self.direction = direction - self.nullable = False - self.optional = False + self.nullable = nullable + self.optional = optional if allow_none: if self.direction == PARAM_DIRECTION_OUT: diff --git a/giscanner/girparser.py b/giscanner/girparser.py index cac166d0..b1583998 100644 --- a/giscanner/girparser.py +++ b/giscanner/girparser.py @@ -280,6 +280,8 @@ class GIRParser(object): typeval, node.attrib.get('direction') or ast.PARAM_DIRECTION_IN, node.attrib.get('transfer-ownership'), + node.attrib.get('nullable') == '1', + node.attrib.get('optional') == '1', node.attrib.get('allow-none') == '1', node.attrib.get('scope'), node.attrib.get('caller-allocates') == '1') diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 49d24bc4..49545e62 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -240,9 +240,11 @@ class GIRWriter(XMLWriter): attrs.append(('transfer-ownership', parameter.transfer)) if parameter.nullable: + attrs.append(('nullable', '1')) if parameter.direction != ast.PARAM_DIRECTION_OUT: attrs.append(('allow-none', '1')) if parameter.optional: + attrs.append(('optional', '1')) if parameter.direction == ast.PARAM_DIRECTION_OUT: attrs.append(('allow-none', '1')) if parameter.scope: |