summaryrefslogtreecommitdiff
path: root/tools/generate.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 /tools/generate.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 'tools/generate.c')
-rw-r--r--tools/generate.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/generate.c b/tools/generate.c
index dcc36faf..8b4185fc 100644
--- a/tools/generate.c
+++ b/tools/generate.c
@@ -566,6 +566,7 @@ write_struct_info (const gchar *namespace,
const gchar *type_name;
const gchar *type_init;
gboolean deprecated;
+ gboolean is_class_struct;
gint i;
int n_elts;
@@ -591,6 +592,10 @@ 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\"");
n_elts = g_struct_info_get_n_fields (info) + g_struct_info_get_n_methods (info);
if (n_elts > 0)
@@ -904,6 +909,7 @@ write_object_info (const gchar *namespace,
gboolean deprecated;
gboolean is_abstract;
GIObjectInfo *pnode;
+ GIStructInfo *class_struct;
gint i;
name = g_base_info_get_name ((GIBaseInfo *)info);
@@ -921,6 +927,13 @@ write_object_info (const gchar *namespace,
write_type_name_attribute (namespace, (GIBaseInfo *)pnode, "parent", file);
g_base_info_unref ((GIBaseInfo *)pnode);
}
+
+ class_struct = g_object_info_get_class_struct (info);
+ if (class_struct)
+ {
+ write_type_name_attribute (namespace, (GIBaseInfo*) class_struct, "glib:class-struct", file);
+ g_base_info_unref ((GIBaseInfo*)class_struct);
+ }
if (is_abstract)
xml_printf (file, " abstract=\"1\"");