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
2cb09abc
Commit
2cb09abc
authored
Oct 20, 2009
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix z.conjugate() for typedef-ed z; disallow external typedef complex
parent
77ec0cc4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
4 deletions
+21
-4
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+10
-2
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+5
-1
tests/run/complex_numbers_T305.pyx
tests/run/complex_numbers_T305.pyx
+5
-0
No files found.
Cython/Compiler/Nodes.py
View file @
2cb09abc
...
...
@@ -16,7 +16,7 @@ from Errors import error, warning, InternalError
import
Naming
import
PyrexTypes
import
TypeSlots
from
PyrexTypes
import
py_object_type
,
error_type
,
C
TypedefType
,
C
FuncType
from
PyrexTypes
import
py_object_type
,
error_type
,
CFuncType
from
Symtab
import
ModuleScope
,
LocalScope
,
GeneratorLocalScope
,
\
StructOrUnionScope
,
PyClassScope
,
CClassScope
from
Cython.Utils
import
open_new_file
,
replace_suffix
...
...
Cython/Compiler/PyrexTypes.py
View file @
2cb09abc
...
...
@@ -150,6 +150,15 @@ class PyrexType(BaseType):
# type information of the struct.
return
1
def
create_typedef_type
(
cname
,
base_type
,
is_external
=
0
):
if
base_type
.
is_complex
:
if
is_external
:
raise
ValueError
(
"Complex external typedefs not supported"
)
return
base_type
else
:
return
CTypedefType
(
cname
,
base_type
,
is_external
)
class
CTypedefType
(
BaseType
):
#
# Pseudo-type defined with a ctypedef statement in a
...
...
@@ -170,6 +179,7 @@ class CTypedefType(BaseType):
def
__init__
(
self
,
cname
,
base_type
,
is_external
=
0
):
assert
not
base_type
.
is_complex
self
.
typedef_cname
=
cname
self
.
typedef_base_type
=
base_type
self
.
typedef_is_external
=
is_external
...
...
@@ -876,8 +886,6 @@ class CComplexType(CNumericType):
None
,
visibility
=
"extern"
)
scope
.
parent_type
=
self
scope
.
declare_var
(
"real"
,
self
.
real_type
,
None
,
"real"
,
is_cdef
=
True
)
scope
.
declare_var
(
"imag"
,
self
.
real_type
,
None
,
"imag"
,
is_cdef
=
True
)
entry
=
scope
.
declare_cfunction
(
...
...
Cython/Compiler/Symtab.py
View file @
2cb09abc
...
...
@@ -342,7 +342,11 @@ class Scope(object):
cname = name
else:
cname = self.mangle(Naming.type_prefix, name)
type = PyrexTypes.CTypedefType(cname, base_type, (visibility == 'extern'))
try:
type = PyrexTypes.create_typedef_type(cname, base_type, (visibility == 'extern'))
except ValueError, e:
error(pos, e.message)
type = PyrexTypes.error_type
entry = self.declare_type(name, type, pos, cname, visibility)
type.qualified_name = entry.qualified_name
return entry
...
...
tests/run/complex_numbers_T305.pyx
View file @
2cb09abc
...
...
@@ -116,3 +116,8 @@ def test_conjugate(float complex z):
def
test_conjugate_double
(
double
complex
z
):
return
z
.
conjugate
()
ctypedef
double
complex
cdouble
def
test_conjugate_typedef
(
cdouble
z
):
return
z
.
conjugate
()
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