mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 08:58:54 +02:00
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:
@@ -1530,6 +1530,7 @@ start_class (GMarkupParseContext *context,
|
||||
{
|
||||
const gchar *name;
|
||||
const gchar *parent;
|
||||
const gchar *class_struct;
|
||||
const gchar *typename;
|
||||
const gchar *typeinit;
|
||||
const gchar *deprecated;
|
||||
@@ -1537,6 +1538,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);
|
||||
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);
|
||||
@@ -1557,6 +1559,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);
|
||||
if (deprecated)
|
||||
iface->deprecated = TRUE;
|
||||
else
|
||||
@@ -2122,6 +2125,7 @@ start_struct (GMarkupParseContext *context,
|
||||
const gchar *disguised;
|
||||
const gchar *gtype_name;
|
||||
const gchar *gtype_init;
|
||||
const gchar *gclass_struct;
|
||||
GIrNodeStruct *struct_;
|
||||
|
||||
name = find_attribute ("name", attribute_names, attribute_values);
|
||||
@@ -2129,6 +2133,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);
|
||||
|
||||
if (name == NULL && ctx->node_stack == NULL)
|
||||
{
|
||||
@@ -2156,6 +2161,8 @@ start_struct (GMarkupParseContext *context,
|
||||
|
||||
if (disguised && strcmp (disguised, "1") == 0)
|
||||
struct_->disguised = TRUE;
|
||||
|
||||
struct_->is_gclass_struct = gclass_struct != NULL;
|
||||
|
||||
struct_->gtype_name = g_strdup (gtype_name);
|
||||
struct_->gtype_init = g_strdup (gtype_init);
|
||||
|
Reference in New Issue
Block a user