Fix for setting real/imaginary parts for MSVC C++.
authorRobert Bradshaw <robertwb@math.washington.edu>
Tue, 17 Nov 2009 17:46:07 +0000 (09:46 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Tue, 17 Nov 2009 17:46:07 +0000 (09:46 -0800)
Cython/Compiler/ExprNodes.py
Cython/Compiler/PyrexTypes.py

index 1b6c2e82849b62b1b0eea6e8b7d8df70678f3f94..1826506a0db10c5f3a2cf791daa0d0b7d2677c78 100644 (file)
@@ -3091,6 +3091,11 @@ class AttributeNode(ExprNode):
                     rhs.py_result()))
             rhs.generate_disposal_code(code)
             rhs.free_temps(code)
+        elif self.obj.type.is_complex:
+            code.putln("__Pyx_SET_C%s(%s, %s);" % (
+                self.member.upper(),
+                self.obj.result_as(self.obj.type),
+                rhs.result_as(self.ctype())))
         else:
             if (self.obj.type.is_extension_type
                   and self.needs_none_check
index a45a180abc9523f95b7048d2fbd6885828c92ecb..5c0c20d73329423bbe421b25abc6177eddbd4925 100644 (file)
@@ -1057,6 +1057,14 @@ proto="""
     #define __Pyx_CREAL(z) ((z).real)
     #define __Pyx_CIMAG(z) ((z).imag)
 #endif
+
+#if defined(_WIN32) && defined(__cplusplus) && CYTHON_CCOMPLEX
+    #define __Pyx_SET_CREAL(z,x) ((z).real(x))
+    #define __Pyx_SET_CIMAG(z,y) ((z).imag(y))
+#else
+    #define __Pyx_SET_CREAL(z,x) __Pyx_CREAL(z) = (x)
+    #define __Pyx_SET_CIMAG(z,y) __Pyx_CIMAG(z) = (y)
+#endif
 """)
 
 complex_type_utility_code = UtilityCode(