C++ class constructor calls.
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 19 Feb 2010 02:01:37 +0000 (18:01 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 19 Feb 2010 02:01:37 +0000 (18:01 -0800)
Cython/Compiler/ExprNodes.py
Cython/Compiler/PyrexTypes.py
Cython/Compiler/Symtab.py
tests/run/cpp_nested_templates.pyx

index a6b52f7d59dc6107b15c50e3d5c43a1e35485f2d..2e5eb16353a7a223223f8c4e01cffbbdcc6e3be2 100755 (executable)
@@ -2453,6 +2453,15 @@ class CallNode(ExprNode):
             self.analyse_types(env)
             self.coerce_to(type, env)
             return True
+        elif type and type.is_cpp_class:
+            for arg in self.args:
+                arg.analyse_types(env)
+            constructor = type.scope.lookup("<init>")
+            self.function = RawCNameExprNode(self.function.pos, constructor.type)
+            self.function.entry = constructor
+            self.function.set_cname(type.declaration_code(""))
+            self.analyse_c_function_call(env)
+            return True
 
     def nogil_check(self, env):
         func_type = self.function_type()
index e9c4ff384e5ef5f1c83e31669c43d3766b622a30..a8f4acceb0c551a5460d3b6d819ee8f0af14f5e1 100755 (executable)
@@ -1890,6 +1890,8 @@ class CppClassType(CType):
 
     def assignable_from_resolved_type(self, other_type):
         # TODO: handle operator=(...) here?
+        if other_type is error_type:
+            return True
         return other_type.is_cpp_class and other_type.is_subclass(self)
     
     def attributes_known(self):
index 70de775dbd2045312b8a21a694c35af37f575212..1e6cdbe8d4eb6f661700a6e597233ff1848ed033 100644 (file)
@@ -1536,6 +1536,7 @@ class CppClassScope(Scope):
             api = 0, in_pxd = 0, modifiers = ()):
         if name == self.name.split('::')[-1] and cname is None:
             name = '<init>'
+            type.return_type = self.lookup(self.name).type
         prev_entry = self.lookup_here(name)
         entry = self.declare_var(name, type, pos, cname, visibility)
         if prev_entry:
index 7c79e3b88ca95f2be593f988bed0dee22411ddbc..85e7c4754a2e6ee8f9c365505f24fcc03bb71dda 100644 (file)
@@ -22,8 +22,7 @@ def test_wrap_pair(int i, double x):
     (2, 2.25, True)
     """
     try:
-        pair = new Pair[int, double](i, x)
-        wrap = new Wrap[Pair[int, double]](deref(pair))
+        wrap = new Wrap[Pair[int, double]](Pair[int, double](i, x))
         return wrap.get().first(), wrap.get().second(), deref(wrap) == deref(wrap)
     finally:
-        del pair, wrap
+        del wrap