[gobject-introspection] giscanner: read (array) and (element-type) annotations for fields



commit b8247d8291f3386363933710d09f698e5e8e98bd
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Thu Apr 21 22:24:11 2011 +0200

    giscanner: read (array) and (element-type) annotations for fields
    
    This way fields are no longer limited to basic types, and can be
    supported without accessor methods.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=646635

 giscanner/maintransformer.py           |   10 +++++--
 tests/scanner/Regress-1.0-expected.gir |   46 ++++++++++++++++++++++++++-----
 tests/scanner/regress.h                |   22 +++++++++++++++
 3 files changed, 67 insertions(+), 11 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index f8bf9f1..1a10434 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -696,9 +696,13 @@ usage is void (*_gtk_reserved1)(void);"""
         if not tag:
             return
         t = tag.options.get(OPT_TYPE)
-        if not t:
-            return
-        field.type = self._transformer.create_type_from_user_string(t.one())
+        if t:
+            field.type = self._transformer.create_type_from_user_string(t.one())
+
+        try:
+            self._adjust_container_type(parent, field, tag.options)
+        except AttributeError:
+            pass
 
     def _apply_annotations_property(self, parent, prop):
         prefix = self._get_annotation_name(parent)
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index d08d999..52c5f8d 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -886,6 +886,44 @@ TpAccount::status-changed</doc>
         </parameters>
       </method>
     </record>
+    <record name="TestStructC" c:type="RegressTestStructC">
+      <field name="another_int" writable="1">
+        <type name="gint" c:type="gint"/>
+      </field>
+      <field name="obj" writable="1">
+        <type name="GObject.Object" c:type="GObject*"/>
+      </field>
+    </record>
+    <record name="TestStructD" c:type="RegressTestStructD">
+      <field name="array1" writable="1">
+        <array c:type="RegressTestStructA**">
+          <type name="TestStructA" c:type="RegressTestStructA*"/>
+        </array>
+      </field>
+      <field name="array2" writable="1">
+        <array c:type="RegressTestStructB**" fixed-size="5">
+          <type name="TestStructB" c:type="RegressTestStructB*"/>
+        </array>
+      </field>
+      <field name="array3" writable="1">
+        <array c:type="gpointer*">
+          <type name="TestObj"/>
+        </array>
+      </field>
+      <field name="field" writable="1">
+        <type name="TestObj"/>
+      </field>
+      <field name="list" writable="1">
+        <type name="GLib.List" c:type="GList*">
+          <type name="TestObj"/>
+        </type>
+      </field>
+      <field name="garray" writable="1">
+        <array name="GLib.PtrArray" c:type="GPtrArray*">
+          <type name="TestObj"/>
+        </array>
+      </field>
+    </record>
     <record name="TestStructFixedArray" c:type="RegressTestStructFixedArray">
       <field name="just_int" writable="1">
         <type name="gint" c:type="gint"/>
@@ -995,14 +1033,6 @@ TpAccount::status-changed</doc>
     <constant name="UTF8_CONSTANT" value="const â?¥ utf8">
       <type name="utf8" c:type="gchar*"/>
     </constant>
-    <record name="_TestStructC" c:type="_RegressTestStructC">
-      <field name="another_int" writable="1">
-        <type name="gint" c:type="gint"/>
-      </field>
-      <field name="obj" writable="1">
-        <type name="GObject.Object" c:type="GObject*"/>
-      </field>
-    </record>
     <function name="aliased_caller_alloc"
               c:identifier="regress_aliased_caller_alloc">
       <return-value transfer-ownership="none">
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 4133396..fd41a29 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -175,6 +175,8 @@ void regress_global_get_flags_out (RegressTestFlags *v);
 /* structures */
 typedef struct _RegressTestStructA RegressTestStructA;
 typedef struct _RegressTestStructB RegressTestStructB;
+typedef struct _RegressTestStructC RegressTestStructC;
+typedef struct _RegressTestStructD RegressTestStructD;
 
 struct _RegressTestStructA
 {
@@ -203,6 +205,26 @@ struct _RegressTestStructC
   GObject *obj;
 };
 
+/* This one has annotated fields */
+/**
+ * RegressTestStructD:
+ * @array1: (array zero-terminated=1):
+ * @array2: (array fixed-size=5):
+ * @array3: (array) (element-type RegressTestObj):
+ * @field: (type RegressTestObj):
+ * @list: (element-type RegressTestObj):
+ * @garray: (element-type RegressTestObj):
+ */
+struct _RegressTestStructD
+{
+  RegressTestStructA **array1;
+  RegressTestStructB **array2;
+  gpointer            *array3;
+  gpointer             field;
+  GList               *list;
+  GPtrArray           *garray;
+};
+
 /* plain-old-data boxed types */
 typedef struct _RegressTestSimpleBoxedA RegressTestSimpleBoxedA;
 typedef struct _RegressTestSimpleBoxedB RegressTestSimpleBoxedB;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]