From c62e213aea1a9bced3ba47ee248d6a35df41d251 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Tue, 17 Nov 2009 09:46:07 -0800 Subject: [PATCH] Fix for setting real/imaginary parts for MSVC C++. --- Cython/Compiler/ExprNodes.py | 5 +++++ Cython/Compiler/PyrexTypes.py | 8 ++++++++ 2 files changed, 13 insertions(+) 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( -- 2.26.2