summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2010-06-15 13:05:59 -0400
committerColin Walters <walters@verbum.org>2010-06-16 20:32:22 -0400
commit59b084e18e8826613de47fa69b791c72574a3900 (patch)
tree1431d37a0dd3f9754775c95c6c9ccc332cfde7f7
parent27b346578c4fccca0e3ed0cf36ee3735dd9694e8 (diff)
downloadgobject-introspection-59b084e18e8826613de47fa69b791c72574a3900.tar.gz
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
-rw-r--r--gir/Everything-1.0-expected.gir6
-rw-r--r--giscanner/annotationparser.py7
-rw-r--r--giscanner/girwriter.py2
-rw-r--r--giscanner/glibtransformer.py2
-rw-r--r--tests/scanner/foo-1.0-expected.gir2
5 files changed, 14 insertions, 5 deletions
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index ec7c5205..50b1a76a 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 d5cc7f63..bea87737 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 7fe5bad1..2dff4fe2 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 b9b4cb62..42488251 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 e2fd2d92..eee3c643 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>