Add support for gtk-doc annotations for allow-none. Add test case.
authorJohan Dahlin <jdahlin@async.com.br>
Fri, 20 Jun 2008 22:27:07 +0000 (22:27 +0000)
committerJohan Dahlin <johan@src.gnome.org>
Fri, 20 Jun 2008 22:27:07 +0000 (22:27 +0000)
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

ChangeLog
giscanner/ast.py
giscanner/girwriter.py
giscanner/transformer.py
tests/parser/Foo-expected.gir
tests/parser/foo-object.h
tests/parser/foo.c

index 7df9267..f0df745 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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:
index 80d5f96..ca5e66d 100644 (file)
@@ -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)
index 389c05f..af297e7 100644 (file)
@@ -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)
 
index 5a6b021..6f7e2a3 100644 (file)
@@ -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,)
index ec144cb..4a4bba1 100644 (file)
           </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"/>
index cea217a..1718197 100644 (file)
@@ -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);
index dbdb07a..281cf14 100644 (file)
@@ -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