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
Kirill Smelkov
cython
Commits
df6713cc
Commit
df6713cc
authored
Apr 03, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Transformation fixes
parent
ed76a7c3
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
35 deletions
+142
-35
Cython/Compiler/CmdLine.py
Cython/Compiler/CmdLine.py
+2
-1
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+46
-28
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+11
-5
Cython/Distutils/extension.py
Cython/Distutils/extension.py
+79
-0
No files found.
Cython/Compiler/CmdLine.py
View file @
df6713cc
...
@@ -30,7 +30,8 @@ Options:
...
@@ -30,7 +30,8 @@ Options:
-D, --no-docstrings Remove docstrings.
-D, --no-docstrings Remove docstrings.
-a, --annotate Produce an colorized version of the source.
-a, --annotate Produce an colorized version of the source.
--convert-range Convert for loops using range() function to for...from loops.
--convert-range Convert for loops using range() function to for...from loops.
"""
--cplus Output a c++ rather than c file.
"""
#The following experimental options are supported only on MacOSX:
#The following experimental options are supported only on MacOSX:
# -C, --compile Compile generated .c file to .o file
# -C, --compile Compile generated .c file to .o file
# -X, --link Link .o file to produce extension module (implies -C)
# -X, --link Link .o file to produce extension module (implies -C)
...
...
Cython/Compiler/ExprNodes.py
View file @
df6713cc
...
@@ -169,9 +169,9 @@ class ExprNode(Node):
...
@@ -169,9 +169,9 @@ class ExprNode(Node):
def
get_child_attrs
(
self
):
def
get_child_attrs
(
self
):
"""Automatically provide the contents of subexprs as children, unless child_attr
"""Automatically provide the contents of subexprs as children, unless child_attr
has been declared. See Nodes.Node.get_child_accessors."""
has been declared. See Nodes.Node.get_child_accessors."""
if
self
.
child_attrs
!=
None
:
if
self
.
child_attrs
is
not
None
:
return
self
.
child_attr
return
self
.
child_attr
s
elif
self
.
subexprs
!=
None
:
elif
self
.
subexprs
is
not
None
:
return
self
.
subexprs
return
self
.
subexprs
def
not_implemented
(
self
,
method_name
):
def
not_implemented
(
self
,
method_name
):
...
@@ -870,6 +870,8 @@ class NameNode(AtomicExprNode):
...
@@ -870,6 +870,8 @@ class NameNode(AtomicExprNode):
def
check_identifier_kind
(
self
):
def
check_identifier_kind
(
self
):
#print "NameNode.check_identifier_kind:", self.entry.name ###
#print "NameNode.check_identifier_kind:", self.entry.name ###
#print self.entry.__dict__ ###
#print self.entry.__dict__ ###
print
self
print
self
.
pos
,
self
.
name
entry
=
self
.
entry
entry
=
self
.
entry
#entry.used = 1
#entry.used = 1
if
not
(
entry
.
is_const
or
entry
.
is_variable
if
not
(
entry
.
is_const
or
entry
.
is_variable
...
@@ -2364,22 +2366,16 @@ class DictNode(ExprNode):
...
@@ -2364,22 +2366,16 @@ class DictNode(ExprNode):
# key_value_pairs [(ExprNode, ExprNode)]
# key_value_pairs [(ExprNode, ExprNode)]
def
compile_time_value
(
self
,
denv
):
def
compile_time_value
(
self
,
denv
):
pairs
=
[(
key
.
compile_time_value
(
denv
),
value
.
compile_time_value
(
denv
))
pairs
=
[(
item
.
key
.
compile_time_value
(
denv
),
item
.
value
.
compile_time_value
(
denv
))
for
(
key
,
value
)
in
self
.
key_value_pairs
]
for
item
in
self
.
key_value_pairs
]
try
:
try
:
return
dict
(
pairs
)
return
dict
(
pairs
)
except
Exception
,
e
:
except
Exception
,
e
:
self
.
compile_time_value_error
(
e
)
self
.
compile_time_value_error
(
e
)
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
new_pairs
=
[]
for
item
in
self
.
key_value_pairs
:
for
key
,
value
in
self
.
key_value_pairs
:
item
.
analyse_types
(
env
)
key
.
analyse_types
(
env
)
value
.
analyse_types
(
env
)
key
=
key
.
coerce_to_pyobject
(
env
)
value
=
value
.
coerce_to_pyobject
(
env
)
new_pairs
.
append
((
key
,
value
))
self
.
key_value_pairs
=
new_pairs
self
.
type
=
py_object_type
self
.
type
=
py_object_type
self
.
is_temp
=
1
self
.
is_temp
=
1
...
@@ -2387,11 +2383,11 @@ class DictNode(ExprNode):
...
@@ -2387,11 +2383,11 @@ class DictNode(ExprNode):
# Custom method used here because key-value
# Custom method used here because key-value
# pairs are evaluated and used one at a time.
# pairs are evaluated and used one at a time.
self
.
allocate_temp
(
env
,
result
)
self
.
allocate_temp
(
env
,
result
)
for
key
,
value
in
self
.
key_value_pairs
:
for
item
in
self
.
key_value_pairs
:
key
.
allocate_temps
(
env
)
item
.
key
.
allocate_temps
(
env
)
value
.
allocate_temps
(
env
)
item
.
value
.
allocate_temps
(
env
)
key
.
release_temp
(
env
)
item
.
key
.
release_temp
(
env
)
value
.
release_temp
(
env
)
item
.
value
.
release_temp
(
env
)
def
generate_evaluation_code
(
self
,
code
):
def
generate_evaluation_code
(
self
,
code
):
# Custom method used here because key-value
# Custom method used here because key-value
...
@@ -2400,21 +2396,39 @@ class DictNode(ExprNode):
...
@@ -2400,21 +2396,39 @@ class DictNode(ExprNode):
"%s = PyDict_New(); %s"
%
(
"%s = PyDict_New(); %s"
%
(
self
.
result_code
,
self
.
result_code
,
code
.
error_goto_if_null
(
self
.
result_code
,
self
.
pos
)))
code
.
error_goto_if_null
(
self
.
result_code
,
self
.
pos
)))
for
key
,
value
in
self
.
key_value_pairs
:
for
item
in
self
.
key_value_pairs
:
key
.
generate_evaluation_code
(
code
)
item
.
generate_evaluation_code
(
code
)
value
.
generate_evaluation_code
(
code
)
code
.
put_error_if_neg
(
self
.
pos
,
code
.
put_error_if_neg
(
self
.
pos
,
"PyDict_SetItem(%s, %s, %s)"
%
(
"PyDict_SetItem(%s, %s, %s)"
%
(
self
.
result_code
,
self
.
result_code
,
key
.
py_result
(),
item
.
key
.
py_result
(),
value
.
py_result
()))
item
.
value
.
py_result
()))
key
.
generate_disposal_code
(
code
)
item
.
generate_disposal_code
(
code
)
value
.
generate_disposal_code
(
code
)
def
annotate
(
self
,
code
):
def
annotate
(
self
,
code
):
for
key
,
value
in
self
.
key_value_pairs
:
for
item
in
self
.
key_value_pairs
:
key
.
annotate
(
code
)
item
.
annotate
(
code
)
value
.
annotate
(
code
)
class
DictItemNode
(
ExprNode
):
# Represents a single item in a DictNode
#
# key ExprNode
# value ExprNode
subexprs
=
[
'key'
,
'value'
]
def
analyse_types
(
self
,
env
):
self
.
key
.
analyse_types
(
env
)
self
.
value
.
analyse_types
(
env
)
self
.
key
=
self
.
key
.
coerce_to_pyobject
(
env
)
self
.
value
=
self
.
value
.
coerce_to_pyobject
(
env
)
def
generate_evaluation_code
(
self
,
code
):
self
.
key
.
generate_evaluation_code
(
code
)
self
.
value
.
generate_evaluation_code
(
code
)
def
generate_disposal_code
(
self
,
code
):
self
.
key
.
generate_disposal_code
(
code
)
self
.
value
.
generate_disposal_code
(
code
)
class
ClassNode
(
ExprNode
):
class
ClassNode
(
ExprNode
):
# Helper class used in the implementation of Python
# Helper class used in the implementation of Python
...
@@ -3411,6 +3425,8 @@ class PrimaryCmpNode(ExprNode, CmpNode):
...
@@ -3411,6 +3425,8 @@ class PrimaryCmpNode(ExprNode, CmpNode):
# Instead, we override all the framework methods
# Instead, we override all the framework methods
# which use it.
# which use it.
child_attrs
=
[
'operand1'
,
'operand2'
,
'cascade'
]
cascade
=
None
cascade
=
None
def
compile_time_value
(
self
,
denv
):
def
compile_time_value
(
self
,
denv
):
...
@@ -3530,6 +3546,8 @@ class CascadedCmpNode(Node, CmpNode):
...
@@ -3530,6 +3546,8 @@ class CascadedCmpNode(Node, CmpNode):
# operand2 ExprNode
# operand2 ExprNode
# cascade CascadedCmpNode
# cascade CascadedCmpNode
child_attrs
=
[
'operand2'
,
'cascade'
]
cascade
=
None
cascade
=
None
def
analyse_types
(
self
,
env
,
operand1
):
def
analyse_types
(
self
,
env
,
operand1
):
...
...
Cython/Compiler/Nodes.py
View file @
df6713cc
...
@@ -477,7 +477,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
...
@@ -477,7 +477,8 @@ class CFuncDeclaratorNode(CDeclaratorNode):
exc_val
=
None
exc_val
=
None
exc_check
=
0
exc_check
=
0
if
return_type
.
is_pyobject
\
if
return_type
.
is_pyobject
\
and
(
self
.
exception_value
or
self
.
exception_check
):
and
(
self
.
exception_value
or
self
.
exception_check
)
\
and
self
.
exception_check
!=
'+'
:
error
(
self
.
pos
,
error
(
self
.
pos
,
"Exception clause not allowed for function returning Python object"
)
"Exception clause not allowed for function returning Python object"
)
else
:
else
:
...
@@ -1841,6 +1842,8 @@ class OverrideCheckNode(StatNode):
...
@@ -1841,6 +1842,8 @@ class OverrideCheckNode(StatNode):
# func_temp
# func_temp
# body
# body
child_attrs
=
[
'body'
]
def
analyse_expressions
(
self
,
env
):
def
analyse_expressions
(
self
,
env
):
self
.
args
=
env
.
arg_entries
self
.
args
=
env
.
arg_entries
if
self
.
py_func
.
is_module_scope
:
if
self
.
py_func
.
is_module_scope
:
...
...
Cython/Compiler/Parsing.py
View file @
df6713cc
...
@@ -702,15 +702,18 @@ def p_dict_maker(s):
...
@@ -702,15 +702,18 @@ def p_dict_maker(s):
s
.
next
()
s
.
next
()
items
=
[]
items
=
[]
while
s
.
sy
!=
'}'
:
while
s
.
sy
!=
'}'
:
key
=
p_simple_expr
(
s
)
items
.
append
(
p_dict_item
(
s
))
s
.
expect
(
':'
)
value
=
p_simple_expr
(
s
)
items
.
append
((
key
,
value
))
if
s
.
sy
!=
','
:
if
s
.
sy
!=
','
:
break
break
s
.
next
()
s
.
next
()
s
.
expect
(
'}'
)
s
.
expect
(
'}'
)
return
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
items
)
return
ExprNodes
.
DictNode
(
pos
,
key_value_pairs
=
items
)
def
p_dict_item
(
s
):
key
=
p_simple_expr
(
s
)
s
.
expect
(
':'
)
value
=
p_simple_expr
(
s
)
return
ExprNodes
.
DictItemNode
(
key
.
pos
,
key
=
key
,
value
=
value
)
def
p_backquote_expr
(
s
):
def
p_backquote_expr
(
s
):
# s.sy == '`'
# s.sy == '`'
...
@@ -1743,8 +1746,11 @@ def p_cdef_statement(s, level, visibility = 'private', api = 0,
...
@@ -1743,8 +1746,11 @@ def p_cdef_statement(s, level, visibility = 'private', api = 0,
if
api
:
if
api
:
if
visibility
not
in
(
'private'
,
'public'
):
if
visibility
not
in
(
'private'
,
'public'
):
error
(
pos
,
"Cannot combine 'api' with '%s'"
%
visibility
)
error
(
pos
,
"Cannot combine 'api' with '%s'"
%
visibility
)
if
visibility
==
'extern'
and
s
.
sy
==
'from'
:
if
(
visibility
==
'extern'
)
and
s
.
sy
==
'from'
:
return
p_cdef_extern_block
(
s
,
level
,
pos
)
return
p_cdef_extern_block
(
s
,
level
,
pos
)
elif
s
.
sy
==
'import'
:
s
.
next
()
return
p_cdef_extern_block
(
s
,
level
,
pos
)
elif
s
.
sy
==
':'
:
elif
s
.
sy
==
':'
:
return
p_cdef_block
(
s
,
level
,
visibility
,
api
)
return
p_cdef_block
(
s
,
level
,
visibility
,
api
)
elif
s
.
sy
==
'class'
:
elif
s
.
sy
==
'class'
:
...
...
Cython/Distutils/extension.py
0 → 100644
View file @
df6713cc
"""Pyrex.Distutils.extension
Provides a modified Extension class, that understands hou to describe
Pyrex extension modules in setup scripts."""
__revision__
=
"$Id:$"
import
os
,
string
,
sys
from
types
import
*
import
distutils.extension
as
_Extension
try
:
import
warnings
except
ImportError
:
warnings
=
None
class
Extension
(
_Extension
.
Extension
):
_Extension
.
Extension
.
__doc__
+
\
"""pyrex_include_dirs : [string]
list of directories to search for Pyrex header files (.pxd) (in
Unix form for portability)
pyrex_create_listing_file : boolean
write pyrex error messages to a listing (.lis) file.
pyrex_cplus : boolean
use the C++ compiler for compiling and linking.
pyrex_c_in_temp : boolean
put generated C files in temp directory.
pyrex_gen_pxi : boolean
generate .pxi file for public declarations
"""
# When adding arguments to this constructor, be sure to update
# user_options.extend in build_ext.py.
def
__init__
(
self
,
name
,
sources
,
include_dirs
=
None
,
define_macros
=
None
,
undef_macros
=
None
,
library_dirs
=
None
,
libraries
=
None
,
runtime_library_dirs
=
None
,
extra_objects
=
None
,
extra_compile_args
=
None
,
extra_link_args
=
None
,
export_symbols
=
None
,
#swig_opts = None,
depends
=
None
,
language
=
None
,
pyrex_include_dirs
=
None
,
pyrex_create_listing
=
0
,
pyrex_cplus
=
0
,
pyrex_c_in_temp
=
0
,
pyrex_gen_pxi
=
0
,
**
kw
):
_Extension
.
Extension
.
__init__
(
self
,
name
,
sources
,
include_dirs
=
include_dirs
,
define_macros
=
define_macros
,
undef_macros
=
undef_macros
,
library_dirs
=
library_dirs
,
libraries
=
libraries
,
runtime_library_dirs
=
runtime_library_dirs
,
extra_objects
=
extra_objects
,
extra_compile_args
=
extra_compile_args
,
extra_link_args
=
extra_link_args
,
export_symbols
=
export_symbols
,
#swig_opts = swig_opts,
depends
=
depends
,
language
=
language
,
**
kw
)
self
.
pyrex_include_dirs
=
pyrex_include_dirs
or
[]
self
.
pyrex_create_listing
=
pyrex_create_listing
self
.
pyrex_cplus
=
pyrex_cplus
self
.
pyrex_c_in_temp
=
pyrex_c_in_temp
self
.
pyrex_gen_pxi
=
pyrex_gen_pxi
# class Extension
read_setup_file
=
_Extension
.
read_setup_file
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