Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
9d1317a6
Commit
9d1317a6
authored
Jan 30, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ticket #445, explicit complex casting
parent
539846c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+16
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
9d1317a6
...
...
@@ -4328,6 +4328,8 @@ class TypecastNode(ExprNode):
elif
from_py
and
to_py
:
if
self
.
typecheck
and
self
.
type
.
is_extension_type
:
self
.
operand
=
PyTypeTestNode
(
self
.
operand
,
self
.
type
,
env
,
notnone
=
True
)
elif
self
.
type
.
is_complex
and
self
.
operand
.
type
.
is_complex
:
self
.
operand
=
self
.
operand
.
coerce_to_simple
(
env
)
def
nogil_check
(
self
,
env
):
if
self
.
type
and
self
.
type
.
is_pyobject
and
self
.
is_temp
:
...
...
@@ -4342,8 +4344,20 @@ class TypecastNode(ExprNode):
pass
def
calculate_result_code
(
self
):
opnd
=
self
.
operand
return
self
.
type
.
cast_code
(
opnd
.
result
())
if
self
.
type
.
is_complex
:
operand_result
=
self
.
operand
.
result
()
if
self
.
operand
.
type
.
is_complex
:
real_part
=
self
.
type
.
real_type
.
cast_code
(
"__Pyx_CREAL(%s)"
%
operand_result
)
imag_part
=
self
.
type
.
real_type
.
cast_code
(
"__Pyx_CIMAG(%s)"
%
operand_result
)
else
:
real_part
=
self
.
type
.
real_type
.
cast_code
(
operand_result
)
imag_part
=
"0"
return
"%s(%s, %s)"
%
(
self
.
type
.
from_parts
,
real_part
,
imag_part
)
else
:
return
self
.
type
.
cast_code
(
self
.
operand
.
result
())
def
get_constant_c_result_code
(
self
):
operand_result
=
self
.
operand
.
get_constant_c_result_code
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment