diff options
author | Johan Dahlin <jdahlin@async.com.br> | 2008-06-20 22:27:07 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2008-06-20 22:27:07 +0000 |
commit | a06270d391b6b2704cf7f2445d17e7ab30e1134f (patch) | |
tree | ce60213409da05edba32b80fe343440b62878db3 | |
parent | b9767e2fe9955e38612d890f9435cff14e215936 (diff) | |
download | gobject-introspection-a06270d391b6b2704cf7f2445d17e7ab30e1134f.tar.gz |
Add support for gtk-doc annotations for allow-none. Add test case.
2008-06-20 Johan Dahlin <jdahlin@async.com.br>
* giscanner/ast.py:
* giscanner/girwriter.py:
* giscanner/transformer.py:
* tests/parser/Foo-expected.gir:
* tests/parser/foo-object.h:
* tests/parser/foo.c (foo_object_allow_none):
Add support for gtk-doc annotations for allow-none.
Add test case.
svn path=/trunk/; revision=291
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | giscanner/ast.py | 1 | ||||
-rw-r--r-- | giscanner/girwriter.py | 2 | ||||
-rw-r--r-- | giscanner/transformer.py | 2 | ||||
-rw-r--r-- | tests/parser/Foo-expected.gir | 13 | ||||
-rw-r--r-- | tests/parser/foo-object.h | 1 | ||||
-rw-r--r-- | tests/parser/foo.c | 12 |
7 files changed, 41 insertions, 1 deletions
@@ -1,3 +1,14 @@ +2008-06-20 Johan Dahlin <jdahlin@async.com.br> + + * giscanner/ast.py: + * giscanner/girwriter.py: + * giscanner/transformer.py: + * tests/parser/Foo-expected.gir: + * tests/parser/foo-object.h: + * tests/parser/foo.c (foo_object_allow_none): + Add support for gtk-doc annotations for allow-none. + Add test case. + 2008-06-19 Johan Dahlin <jdahlin@async.com.br> * giscanner/ast.py: diff --git a/giscanner/ast.py b/giscanner/ast.py index 80d5f968..ca5e66d5 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -142,6 +142,7 @@ class Parameter(Node): self.type = typenode self.direction = PARAM_DIRECTION_IN self.transfer = False + self.allow_none = False def __repr__(self): return 'Parameter(%r, %r)' % (self.name, self.type) diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 389c05fa..af297e79 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -110,6 +110,8 @@ class GIRWriter(XMLWriter): if parameter.transfer: attrs.append(('transfer-ownership', str(int(parameter.transfer)))) + if parameter.allow_none: + attrs.append(('allow-none', '1')) with self.tagcontext('parameter', attrs): self._write_type(parameter.type) diff --git a/giscanner/transformer.py b/giscanner/transformer.py index 5a6b021b..6f7e2a35 100644 --- a/giscanner/transformer.py +++ b/giscanner/transformer.py @@ -221,6 +221,8 @@ class Transformer(object): param.direction = 'out' elif option == 'callee-owns': param.transfer = True + elif option == 'allow-none': + param.allow_none = True else: print 'Unhandled parameter annotation option: %s' % ( option,) diff --git a/tests/parser/Foo-expected.gir b/tests/parser/Foo-expected.gir index ec144cb5..4a4bba13 100644 --- a/tests/parser/Foo-expected.gir +++ b/tests/parser/Foo-expected.gir @@ -66,6 +66,19 @@ </parameter> </parameters> </method> + <method name="allow_none" c:identifier="foo_object_allow_none"> + <return-value> + <type name="GLib.Object" c:type="GObject*"/> + </return-value> + <parameters> + <parameter name="object"> + <type name="Object" c:type="FooObject*"/> + </parameter> + <parameter name="allow_none" allow-none="1"> + <type name="string" c:type="gchar*"/> + </parameter> + </parameters> + </method> <method name="inout" c:identifier="foo_object_inout"> <return-value> <type name="int32" c:type="gint"/> diff --git a/tests/parser/foo-object.h b/tests/parser/foo-object.h index cea217ae..1718197e 100644 --- a/tests/parser/foo-object.h +++ b/tests/parser/foo-object.h @@ -51,6 +51,7 @@ UtilityObject* foo_object_external_type (FooObject *object); gint foo_object_out (FooObject *object, int *outarg); GObject* foo_object_create_object (FooObject *object); +GObject* foo_object_allow_none (FooObject *object, gchar *allow_none); gint foo_object_inout (FooObject *object, int *inoutarg); gint foo_object_inout2 (FooObject *object, int *inoutarg); gint foo_object_inout3 (FooObject *object, int *inoutarg); diff --git a/tests/parser/foo.c b/tests/parser/foo.c index dbdb07a3..281cf14c 100644 --- a/tests/parser/foo.c +++ b/tests/parser/foo.c @@ -201,7 +201,7 @@ foo_object_inout2 (FooObject *object, int *inoutarg) * * This is a 3th test for out arguments * - * @inoutarg: (in-out): This is an argument test + * @inoutarg: (in-out) (allow-none): This is an argument test * Return value: an int */ gint @@ -293,6 +293,16 @@ foo_object_create_object (FooObject *object) return g_object_ref (object); } +/** + * foo_object_allow_none: + * @object: a #GObject + * @allow_none: (allow-none): + **/ +GObject* +foo_object_allow_none (FooObject *object, gchar *allow_none) +{ +} + G_DEFINE_TYPE (FooSubobject, foo_subobject, FOO_TYPE_OBJECT); static void |