summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rottmann <a.rottmann@gmx.at>2009-01-03 14:36:59 +0000
committerJohan Dahlin <johan@src.gnome.org>2009-01-03 14:36:59 +0000
commit7acaf91d3e2c3debd7dc398d71948362e9ff12c7 (patch)
tree05ffe83486051476ccbd3deccd61638813b12825
parent5a4afe2a77d0ff7d9fea13dd93c3304a6ca993de (diff)
downloadgobject-introspection-7acaf91d3e2c3debd7dc398d71948362e9ff12c7.tar.gz
Bug 563469 – Arrays not treated correctly in struct offset calculation
2009-01-03 Andreas Rottmann <a.rottmann@gmx.at> Bug 563469 – Arrays not treated correctly in struct offset calculation * tests/scanner/foo.h (FooObject): Added field `some_int'. * tests/scanner/foo-1.0-expected.gir, * tests/scanner/foo-1.0-expected.tgir: Adapted. * giscanner/glibtransformer.py (GLibTransformer._create_gobject): carry over object fields from original (struct) node. (GLibTransformer._pair_class_struct): Don't add fields of the class struct to to the node for the class, they should go under a nested <record> element (see also Bug 551738). This is needed as otherwise offset calculation would not work, as the instance fields are mingled with the class fields without a way to distinguish them. svn path=/trunk/; revision=1000
-rw-r--r--ChangeLog17
-rw-r--r--giscanner/glibtransformer.py10
-rw-r--r--tests/scanner/foo-1.0-expected.gir16
-rw-r--r--tests/scanner/foo-1.0-expected.tgir3
-rw-r--r--tests/scanner/foo.h2
5 files changed, 30 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index d539c583..ab812fd4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-01-03 Andreas Rottmann <a.rottmann@gmx.at>
+
+ Bug 563469 – Arrays not treated correctly in struct offset calculation
+
+ * tests/scanner/foo.h (FooObject): Added field `some_int'.
+ * tests/scanner/foo-1.0-expected.gir,
+ * tests/scanner/foo-1.0-expected.tgir: Adapted.
+
+ * giscanner/glibtransformer.py (GLibTransformer._create_gobject):
+ carry over object fields from original (struct) node.
+ (GLibTransformer._pair_class_struct): Don't add fields of the
+ class struct to to the node for the class, they should go under a
+ nested <record> element (see also Bug 551738). This is needed as
+ otherwise offset calculation would not work, as the instance
+ fields are mingled with the class fields without a way to
+ distinguish them.
+
2009-01-03 Johan Dahlin <jdahlin@async.com.br>
* misc/pep8.py:
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index 5ad8e303..aacaa508 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -248,9 +248,10 @@ class GLibTransformer(object):
parent_type_name = 'GObject'
parent_gitype = self._resolve_gtypename(parent_type_name)
symbol = 'g_initially_unowned_get_type'
- node = GLibObject(node.name, parent_gitype, type_name, symbol, True)
- self._add_attribute(node)
- self._register_internal_type(type_name, node)
+ gnode = GLibObject(node.name, parent_gitype, type_name, symbol, True)
+ gnode.fields.extend(node.fields)
+ self._add_attribute(gnode)
+ self._register_internal_type(type_name, gnode)
# Parser
def _parse_node(self, node):
@@ -499,8 +500,7 @@ class GLibTransformer(object):
name = self._resolve_type_name(name)
resolved = self._transformer.remove_prefix(name)
pair_class = self._get_attribute(resolved)
- if pair_class and isinstance(pair_class,
- (GLibObject, GLibInterface)):
+ if pair_class and isinstance(pair_class, GLibInterface):
for field in maybe_class.fields[1:]:
pair_class.fields.append(field)
return
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index 9db4c29a..db76f277 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -180,19 +180,9 @@
<field name="parent_instance">
<type name="GObject.Object" c:type="GObject"/>
</field>
- <callback name="virtual_method" c:type="virtual_method">
- <return-value transfer-ownership="none">
- <type name="boolean" c:type="gboolean"/>
- </return-value>
- <parameters>
- <parameter name="object" transfer-ownership="none">
- <type name="Object" c:type="FooObject*"/>
- </parameter>
- <parameter name="first_param" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
- </parameters>
- </callback>
+ <field name="some_int">
+ <type name="int" c:type="int"/>
+ </field>
<glib:signal name="signal">
<return-value transfer-ownership="full">
<type name="utf8" c:type="gchararray"/>
diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir
index d44f118c..168373e3 100644
--- a/tests/scanner/foo-1.0-expected.tgir
+++ b/tests/scanner/foo-1.0-expected.tgir
@@ -31,6 +31,9 @@
<field name="parent_instance">
<type name="GObject.Object"/>
</field>
+ <field name="some_int">
+ <type name="int"/>
+ </field>
<constructor name="new" c:identifier="foo_object_new">
<return-value transfer-ownership="full">
<type name="Object"/>
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index fd9d3590..b51d0c88 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -55,6 +55,8 @@ void foo_sub_interface_do_bar (FooSubInterface *self);
struct _FooObject
{
GObject parent_instance;
+
+ int some_int;
};
struct _FooObjectClass