summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Komulainen <tommi.komulainen@iki.fi>2008-10-22 10:46:22 +0000
committerTommi Komulainen <tko@src.gnome.org>2008-10-22 10:46:22 +0000
commit7b171be482d33af3f4a6afa6bf34b433ce70fdb1 (patch)
tree376502991554e7b22f051624c2f16b658ac40c64
parentf66b137d74b4a5337e71f69dbabc86b1e5012d99 (diff)
downloadgobject-introspection-7b171be482d33af3f4a6afa6bf34b433ce70fdb1.tar.gz
Bug 557092 – Callback annotations not used
2008-10-22 Tommi Komulainen <tommi.komulainen@iki.fi> * giscanner/transformer.py (_create_callback): use annotations for callbacks * tests/scanner/annotation.h * tests/scanner/annotation-1.0-expected.gir: add tests svn path=/trunk/; revision=781
-rw-r--r--ChangeLog9
-rw-r--r--giscanner/transformer.py7
-rw-r--r--tests/scanner/annotation-1.0-expected.gir24
-rw-r--r--tests/scanner/annotation.h16
4 files changed, 54 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index f5ab64e3..f98b7835 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-10-22 Tommi Komulainen <tommi.komulainen@iki.fi>
+
+ Bug 557092 – Callback annotations not used
+
+ * giscanner/transformer.py (_create_callback): use annotations
+ for callbacks
+ * tests/scanner/annotation.h
+ * tests/scanner/annotation-1.0-expected.gir: add tests
+
2008-10-21 Colin Walters <walters@verbum.org>
* giscanner/scannerlexer.l: Don't require trailing whitespace after
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 75ede595..7e74f4d8 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -542,8 +542,11 @@ class Transformer(object):
return union
def _create_callback(self, symbol):
- parameters = self._create_parameters(symbol.base_type.base_type)
- retval = self._create_return(symbol.base_type.base_type.base_type)
+ directives = symbol.directives()
+ parameters = self._create_parameters(symbol.base_type.base_type,
+ directives)
+ retval = self._create_return(symbol.base_type.base_type.base_type,
+ directives.get('return', {}))
if symbol.ident.find('_') > 0:
name = self.remove_prefix(symbol.ident, True)
else:
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index 69325745..0bd230f0 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -7,6 +7,30 @@
<include name="GObject" version="2.0"/>
<include name="utility" version="1.0"/>
<namespace name="annotation" version="1.0" shared-library="annotation">
+ <callback name="Callback" c:type="AnnotationCallback">
+ <return-value transfer-ownership="none">
+ <type name="int" c:type="gint*"/>
+ </return-value>
+ <parameters>
+ <parameter name="in" transfer-ownership="none">
+ <type name="int" c:type="gint*"/>
+ </parameter>
+ </parameters>
+ </callback>
+ <callback name="ListCallback" c:type="AnnotationListCallback">
+ <return-value transfer-ownership="container">
+ <type name="GLib.List" c:type="GList*">
+ <type name="utf8"/>
+ </type>
+ </return-value>
+ <parameters>
+ <parameter name="in" transfer-ownership="none">
+ <type name="GLib.List" c:type="GList*">
+ <type name="utf8"/>
+ </type>
+ </parameter>
+ </parameters>
+ </callback>
<class name="Object"
c:type="AnnotationObject"
parent="GObject.Object"
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index c15d578d..ea78786a 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -3,6 +3,22 @@
#include <glib-object.h>
+/**
+ * AnnotationCallback:
+ * @in: (in) (transfer none): array of ints
+ *
+ * Return value: (transfer none): array of ints
+ */
+typedef const gint* (*AnnotationCallback) (const gint *in);
+
+/**
+ * AnnotationListCallback:
+ * @in: (in) (transfer none) (element-type utf8): list of strings
+ *
+ * Return value: (transfer container) (element-type utf8): list of strings
+ */
+typedef GList* (*AnnotationListCallback) (GList *in);
+
typedef struct _AnnotationObject AnnotationObject;
typedef struct _AnnotationObjectClass AnnotationObjectClass;