summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-10-19 18:18:14 -0400
committerColin Walters <walters@verbum.org>2009-10-21 14:19:26 -0400
commit0d9cfb004d528fd0a7a0b05943db3b2097d8a085 (patch)
tree4ff2d7c08d762c0ee28e3625cc28af5db743ba7c
parentf152f5e97df7783c61907b5f201840afbd46331f (diff)
downloadgobject-introspection-0d9cfb004d528fd0a7a0b05943db3b2097d8a085.tar.gz
Use best known derived parent
In the case where a known class derives from a hidden one, we want to use the most-derived parent class, rather than simply falling back to GObject. Example: ShellEmbedWidget in gnome-shell derives from ClutterGLXTexturePixmap from clutter, which is a hidden class. ClutterGLXTexturePixmap's parent itself is ClutterX11TexturePixmap, which is also hidden. But its parent is ClutterTexture, which we do know. Use that. https://bugzilla.gnome.org/show_bug.cgi?id=598993
-rw-r--r--girepository/gdump.c22
-rw-r--r--giscanner/glibtransformer.py18
2 files changed, 37 insertions, 3 deletions
diff --git a/girepository/gdump.c b/girepository/gdump.c
index 519672aa..b4a3e8eb 100644
--- a/girepository/gdump.c
+++ b/girepository/gdump.c
@@ -154,7 +154,27 @@ dump_object_type (GType type, const char *symbol, GOutputStream *out)
escaped_printf (out, " <class name=\"%s\" get-type=\"%s\"",
g_type_name (type), symbol);
if (type != G_TYPE_OBJECT)
- escaped_printf (out, " parent=\"%s\"", g_type_name (g_type_parent (type)));
+ {
+ GString *parent_str;
+ GType parent;
+ gboolean first = TRUE;
+
+ parent = type;
+ parent_str = g_string_new ("");
+ do
+ {
+ parent = g_type_parent (parent);
+ if (first)
+ first = FALSE;
+ else
+ g_string_append_c (parent_str, ',');
+ g_string_append (parent_str, g_type_name (parent));
+ } while (parent != G_TYPE_OBJECT && parent != G_TYPE_INVALID);
+
+ escaped_printf (out, " parents=\"%s\"", parent_str->str);
+
+ g_string_free (parent_str, TRUE);
+ }
if (G_TYPE_IS_ABSTRACT (type))
escaped_printf (out, " abstract=\"1\"");
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index 5b94ef75..76085c1a 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -255,6 +255,17 @@ class GLibTransformer(object):
self._names)
except KeyError, e:
return Unresolved(gtype_name)
+
+ def _resolve_gtypename_chain(self, gtype_names):
+ """Like _resolve_gtypename, but grab the first one that resolves.
+ If none of them do, return an Unresolved for the first."""
+ for gtype_name in gtype_names:
+ try:
+ return self._transformer.gtypename_to_giname(gtype_name,
+ self._names)
+ except KeyError, e:
+ continue
+ return Unresolved(gtype_names[0])
def _execute_binary(self):
in_path = os.path.join(self._binary.tmpdir, 'types.txt')
@@ -687,8 +698,11 @@ class GLibTransformer(object):
# to skip it
if type_name == 'GObject':
return
- parent_type_name = xmlnode.attrib['parent']
- parent_gitype = self._resolve_gtypename(parent_type_name)
+ # Get a list of parents here; some of them may be hidden, and what
+ # we really want to do is use the most-derived one that we know of.
+ #
+ parent_type_names = xmlnode.attrib['parents'].split(',')
+ parent_gitype = self._resolve_gtypename_chain(parent_type_names)
is_abstract = not not xmlnode.attrib.get('abstract', False)
node = GLibObject(
self._transformer.remove_prefix(type_name),