Bug 572434 - Associate interfaces with their C structures
authorColin Walters <walters@verbum.org>
Fri, 20 Feb 2009 22:34:20 +0000 (17:34 -0500)
committerColin Walters <walters@verbum.org>
Wed, 25 Feb 2009 22:31:49 +0000 (17:31 -0500)
Similar to GObject class structs, we pair up GInterfaces with
their C structures.

Also, move some GLib-specific things into glibast.py, and make
the naming more generic.

24 files changed:
docs/reference/gi-sections.txt
girepository/ginfo.c
girepository/girepository.h
girepository/girnode.c
girepository/girnode.h
girepository/girparser.c
girepository/gtypelib.c
girepository/gtypelib.h
giscanner/ast.py
giscanner/girwriter.py
giscanner/glibast.py
giscanner/glibtransformer.py
tests/repository/gitestrepo.c
tests/scanner/BarApp-1.0-expected.gir
tests/scanner/BarApp-1.0-expected.tgir
tests/scanner/annotation-1.0-expected.gir
tests/scanner/annotation-1.0-expected.tgir
tests/scanner/drawable-1.0-expected.gir
tests/scanner/drawable-1.0-expected.tgir
tests/scanner/foo-1.0-expected.gir
tests/scanner/foo-1.0-expected.tgir
tests/scanner/utility-1.0-expected.gir
tests/scanner/utility-1.0-expected.tgir
tools/generate.c

index 69d87edf83e1c09ab978be1e6fd99a3ed96ec91d..96ef8fbaf2d2fb0c4fbe960b7d957f89d02c7095 100644 (file)
@@ -131,7 +131,7 @@ g_struct_info_get_method
 g_struct_info_find_method
 g_struct_info_get_size
 g_struct_info_get_alignment
-g_struct_info_is_class_struct
+g_struct_info_is_gtype_struct
 g_registered_type_info_get_type_name
 g_registered_type_info_get_type_init
 g_registered_type_info_get_g_type
@@ -171,6 +171,7 @@ g_interface_info_get_n_vfuncs
 g_interface_info_get_vfunc
 g_interface_info_get_n_constants
 g_interface_info_get_constant
+g_interface_info_get_iface_struct
 g_property_info_get_flags
 g_property_info_get_type
 g_signal_info_get_flags
index 7ecfe6337865e8130803aae4894fefb301cfed10..1c34ee2bdbf45bd6b64bb6c73f859e04809b8597 100644 (file)
@@ -1182,22 +1182,22 @@ g_struct_info_get_alignment (GIStructInfo *info)
 }
 
 /**
- * g_struct_info_is_class_struct:
+ * g_struct_info_is_gtype_struct:
  * @info: GIStructInfo
  * 
  * Return true if this structure represents the "class structure" for some
- * GObject.  This function is mainly useful to hide this kind of structure
- * from public APIs.
+ * #GObject or #GInterface.  This function is mainly useful to hide this kind of structure
+ * from generated public APIs.
  *
- * Returns: TRUE if it's a class struct, otherwise FALSE
+ * Returns: %TRUE if this is a class struct, %FALSE otherwise
  */
 gboolean
-g_struct_info_is_class_struct (GIStructInfo *info)
+g_struct_info_is_gtype_struct (GIStructInfo *info)
 {
   GIBaseInfo *base = (GIBaseInfo *)info;
   StructBlob *blob = (StructBlob *)&base->typelib->data[base->offset];
 
-  return blob->is_class_struct;
+  return blob->is_gtype_struct;
 }
 
 gint
@@ -1495,10 +1495,10 @@ g_object_info_get_constant (GIObjectInfo *info,
  * g_object_info_get_class_struct:
  * @info: A #GIObjectInfo to query
  * 
- * Every GObject has two structures; an instance structure and a class
+ * Every #GObject has two structures; an instance structure and a class
  * structure.  This function returns the metadata for the class structure.
  *
- * Returns: a GIStrucTInfo for the class struct or NULL if none found.
+ * Returns: a #GIStructInfo for the class struct or %NULL if none found.
  */
 GIStructInfo *
 g_object_info_get_class_struct (GIObjectInfo *info)
@@ -1506,9 +1506,9 @@ g_object_info_get_class_struct (GIObjectInfo *info)
   GIBaseInfo *base = (GIBaseInfo *)info;
   ObjectBlob *blob = (ObjectBlob *)&base->typelib->data[base->offset];
 
-  if (blob->class_struct)
+  if (blob->gtype_struct)
     return (GIStructInfo *) g_info_from_entry (base->repository,
-                                               base->typelib, blob->class_struct);
+                                               base->typelib, blob->gtype_struct);
   else
     return NULL;
 }
@@ -1691,8 +1691,26 @@ g_interface_info_get_constant (GIInterfaceInfo *info,
                                        base->typelib, offset);  
 }
 
+/**
+ * g_interface_info_get_iface_struct:
+ * @info: A #GIInterfaceInfo to query
+ *
+ * Returns the layout C structure associated with this #GInterface.
+ *
+ * Returns: A #GIStructInfo for the class struct or %NULL if none found.
+ */
+GIStructInfo *
+g_interface_info_get_iface_struct (GIInterfaceInfo *info)
+{
+  GIBaseInfo *base = (GIBaseInfo *)info;
+  InterfaceBlob *blob = (InterfaceBlob *)&base->typelib->data[base->offset];
 
-
+  if (blob->gtype_struct)
+    return (GIStructInfo *) g_info_from_entry (base->repository,
+                                               base->typelib, blob->gtype_struct);
+  else
+    return NULL;
+}
 
 /* GIPropertyInfo functions */
 GParamFlags
