diff options
author | Colin Walters <walters@verbum.org> | 2009-02-27 19:02:48 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2009-03-05 15:52:12 -0500 |
commit | fdbe3cc3e1cfaa546648a76b1dca72beead0b65b (patch) | |
tree | 01156e22ec59d29c642d59ce7ad75f383d77466a /giscanner/girwriter.py | |
parent | b8e3172424ba956a0d18eae8deb305310b2cab74 (diff) | |
download | gobject-introspection-fdbe3cc3e1cfaa546648a76b1dca72beead0b65b.tar.gz |
Bug 557383 - Virtual method support
Broadly speaking, this change adds the concept of <vfunc> to the .gir.
The typelib already had most of the infrastructure for virtual functions,
though there is one API addition.
The scanner assumes that any class callback slot that doesn't match
a signal name is a virtual. In the .gir, we write out *both* the <method>
wrapper and a <vfunc>. If we can determine an association between
them (based on the names matching, or a new Virtual: annotation),
then we notate that in the .gir.
The typelib gains an association from the vfunc to the function, if
it exists. This will be useful for bindings since they already know
how to consume FunctionInfo.
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r-- | giscanner/girwriter.py | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py index 88510b04..e30bc6b9 100644 --- a/giscanner/girwriter.py +++ b/giscanner/girwriter.py @@ -158,18 +158,22 @@ and/or use gtk-doc annotations. ''') attrs.append(('c:type', alias.ctype)) self.write_tag('alias', attrs) - def _write_function(self, func, tag_name='function'): - attrs = [('name', func.name), - ('c:identifier', func.symbol)] - if func.doc: - attrs.append(('doc', func.doc)) - self._append_version(func, attrs) - self._append_deprecated(func, attrs) - self._append_throws(func, attrs) + def _write_callable(self, callable, tag_name, extra_attrs): + attrs = [('name', callable.name)] + attrs.extend(extra_attrs) + if callable.doc: + attrs.append(('doc', callable.doc)) + self._append_version(callable, attrs) + self._append_deprecated(callable, attrs) + self._append_throws(callable, attrs) with self.tagcontext(tag_name, attrs): - self._write_attributes(func) - self._write_return_type(func.retval) - self._write_parameters(func.parameters) + self._write_attributes(callable) + self._write_return_type(callable.retval) + self._write_parameters(callable.parameters) + + def _write_function(self, func, tag_name='function'): + attrs = [('c:identifier', func.symbol)] + self._write_callable(func, tag_name, attrs) def _write_method(self, method): self._write_function(method, tag_name='method') @@ -354,6 +358,8 @@ and/or use gtk-doc annotations. ''') self._write_constructor(method) for method in node.static_methods: self._write_static_method(method) + for vfunc in node.virtual_methods: + self._write_vfunc(vfunc) for method in node.methods: self._write_method(method) for prop in node.properties: @@ -395,18 +401,15 @@ and/or use gtk-doc annotations. ''') self._write_attributes(prop) self._write_type(prop.type) + def _write_vfunc(self, vf): + attrs = [] + if vf.invoker: + attrs.append(('invoker', vf.invoker)) + self._write_callable(vf, 'virtual-method', attrs) + def _write_callback(self, callback): - # FIXME: reuse _write_function - attrs = [('name', callback.name), ('c:type', callback.ctype)] - if callback.doc: - attrs.append(('doc', callback.doc)) - self._append_version(callback, attrs) - self._append_deprecated(callback, attrs) - self._append_throws(callback, attrs) - with self.tagcontext('callback', attrs): - self._write_attributes(callback) - self._write_return_type(callback.retval) - self._write_parameters(callback.parameters) + attrs = [('c:type', callback.ctype)] + self._write_callable(callback, 'callback', attrs) def _boxed_attrs(self, boxed): return [('glib:type-name', boxed.type_name), |