gobject-introspection r656 - trunk/tests/scanner



Author: walters
Date: Fri Oct  3 19:30:17 2008
New Revision: 656
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=656&view=rev

Log:
Extend coverage of boxed struct/union test cases


Modified:
   trunk/tests/scanner/foo-expected.gir
   trunk/tests/scanner/foo.c
   trunk/tests/scanner/foo.h

Modified: trunk/tests/scanner/foo-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-expected.gir	(original)
+++ trunk/tests/scanner/foo-expected.gir	Fri Oct  3 19:30:17 2008
@@ -345,6 +345,25 @@
         </parameter>
       </parameters>
     </function>
+    <function name="rectangle_new" c:identifier="foo_rectangle_new">
+      <return-value>
+        <type name="Rectangle" c:type="FooRectangle*"/>
+      </return-value>
+      <parameters>
+        <parameter name="x">
+          <type name="int" c:type="int"/>
+        </parameter>
+        <parameter name="y">
+          <type name="int" c:type="int"/>
+        </parameter>
+        <parameter name="width">
+          <type name="int" c:type="int"/>
+        </parameter>
+        <parameter name="height">
+          <type name="int" c:type="int"/>
+        </parameter>
+      </parameters>
+    </function>
     <record name="EventAny" c:type="FooEventAny">
       <field name="send_event">
         <type name="int8" c:type="gint8"/>
@@ -369,5 +388,64 @@
         <type name="EventExpose" c:type="FooEventExpose"/>
       </field>
     </union>
+    <record name="BRect"
+            c:type="FooBRect"
+            glib:type-name="FooBRect"
+            glib:get-type="foo_brect_get_type">
+      <field name="x">
+        <type name="double" c:type="double"/>
+      </field>
+      <field name="y">
+        <type name="double" c:type="double"/>
+      </field>
+      <constructor name="new" c:identifier="foo_brect_new">
+        <return-value>
+          <type name="BRect" c:type="FooBRect*"/>
+        </return-value>
+        <parameters>
+          <parameter name="x">
+            <type name="double" c:type="double"/>
+          </parameter>
+          <parameter name="y">
+            <type name="double" c:type="double"/>
+          </parameter>
+        </parameters>
+      </constructor>
+      <method name="add" c:identifier="foo_brect_add">
+        <return-value>
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="b2">
+            <type name="BRect" c:type="FooBRect*"/>
+          </parameter>
+        </parameters>
+      </method>
+    </record>
+    <union name="BUnion"
+           c:type="FooBUnion"
+           glib:type-name="FooBUnion"
+           glib:get-type="foo_bunion_get_type">
+      <field name="type">
+        <type name="int" c:type="int"/>
+      </field>
+      <field name="v">
+        <type name="double" c:type="double"/>
+      </field>
+      <field name="rect">
+        <type name="BRect" c:type="FooBRect*"/>
+      </field>
+      <constructor name="new" c:identifier="foo_bunion_new">
+        <return-value>
+          <type name="BUnion" c:type="FooBUnion*"/>
+        </return-value>
+      </constructor>
+      <method name="get_contained_type"
+              c:identifier="foo_bunion_get_contained_type">
+        <return-value>
+          <type name="int" c:type="int"/>
+        </return-value>
+      </method>
+    </union>
   </namespace>
 </repository>

Modified: trunk/tests/scanner/foo.c
==============================================================================
--- trunk/tests/scanner/foo.c	(original)
+++ trunk/tests/scanner/foo.c	Fri Oct  3 19:30:17 2008
@@ -294,3 +294,27 @@
 					     (GBoxedFreeFunc) foo_dbus_data_free);
   return our_type;
 }
+
+GType
+foo_brect_get_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("FooBRect",
+					     (GBoxedCopyFunc) g_memdup, /* Won't work */
+					     (GBoxedFreeFunc) g_free);
+  return our_type;
+}
+
+GType
+foo_bunion_get_type (void)
+{
+  static GType our_type = 0;
+  
+  if (our_type == 0)
+    our_type = g_boxed_type_register_static ("FooBUnion",
+					     (GBoxedCopyFunc) g_memdup, /* Won't work */
+					     (GBoxedFreeFunc) g_free);
+  return our_type;
+}

Modified: trunk/tests/scanner/foo.h
==============================================================================
--- trunk/tests/scanner/foo.h	(original)
+++ trunk/tests/scanner/foo.h	Fri Oct  3 19:30:17 2008
@@ -167,6 +167,9 @@
 
 void foo_rectangle_add(FooRectangle *r1, const FooRectangle *r2);
 
+FooRectangle * foo_rectangle_new (int x, int y, int width, int height);
+
+
 typedef struct _FooEventAny FooEventAny;
 typedef struct _FooEventExpose FooEventExpose;
 
@@ -192,4 +195,35 @@
 
 typedef void FooXEvent;
 
+/* And now some boxed variants */
+
+typedef struct _FooBRect          FooBRect;
+
+struct _FooBRect
+{
+  double x;
+  double y;
+};
+
+GType foo_brect_get_type (void);
+
+FooBRect *foo_brect_new (double x, double y);
+
+void foo_brect_add (FooBRect *b1, FooBRect *b2);
+
+typedef union _FooBUnion FooBUnion;
+
+union _FooBUnion
+{
+  int type;
+  double v;
+  FooBRect *rect;
+};
+
+FooBUnion *foo_bunion_new (void);
+
+GType foo_bunion_get_type (void);
+
+int foo_bunion_get_contained_type (FooBUnion *bunion);
+
 #endif /* __FOO_OBJECT_H__ */



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