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
This commit is contained in:
Colin Walters 2009-02-06 18:37:13 +00:00 committed by Philip Withnall
parent 981e55ef57
commit d90d14cf67

View File

@ -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\"");