From 4470a24e8cf3827efaddcfe240c3271cf1a0d6c0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 25 Feb 2009 18:43:14 -0500 Subject: Bug 557383 - Virtual function support In order to determine whether a method is virtual, by default we look at the class table to find a callback field. This should be fairly reliable, but we may also later need annotations to more finely control this in the case of a name clash with a signal. --- giscanner/glibtransformer.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'giscanner/glibtransformer.py') diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py index 5a7a96d2..fc7f17c5 100644 --- a/giscanner/glibtransformer.py +++ b/giscanner/glibtransformer.py @@ -159,6 +159,10 @@ 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) @@ -573,10 +577,19 @@ class GLibTransformer(object): for field in maybe_class.fields: if isinstance(field, Field): field.writable = False - # 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) + + # 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 + gclass_struct = GLibRecord.from_record(class_struct) self._remove_attribute(class_struct.name) self._add_attribute(gclass_struct, True) -- cgit v1.2.1