diff options
author | Colin Walters <walters@verbum.org> | 2009-02-26 14:44:24 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2009-02-26 14:44:24 -0500 |
commit | 1b3ce6945e359e6cfbf1805be19db9599f134e09 (patch) | |
tree | bc3874a0c1850d485b5181fb2cc64266d9b315d8 /giscanner | |
parent | 7b62eef116bec87fbd2c3ea13af95fcfc2e05cfd (diff) | |
parent | 4470a24e8cf3827efaddcfe240c3271cf1a0d6c0 (diff) | |
download | gobject-introspection-1b3ce6945e359e6cfbf1805be19db9599f134e09.tar.gz |
Merge branch 'bug557383-vfuncs'
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/ast.py | 6 | ||||
-rw-r--r-- | giscanner/girwriter.py | 6 | ||||
-rw-r--r-- | giscanner/glibtransformer.py | 21 |
3 files changed, 23 insertions, 10 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py index e708258c..4bd674d1 100644 --- a/giscanner/ast.py +++ b/giscanner/ast.py @@ -205,6 +205,7 @@ 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): @@ -222,11 +223,6 @@ 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 df527090..9a08aaa5 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -167,7 +167,11 @@ and/or use gtk-doc annotations. ''') self._write_parameters(func.parameters) def _write_method(self, method): - self._write_function(method, tag_name='method') + if method.is_virtual: + tag_name = 'vfunc' + else: + tag_name = 'method' + self._write_function(method, tag_name) def _write_static_method(self, method): self._write_function(method, tag_name='function') 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) |