Add test for interface prereq
authorColin Walters <walters@src.gnome.org>
Mon, 17 Nov 2008 00:27:44 +0000 (00:27 +0000)
committerColin Walters <walters@src.gnome.org>
Mon, 17 Nov 2008 00:27:44 +0000 (00:27 +0000)
svn path=/trunk/; revision=935

girepository/girparser.c
tests/scanner/foo-1.0-expected.gir
tests/scanner/foo-1.0-expected.tgir
tests/scanner/foo.c
tests/scanner/foo.h

index 43f3402..48e3119 100644 (file)
@@ -2519,7 +2519,7 @@ start_element_handler (GMarkupParseContext *context,
              GIrNodeInterface *iface;
 
              iface = (GIrNodeInterface *)ctx->current_node;
-             iface ->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
+             iface->prerequisites = g_list_append (iface->prerequisites, g_strdup (name));
            }
          goto out;
        }
index dfeb71e..21d70c5 100644 (file)
         </parameters>
       </callback>
     </record>
+    <interface name="SubInterface"
+               c:type="FooSubInterface"
+               glib:type-name="FooSubInterface"
+               glib:get-type="foo_sub_interface_get_type">
+      <prerequisite name="Interface"/>
+      <method name="do_bar" c:identifier="foo_sub_interface_do_bar">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+      </method>
+      <callback name="do_bar" c:type="do_bar">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="self" transfer-ownership="none">
+            <type name="SubInterface" c:type="FooSubInterface*"/>
+          </parameter>
+        </parameters>
+      </callback>
+    </interface>
+    <record name="SubInterfaceIface" c:type="FooSubInterfaceIface">
+      <field name="parent_iface">
+        <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
+      </field>
+      <callback name="do_bar" c:type="do_bar">
+        <return-value transfer-ownership="none">
+          <type name="none" c:type="void"/>
+        </return-value>
+        <parameters>
+          <parameter name="self" transfer-ownership="none">
+            <type name="SubInterface" c:type="FooSubInterface*"/>
+          </parameter>
+        </parameters>
+      </callback>
+    </record>
     <class name="Object"
            c:type="FooObject"
            parent="GObject.Object"
index b2a76eb..2591fdf 100644 (file)
         <type name="GObject.TypeInterface"/>
       </field>
     </record>
+    <interface name="SubInterface" glib:type-name="FooSubInterface" glib:get-type="foo_sub_interface_get_type">
+      <prerequisite name="Interface"/>
+      <method name="do_bar" c:identifier="foo_sub_interface_do_bar">
+        <return-value transfer-ownership="none">
+          <type name="none"/>
+        </return-value>
+      </method>
+    </interface>
+    <record name="SubInterfaceIface">
+      <field name="parent_iface">
+        <type name="GObject.TypeInterface"/>
+      </field>
+    </record>
     <class name="Object" parent="GObject.Object" glib:type-name="FooObject" glib:get-type="foo_object_get_type">
       <implements name="Interface"/>
       <field name="parent_instance">
index ee1f4f1..50b78c2 100644 (file)
@@ -75,6 +75,30 @@ foo_foo_interface_init (gpointer         g_iface,
   iface->do_foo = foo_do_foo;
 }
 
+GType
+foo_sub_interface_get_type (void)
+{
+  static GType object_type = 0;
+
+  if (!object_type)
+    {
+      object_type = g_type_register_static_simple (G_TYPE_INTERFACE,
+                                                   "FooSubInterface",
+                                                   sizeof (FooSubInterfaceIface),
+                                                   NULL, 0, NULL, 0);
+
+      g_type_interface_add_prerequisite (object_type, FOO_TYPE_INTERFACE);
+    }
+
+  return object_type;
+}
+
+void foo_sub_interface_do_bar (FooSubInterface *self)
+{
+  FOO_SUBINTERFACE_GET_INTERFACE(self)->do_bar (self);
+}
+
+
 G_DEFINE_TYPE_EXTENDED (FooObject, foo_object, G_TYPE_OBJECT,
                        0, G_IMPLEMENT_INTERFACE (FOO_TYPE_INTERFACE,
                                                  foo_foo_interface_init));
index 37bc291..c7da0a4 100644 (file)
@@ -9,6 +9,12 @@
 #define FOO_IS_INTERFACE(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_INTERFACE))
 #define FOO_INTERFACE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), FOO_TYPE_INTERFACE, FooInterfaceIface))
 
+#define FOO_TYPE_SUBINTERFACE           (foo_sub_interface_get_type ())
+#define FOO_SUBINTERFACE(object)        (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_SUBINTERFACE, FooSubInterface))
+#define FOO_IS_SUBINTERFACE(object)     (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_SUBINTERFACE))
+#define FOO_SUBINTERFACE_GET_INTERFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), FOO_TYPE_SUBINTERFACE, FooSubInterfaceIface))
+
+
 #define FOO_TYPE_OBJECT              (foo_object_get_type ())
 #define FOO_OBJECT(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), FOO_TYPE_OBJECT, FooObject))
 #define FOO_IS_OBJECT(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), FOO_TYPE_OBJECT))
@@ -19,6 +25,8 @@
 
 typedef struct _FooInterface       FooInterface;
 typedef struct _FooInterfaceIface  FooInterfaceIface;
+typedef struct _FooSubInterface       FooSubInterface;
+typedef struct _FooSubInterfaceIface  FooSubInterfaceIface;
 typedef struct _FooObject          FooObject;
 typedef struct _FooObjectClass     FooObjectClass;
 typedef struct _FooSubobject       FooSubobject;
@@ -33,6 +41,17 @@ struct _FooInterfaceIface
 
 GType                 foo_interface_get_type       (void) G_GNUC_CONST;
 
+struct _FooSubInterfaceIface
+{
+  GTypeInterface parent_iface;
+
+  void (*do_bar) (FooSubInterface *self);
+};
+
+GType                 foo_sub_interface_get_type       (void) G_GNUC_CONST;
+
+void foo_sub_interface_do_bar (FooSubInterface *self);
+
 struct _FooObject
 {
   GObject parent_instance;