[gobject-introspection] Preserve the c:type of array elements



commit 751a9fa80a31c01cd26ff35f0e66f428372ea88b
Author: Tomeu Vizoso <tomeu vizoso collabora co uk>
Date:   Thu Jan 20 16:34:45 2011 +0100

    Preserve the c:type of array elements
    
    So the element type has the correct is_pointer flag
    
    https://bugzilla.gnome.org/show_bug.cgi?id=638929

 giscanner/maintransformer.py              |    5 ++-
 tests/scanner/Annotation-1.0-expected.gir |   14 ++++++------
 tests/scanner/Foo-1.0-expected.gir        |    4 +-
 tests/scanner/Regress-1.0-expected.gir    |   34 ++++++++++++++--------------
 4 files changed, 29 insertions(+), 28 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 8ada929..ee94554 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -325,8 +325,9 @@ usage is void (*_gtk_reserved1)(void);"""
             # We're assuming here that Foo* with an (array) annotation
             # and no (element-type) means array of Foo
             element_type_node = node.type.clone()
-            # Explicitly erase ctype since it's no longer valid
-            element_type_node.ctype = None
+            # The element's ctype is the array's dereferenced
+            if element_type_node.ctype.endswith('*'):
+                element_type_node.ctype = element_type_node.ctype[:-1]
 
         if isinstance(node.type, ast.Array):
             array_type = node.type.array_type
diff --git a/tests/scanner/Annotation-1.0-expected.gir b/tests/scanner/Annotation-1.0-expected.gir
index e47a4b9..e05e61b 100644
--- a/tests/scanner/Annotation-1.0-expected.gir
+++ b/tests/scanner/Annotation-1.0-expected.gir
@@ -147,7 +147,7 @@ and/or use gtk-doc annotations.  -->
           <parameter name="nums" transfer-ownership="none">
             <doc xml:whitespace="preserve">Sequence of numbers</doc>
             <array c:type="int*">
-              <type name="gint"/>
+              <type name="gint" c:type="int"/>
             </array>
           </parameter>
         </parameters>
@@ -162,7 +162,7 @@ and/or use gtk-doc annotations.  -->
           <parameter name="nums" transfer-ownership="none">
             <doc xml:whitespace="preserve">Sequence of numbers that are zero-terminated</doc>
             <array length="1" zero-terminated="0" c:type="int*">
-              <type name="gint"/>
+              <type name="gint" c:type="int"/>
             </array>
           </parameter>
           <parameter name="n_nums" transfer-ownership="none">
@@ -181,7 +181,7 @@ and/or use gtk-doc annotations.  -->
           <parameter name="nums" transfer-ownership="none">
             <doc xml:whitespace="preserve">Sequence of numbers that are zero-terminated</doc>
             <array length="1" c:type="int*">
-              <type name="gint"/>
+              <type name="gint" c:type="int"/>
             </array>
           </parameter>
           <parameter name="n_nums" transfer-ownership="none">
@@ -378,7 +378,7 @@ each string needs to be freed.</doc>
                      transfer-ownership="full">
             <doc xml:whitespace="preserve">Argument vector</doc>
             <array length="0" c:type="char***">
-              <type name="utf8"/>
+              <type name="utf8" c:type="char**"/>
             </array>
           </parameter>
         </parameters>
@@ -392,7 +392,7 @@ each string needs to be freed.</doc>
           <parameter name="data" transfer-ownership="none">
             <doc xml:whitespace="preserve">The data</doc>
             <array length="1" c:type="guchar*">
-              <type name="guint8"/>
+              <type name="guint8" c:type="guchar"/>
             </array>
           </parameter>
           <parameter name="length" transfer-ownership="none">
@@ -687,7 +687,7 @@ detection, and fixing it via annotations.</doc>
                    transfer-ownership="full">
           <doc xml:whitespace="preserve">The arguments.</doc>
           <array length="0" c:type="char***">
-            <type name="utf8"/>
+            <type name="utf8" c:type="char**"/>
           </array>
         </parameter>
       </parameters>
@@ -790,7 +790,7 @@ detection, and fixing it via annotations.</doc>
                    caller-allocates="0"
                    transfer-ownership="full">
           <array c:type="char***">
-            <type name="utf8"/>
+            <type name="utf8" c:type="char**"/>
           </array>
         </parameter>
       </parameters>
diff --git a/tests/scanner/Foo-1.0-expected.gir b/tests/scanner/Foo-1.0-expected.gir
index e527cad..fa5ee93 100644
--- a/tests/scanner/Foo-1.0-expected.gir
+++ b/tests/scanner/Foo-1.0-expected.gir
@@ -1085,7 +1085,7 @@ exposed to language bindings.</doc>
       <parameters>
         <parameter name="array" transfer-ownership="none">
           <array c:type="char**">
-            <type name="utf8"/>
+            <type name="utf8" c:type="char*"/>
           </array>
         </parameter>
       </parameters>
@@ -1098,7 +1098,7 @@ exposed to language bindings.</doc>
       <parameters>
         <parameter name="array" transfer-ownership="none">
           <array c:type="gchar**">
-            <type name="utf8"/>
+            <type name="utf8" c:type="gchar*"/>
           </array>
         </parameter>
       </parameters>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 3d4e56f..abf46f1 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -1069,7 +1069,7 @@ TpAccount::status-changed</doc>
         <parameter name="ints" transfer-ownership="none">
           <doc xml:whitespace="preserve">a list of 5 integers</doc>
           <array c:type="int*" fixed-size="5">
-            <type name="gint"/>
+            <type name="gint" c:type="int"/>
           </array>
         </parameter>
       </parameters>
@@ -1086,7 +1086,7 @@ TpAccount::status-changed</doc>
                    transfer-ownership="full">
           <doc xml:whitespace="preserve">a list of 5 integers ranging from 0 to 4</doc>
           <array c:type="int**" fixed-size="5">
-            <type name="gint"/>
+            <type name="gint" c:type="int*"/>
           </array>
         </parameter>
       </parameters>
@@ -1096,7 +1096,7 @@ TpAccount::status-changed</doc>
       <return-value transfer-ownership="full">
         <doc xml:whitespace="preserve">a list of 5 integers ranging from 0 to 4</doc>
         <array c:type="int*" fixed-size="5">
-          <type name="gint"/>
+          <type name="gint" c:type="int"/>
         </array>
       </return-value>
     </function>
@@ -1112,7 +1112,7 @@ TpAccount::status-changed</doc>
         <parameter name="ints" transfer-ownership="none">
           <doc xml:whitespace="preserve">List of ints</doc>
           <array length="0" c:type="gint16*">
-            <type name="gint16"/>
+            <type name="gint16" c:type="gint16"/>
           </array>
         </parameter>
       </parameters>
@@ -1129,7 +1129,7 @@ TpAccount::status-changed</doc>
         <parameter name="ints" transfer-ownership="none">
           <doc xml:whitespace="preserve">List of ints</doc>
           <array length="0" c:type="gint32*">
-            <type name="gint32"/>
+            <type name="gint32" c:type="gint32"/>
           </array>
         </parameter>
       </parameters>
@@ -1146,7 +1146,7 @@ TpAccount::status-changed</doc>
         <parameter name="ints" transfer-ownership="none">
           <doc xml:whitespace="preserve">List of ints</doc>
           <array length="0" c:type="gint64*">
-            <type name="gint64"/>
+            <type name="gint64" c:type="gint64"/>
           </array>
         </parameter>
       </parameters>
@@ -1163,7 +1163,7 @@ TpAccount::status-changed</doc>
         <parameter name="ints" transfer-ownership="none">
           <doc xml:whitespace="preserve">List of ints</doc>
           <array length="0" c:type="gint8*">
-            <type name="gint8"/>
+            <type name="gint8" c:type="gint8"/>
           </array>
         </parameter>
       </parameters>
@@ -1181,7 +1181,7 @@ TpAccount::status-changed</doc>
         <parameter name="types" transfer-ownership="none">
           <doc xml:whitespace="preserve">List of types</doc>
           <array length="0" c:type="GType*">
-            <type name="GType"/>
+            <type name="GType" c:type="GType"/>
           </array>
         </parameter>
       </parameters>
@@ -1191,7 +1191,7 @@ TpAccount::status-changed</doc>
       <return-value transfer-ownership="full">
         <doc xml:whitespace="preserve">a new array of integers.</doc>
         <array length="0" c:type="int*">
-          <type name="gint"/>
+          <type name="gint" c:type="int"/>
         </array>
       </return-value>
       <parameters>
@@ -1216,7 +1216,7 @@ TpAccount::status-changed</doc>
         <parameter name="ints" transfer-ownership="none">
           <doc xml:whitespace="preserve">List of ints</doc>
           <array length="0" c:type="int*">
-            <type name="gint"/>
+            <type name="gint" c:type="int"/>
           </array>
         </parameter>
       </parameters>
@@ -1240,7 +1240,7 @@ TpAccount::status-changed</doc>
                    transfer-ownership="full">
           <doc xml:whitespace="preserve">a list of integers whose items will be increased by 1, except the first that will be dropped</doc>
           <array length="0" c:type="int**">
-            <type name="gint"/>
+            <type name="gint" c:type="int*"/>
           </array>
         </parameter>
       </parameters>
@@ -1250,7 +1250,7 @@ TpAccount::status-changed</doc>
       <return-value transfer-ownership="none">
         <doc xml:whitespace="preserve">a static array of integers.</doc>
         <array length="0" c:type="int*">
-          <type name="gint"/>
+          <type name="gint" c:type="int"/>
         </array>
       </return-value>
       <parameters>
@@ -1271,7 +1271,7 @@ TpAccount::status-changed</doc>
       <parameters>
         <parameter name="arr" transfer-ownership="none" allow-none="1">
           <array length="1" c:type="int*">
-            <type name="gint"/>
+            <type name="gint" c:type="int"/>
           </array>
         </parameter>
         <parameter name="len" transfer-ownership="none">
@@ -1292,7 +1292,7 @@ TpAccount::status-changed</doc>
                    transfer-ownership="full"
                    allow-none="1">
           <array length="1" c:type="int**">
-            <type name="gint"/>
+            <type name="gint" c:type="int*"/>
           </array>
         </parameter>
         <parameter name="len"
@@ -1323,7 +1323,7 @@ TpAccount::status-changed</doc>
                    transfer-ownership="full">
           <doc xml:whitespace="preserve">a list of 5 integers, from 0 to 4 in consecutive order</doc>
           <array length="0" c:type="int**">
-            <type name="gint"/>
+            <type name="gint" c:type="int*"/>
           </array>
         </parameter>
       </parameters>
@@ -2084,7 +2084,7 @@ call and can be released on return.</doc>
       <parameters>
         <parameter name="arr" transfer-ownership="none">
           <array c:type="char**">
-            <type name="utf8"/>
+            <type name="utf8" c:type="char*"/>
           </array>
         </parameter>
       </parameters>
@@ -2127,7 +2127,7 @@ call and can be released on return.</doc>
                    caller-allocates="0"
                    transfer-ownership="container">
           <array c:type="char***">
-            <type name="utf8"/>
+            <type name="utf8" c:type="char**"/>
           </array>
         </parameter>
       </parameters>



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