index 3508f4ddbe0e173beb9524def4d7dbeab27114aa..61a9116245ae32e5545dd1da4685726288320d66 100644 (file)
@@ -417,7 +417,7 @@ GIFunctionInfo *       g_struct_info_find_method   (GIStructInfo *info,
                                                    const gchar *name);
 gsize                  g_struct_info_get_size      (GIStructInfo *info);
 gsize                  g_struct_info_get_alignment (GIStructInfo *info);
-gboolean               g_struct_info_is_class_struct (GIStructInfo *info);
+gboolean               g_struct_info_is_gtype_struct (GIStructInfo *info);
 
 /* GIRegisteredTypeInfo */
 
@@ -487,6 +487,8 @@ gint                   g_interface_info_get_n_constants     (GIInterfaceInfo *in
 GIConstantInfo *       g_interface_info_get_constant        (GIInterfaceInfo *info,
                                                             gint        n);
 
+GIStructInfo *         g_interface_info_get_iface_struct    (GIInterfaceInfo *info);
+
 
 /* GIPropertyInfo  */
 
index 0aafa44de8c1c2fe4bd7b926cf8a982cbbb8c032..7863c25487bd8c117b35d46654d836a5f317ad08 100644 (file)
@@ -286,7 +286,8 @@ g_ir_node_free (GIrNode *node)
        g_free (iface->gtype_name);
        g_free (iface->gtype_init);
 
-        g_free (iface->class_struct);  
+
+       g_free (iface->glib_type_struct);
        g_free (iface->parent);
 
        for (l = iface->interfaces; l; l = l->next)
@@ -652,8 +653,8 @@ g_ir_node_get_full_size_internal (GIrNode *parent,
        size = sizeof(ObjectBlob);
        if (iface->parent)
          size += ALIGN_VALUE (strlen (iface->parent) + 1, 4);
-        if (iface->class_struct)
-          size += ALIGN_VALUE (strlen (iface->class_struct) + 1, 4);   
+        if (iface->glib_type_struct)
+          size += ALIGN_VALUE (strlen (iface->glib_type_struct) + 1, 4);
        size += ALIGN_VALUE (strlen (node->name) + 1, 4);
        size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4);
        if (iface->gtype_init)
@@ -1781,7 +1782,7 @@ g_ir_node_build_typelib (GIrNode         *node,
        
        blob->blob_type = BLOB_TYPE_STRUCT;
        blob->deprecated = struct_->deprecated;
-       blob->is_class_struct = struct_->is_gclass_struct;
+       blob->is_gtype_struct = struct_->is_gtype_struct;
        blob->reserved = 0;
        blob->name = write_string (node->name, strings, data, offset2);
        blob->alignment = struct_->alignment;
@@ -1984,10 +1985,10 @@ g_ir_node_build_typelib (GIrNode         *node,
          blob->parent = find_entry (module, modules, object->parent);
        else
          blob->parent = 0;
-       if (object->class_struct)
-         blob->class_struct = find_entry (module, modules, object->class_struct);
+       if (object->glib_type_struct)
+         blob->gtype_struct = find_entry (module, modules, object->glib_type_struct);
        else
-         blob->class_struct = 0;
+         blob->gtype_struct = 0;
 
        blob->n_interfaces = 0;
        blob->n_fields = 0;
@@ -2049,6 +2050,10 @@ g_ir_node_build_typelib (GIrNode         *node,
        blob->name = write_string (node->name, strings, data, offset2);
        blob->gtype_name = write_string (iface->gtype_name, strings, data, offset2);
        blob->gtype_init = write_string (iface->gtype_init, strings, data, offset2);
+       if (iface->glib_type_struct)
+         blob->gtype_struct = find_entry (module, modules, iface->glib_type_struct);
+       else
+         blob->gtype_struct = 0;
        blob->n_prerequisites = 0;
        blob->n_properties = 0;
        blob->n_methods = 0;
index 33848db6f2770e4fa2bdb0b2acdacf1eae2c2cda..7ea8a32a5d14b1c923d2c26baff358114c7ea6fe 100644 (file)
@@ -237,7 +237,7 @@ struct _GIrNodeInterface
   gchar *gtype_init;
 
   gchar *parent;
-  gchar *class_struct; /* Only applies to classes */
+  gchar *glib_type_struct;
   
   GList *interfaces;
   GList *prerequisites;
@@ -302,7 +302,7 @@ struct _GIrNodeStruct
 
   gboolean deprecated;
   gboolean disguised;
-  gboolean is_gclass_struct;
+  gboolean is_gtype_struct;
 
   gchar *gtype_name;
   gchar *gtype_init;
index 795658e8a113e984239099eb84d50cb377dd12e8..e08b3fcd06a3dca1e7c8d7b35da476df191ced86 100644 (file)
@@ -1482,10 +1482,12 @@ start_interface (GMarkupParseContext *context,
       const gchar *typename;
       const gchar *typeinit;
       const gchar *deprecated;
+      const gchar *glib_type_struct;
       
       name = find_attribute ("name", attribute_names, attribute_values);
       typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
       typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
+      glib_type_struct = find_attribute ("glib:type-struct", attribute_names, attribute_values);
       deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
       
       if (name == NULL)
@@ -1502,6 +1504,7 @@ start_interface (GMarkupParseContext *context,
          ((GIrNode *)iface)->name = g_strdup (name);
          iface->gtype_name = g_strdup (typename);
          iface->gtype_init = g_strdup (typeinit);
+          iface->glib_type_struct = g_strdup (glib_type_struct);
          if (deprecated)
            iface->deprecated = TRUE;
          else
@@ -1533,7 +1536,7 @@ start_class (GMarkupParseContext *context,
     {
       const gchar *name;
       const gchar *parent;
-      const gchar *class_struct;      
+      const gchar *glib_type_struct;
       const gchar *typename;
       const gchar *typeinit;
       const gchar *deprecated;
@@ -1541,7 +1544,7 @@ start_class (GMarkupParseContext *context,
       
       name = find_attribute ("name", attribute_names, attribute_values);
       parent = find_attribute ("parent", attribute_names, attribute_values);
-      class_struct = find_attribute ("glib:class-struct", attribute_names, attribute_values);      
+      glib_type_struct = find_attribute ("glib:type-struct", attribute_names, attribute_values);
       typename = find_attribute ("glib:type-name", attribute_names, attribute_values);
       typeinit = find_attribute ("glib:get-type", attribute_names, attribute_values);
       deprecated = find_attribute ("deprecated", attribute_names, attribute_values);
@@ -1562,7 +1565,7 @@ start_class (GMarkupParseContext *context,
          iface->gtype_name = g_strdup (typename);
          iface->gtype_init = g_strdup (typeinit);
          iface->parent = g_strdup (parent);
-         iface->class_struct = g_strdup (class_struct);
+         iface->glib_type_struct = g_strdup (glib_type_struct);
          if (deprecated)
            iface->deprecated = TRUE;
          else
@@ -2128,7 +2131,7 @@ start_struct (GMarkupParseContext *context,
       const gchar *disguised;
       const gchar *gtype_name;
       const gchar *gtype_init;
-      const gchar *gclass_struct;
+      const gchar *gtype_struct;
       GIrNodeStruct *struct_;
       
       name = find_attribute ("name", attribute_names, attribute_values);
@@ -2136,7 +2139,7 @@ start_struct (GMarkupParseContext *context,
       disguised = find_attribute ("disguised", attribute_names, attribute_values);
       gtype_name = find_attribute ("glib:type-name", attribute_names, attribute_values);
       gtype_init = find_attribute ("glib:get-type", attribute_names, attribute_values);
-      gclass_struct = find_attribute ("glib:is-class-struct-for", attribute_names, attribute_values);      
+      gtype_struct = find_attribute ("glib:is-gtype-struct-for", attribute_names, attribute_values);
 
       if (name == NULL && ctx->node_stack == NULL)
        {
@@ -2165,7 +2168,7 @@ start_struct (GMarkupParseContext *context,
       if (disguised && strcmp (disguised, "1") == 0)
        struct_->disguised = TRUE;
       
-      struct_->is_gclass_struct = gclass_struct != NULL;
+      struct_->is_gtype_struct = gtype_struct != NULL;
 
       struct_->gtype_name = g_strdup (gtype_name);
       struct_->gtype_init = g_strdup (gtype_init);
index 673436a0404cdffd0f7e917d4911869697bc3f2f..6ff00bfbf8f64d08786e5f76100bc4182e57de34 100644 (file)
@@ -183,7 +183,7 @@ g_typelib_check_sanity (void)
   CHECK_SIZE (SignalBlob, 16);
   CHECK_SIZE (VFuncBlob, 20);
   CHECK_SIZE (ObjectBlob, 44);
-  CHECK_SIZE (InterfaceBlob, 36);
+  CHECK_SIZE (InterfaceBlob, 40);
   CHECK_SIZE (ConstantBlob, 24);
   CHECK_SIZE (AnnotationBlob, 12);
   CHECK_SIZE (UnionBlob, 40);
@@ -1458,11 +1458,11 @@ validate_object_blob (ValidateContext *ctx,
        }
     }
   
-  if (blob->class_struct != 0)
+  if (blob->gtype_struct != 0)
     {
       DirEntry *entry;
 
-      entry = get_dir_entry_checked (typelib, blob->class_struct, error);
+      entry = get_dir_entry_checked (typelib, blob->gtype_struct, error);
       if (!entry)
         return FALSE;
       if (entry->blob_type != BLOB_TYPE_STRUCT && entry->local)
index 9a78873e7d4b47fd3652b25d88c1cc8441d3e5a7..7a2838f183b40632e15ac3385f48ce3953bbde75 100644 (file)
@@ -72,6 +72,7 @@ G_BEGIN_DECLS
 TYPELIB HISTORY
 -----
 Version 1.0
+- Rename class_struct to gtype_struct, add to interfaces
 
 Changes since 0.9:
 - Add padding to structures
@@ -651,7 +652,7 @@ typedef struct {
  * @deprecated: Whether this structure is deprecated
  * @unregistered: If this is set, the type is not registered with GType.
  * @alignment: The byte boundary that the struct is aligned to in memory
- * @is_class_struct: Whether this structure is the "class structure" for a GObject
+ * @is_gtype_struct: Whether this structure is the class or interface layout for a GObject
  * @size: The size of the struct in bytes.
  * @gtype_name: String name of the associated #GType
  * @gtype_init: String naming the symbol which gets the runtime #GType
@@ -666,7 +667,7 @@ typedef struct {
 
   guint16   deprecated   : 1;
   guint16   unregistered : 1;
-  guint16   is_class_struct : 1;
+  guint16   is_gtype_struct : 1;
   guint16   alignment    : 6;  
   guint16   reserved     : 7;
 
@@ -900,7 +901,7 @@ typedef struct {
   guint32   gtype_init;
 
   guint16   parent;
-  guint16   class_struct;
+  guint16   gtype_struct;
 
   guint16   n_interfaces;
   guint16   n_fields;
@@ -929,6 +930,7 @@ typedef struct {
 
 /**
  * InterfaceBlob:
+ * @gtype_struct: Name of the interface "class" C structure
  * @n_prerequisites: Number of prerequisites
  * @n_properties: Number of properties
  * @n_methods: Number of methods
@@ -952,6 +954,7 @@ typedef struct {
 
   guint32 gtype_name;
   guint32 gtype_init;
+  guint16 gtype_struct;
 
   guint16 n_prerequisites;
   guint16 n_properties;
index ff65312c18ebe81efc587241c04312bb8c2369ea..e708258c6251b71096488b5e7353c24682fdd53a 100644 (file)
@@ -1,6 +1,7 @@
 # -*- Mode: Python -*-
 # GObject-Introspection - a framework for introspecting GObject libraries
 # Copyright (C) 2008  Johan Dahlin
+# Copyright (C) 2008, 2009 Red Hat, Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -366,11 +367,7 @@ class Record(Node):
         self.symbol = symbol
         self.disguised = disguised
         self.doc = None
-        self.constructors = []
         self.methods = []
-        # If true, this record defines the FooClass C structure
-        # for some Foo GObject
-        self.is_gobject_struct_for = False
 
 # BW compat, remove
 Struct = Record
@@ -410,7 +407,7 @@ class Class(Node):
         Node.__init__(self, name)
         self.ctype = name
         self.parent = parent
-        self.class_struct = None
+        self.glib_type_struct = None
         self.is_abstract = is_abstract
         self.methods = []
         self.static_methods = []
@@ -432,6 +429,7 @@ class Interface(Node):
         Node.__init__(self, name)
         self.parent = parent
         self.methods = []
+        self.glib_type_struct = None
         self.properties = []
         self.fields = []
         self.prerequisites = []
index 4742840d9f358e23fe0e04880dfe8b5b86db8a51..df527090507bbcdb1bd0fdbbfae2fdd129742c11 100644 (file)
@@ -1,6 +1,7 @@
 # -*- Mode: Python -*-
 # GObject-Introspection - a framework for introspecting GObject libraries
 # Copyright (C) 2008  Johan Dahlin
+# Copyright (C) 2008, 2009 Red Hat, Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -27,7 +28,8 @@ from .ast import (Alias, Array, Bitfield, Callback, Class, Constant, Enum,
                   Function, Interface, List, Map, Member, Struct, Union,
                   Varargs)
 from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember,
-                      GLibFlags, GLibObject, GLibInterface)
+                      GLibFlags, GLibObject, GLibInterface,
+                      GLibRecord)
 from .xmlwriter import XMLWriter
 
 
@@ -330,9 +332,8 @@ and/or use gtk-doc annotations. ''')
             attrs.append(('glib:type-name', node.type_name))
             if node.get_type:
                 attrs.append(('glib:get-type', node.get_type))
-        if isinstance(node, GLibObject):
-            if node.class_struct:
-                attrs.append(('glib:class-struct', node.class_struct.name))
+            if node.glib_type_struct:
+                attrs.append(('glib:type-struct', node.glib_type_struct.name))
         with self.tagcontext(tag_name, attrs):
             if isinstance(node, GLibObject):
                 for iface in node.interfaces:
@@ -408,9 +409,10 @@ and/or use gtk-doc annotations. ''')
             attrs.append(('c:type', record.symbol))
         if record.disguised:
             attrs.append(('disguised', '1'))
-        if record.is_gobject_struct_for:
-            attrs.append(('glib:is-class-struct-for',
-                          record.is_gobject_struct_for))
+        if isinstance(record, GLibRecord):
+            if record.is_gtype_struct_for:
+                attrs.append(('glib:is-gtype-struct-for',
+                              record.is_gtype_struct_for))
         if record.doc:
             attrs.append(('doc', record.doc))
         self._append_version(record, attrs)
index f61cd5f30e7e4e627aeadf879cb3332d45397e96..e2a9d5b2f3e7058d99af0fda1bd531ba7496c5b4 100644 (file)
@@ -19,7 +19,7 @@
 #
 
 from .ast import (Bitfield, Class, Enum, Interface, Member, Node,
-                  Property, Struct, Union)
+                  Property, Struct, Union, Record)
 from .ast import (
     type_names, default_array_types,
     TYPE_STRING, TYPE_INT8, TYPE_UINT8, TYPE_INT16, TYPE_UINT16,
@@ -62,6 +62,22 @@ type_names['gushort'] = TYPE_UINT16
 default_array_types['guint8*'] = TYPE_UINT8
 default_array_types['gchar**'] = TYPE_STRING
 
+class GLibRecord(Record):
+    def __init__(self, *args, **kwargs):
+        Record.__init__(self, *args, **kwargs)
+
+    @classmethod
+    def from_record(cls, record):
+        obj = cls(record.name, record.symbol)
+        obj.fields = record.fields
+        obj.constructors = record.constructors
+        obj.disguised = record.disguised
+        obj.doc = record.doc
+        obj.methods = record.methods
+        # If true, this record defines the FooClass C structure
+        # for some Foo GObject (or similar for GInterface)
+        obj.is_gtype_struct_for = False
+        return obj
 
 class GLibEnum(Enum):
 
index e5dd3a1807f742e03e5957b1f8acedd6aeb25b6b..5a7a96d2e746cf24891cb43a49a9b26ee69e5f21 100644 (file)
@@ -32,7 +32,7 @@ from .ast import (Alias, Bitfield, Callback, Constant, Enum, Function, Member,
 from .transformer import Names
 from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags,
                       GLibInterface, GLibObject, GLibSignal, GLibBoxedStruct,
-                      GLibBoxedUnion, GLibBoxedOther, type_names)
+                      GLibBoxedUnion, GLibBoxedOther, GLibRecord, type_names)
 from .utils import to_underscores, to_underscores_noprefix
 
 default_array_types['guchar*'] = TYPE_UINT8
@@ -573,13 +573,15 @@ class GLibTransformer(object):
         for field in maybe_class.fields:
             if isinstance(field, Field):
                 field.writable = False
+        # TODO: remove this, we should be computing vfuncs instead
         if isinstance(pair_class, GLibInterface):
             for field in maybe_class.fields[1:]:
                 pair_class.fields.append(field)
-            return
-        elif isinstance(pair_class, GLibObject):
-            pair_class.class_struct = class_struct
-            class_struct.is_gobject_struct_for = name
+        gclass_struct = GLibRecord.from_record(class_struct)
+        self._remove_attribute(class_struct.name)
+        self._add_attribute(gclass_struct, True)
+        pair_class.glib_type_struct = gclass_struct
+        gclass_struct.is_gtype_struct_for = name
 
     # Introspection
 
index 007ce02ea1a971861dd42076c517c9371a7a7cdd..0e674670b41385f65494ff8d58e928e390110df2 100644 (file)
@@ -70,5 +70,8 @@ main(int argc, char **argv)
 
   test_constructor_return_type (info);
 
+  info = g_irepository_find_by_name (repo, "Gio", "ThisDoesNotExist");
+  g_assert (info == NULL);
+
   exit(0);
 }
index 91b044dd8eb86ca48923d7e471b672cca3f20335..da8c825ed09da6512ba4b2929921e2631931745e 100644 (file)
@@ -15,14 +15,14 @@ and/or use gtk-doc annotations.  -->
            parent="GObject.Object"
            glib:type-name="BarBaz"
            glib:get-type="bar_baz_get_type"
-           glib:class-struct="BazClass">
+           glib:type-struct="BazClass">
       <field name="parent_instance">
         <type name="GObject.Object" c:type="GObject"/>
       </field>
     </class>
     <record name="BazClass"
             c:type="BarBazClass"
-            glib:is-class-struct-for="Baz">
+            glib:is-gtype-struct-for="Baz">
       <field name="parent_class">
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
index 4a99be5de340dee0e6c339bfc174696daee1f8b8..20173cb962a164bcdd0a7edefa8289266da89d2b 100644 (file)
@@ -6,12 +6,12 @@
   <include name="GObject" version="2.0"/>
   <include name="GLib" version="2.0"/>
   <namespace name="BarApp" version="1.0" shared-library="">
-    <class name="Baz" parent="GObject.Object" glib:class-struct="BazClass" glib:type-name="BarBaz" glib:get-type="bar_baz_get_type">
+    <class name="Baz" parent="GObject.Object" glib:type-struct="BazClass" glib:type-name="BarBaz" glib:get-type="bar_baz_get_type">
       <field name="parent_instance">
         <type name="GObject.Object"/>
       </field>
     </class>
-    <record name="BazClass" glib:is-class-struct="1">
+    <record name="BazClass" glib:is-gtype-struct="1">
       <field name="parent_class">
         <type name="GObject.ObjectClass"/>
       </field>
index 1833f7391c8726f1a30843928a0659745b1e5b40..053d459a0ef6f15f917194ff2478c676eb56b072 100644 (file)
@@ -61,7 +61,7 @@ and/or use gtk-doc annotations.  -->
            parent="GObject.Object"
            glib:type-name="AnnotationObject"
            glib:get-type="annotation_object_get_type"
-           glib:class-struct="ObjectClass">
+           glib:type-struct="ObjectClass">
       <method name="method" c:identifier="annotation_object_method">
         <return-value transfer-ownership="none">
           <type name="int" c:type="gint"/>
@@ -472,7 +472,7 @@ known by GObject as it&apos;s only marked as G_TYPE_POINTER">
     </class>
     <record name="ObjectClass"
             c:type="AnnotationObjectClass"
-            glib:is-class-struct-for="Object">
+            glib:is-gtype-struct-for="Object">
       <field name="parent_class">
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
index a201ec622f3283238553443bc1420a4a3909e825..643ffb28e15b41766ea7ae049d79edafc9da1a87 100644 (file)
@@ -47,7 +47,7 @@
         </parameter>
       </parameters>
     </callback>
-    <class name="Object" parent="GObject.Object" glib:class-struct="ObjectClass" glib:type-name="AnnotationObject" glib:get-type="annotation_object_get_type">
+    <class name="Object" parent="GObject.Object" glib:type-struct="ObjectClass" glib:type-name="AnnotationObject" glib:get-type="annotation_object_get_type">
       <field name="parent_instance">
         <type name="GObject.Object"/>
       </field>
         </parameters>
       </glib:signal>
     </class>
-    <record name="ObjectClass" glib:is-class-struct="1">
+    <record name="ObjectClass" glib:is-gtype-struct="1">
       <field name="parent_class">
         <type name="GObject.ObjectClass"/>
       </field>
index 4affc68e815c10848079a8daf883c81cbd4855bd..052e788af22c1da6e5eb0aedab8e573d9c7e5e4b 100644 (file)
@@ -17,7 +17,7 @@ and/or use gtk-doc annotations.  -->
            abstract="1"
            glib:type-name="TestDrawable"
            glib:get-type="test_drawable_get_type"
-           glib:class-struct="TestDrawableClass">
+           glib:type-struct="TestDrawableClass">
       <method name="do_foo" c:identifier="test_drawable_do_foo">
         <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
@@ -72,7 +72,7 @@ and/or use gtk-doc annotations.  -->
     </class>
     <record name="TestDrawableClass"
             c:type="TestDrawableClass"
-            glib:is-class-struct-for="TestDrawable">
+            glib:is-gtype-struct-for="TestDrawable">
       <field name="parent_class">
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
index 612022b70da688a4d38d08a0dc951c9a2b30479d..2c939612ca3b5cb99fb91b12958144405e80f519 100644 (file)
@@ -7,7 +7,7 @@
   <include name="GObject" version="2.0"/>
   <include name="GLib" version="2.0"/>
   <namespace name="drawable" version="1.0" shared-library="drawable">
-    <class name="TestDrawable" parent="GObject.Object" glib:class-struct="TestDrawableClass" abstract="1" glib:type-name="TestDrawable" glib:get-type="test_drawable_get_type">
+    <class name="TestDrawable" parent="GObject.Object" glib:type-struct="TestDrawableClass" abstract="1" glib:type-name="TestDrawable" glib:get-type="test_drawable_get_type">
       <field name="parent_instance">
         <type name="GObject.Object"/>
       </field>
@@ -58,7 +58,7 @@
         </parameters>
       </method>
     </class>
-    <record name="TestDrawableClass" glib:is-class-struct="1">
+    <record name="TestDrawableClass" glib:is-gtype-struct="1">
       <field name="parent_class">
         <type name="GObject.ObjectClass"/>
       </field>
index 4bd77452cd2df61248476597a29e336e157c857e..0f6b1f1f2155aa62f7f88b33ba681a5efdbd6019 100644 (file)
@@ -94,7 +94,7 @@ and/or use gtk-doc annotations.  -->
            parent="GObject.Object"
            glib:type-name="FooBuffer"
            glib:get-type="foo_buffer_get_type"
-           glib:class-struct="BufferClass">
+           glib:type-struct="BufferClass">
       <implements name="Interface"/>
       <method name="some_method" c:identifier="foo_buffer_some_method">
         <return-value transfer-ownership="none">
@@ -104,7 +104,7 @@ and/or use gtk-doc annotations.  -->
     </class>
     <record name="BufferClass"
             c:type="FooBufferClass"
-            glib:is-class-struct-for="Buffer">
+            glib:is-gtype-struct-for="Buffer">
     </record>
     <callback name="Callback" c:type="FooCallback">
       <return-value transfer-ownership="none">
@@ -230,7 +230,8 @@ and/or use gtk-doc annotations.  -->
     <interface name="Interface"
                c:type="FooInterface"
                glib:type-name="FooInterface"
-               glib:get-type="foo_interface_get_type">
+               glib:get-type="foo_interface_get_type"
+               glib:type-struct="InterfaceIface">
       <callback name="do_foo" c:type="do_foo">
         <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
@@ -242,7 +243,9 @@ and/or use gtk-doc annotations.  -->
         </parameters>
       </callback>
     </interface>
-    <record name="InterfaceIface" c:type="FooInterfaceIface">
+    <record name="InterfaceIface"
+            c:type="FooInterfaceIface"
+            glib:is-gtype-struct-for="Interface">
       <field name="parent_iface">
         <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
       </field>
@@ -262,7 +265,7 @@ and/or use gtk-doc annotations.  -->
            parent="GObject.Object"
            glib:type-name="FooObject"
            glib:get-type="foo_object_get_type"
-           glib:class-struct="ObjectClass">
+           glib:type-struct="ObjectClass">
       <implements name="Interface"/>
       <constructor name="new" c:identifier="foo_object_new">
         <return-value transfer-ownership="full">
@@ -381,7 +384,7 @@ and/or use gtk-doc annotations.  -->
     </class>
     <record name="ObjectClass"
             c:type="FooObjectClass"
-            glib:is-class-struct-for="Object">
+            glib:is-gtype-struct-for="Object">
       <field name="parent_class">
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
@@ -461,7 +464,8 @@ and/or use gtk-doc annotations.  -->
     <interface name="SubInterface"
                c:type="FooSubInterface"
                glib:type-name="FooSubInterface"
-               glib:get-type="foo_sub_interface_get_type">
+               glib:get-type="foo_sub_interface_get_type"
+               glib:type-struct="SubInterfaceIface">
       <prerequisite name="Interface"/>
       <method name="do_bar" c:identifier="foo_sub_interface_do_bar">
         <return-value transfer-ownership="none">
@@ -479,7 +483,9 @@ and/or use gtk-doc annotations.  -->
         </parameters>
       </callback>
     </interface>
-    <record name="SubInterfaceIface" c:type="FooSubInterfaceIface">
+    <record name="SubInterfaceIface"
+            c:type="FooSubInterfaceIface"
+            glib:is-gtype-struct-for="SubInterface">
       <field name="parent_iface">
         <type name="GObject.TypeInterface" c:type="GTypeInterface"/>
       </field>
@@ -500,7 +506,7 @@ and/or use gtk-doc annotations.  -->
            abstract="1"
            glib:type-name="FooSubobject"
            glib:get-type="foo_subobject_get_type"
-           glib:class-struct="SubobjectClass">
+           glib:type-struct="SubobjectClass">
       <implements name="Interface"/>
       <constructor name="new" c:identifier="foo_subobject_new">
         <return-value transfer-ownership="full">
@@ -513,7 +519,7 @@ and/or use gtk-doc annotations.  -->
     </class>
     <record name="SubobjectClass"
             c:type="FooSubobjectClass"
-            glib:is-class-struct-for="Subobject">
+            glib:is-gtype-struct-for="Subobject">
       <field name="parent_class">
         <type name="ObjectClass" c:type="FooObjectClass"/>
       </field>
index dcd978915a9397f8f63a04e5722d1d3a10c956e1..f8e1ee59674d6fe994f7f4415b6e07d1c4831684 100644 (file)
@@ -71,7 +71,7 @@
         </return-value>
       </method>
     </record>
-    <class name="Buffer" parent="GObject.Object" glib:class-struct="BufferClass" glib:type-name="FooBuffer" glib:get-type="foo_buffer_get_type">
+    <class name="Buffer" parent="GObject.Object" glib:type-struct="BufferClass" glib:type-name="FooBuffer" glib:get-type="foo_buffer_get_type">
       <implements name="Interface"/>
       <method name="some_method" c:identifier="foo_buffer_some_method">
         <return-value transfer-ownership="none">
@@ -79,7 +79,7 @@
         </return-value>
       </method>
     </class>
-    <record name="BufferClass" glib:is-class-struct="1"/>
+    <record name="BufferClass" glib:is-gtype-struct="1"/>
     <callback name="Callback">
       <return-value transfer-ownership="none">
         <type name="boolean"/>
       <member name="second" value="2"/>
       <member name="third" value="4"/>
     </bitfield>
-    <interface name="Interface" glib:type-name="FooInterface" glib:get-type="foo_interface_get_type"/>
-    <record name="InterfaceIface">
+    <interface name="Interface" glib:type-name="FooInterface" glib:get-type="foo_interface_get_type" glib:type-struct="InterfaceIface"/>
+    <record name="InterfaceIface" glib:is-gtype-struct="1">
       <field name="parent_iface">
         <type name="GObject.TypeInterface"/>
       </field>
     </record>
-    <class name="Object" parent="GObject.Object" glib:class-struct="ObjectClass" glib:type-name="FooObject" glib:get-type="foo_object_get_type">
+    <class name="Object" parent="GObject.Object" glib:type-struct="ObjectClass" glib:type-name="FooObject" glib:get-type="foo_object_get_type">
       <implements name="Interface"/>
       <field name="parent_instance">
         <type name="GObject.Object"/>
         </parameters>
       </glib:signal>
     </class>
-    <record name="ObjectClass" glib:is-class-struct="1">
+    <record name="ObjectClass" glib:is-gtype-struct="1">
       <field name="parent_class">
         <type name="GObject.ObjectClass"/>
       </field>
       </field>
     </record>
     <record name="StructPrivate"/>
-    <interface name="SubInterface" glib:type-name="FooSubInterface" glib:get-type="foo_sub_interface_get_type">
+    <interface name="SubInterface" glib:type-name="FooSubInterface" glib:get-type="foo_sub_interface_get_type" glib:type-struct="SubInterfaceIface">
       <prerequisite name="Interface"/>
       <method name="do_bar" c:identifier="foo_sub_interface_do_bar">
         <return-value transfer-ownership="none">
         </return-value>
       </method>
     </interface>
-    <record name="SubInterfaceIface">
+    <record name="SubInterfaceIface" glib:is-gtype-struct="1">
       <field name="parent_iface">
         <type name="GObject.TypeInterface"/>
       </field>
     </record>
-    <class name="Subobject" parent="Object" glib:class-struct="SubobjectClass" abstract="1" glib:type-name="FooSubobject" glib:get-type="foo_subobject_get_type">
+    <class name="Subobject" parent="Object" glib:type-struct="SubobjectClass" abstract="1" glib:type-name="FooSubobject" glib:get-type="foo_subobject_get_type">
       <implements name="Interface"/>
       <field name="parent_instance">
         <type name="Object"/>
         </return-value>
       </constructor>
     </class>
-    <record name="SubobjectClass" glib:is-class-struct="1">
+    <record name="SubobjectClass" glib:is-gtype-struct="1">
       <field name="parent_class">
         <type name="ObjectClass"/>
       </field>
index 3d8aed064c58f46dd86e436b5718a758ff6ca10e..7ff6ca5a9dad59399a7bbef2b895d0d2d0d6dcf7 100644 (file)
@@ -52,7 +52,7 @@ and/or use gtk-doc annotations.  -->
            parent="GObject.Object"
            glib:type-name="UtilityObject"
            glib:get-type="utility_object_get_type"
-           glib:class-struct="ObjectClass">
+           glib:type-struct="ObjectClass">
       <method name="watch_dir" c:identifier="utility_object_watch_dir">
         <return-value transfer-ownership="none">
           <type name="none" c:type="void"/>
@@ -81,7 +81,7 @@ and/or use gtk-doc annotations.  -->
     </class>
     <record name="ObjectClass"
             c:type="UtilityObjectClass"
-            glib:is-class-struct-for="Object">
+            glib:is-gtype-struct-for="Object">
       <field name="parent_class">
         <type name="GObject.ObjectClass" c:type="GObjectClass"/>
       </field>
index 34bdce55948470367f0c63328d68a652b3d5dcb7..46ba2922a53d2fca008cde5301548e89885be551 100644 (file)
@@ -34,7 +34,7 @@
       <member name="b" value="1"/>
       <member name="c" value="2"/>
     </enumeration>
-    <class name="Object" parent="GObject.Object" glib:class-struct="ObjectClass" glib:type-name="UtilityObject" glib:get-type="utility_object_get_type">
+    <class name="Object" parent="GObject.Object" glib:type-struct="ObjectClass" glib:type-name="UtilityObject" glib:get-type="utility_object_get_type">
       <field name="parent_instance">
         <type name="GObject.Object"/>
       </field>
@@ -58,7 +58,7 @@
         </parameters>
       </method>
     </class>
-    <record name="ObjectClass" glib:is-class-struct="1">
+    <record name="ObjectClass" glib:is-gtype-struct="1">
       <field name="parent_class">
         <type name="GObject.ObjectClass"/>
       </field>
index 8b4185fcec050f8aba28278758e711c5c950c410..80c3980775cfeb859ad62a6d70ab8b656358a450 100644 (file)
@@ -566,7 +566,7 @@ write_struct_info (const gchar  *namespace,
   const gchar *type_name;
   const gchar *type_init;
   gboolean deprecated;
-  gboolean is_class_struct;
+  gboolean is_gtype_struct;
   gint i;
   int n_elts;
 
@@ -593,9 +593,9 @@ write_struct_info (const gchar  *namespace,
   if (deprecated)
     xml_printf (file, " deprecated=\"1\"");
   
-  is_class_struct = g_struct_info_is_class_struct (info);
-  if (is_class_struct)
-    xml_printf (file, " glib:is-class-struct=\"1\"");
+  is_gtype_struct = g_struct_info_is_gtype_struct (info);
+  if (is_gtype_struct)
+    xml_printf (file, " glib:is-gtype-struct=\"1\"");
        
   n_elts = g_struct_info_get_n_fields (info) + g_struct_info_get_n_methods (info);
   if (n_elts > 0)
@@ -931,7 +931,7 @@ write_object_info (const gchar  *namespace,
   class_struct = g_object_info_get_class_struct (info);
   if (class_struct)
     {
-      write_type_name_attribute (namespace, (GIBaseInfo*) class_struct, "glib:class-struct", file);
+      write_type_name_attribute (namespace, (GIBaseInfo*) class_struct, "glib:type-struct", file);
       g_base_info_unref ((GIBaseInfo*)class_struct);
     }
 
@@ -1009,6 +1009,7 @@ write_interface_info (const gchar     *namespace,
   const gchar *name;
   const gchar *type_name;
   const gchar *type_init;
+  GIStructInfo *class_struct;
   gboolean deprecated;
   gint i;
 
@@ -1021,6 +1022,13 @@ write_interface_info (const gchar     *namespace,
   xml_printf (file, " name=\"%s\" glib:type-name=\"%s\" glib:get-type=\"%s\"",
             name, type_name, type_init);
 
+  class_struct = g_interface_info_get_iface_struct (info);
+  if (class_struct)
+    {
+      write_type_name_attribute (namespace, (GIBaseInfo*) class_struct, "glib:type-struct", file);
+      g_base_info_unref ((GIBaseInfo*)class_struct);
+    }
+
   if (deprecated)
     xml_printf (file, " deprecated=\"1\"");