[gobject-introspection] Apply annotations from invoker to vfunc
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] Apply annotations from invoker to vfunc
- Date: Thu, 17 Jun 2010 02:02:10 +0000 (UTC)
commit 59b084e18e8826613de47fa69b791c72574a3900
Author: Colin Walters <walters verbum org>
Date: Tue Jun 15 13:05:59 2010 -0400
Apply annotations from invoker to vfunc
We typically expect people to annotate e.g. GList for virtuals
on the invoker, not on the virtual slot, since the invoker feels
like the public API.
https://bugzilla.gnome.org/show_bug.cgi?id=621570
gir/Everything-1.0-expected.gir | 6 +++++-
giscanner/annotationparser.py | 7 ++++++-
giscanner/girwriter.py | 2 +-
giscanner/glibtransformer.py | 2 +-
tests/scanner/foo-1.0-expected.gir | 2 +-
5 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index ec7c520..50b1a76 100644
--- a/gir/Everything-1.0-expected.gir
+++ b/gir/Everything-1.0-expected.gir
@@ -236,7 +236,11 @@ and/or use gtk-doc annotations. -->
</parameter>
</parameters>
</function>
- <virtual-method name="matrix" invoker="do_matrix">
+ <virtual-method name="matrix"
+ invoker="do_matrix"
+ doc="This method is virtual. Notably its name differs from the virtual
+slot name, which makes it useful for testing bindings handle this
+case.">
<return-value transfer-ownership="none">
<type name="int" c:type="int"/>
</return-value>
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d5cc7f6..bea8773 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -497,7 +497,7 @@ class AnnotationApplier(object):
for vfunc in parent.virtual_methods:
if vfunc.name == invoker_name:
matched = True
- vfunc.invoker = meth.name
+ vfunc.invoker = meth
break
if not matched:
print "warning: unmatched virtual invoker %r for method %r" % \
@@ -506,6 +506,11 @@ class AnnotationApplier(object):
def _parse_vfunc(self, parent, vfunc):
key = '%s::%s' % (parent.type_name, vfunc.name)
self._parse_callable(vfunc, self._blocks.get(key))
+ if vfunc.invoker:
+ # We normally expect annotations like (element-type) to be
+ # applied to the invoker.
+ block = self._blocks.get(vfunc.invoker.symbol)
+ self._parse_callable(vfunc, block)
def _parse_field(self, parent, field, block=None):
if isinstance(field, Callback):
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 7fe5bad..2dff4fe 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -410,7 +410,7 @@ and/or use gtk-doc annotations. ''')
def _write_vfunc(self, vf):
attrs = []
if vf.invoker:
- attrs.append(('invoker', vf.invoker))
+ attrs.append(('invoker', vf.invoker.name))
self._write_callable(vf, 'virtual-method', attrs)
def _write_callback(self, callback):
diff --git a/giscanner/glibtransformer.py b/giscanner/glibtransformer.py
index b9b4cb6..4248825 100644
--- a/giscanner/glibtransformer.py
+++ b/giscanner/glibtransformer.py
@@ -679,7 +679,7 @@ class GLibTransformer(object):
method.retval != vfunc.retval or
method.parameters != vfunc.parameters):
continue
- vfunc.invoker = method.name
+ vfunc.invoker = method
gclass_struct = GLibRecord.from_record(class_struct)
self._remove_attribute(class_struct.name)
diff --git a/tests/scanner/foo-1.0-expected.gir b/tests/scanner/foo-1.0-expected.gir
index e2fd2d9..eee3c64 100644
--- a/tests/scanner/foo-1.0-expected.gir
+++ b/tests/scanner/foo-1.0-expected.gir
@@ -329,7 +329,7 @@ uses a C sugar return type.">
</parameter>
</parameters>
</virtual-method>
- <virtual-method name="read_fn" invoker="read">
+ <virtual-method name="read_fn" invoker="read" doc="Read some stuff.">
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]