[gobject-introspection] Bug 574139 – There is no way to identify 'user_d



commit 2bd97368f6ced0d23977ce980ac159453cc18d8c
Author: Andreas Rottmann <a rottmann gmx at>
Date:   Mon Mar 9 18:33:00 2009 +0100

    Bug 574139 â?? There is no way to identify 'user_data' arguments in the callback signature
    
    Add a heuristic to the scanner that flags arguments of callbacks that
    are named 'user_data' (exact match) and have a 'any (void*) type.
    
    These arguments are marked by setting the 'closure' field of ArgBlob
    to the index of themselves.
    
    Signed-off-by: Andreas Rottmann <a rottmann gmx at>
---
 giscanner/transformer.py                   |   11 +++++++++--
 tests/scanner/annotation-1.0-expected.gir  |    2 +-
 tests/scanner/annotation-1.0-expected.tgir |    2 +-
 tests/scanner/utility-1.0-expected.gir     |    2 +-
 tests/scanner/utility-1.0-expected.tgir    |    2 +-
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 8e3219a..9aebbd8 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -534,13 +534,20 @@ class Transformer(object):
         return self._create_compound(Union, symbol, anonymous)
 
     def _create_callback(self, symbol):
-        parameters = self._create_parameters(symbol.base_type.base_type)
+        parameters = list(self._create_parameters(symbol.base_type.base_type))
         retval = self._create_return(symbol.base_type.base_type.base_type)
+
+        # Mark the 'user_data' arguments
+        for i, param in enumerate(parameters):
+            if (param.type.name == 'any' and
+                param.name == 'user_data'):
+                param.closure_index = i
+
         if symbol.ident.find('_') > 0:
             name = self.remove_prefix(symbol.ident, True)
         else:
             name = self.remove_prefix(symbol.ident)
-        callback = Callback(name, retval, list(parameters), symbol.ident)
+        callback = Callback(name, retval, parameters, symbol.ident)
 
         return callback
 
diff --git a/tests/scanner/annotation-1.0-expected.gir b/tests/scanner/annotation-1.0-expected.gir
index f427345..1af7271 100644
--- a/tests/scanner/annotation-1.0-expected.gir
+++ b/tests/scanner/annotation-1.0-expected.gir
@@ -34,7 +34,7 @@ and/or use gtk-doc annotations.  -->
         <parameter name="item" transfer-ownership="none">
           <type name="utf8" c:type="char*"/>
         </parameter>
-        <parameter name="user_data" transfer-ownership="none">
+        <parameter name="user_data" transfer-ownership="none" closure="2">
           <type name="any" c:type="gpointer"/>
         </parameter>
       </parameters>
diff --git a/tests/scanner/annotation-1.0-expected.tgir b/tests/scanner/annotation-1.0-expected.tgir
index 2075143..2a1426b 100644
--- a/tests/scanner/annotation-1.0-expected.tgir
+++ b/tests/scanner/annotation-1.0-expected.tgir
@@ -28,7 +28,7 @@
         <parameter name="item" transfer-ownership="none">
           <type name="utf8"/>
         </parameter>
-        <parameter name="user_data" transfer-ownership="none">
+        <parameter name="user_data" transfer-ownership="none" closure="2">
           <type name="any"/>
         </parameter>
       </parameters>
diff --git a/tests/scanner/utility-1.0-expected.gir b/tests/scanner/utility-1.0-expected.gir
index 0ca72cb..331979c 100644
--- a/tests/scanner/utility-1.0-expected.gir
+++ b/tests/scanner/utility-1.0-expected.gir
@@ -37,7 +37,7 @@ and/or use gtk-doc annotations.  -->
         <parameter name="path" transfer-ownership="none">
           <type name="utf8" c:type="char*"/>
         </parameter>
-        <parameter name="user_data" transfer-ownership="none">
+        <parameter name="user_data" transfer-ownership="none" closure="1">
           <type name="any" c:type="gpointer"/>
         </parameter>
       </parameters>
diff --git a/tests/scanner/utility-1.0-expected.tgir b/tests/scanner/utility-1.0-expected.tgir
index 2653584..dfd2aa8 100644
--- a/tests/scanner/utility-1.0-expected.tgir
+++ b/tests/scanner/utility-1.0-expected.tgir
@@ -24,7 +24,7 @@
         <parameter name="path" transfer-ownership="none">
           <type name="utf8"/>
         </parameter>
-        <parameter name="user_data" transfer-ownership="none">
+        <parameter name="user_data" transfer-ownership="none" closure="1">
           <type name="any"/>
         </parameter>
       </parameters>



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