From 251de52b083d3e0e42f25cb164a46865c2c2b9a9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 20 Feb 2009 22:34:20 +0000 Subject: Bug 572434 - Associate interfaces with their C structures 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. --- diff --git a/docs/reference/gi-sections.txt b/docs/reference/gi-sections.txt index 69d87ed..96ef8fb 100644 --- a/docs/reference/gi-sections.txt +++ b/docs/reference/gi-sections.txt @@ -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 diff --git a/girepository/ginfo.c b/girepository/ginfo.c index 7ecfe63..1c34ee2 100644 --- a/girepository/ginfo.c +++ b/girepository/ginfo.c @@ -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 diff --git a/girepository/girepository.h b/girepository/girepository.h index 3508f4d..61a9116 100644 --- a/girepository/girepository.h +++ b/girepository/girepository.h @@ -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 */ diff --git a/girepository/girnode.c b/girepository/girnode.c index 0aafa44..7863c25 100644 --- a/girepository/girnode.c +++ b/girepository/girnode.c @@ -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; diff --git a/girepository/girnode.h b/girepository/girnode.h index 33848db..7ea8a32 100644 --- a/girepository/girnode.h +++ b/girepository/girnode.h @@ -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; diff --git a/girepository/girparser.c b/girepository/girparser.c index 795658e..e08b3fc 100644 --- a/girepository/girparser.c +++ b/girepository/girparser.c @@ -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); diff --git a/girepository/gtypelib.c b/girepository/gtypelib.c index 673436a..6ff00bf 100644 --- a/girepository/gtypelib.c +++ b/girepository/gtypelib.c @@ -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) diff --git a/girepository/gtypelib.h b/girepository/gtypelib.h index 9a78873..7a2838f 100644 --- a/girepository/gtypelib.h +++ b/girepository/gtypelib.h @@ -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; diff --git a/giscanner/ast.py b/giscanner/ast.py index ff65312..e708258 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -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 = [] diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 4742840..df52709 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -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) diff --git a/giscanner/glibast.py b/giscanner/glibast.py index f61cd5f..e2a9d5b 100644 --- a/giscanner/glibast.py +++ b/giscanner/glibast.py @@ -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): diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index e5dd3a1..5a7a96d 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -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 diff --git a/tests/repository/gitestrepo.c b/tests/repository/gitestrepo.c index 007ce02..0e67467 100644 --- a/tests/repository/gitestrepo.c +++ b/tests/repository/gitestrepo.c @@ -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); } diff --git a/tests/scanner/BarApp-1.0-expected.gir b/tests/scanner/BarApp-1.0-expected.gir index 91b044d..da8c825 100644 --- a/tests/scanner/BarApp-1.0-expected.gir +++ b/tests/scanner/BarApp-1.0-expected.gir @@ -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"> + glib:is-gtype-struct-for="Baz"> diff --git a/tests/scanner/BarApp-1.0-expected.tgir b/tests/scanner/BarApp-1.0-expected.tgir index 4a99be5..20173cb 100644 --- a/tests/scanner/BarApp-1.0-expected.tgir +++ b/tests/scanner/BarApp-1.0-expected.tgir @@ -6,12 +6,12 @@ - + - + diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir index 1833f73..053d459 100644 --- a/tests/scanner/annotation-1.0-expected.gir +++ b/tests/scanner/annotation-1.0-expected.gir @@ -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"> @@ -472,7 +472,7 @@ known by GObject as it's only marked as G_TYPE_POINTER"> + glib:is-gtype-struct-for="Object"> diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir index a201ec6..643ffb2 100644 --- a/tests/scanner/annotation-1.0-expected.tgir +++ b/tests/scanner/annotation-1.0-expected.tgir @@ -47,7 +47,7 @@ - + @@ -349,7 +349,7 @@ - + diff --git a/tests/scanner/drawable-1.0-expected.gir b/tests/scanner/drawable-1.0-expected.gir index 4affc68..052e788 100644 --- a/tests/scanner/drawable-1.0-expected.gir +++ b/tests/scanner/drawable-1.0-expected.gir @@ -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"> @@ -72,7 +72,7 @@ and/or use gtk-doc annotations. --> + glib:is-gtype-struct-for="TestDrawable"> diff --git a/tests/scanner/drawable-1.0-expected.tgir b/tests/scanner/drawable-1.0-expected.tgir index 612022b..2c93961 100644 --- a/tests/scanner/drawable-1.0-expected.tgir +++ b/tests/scanner/drawable-1.0-expected.tgir @@ -7,7 +7,7 @@ - + @@ -58,7 +58,7 @@ - + diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir index 4bd7745..0f6b1f1 100644 --- a/tests/scanner/foo-1.0-expected.gir +++ b/tests/scanner/foo-1.0-expected.gir @@ -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"> @@ -104,7 +104,7 @@ and/or use gtk-doc annotations. --> + glib:is-gtype-struct-for="Buffer"> @@ -230,7 +230,8 @@ and/or use gtk-doc annotations. --> + glib:get-type="foo_interface_get_type" + glib:type-struct="InterfaceIface"> @@ -242,7 +243,9 @@ and/or use gtk-doc annotations. --> - + @@ -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"> @@ -381,7 +384,7 @@ and/or use gtk-doc annotations. --> + glib:is-gtype-struct-for="Object"> @@ -461,7 +464,8 @@ and/or use gtk-doc annotations. --> + glib:get-type="foo_sub_interface_get_type" + glib:type-struct="SubInterfaceIface"> @@ -479,7 +483,9 @@ and/or use gtk-doc annotations. --> - + @@ -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"> @@ -513,7 +519,7 @@ and/or use gtk-doc annotations. --> + glib:is-gtype-struct-for="Subobject"> diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir index dcd9789..f8e1ee5 100644 --- a/tests/scanner/foo-1.0-expected.tgir +++ b/tests/scanner/foo-1.0-expected.tgir @@ -71,7 +71,7 @@ - + @@ -79,7 +79,7 @@ - + @@ -161,13 +161,13 @@ - - + + - + @@ -272,7 +272,7 @@ - + @@ -335,7 +335,7 @@ - + @@ -343,12 +343,12 @@ - + - + @@ -359,7 +359,7 @@ - + diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir index 3d8aed0..7ff6ca5 100644 --- a/tests/scanner/utility-1.0-expected.gir +++ b/tests/scanner/utility-1.0-expected.gir @@ -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"> @@ -81,7 +81,7 @@ and/or use gtk-doc annotations. --> + glib:is-gtype-struct-for="Object"> diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir index 34bdce5..46ba292 100644 --- a/tests/scanner/utility-1.0-expected.tgir +++ b/tests/scanner/utility-1.0-expected.tgir @@ -34,7 +34,7 @@ - + @@ -58,7 +58,7 @@ - + diff --git a/tools/generate.c b/tools/generate.c index 8b4185f..80c3980 100644 --- a/tools/generate.c +++ b/tools/generate.c @@ -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\""); -- cgit v0.9.1