From: Robert Bradshaw Date: Tue, 17 Nov 2009 17:46:07 +0000 (-0800) Subject: Fix for setting real/imaginary parts for MSVC C++. X-Git-Tag: 0.12~5 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c62e213aea1a9bced3ba47ee248d6a35df41d251;p=cython.git Fix for setting real/imaginary parts for MSVC C++. --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 1b6c2e82..1826506a 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index a45a180a..5c0c20d7 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -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(