summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2011-11-25 12:09:51 -0200
committerJohan Dahlin <jdahlin@litl.com>2011-11-25 12:10:39 -0200
commit699ad0fec427c79bec1c41b2cf8e2441b9b959bc (patch)
tree457ff8073378be85ba8566afec81328fd12bbf2e
parent9b27ce73aaeb4159daa873cdb314a50447a3143d (diff)
downloadgobject-introspection-699ad0fec427c79bec1c41b2cf8e2441b9b959bc.tar.gz
Add a floating alias for none
https://bugzilla.gnome.org/show_bug.cgi?id=657202
-rw-r--r--giscanner/annotationparser.py4
-rw-r--r--giscanner/maintransformer.py13
-rw-r--r--tests/scanner/Annotation-1.0-expected.gir7
-rw-r--r--tests/scanner/annotation.c13
-rw-r--r--tests/scanner/annotation.h2
5 files changed, 34 insertions, 5 deletions
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 243b6afd..e0a7cec6 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -111,6 +111,7 @@ OPT_SCOPE_NOTIFIED = 'notified'
OPT_TRANSFER_NONE = 'none'
OPT_TRANSFER_CONTAINER = 'container'
OPT_TRANSFER_FULL = 'full'
+OPT_TRANSFER_FLOATING = 'floating'
class DocBlock(object):
@@ -346,7 +347,8 @@ class DocTag(object):
n_params=1,
choices=[OPT_TRANSFER_FULL,
OPT_TRANSFER_CONTAINER,
- OPT_TRANSFER_NONE])
+ OPT_TRANSFER_NONE,
+ OPT_TRANSFER_FLOATING])
elif option == OPT_TYPE:
self._validate_option('type', value, required=True,
n_params=1)
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 5b1ffb79..73586004 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -32,7 +32,8 @@ from .annotationparser import (OPT_ALLOW_NONE, OPT_ARRAY, OPT_ATTRIBUTE,
OPT_TYPE, OPT_CLOSURE, OPT_DESTROY, OPT_TRANSFER, OPT_SKIP,
OPT_FOREIGN, OPT_ARRAY_FIXED_SIZE,
OPT_ARRAY_LENGTH, OPT_ARRAY_ZERO_TERMINATED,
- OPT_CONSTRUCTOR, OPT_METHOD)
+ OPT_CONSTRUCTOR, OPT_METHOD,
+ OPT_TRANSFER_NONE, OPT_TRANSFER_FLOATING)
from .annotationparser import AnnotationParser
from .transformer import TransformerException
from .utils import to_underscores, to_underscores_noprefix
@@ -569,7 +570,10 @@ usage is void (*_gtk_reserved1)(void);"""
transfer_tag = options.get(OPT_TRANSFER)
if transfer_tag and transfer_tag.length() == 1:
- node.transfer = transfer_tag.one()
+ transfer = transfer_tag.one()
+ if transfer == OPT_TRANSFER_FLOATING:
+ transfer = OPT_TRANSFER_NONE
+ node.transfer = transfer
self._adjust_container_type(parent, node, options)
@@ -755,7 +759,10 @@ usage is void (*_gtk_reserved1)(void);"""
return
transfer_tag = block.get(OPT_TRANSFER)
if transfer_tag is not None:
- prop.transfer = transfer_tag.value
+ transfer = transfer_tag.value
+ if transfer == OPT_TRANSFER_FLOATING:
+ transfer = OPT_TRANSFER_NONE
+ prop.transfer = transfer
else:
prop.transfer = self._get_transfer_default(parent, prop)
type_tag = block.get(TAG_TYPE)
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index 4449604c..88b9ea4e 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -835,6 +835,13 @@ detection, and fixing it via annotations.</doc>
<type name="GObject.Object" c:type="GObject*"/>
</return-value>
</function>
+ <function name="transfer_floating"
+ c:identifier="annotation_transfer_floating">
+ <return-value transfer-ownership="none">
+ <doc xml:whitespace="preserve">A floating object</doc>
+ <type name="GObject.Object" c:type="GObject*"/>
+ </return-value>
+ </function>
<function name="versioned"
c:identifier="annotation_versioned"
version="0.6">
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index 07e5a349..f28befac 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -813,7 +813,7 @@ annotation_space_after_comment_bug631690 (void)
}
/**
- * annotation_return_filename
+ * annotation_return_filename:
*
* Returns: (type filename): An annotated filename
*/
@@ -822,3 +822,14 @@ annotation_return_filename (void)
{
return "a utf-8 filename";
}
+
+/**
+ * annotation_transfer_floating:
+ *
+ * Returns: (transfer floating): A floating object
+ */
+GObject *
+annotation_transfer_floating(void)
+{
+ return NULL;
+}
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index 8bfbfd21..b3b4bd4c 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -169,6 +169,8 @@ void annotation_space_after_comment_bug631690 (void);
gchar* annotation_return_filename (void);
+GObject * annotation_transfer_floating(void);
+
/* This one we can handle properly */
#define ANNOTATION_CALCULATED_DEFINE (10 * 10)