summaryrefslogtreecommitdiff
path: root/girepository/girnode.c
diff options
context:
space:
mode:
authorColin Walters <walters@src.gnome.org>2009-02-06 18:37:13 +0000
committerColin Walters <walters@src.gnome.org>2009-02-06 18:37:13 +0000
commitd1bf6a23c6fa14e918aa93e346237b1c832fb2ea (patch)
tree715bf149bfa948eed8a1da945e2c0984ea81df73 /girepository/girnode.c
parent3ae9127e53032065df14be8539aba0cf50835386 (diff)
downloadgobject-introspection-d1bf6a23c6fa14e918aa93e346237b1c832fb2ea.tar.gz
Bug 551738 - Associate classes with their structs
Inside glibtransformer, we now look at structures ending in "Class" and see if they have an associated GlibObject (i.e. a structure of the same name without the "Class" suffix). If found, pair them up. The .gir file for <class> gains an attribute denoting its associated class struct. Any <record> many now have a glib:is-class-struct-for annotation which tells which (if any) <class> for which it defines the layout. In the .typelib, we record the association between the class and its structure. Generic structures however just have a boolean saying whether they're a class struct. (Going from a generic class struct to its class should not be necessary). Finally, we expose GIRepository APIs to access both bits of information from the .typelib. svn path=/trunk/; revision=1088
Diffstat (limited to 'girepository/girnode.c')
-rw-r--r--girepository/girnode.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/girepository/girnode.c b/girepository/girnode.c
index abec606a..cc8aa508 100644
--- a/girepository/girnode.c
+++ b/girepository/girnode.c
@@ -285,7 +285,8 @@ g_ir_node_free (GIrNode *node)
g_free (node->name);
g_free (iface->gtype_name);
g_free (iface->gtype_init);
-
+
+ g_free (iface->class_struct);
g_free (iface->parent);
for (l = iface->interfaces; l; l = l->next)
@@ -431,7 +432,7 @@ g_ir_node_get_size (GIrNode *node)
GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->interfaces);
- size = 32 + 2 * (n + (n % 2));
+ size = sizeof(ObjectBlob) + 2 * (n + (n % 2));
for (l = iface->members; l; l = l->next)
size += g_ir_node_get_size ((GIrNode *)l->data);
@@ -647,9 +648,11 @@ g_ir_node_get_full_size_internal (GIrNode *parent,
GIrNodeInterface *iface = (GIrNodeInterface *)node;
n = g_list_length (iface->interfaces);
- size = 32;
+ 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);
size += ALIGN_VALUE (strlen (node->name) + 1, 4);
size += ALIGN_VALUE (strlen (iface->gtype_name) + 1, 4);
if (iface->gtype_init)
@@ -1792,6 +1795,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->reserved = 0;
blob->name = write_string (node->name, strings, data, offset2);
blob->alignment = struct_->alignment;
@@ -2001,6 +2005,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);
+ else
+ blob->class_struct = 0;
blob->n_interfaces = 0;
blob->n_fields = 0;
@@ -2010,7 +2018,7 @@ g_ir_node_build_typelib (GIrNode *node,
blob->n_vfuncs = 0;
blob->n_constants = 0;
- *offset += 32;
+ *offset += sizeof(ObjectBlob);
for (l = object->interfaces; l; l = l->next)
{
blob->n_interfaces++;