summaryrefslogtreecommitdiff
path: root/giscanner
diff options
context:
space:
mode:
authorColin Walters <walters@src.gnome.org>2009-02-02 16:31:06 +0000
committerColin Walters <walters@src.gnome.org>2009-02-02 16:31:06 +0000
commite165360bf91fbd34507e84cffc9283b8b171401b (patch)
tree765f0e4db4fc104f724b61aba721cfdee5030f5d /giscanner
parent34c6fe51cd8d669d95aef52bda9abbc38257bca9 (diff)
downloadgobject-introspection-e165360bf91fbd34507e84cffc9283b8b171401b.tar.gz
Bug 569408, Bug 568680 - Scanner misses fields (at least in GObject.Object)
The scanner misses all fields of the GObject struct -- there are no <field> children of the <class> element for GObject in the GIR. This of course yields wrong field offsets for all derived objects. svn path=/trunk/; revision=1079
Diffstat (limited to 'giscanner')
-rw-r--r--giscanner/glibtransformer.py14
-rw-r--r--giscanner/transformer.py38
2 files changed, 26 insertions, 26 deletions
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index b9d2369f..51076a2f 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -261,8 +261,20 @@ class GLibTransformer(object):
parent_type_name = 'GObject'
parent_gitype = self._resolve_gtypename(parent_type_name)
symbol = 'g_initially_unowned_get_type'
+ else:
+ assert False
gnode = GLibObject(node.name, parent_gitype, type_name, symbol, True)
- gnode.fields.extend(node.fields)
+ if type_name == 'GObject':
+ gnode.fields.extend(node.fields)
+ else:
+ # http://bugzilla.gnome.org/show_bug.cgi?id=569408
+ # GInitiallyUnowned is actually a typedef for GObject, but
+ # that's not reflected in the GIR, where it appears as a
+ # subclass (as it appears in the GType hierarchy). So
+ # what we do here is copy all of the GObject fields into
+ # GInitiallyUnowned so that struct offset computation
+ # works correctly.
+ gnode.fields = self._names.names['Object'][1].fields
self._add_attribute(gnode)
self._register_internal_type(type_name, gnode)
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index d31300e4..1d781c60 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -478,45 +478,33 @@ class Transformer(object):
self._typedefs_ns[callback.name] = callback
return callback
- def _create_struct(self, symbol):
- struct = self._typedefs_ns.get(symbol.ident, None)
- if struct is None:
+ def _create_compound(self, klass, symbol):
+ compound = self._typedefs_ns.get(symbol.ident, None)
+ if compound is None:
# This is a bit of a hack; really we should try
# to resolve through the typedefs to find the real
# name
if symbol.ident.startswith('_'):
name = symbol.ident[1:]
+ compound = self._typedefs_ns.get(name, None)
else:
name = symbol.ident
- name = self.remove_prefix(name)
- struct = Struct(name, symbol.ident)
+ if compound is None:
+ name = self.remove_prefix(name)
+ compound = klass(name, symbol.ident)
for child in symbol.base_type.child_list:
field = self._traverse_one(child)
if field:
- struct.fields.append(field)
+ compound.fields.append(field)
- return struct
+ return compound
- def _create_union(self, symbol):
- union = self._typedefs_ns.get(symbol.ident, None)
- if union is None:
- # This is a bit of a hack; really we should try
- # to resolve through the typedefs to find the real
- # name
- if symbol.ident.startswith('_'):
- name = symbol.ident[1:]
- else:
- name = symbol.ident
- name = self.remove_prefix(name)
- union = Union(name, symbol.ident)
-
- for child in symbol.base_type.child_list:
- field = self._traverse_one(child)
- if field:
- union.fields.append(field)
+ def _create_struct(self, symbol):
+ return self._create_compound(Struct, symbol)
- return union
+ def _create_union(self, symbol):
+ return self._create_compound(Union, symbol)
def _create_callback(self, symbol):
parameters = self._create_parameters(symbol.base_type.base_type)