[gobject-introspection] Add a test for "(in) (transfer floating)" parameters beeing an alias for "(in) (transfer none)".



commit 12c304562add775dd80f698ad23aa59e8e87d879
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Thu Jan 8 21:31:20 2015 +0100

    Add a test for "(in) (transfer floating)" parameters beeing an alias for "(in) (transfer none)".
    
    The "(in)" alias was (unintenionally?) introduced in
    https://git.gnome.org/browse/gobject-introspection/commit/?id=699ad0fec427c79bec1
    which added an alias for return annotations. This change makes sure that this continues
    to work.
    
    Functions which ref_sink in params are currently marked as transfer-none since in the
    case of non-floating objects (which all bindings use) no ownership gets transfered.
    But in case of floating objects, which is the common case when using the C API directly,
    the ownership _is_ transfered. Using transfer-floating should make this clearer
    while giving the same result for bindings.
    
    Functions where this could be used: gst_bin_add, gtk_container_add, gst_element_add_pad
    
    See https://bugzilla.gnome.org/show_bug.cgi?id=657202 and 
https://bugzilla.gnome.org/show_bug.cgi?id=702960
    
    https://bugzilla.gnome.org/show_bug.cgi?id=742618

 .../Regress.annotation_transfer_floating.page      |   10 +++++++++-
 .../Regress.annotation_transfer_floating.page      |   10 +++++++++-
 .../Regress.annotation_transfer_floating.page      |   11 ++++++++++-
 tests/scanner/Regress-1.0-expected.gir             |    6 ++++++
 tests/scanner/annotation.c                         |    3 ++-
 tests/scanner/annotation.h                         |    2 +-
 6 files changed, 37 insertions(+), 5 deletions(-)
---
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.annotation_transfer_floating.page 
b/tests/scanner/Regress-1.0-C-expected/Regress.annotation_transfer_floating.page
index 78684c8..440535f 100644
--- a/tests/scanner/Regress-1.0-C-expected/Regress.annotation_transfer_floating.page
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.annotation_transfer_floating.page
@@ -12,16 +12,24 @@
         <api:type>GObject*</api:type>
       </api:returns>
       <api:name>regress_annotation_transfer_floating</api:name>
+      <api:arg>
+        <api:type>GObject*</api:type>
+        <api:name>object</api:name>
+      </api:arg>
     </api:function>
   </info>
   <title>regress_annotation_transfer_floating</title>
   <synopsis><code mime="text/x-csrc">
-GObject* regress_annotation_transfer_floating (void);
+GObject* regress_annotation_transfer_floating (GObject* object);
   </code></synopsis>
 
 
 <terms>
 <item>
+<title><code>object</code></title>
+  <p>an object</p>
+</item>
+<item>
 <title><code>Returns</code></title>
   <p>A floating object</p>
 </item>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.annotation_transfer_floating.page 
b/tests/scanner/Regress-1.0-Gjs-expected/Regress.annotation_transfer_floating.page
index be5134b..7918381 100644
--- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.annotation_transfer_floating.page
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.annotation_transfer_floating.page
@@ -12,11 +12,15 @@
         <api:type>GObject.Object</api:type>
       </api:returns>
       <api:name>regress_annotation_transfer_floating</api:name>
+      <api:arg>
+        <api:type>GObject.Object</api:type>
+        <api:name>object</api:name>
+      </api:arg>
     </api:function>
   </info>
   <title>Regress.annotation_transfer_floating</title>
   <synopsis><code mime="text/x-gjs">
-function annotation_transfer_floating(): <link 
href="../GObject-2.0/GObject.Object.html">GObject.Object</link> {
+function annotation_transfer_floating(object: <link 
href="../GObject-2.0/GObject.Object.html">GObject.Object</link>): <link 
href="../GObject-2.0/GObject.Object.html">GObject.Object</link> {
     // Gjs wrapper for regress_annotation_transfer_floating()
 }
   </code></synopsis>
@@ -24,6 +28,10 @@ function annotation_transfer_floating(): <link href="../GObject-2.0/GObject.Obje
 
 <terms>
 <item>
+<title><code>object</code></title>
+  <p>an object</p>
+</item>
+<item>
 <title><code>Returns</code></title>
   <p>A floating object</p>
 </item>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.annotation_transfer_floating.page 
b/tests/scanner/Regress-1.0-Python-expected/Regress.annotation_transfer_floating.page
index f8f68c1..1f247cf 100644
--- a/tests/scanner/Regress-1.0-Python-expected/Regress.annotation_transfer_floating.page
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.annotation_transfer_floating.page
@@ -12,18 +12,27 @@
         <api:type>GObject.Object</api:type>
       </api:returns>
       <api:name>regress_annotation_transfer_floating</api:name>
+      <api:arg>
+        <api:type>GObject.Object</api:type>
+        <api:name>object</api:name>
+      </api:arg>
     </api:function>
   </info>
   <title>Regress.annotation_transfer_floating</title>
   <synopsis><code mime="text/x-python">
+@accepts(GObject.Object)
 @returns(GObject.Object)
-def annotation_transfer_floating():
+def annotation_transfer_floating(object):
     # Python wrapper for regress_annotation_transfer_floating()
   </code></synopsis>
 
 
 <terms>
 <item>
+<title><code>object</code></title>
+  <p>an object</p>
+</item>
+<item>
 <title><code>Returns</code></title>
 {formatter.format(node, node.retval.doc)}
 </item>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 91efacc..7596282 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -4542,6 +4542,12 @@ detection, and fixing it via annotations.</doc>
         <doc xml:space="preserve">A floating object</doc>
         <type name="GObject.Object" c:type="GObject*"/>
       </return-value>
+      <parameters>
+        <parameter name="object" transfer-ownership="none">
+          <doc xml:space="preserve">an object</doc>
+          <type name="GObject.Object" c:type="GObject*"/>
+        </parameter>
+      </parameters>
     </function>
     <function name="annotation_versioned"
               c:identifier="regress_annotation_versioned"
diff --git a/tests/scanner/annotation.c b/tests/scanner/annotation.c
index da364e1..49bdd24 100644
--- a/tests/scanner/annotation.c
+++ b/tests/scanner/annotation.c
@@ -821,11 +821,12 @@ regress_annotation_return_filename (void)
 
 /**
  * regress_annotation_transfer_floating:
+ * @object: (in) (transfer floating): an object
  *
  * Returns: (transfer floating): A floating object
  */
 GObject *
-regress_annotation_transfer_floating(void)
+regress_annotation_transfer_floating (GObject *object)
 {
   return NULL;
 }
diff --git a/tests/scanner/annotation.h b/tests/scanner/annotation.h
index 07894df..92c0b6b 100644
--- a/tests/scanner/annotation.h
+++ b/tests/scanner/annotation.h
@@ -276,7 +276,7 @@ gchar* regress_annotation_return_filename (void);
 
 
 _GI_TEST_EXTERN
-GObject * regress_annotation_transfer_floating(void);
+GObject * regress_annotation_transfer_floating (GObject *object);
 
 /* This one we can handle properly */
 #define REGRESS_ANNOTATION_CALCULATED_DEFINE (10 * 10)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]