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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
a313eb32
Commit
a313eb32
authored
Aug 05, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"from cython cimport boundscheck" working
parent
7b3d38c8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
13 deletions
+36
-13
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+29
-13
tests/compile/c_options.pyx
tests/compile/c_options.pyx
+7
-0
No files found.
Cython/Compiler/ParseTreeTransforms.py
View file @
a313eb32
...
@@ -276,6 +276,7 @@ class ResolveOptions(CythonTransform):
...
@@ -276,6 +276,7 @@ class ResolveOptions(CythonTransform):
super
(
ResolveOptions
,
self
).
__init__
(
context
)
super
(
ResolveOptions
,
self
).
__init__
(
context
)
self
.
compilation_option_overrides
=
compilation_option_overrides
self
.
compilation_option_overrides
=
compilation_option_overrides
self
.
cython_module_names
=
set
()
self
.
cython_module_names
=
set
()
self
.
option_names
=
{}
def
visit_ModuleNode
(
self
,
node
):
def
visit_ModuleNode
(
self
,
node
):
options
=
copy
.
copy
(
Options
.
option_defaults
)
options
=
copy
.
copy
(
Options
.
option_defaults
)
...
@@ -294,8 +295,21 @@ class ResolveOptions(CythonTransform):
...
@@ -294,8 +295,21 @@ class ResolveOptions(CythonTransform):
else
:
else
:
modname
=
u"cython"
modname
=
u"cython"
self
.
cython_module_names
.
add
(
modname
)
self
.
cython_module_names
.
add
(
modname
)
elif
node
.
as_name
and
node
.
as_name
in
self
.
cython_module_names
:
return
node
self
.
cython_module_names
.
remove
(
node
.
as_name
)
def
visit_FromCImportStatNode
(
self
,
node
):
if
node
.
module_name
==
u"cython"
:
newimp
=
[]
for
pos
,
name
,
as_name
,
kind
in
node
.
imported_names
:
if
name
in
Options
.
option_types
:
self
.
option_names
[
as_name
]
=
name
if
kind
is
not
None
:
self
.
context
.
nonfatal_error
(
PostParseError
(
pos
,
"Compiler option imports must be plain imports"
))
return
None
else
:
newimp
.
append
((
pos
,
name
,
as_name
,
kind
))
node
.
imported_names
=
newimpo
return
node
return
node
def
visit_Node
(
self
,
node
):
def
visit_Node
(
self
,
node
):
...
@@ -307,11 +321,17 @@ class ResolveOptions(CythonTransform):
...
@@ -307,11 +321,17 @@ class ResolveOptions(CythonTransform):
# If node is the contents of an option (in a with statement or
# If node is the contents of an option (in a with statement or
# decorator), returns (optionname, value).
# decorator), returns (optionname, value).
# Otherwise, returns None
# Otherwise, returns None
if
(
isinstance
(
node
,
SimpleCallNode
)
and
optname
=
None
isinstance
(
node
.
function
,
AttributeNode
)
and
if
isinstance
(
node
,
SimpleCallNode
):
if
(
isinstance
(
node
.
function
,
AttributeNode
)
and
isinstance
(
node
.
function
.
obj
,
NameNode
)
and
isinstance
(
node
.
function
.
obj
,
NameNode
)
and
node
.
function
.
obj
.
name
in
self
.
cython_module_names
):
node
.
function
.
obj
.
name
in
self
.
cython_module_names
):
optname
=
node
.
function
.
attribute
optname
=
node
.
function
.
attribute
elif
(
isinstance
(
node
.
function
,
NameNode
)
and
node
.
function
.
name
in
self
.
option_names
):
optname
=
self
.
option_names
[
node
.
function
.
name
]
if
optname
:
optiontype
=
Options
.
option_types
.
get
(
optname
)
optiontype
=
Options
.
option_types
.
get
(
optname
)
if
optiontype
:
if
optiontype
:
args
=
node
.
args
args
=
node
.
args
...
@@ -322,11 +342,7 @@ class ResolveOptions(CythonTransform):
...
@@ -322,11 +342,7 @@ class ResolveOptions(CythonTransform):
return
(
optname
,
args
[
0
].
value
)
return
(
optname
,
args
[
0
].
value
)
else
:
else
:
assert
False
assert
False
else
:
return
None
options
.
append
((
dec
.
function
.
attribute
,
dec
.
args
,
dec
.
function
.
pos
))
return
False
else
:
return
None
return
None
def
visit_with_options
(
self
,
node
,
options
):
def
visit_with_options
(
self
,
node
,
options
):
...
...
tests/compile/c_options.pyx
View file @
a313eb32
...
@@ -19,3 +19,10 @@ def h(object[int, 2] buf):
...
@@ -19,3 +19,10 @@ def h(object[int, 2] buf):
print
buf
[
3
,
2
]
print
buf
[
3
,
2
]
with
cy
.
boundscheck
(
True
):
with
cy
.
boundscheck
(
True
):
print
buf
[
3
,
2
]
print
buf
[
3
,
2
]
from
cython
cimport
boundscheck
as
bc
def
i
(
object
[
int
]
buf
):
with
bc
(
True
):
print
buf
[
3
]
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