[gobject-introspection] scanner: Always explicitely set the scope of callbacks
- From: Johan Bilien <jobi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Always explicitely set the scope of callbacks
- Date: Fri, 15 Jan 2010 18:33:01 +0000 (UTC)
commit 18d8b801792595760e2695dedae868db6e5b22d8
Author: Johan Bilien <jobi litl com>
Date: Thu Jan 14 17:02:36 2010 -0500
scanner: Always explicitely set the scope of callbacks
default to 'call' as stated in the annotation documentation.
https://bugzilla.gnome.org/show_bug.cgi?id=607026
gir/Everything-1.0-expected.gir | 2 +-
giscanner/annotationparser.py | 2 +-
giscanner/transformer.py | 4 ++++
tests/scanner/annotation-1.0-expected.gir | 5 +++--
tests/scanner/annotation-1.0-expected.tgir | 6 +++---
5 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir
index 5bb6c18..145a9c9 100644
--- a/gir/Everything-1.0-expected.gir
+++ b/gir/Everything-1.0-expected.gir
@@ -698,7 +698,7 @@ is invoked.">
<parameter name="user_data" transfer-ownership="none">
<type name="any" c:type="gpointer"/>
</parameter>
- <parameter name="notify" transfer-ownership="none">
+ <parameter name="notify" transfer-ownership="none" scope="call">
<type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
</parameter>
</parameters>
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index d91bb1c..aa04ef4 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -507,7 +507,7 @@ class AnnotationApplier(object):
def _parse_param(self, parent, param, tag):
options = getattr(tag, 'options', {})
- if isinstance(parent, Function) and not param.scope:
+ if isinstance(parent, Function):
scope = options.get(OPT_SCOPE)
if scope:
param.scope = scope.one()
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 1024ee3..f31408f 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -295,6 +295,10 @@ class Transformer(object):
if not self._type_is_callback(param.type):
continue
+ # set a default scope
+ if param.scope is None:
+ param.scope = 'call'
+
# j is the index where we look for closure/destroy to
# group with the callback param
j = i + 1
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index 2eef210..ab81ae1 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -463,7 +463,7 @@ type.">
<parameter name="user_data" transfer-ownership="none">
<type name="any" c:type="gpointer"/>
</parameter>
- <parameter name="destroy" transfer-ownership="none">
+ <parameter name="destroy" transfer-ownership="none" scope="call">
<type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
</parameter>
</parameters>
@@ -555,12 +555,13 @@ detection, and fixing it via annotations.">
<parameters>
<parameter name="callback"
transfer-ownership="none"
+ scope="call"
closure="2"
destroy="1"
doc="Destroy notification">
<type name="Callback" c:type="AnnotationCallback"/>
</parameter>
- <parameter name="destroy" transfer-ownership="none">
+ <parameter name="destroy" transfer-ownership="none" scope="call">
<type name="NotifyFunc" c:type="AnnotationNotifyFunc"/>
</parameter>
<parameter name="data" transfer-ownership="none">
diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir
index 1507174..9e9370b 100644
--- a/tests/scanner/annotation-1.0-expected.tgir
+++ b/tests/scanner/annotation-1.0-expected.tgir
@@ -345,7 +345,7 @@
<parameter name="user_data" transfer-ownership="none">
<type name="any"/>
</parameter>
- <parameter name="destroy" transfer-ownership="none">
+ <parameter name="destroy" transfer-ownership="none" scope="call">
<type name="GLib.DestroyNotify"/>
</parameter>
</parameters>
@@ -409,10 +409,10 @@
<type name="none"/>
</return-value>
<parameters>
- <parameter name="callback" transfer-ownership="none" closure="2" destroy="1">
+ <parameter name="callback" transfer-ownership="none" scope="call" closure="2" destroy="1">
<type name="Callback"/>
</parameter>
- <parameter name="destroy" transfer-ownership="none">
+ <parameter name="destroy" transfer-ownership="none" scope="call">
<type name="NotifyFunc"/>
</parameter>
<parameter name="data" transfer-ownership="none">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]