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
Boxiang Sun
cython
Commits
80e9ca42
Commit
80e9ca42
authored
May 14, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complex type parsing, very basic support if supported by C compiler
parent
adcd8939
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
2 deletions
+31
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+3
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+6
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+22
-1
No files found.
Cython/Compiler/Nodes.py
View file @
80e9ca42
...
...
@@ -674,6 +674,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
# is_basic_c_type boolean
# signed boolean
# longness integer
# complex boolean
# is_self_arg boolean Is self argument of C method
child_attrs
=
[]
...
...
@@ -714,6 +715,8 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
self
.
arg_name
=
self
.
name
else
:
error
(
self
.
pos
,
"'%s' is not a type identifier"
%
self
.
name
)
if
self
.
complex
:
type
=
PyrexTypes
.
CCompelxType
(
type
)
if
type
:
return
type
else
:
...
...
Cython/Compiler/Parsing.py
View file @
80e9ca42
...
...
@@ -1692,6 +1692,7 @@ def p_c_simple_base_type(s, self_flag, nonempty):
is_basic
=
0
signed
=
1
longness
=
0
complex
=
0
module_path
=
[]
pos
=
s
.
position
()
if
not
s
.
sy
==
'IDENT'
:
...
...
@@ -1710,6 +1711,9 @@ def p_c_simple_base_type(s, self_flag, nonempty):
s
.
next
()
else
:
name
=
'int'
if
s
.
sy
==
'IDENT'
and
s
.
systring
==
'complex'
:
complex
=
1
s
.
next
()
elif
looking_at_dotted_name
(
s
):
#print "p_c_simple_base_type: looking_at_type_name at", s.position()
name
=
s
.
systring
...
...
@@ -1738,7 +1742,8 @@ def p_c_simple_base_type(s, self_flag, nonempty):
type_node
=
Nodes
.
CSimpleBaseTypeNode
(
pos
,
name
=
name
,
module_path
=
module_path
,
is_basic_c_type
=
is_basic
,
signed
=
signed
,
longness
=
longness
,
is_self_arg
=
self_flag
)
complex
=
complex
,
longness
=
longness
,
is_self_arg
=
self_flag
)
# Treat trailing [] on type as buffer access if it appears in a context
...
...
Cython/Compiler/PyrexTypes.py
View file @
80e9ca42
...
...
@@ -33,6 +33,7 @@ class PyrexType(BaseType):
# is_int boolean Is a C integer type
# is_longlong boolean Is a long long or unsigned long long.
# is_float boolean Is a C floating point type
# is_complex boolean Is a C complex type
# is_void boolean Is the C void type
# is_array boolean Is a C array type
# is_ptr boolean Is a C pointer type
...
...
@@ -83,6 +84,7 @@ class PyrexType(BaseType):
is_int
=
0
is_longlong
=
0
is_float
=
0
is_complex
=
0
is_void
=
0
is_array
=
0
is_ptr
=
0
...
...
@@ -698,7 +700,24 @@ class CFloatType(CNumericType):
self
.
math_h_modifier
=
math_h_modifier
def
assignable_from_resolved_type
(
self
,
src_type
):
return
src_type
.
is_numeric
or
src_type
is
error_type
return
(
src_type
.
is_numeric
and
not
src_type
.
is_complex
)
or
src_type
is
error_type
class
CCompelxType
(
CNumericType
):
is_complex
=
1
def
__init__
(
self
,
real_type
):
self
.
real_type
=
real_type
CNumericType
.
__init__
(
self
,
real_type
.
rank
+
0.5
,
real_type
.
signed
)
def
sign_and_name
(
self
):
return
self
.
real_type
.
sign_and_name
()
+
" complex"
def
assignable_from_resolved_type
(
self
,
src_type
):
return
(
src_type
.
is_complex
and
self
.
real_type
.
assignable_from_resolved_type
(
src_type
.
real_type
)
or
src_type
.
is_numeric
and
self
.
real_type
.
assignable_from_resolved_type
(
src_type
)
or
src_type
is
error_type
)
class
CArrayType
(
CType
):
...
...
@@ -1615,3 +1634,5 @@ static INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
}
"""
+
type_conversion_functions
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