Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2009-02-26 21:52:42 (GMT)
committer Colin Walters <walters@verbum.org>2009-02-26 21:52:42 (GMT)
commitca21c1ce6f2fa9f8be9307121ce27a46cc9c0ed0 (patch)
treebe25649d977e3daa4d461a5359b7cef677c94975
parente49a883d0997127cd3a0ad7e522666f30190e792 (diff)
Revert "Bug 557383 - Virtual function support"
This reverts commit 4470a24e8cf3827efaddcfe240c3271cf1a0d6c0. Needs more work as it turns out, we need to figure out the binding story.
-rw-r--r--giscanner/ast.py6
-rw-r--r--giscanner/girwriter.py6
-rw-r--r--giscanner/glibtransformer.py21
-rw-r--r--tests/scanner/foo-1.0-expected.gir35
-rw-r--r--tests/scanner/foo-1.0-expected.tgir27
-rw-r--r--tests/scanner/foo.c10
-rw-r--r--tests/scanner/foo.h6
7 files changed, 35 insertions, 76 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 4bd674d..e708258 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -205,7 +205,6 @@ class Function(Node):
self.symbol = symbol
self.throws = not not throws
self.is_method = False
- self.is_virtual = False
self.doc = None
def get_parameter_index(self, name):
@@ -223,6 +222,11 @@ class Function(Node):
self.name, self.retval,
self.parameters)
+
+class VFunction(Function):
+ pass
+
+
class Type(Node):
def __init__(self, name, ctype=None):
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 9a08aaa..df52709 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -167,11 +167,7 @@ and/or use gtk-doc annotations. ''')
self._write_parameters(func.parameters)
def _write_method(self, method):
- if method.is_virtual:
- tag_name = 'vfunc'
- else:
- tag_name = 'method'
- self._write_function(method, tag_name)
+ self._write_function(method, tag_name='method')
def _write_static_method(self, method):
self._write_function(method, tag_name='function')
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index fc7f17c..5a7a96d 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -159,10 +159,6 @@ class GLibTransformer(object):
except KeyError, e:
print "WARNING: DELETING node %s: %s" % (node.name, e)
self._remove_attribute(node.name)
- # Another pass, since we need to have the methods parsed
- # in order to correctly modify them after class/record
- # pairing
- for (ns, node) in nodes:
# associate GtkButtonClass with GtkButton
if isinstance(node, Record):
self._pair_class_record(node)
@@ -577,19 +573,10 @@ class GLibTransformer(object):
for field in maybe_class.fields:
if isinstance(field, Field):
field.writable = False
-
- # Pair up virtual methods by finding a slot in
- # the class with the same name
- for field in maybe_class.fields:
- if not isinstance(field, Callback):
- continue
- matched = False
- for method in pair_class.methods:
- if (method.name == field.name and
- len(method.parameters)+1 == len(field.parameters)):
- method.is_virtual = True
- break
-
+ # TODO: remove this, we should be computing vfuncs instead
+ if isinstance(pair_class, GLibInterface):
+ for field in maybe_class.fields[1:]:
+ pair_class.fields.append(field)
gclass_struct = GLibRecord.from_record(class_struct)
self._remove_attribute(class_struct.name)
self._add_attribute(gclass_struct, True)
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index 38bde58..0f6b1f1 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -232,16 +232,16 @@ and/or use gtk-doc annotations. -->
glib:type-name="FooInterface"
glib:get-type="foo_interface_get_type"
glib:type-struct="InterfaceIface">
- <vfunc name="do_foo" c:identifier="foo_interface_do_foo">
+ <callback name="do_foo" c:type="do_foo">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
- <parameter name="x" transfer-ownership="none">
- <type name="int" c:type="int"/>
+ <parameter name="self" transfer-ownership="none">
+ <type name="Interface" c:type="FooInterface*"/>
</parameter>
</parameters>
- </vfunc>
+ </callback>
</interface>
<record name="InterfaceIface"
c:type="FooInterfaceIface"
@@ -257,9 +257,6 @@ and/or use gtk-doc annotations. -->
<parameter name="self" transfer-ownership="none">
<type name="Interface" c:type="FooInterface*"/>
</parameter>
- <parameter name="x" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
</parameters>
</callback>
</record>
@@ -362,16 +359,6 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</method>
- <vfunc name="virtual_method" c:identifier="foo_object_virtual_method">
- <return-value transfer-ownership="none">
- <type name="none" c:type="void"/>
- </return-value>
- <parameters>
- <parameter name="first_param" transfer-ownership="none">
- <type name="int" c:type="int"/>
- </parameter>
- </parameters>
- </vfunc>
<property name="string" writable="1" construct="1">
<type name="utf8" c:type="gchararray"/>
</property>
@@ -480,11 +467,21 @@ and/or use gtk-doc annotations. -->
glib:get-type="foo_sub_interface_get_type"
glib:type-struct="SubInterfaceIface">
<prerequisite name="Interface"/>
- <vfunc name="do_bar" c:identifier="foo_sub_interface_do_bar">
+ <method name="do_bar" c:identifier="foo_sub_interface_do_bar">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ </method>
+ <callback name="do_bar" c:type="do_bar">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
- </vfunc>
+ <parameters>
+ <parameter name="self" transfer-ownership="none">
+ <type name="SubInterface" c:type="FooSubInterface*"/>
+ </parameter>
+ </parameters>
+ </callback>
</interface>
<record name="SubInterfaceIface"
c:type="FooSubInterfaceIface"
diff --git a/tests/scanner/foo-1.0-expected.tgir b/tests/scanner/foo-1.0-expected.tgir
index e2a02b1..f8e1ee5 100644
--- a/tests/scanner/foo-1.0-expected.tgir
+++ b/tests/scanner/foo-1.0-expected.tgir
@@ -161,18 +161,7 @@
<member name="second" value="2"/>
<member name="third" value="4"/>
</bitfield>
- <interface name="Interface" glib:type-name="FooInterface" glib:get-type="foo_interface_get_type" glib:type-struct="InterfaceIface">
- <vfunc name="do_foo" offset="0">
- <return-value transfer-ownership="none">
- <type name="none"/>
- </return-value>
- <parameters>
- <parameter name="x" transfer-ownership="none">
- <type name="int"/>
- </parameter>
- </parameters>
- </vfunc>
- </interface>
+ <interface name="Interface" glib:type-name="FooInterface" glib:get-type="foo_interface_get_type" glib:type-struct="InterfaceIface"/>
<record name="InterfaceIface" glib:is-gtype-struct="1">
<field name="parent_iface">
<type name="GObject.TypeInterface"/>
@@ -282,16 +271,6 @@
</parameter>
</parameters>
</glib:signal>
- <vfunc name="virtual_method" offset="0">
- <return-value transfer-ownership="none">
- <type name="none"/>
- </return-value>
- <parameters>
- <parameter name="first_param" transfer-ownership="none">
- <type name="int"/>
- </parameter>
- </parameters>
- </vfunc>
</class>
<record name="ObjectClass" glib:is-gtype-struct="1">
<field name="parent_class">
@@ -358,11 +337,11 @@
<record name="StructPrivate"/>
<interface name="SubInterface" glib:type-name="FooSubInterface" glib:get-type="foo_sub_interface_get_type" glib:type-struct="SubInterfaceIface">
<prerequisite name="Interface"/>
- <vfunc name="do_bar" offset="0">
+ <method name="do_bar" c:identifier="foo_sub_interface_do_bar">
<return-value transfer-ownership="none">
<type name="none"/>
</return-value>
- </vfunc>
+ </method>
</interface>
<record name="SubInterfaceIface" glib:is-gtype-struct="1">
<field name="parent_iface">
diff --git a/tests/scanner/foo.c b/tests/scanner/foo.c
index 98d2f4b..0488260 100644
--- a/tests/scanner/foo.c
+++ b/tests/scanner/foo.c
@@ -8,8 +8,8 @@ int foo_init_argv (int argc, char **argv);
int foo_init_argv_address (int *argc, char ***argv);
void foo_private_function (FooObject *foo);
void foo_test_unsigned (unsigned int uint);
-void foo_interface_do_foo (FooInterface *self, int x);
-void foo_do_foo (FooInterface *self, int x);
+void foo_interface_do_foo (FooInterface *self);
+void foo_do_foo (FooInterface *self);
int foo_enum_method (FooEnumType foo_enum);
FooHidden * foo_hidden_copy (const FooHidden *boxed);
void foo_hidden_free (FooHidden *boxed);
@@ -47,9 +47,9 @@ foo_interface_get_type (void)
return object_type;
}
-void foo_interface_do_foo (FooInterface *self, int x)
+void foo_interface_do_foo (FooInterface *self)
{
- FOO_INTERFACE_GET_INTERFACE(self)->do_foo (self, x);
+ FOO_INTERFACE_GET_INTERFACE(self)->do_foo (self);
}
enum {
@@ -191,7 +191,7 @@ foo_object_take_all (FooObject *object, int x, ...)
}
void
-foo_do_foo (FooInterface *self, int x)
+foo_do_foo (FooInterface *self)
{
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index 2eeed6d..da30df3 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -48,13 +48,11 @@ struct _FooInterfaceIface
{
GTypeInterface parent_iface;
- void (*do_foo) (FooInterface *self, int x);
+ void (*do_foo) (FooInterface *self);
};
GType foo_interface_get_type (void) G_GNUC_CONST;
-void foo_interface_do_foo (FooInterface *iface, int x);
-
struct _FooSubInterfaceIface
{
GTypeInterface parent_iface;
@@ -107,8 +105,6 @@ char * foo_object_dup_name (FooObject *object);
void foo_object_handle_glyph (FooObject *object, UtilityGlyph glyph);
-void foo_object_virtual_method (FooObject *object, int first_param);
-
int foo_object_static_meth ();
struct _FooSubobject