[gobject-introspection] scanner: Associate constructors with correct class



commit 718d2b008f4e19f8dc8304559e528ac56638a478
Author: Colin Walters <walters verbum org>
Date:   Thu Sep 2 12:19:21 2010 -0400

    scanner: Associate constructors with correct class

 giscanner/maintransformer.py           |    4 +++-
 tests/scanner/Regress-1.0-expected.gir |    2 +-
 tests/scanner/regress.c                |    2 +-
 tests/scanner/regress.h                |    2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 5a5a21e..9a8d93d 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -818,6 +818,8 @@ method or constructor of some type."""
                 "Can't find matching type for constructor; symbol=%r" % (func.symbol, ))
             return False
         (origin_node, funcname) = split
+        if not isinstance(origin_node, (ast.Class, glibast.GLibBoxed)):
+            return False
         if isinstance(target, ast.Class):
             parent = origin_node
             while parent and (not parent.create_type().target_giname == 'GObject.Object'):
@@ -847,7 +849,7 @@ method or constructor of some type."""
         self._namespace.float(func)
         func.name = funcname
         func.is_constructor = True
-        target.constructors.append(func)
+        origin_node.constructors.append(func)
         # Constructors have default return semantics
         if not func.retval.transfer:
             func.retval.transfer = self._get_transfer_default_return(func, func.retval)
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index d540a95..4014e5e 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -733,7 +733,7 @@ case.</doc>
            glib:type-struct="TestSubObjClass">
       <constructor name="new" c:identifier="regress_test_sub_obj_new">
         <return-value transfer-ownership="full">
-          <type name="TestSubObj" c:type="RegressTestSubObj*"/>
+          <type name="TestObj" c:type="RegressTestObj*"/>
         </return-value>
       </constructor>
       <method name="instance_method"
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 2f3b827..eee63c5 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -2099,7 +2099,7 @@ regress_test_sub_obj_init (RegressTestSubObj *obj)
 {
 }
 
-RegressTestSubObj*
+RegressTestObj*
 regress_test_sub_obj_new ()
 {
   return g_object_new (REGRESS_TEST_TYPE_SUB_OBJ, NULL);
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 6dafd9c..443d032 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -334,7 +334,7 @@ struct _RegressTestSubObjClass
 };
 
 GType       regress_test_sub_obj_get_type (void);
-RegressTestSubObj* regress_test_sub_obj_new (void);
+RegressTestObj* regress_test_sub_obj_new (void);
 void        regress_test_sub_obj_unset_bare (RegressTestSubObj *obj);
 int         regress_test_sub_obj_instance_method (RegressTestSubObj *obj);
 



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