From a06270d391b6b2704cf7f2445d17e7ab30e1134f Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Fri, 20 Jun 2008 22:27:07 +0000 Subject: Add support for gtk-doc annotations for allow-none. Add test case. 2008-06-20 Johan Dahlin * 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 --- ChangeLog | 11 +++++++++++ giscanner/ast.py | 1 + giscanner/girwriter.py | 2 ++ giscanner/transformer.py | 2 ++ tests/parser/Foo-expected.gir | 13 +++++++++++++ tests/parser/foo-object.h | 1 + tests/parser/foo.c | 12 +++++++++++- 7 files changed, 41 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7df92672..f0df7457 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-06-20 Johan Dahlin + + * 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 * 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 @@ + + + + + + + + + + + + + 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 -- cgit v1.2.1