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
422a77f8
Commit
422a77f8
authored
Oct 15, 2009
by
Peter Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
naming references changed from 'option' to 'directive'
parent
49ef0f6b
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
87 deletions
+87
-87
Cython/Compiler/CmdLine.py
Cython/Compiler/CmdLine.py
+1
-1
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+18
-18
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+65
-65
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+3
-3
No files found.
Cython/Compiler/CmdLine.py
View file @
422a77f8
...
@@ -126,7 +126,7 @@ def parse_command_line(args):
...
@@ -126,7 +126,7 @@ def parse_command_line(args):
options
.
emit_linenums
=
True
options
.
emit_linenums
=
True
elif
option
in
(
"-X"
,
"--directive"
):
elif
option
in
(
"-X"
,
"--directive"
):
try
:
try
:
options
.
compiler_directives
=
Options
.
parse_
option
_list
(
pop_arg
())
options
.
compiler_directives
=
Options
.
parse_
directive
_list
(
pop_arg
())
except
ValueError
,
e
:
except
ValueError
,
e
:
sys
.
stderr
.
write
(
"Error in compiler directive: %s
\
n
"
%
e
.
message
)
sys
.
stderr
.
write
(
"Error in compiler directive: %s
\
n
"
%
e
.
message
)
sys
.
exit
(
1
)
sys
.
exit
(
1
)
...
...
Cython/Compiler/Options.py
View file @
422a77f8
...
@@ -55,7 +55,7 @@ embed = False
...
@@ -55,7 +55,7 @@ embed = False
# Declare compiler directives
# Declare compiler directives
option
_defaults
=
{
directive
_defaults
=
{
'boundscheck'
:
True
,
'boundscheck'
:
True
,
'nonecheck'
:
False
,
'nonecheck'
:
False
,
'embedsignature'
:
False
,
'embedsignature'
:
False
,
...
@@ -77,35 +77,35 @@ option_defaults = {
...
@@ -77,35 +77,35 @@ option_defaults = {
}
}
# Override types possibilities above, if needed
# Override types possibilities above, if needed
option
_types
=
{}
directive
_types
=
{}
for
key
,
val
in
option
_defaults
.
items
():
for
key
,
val
in
directive
_defaults
.
items
():
if
key
not
in
option
_types
:
if
key
not
in
directive
_types
:
option
_types
[
key
]
=
type
(
val
)
directive
_types
[
key
]
=
type
(
val
)
option
_scopes
=
{
# defaults to available everywhere
directive
_scopes
=
{
# defaults to available everywhere
# 'module', 'function', 'class', 'with statement'
# 'module', 'function', 'class', 'with statement'
'autotestdict'
:
(
'module'
,),
'autotestdict'
:
(
'module'
,),
'test_assert_path_exists'
:
(
'function'
,),
'test_assert_path_exists'
:
(
'function'
,),
'test_fail_if_path_exists'
:
(
'function'
,),
'test_fail_if_path_exists'
:
(
'function'
,),
}
}
def
parse_
option
_value
(
name
,
value
):
def
parse_
directive
_value
(
name
,
value
):
"""
"""
Parses value as an option value for the given name and returns
Parses value as an option value for the given name and returns
the interpreted value. None is returned if the option does not exist.
the interpreted value. None is returned if the option does not exist.
>>> print parse_
option
_value('nonexisting', 'asdf asdfd')
>>> print parse_
directive
_value('nonexisting', 'asdf asdfd')
None
None
>>> parse_
option
_value('boundscheck', 'True')
>>> parse_
directive
_value('boundscheck', 'True')
True
True
>>> parse_
option
_value('boundscheck', 'true')
>>> parse_
directive
_value('boundscheck', 'true')
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: boundscheck directive must be set to True or False
ValueError: boundscheck directive must be set to True or False
"""
"""
type
=
option
_types
.
get
(
name
)
type
=
directive
_types
.
get
(
name
)
if
not
type
:
return
None
if
not
type
:
return
None
if
type
is
bool
:
if
type
is
bool
:
if
value
==
"True"
:
return
True
if
value
==
"True"
:
return
True
...
@@ -119,25 +119,25 @@ def parse_option_value(name, value):
...
@@ -119,25 +119,25 @@ def parse_option_value(name, value):
else
:
else
:
assert
False
assert
False
def
parse_
option
_list
(
s
):
def
parse_
directive
_list
(
s
):
"""
"""
Parses a comma-seperated list of pragma options. Whitespace
Parses a comma-seperated list of pragma options. Whitespace
is not considered.
is not considered.
>>> parse_
option
_list(' ')
>>> parse_
directive
_list(' ')
{}
{}
>>> (parse_
option
_list('boundscheck=True') ==
>>> (parse_
directive
_list('boundscheck=True') ==
... {'boundscheck': True})
... {'boundscheck': True})
True
True
>>> parse_
option
_list(' asdf')
>>> parse_
directive
_list(' asdf')
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Expected "=" in option "asdf"
ValueError: Expected "=" in option "asdf"
>>> parse_
option
_list('boundscheck=hey')
>>> parse_
directive
_list('boundscheck=hey')
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Must pass a boolean value for option "boundscheck"
ValueError: Must pass a boolean value for option "boundscheck"
>>> parse_
option
_list('unknown=True')
>>> parse_
directive
_list('unknown=True')
Traceback (most recent call last):
Traceback (most recent call last):
...
...
ValueError: Unknown option: "unknown"
ValueError: Unknown option: "unknown"
...
@@ -149,7 +149,7 @@ def parse_option_list(s):
...
@@ -149,7 +149,7 @@ def parse_option_list(s):
if
not
'='
in
item
:
raise
ValueError
(
'Expected "=" in option "%s"'
%
item
)
if
not
'='
in
item
:
raise
ValueError
(
'Expected "=" in option "%s"'
%
item
)
name
,
value
=
item
.
strip
().
split
(
'='
)
name
,
value
=
item
.
strip
().
split
(
'='
)
try
:
try
:
type
=
option
_types
[
name
]
type
=
directive
_types
[
name
]
except
KeyError
:
except
KeyError
:
raise
ValueError
(
'Unknown option: "%s"'
%
name
)
raise
ValueError
(
'Unknown option: "%s"'
%
name
)
if
type
is
bool
:
if
type
is
bool
:
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
422a77f8
This diff is collapsed.
Click to expand it.
Cython/Compiler/Parsing.py
View file @
422a77f8
...
@@ -2582,7 +2582,7 @@ def p_compiler_directive_comments(s):
...
@@ -2582,7 +2582,7 @@ def p_compiler_directive_comments(s):
if m:
if m:
name = m.group(1)
name = m.group(1)
try:
try:
value = Options.parse_
option
_value(str(name), str(m.group(2).strip()))
value = Options.parse_
directive
_value(str(name), str(m.group(2).strip()))
if value is not None: # can be False!
if value is not None: # can be False!
result[name] = value
result[name] = value
except ValueError, e:
except ValueError, e:
...
@@ -2593,7 +2593,7 @@ def p_compiler_directive_comments(s):
...
@@ -2593,7 +2593,7 @@ def p_compiler_directive_comments(s):
def p_module(s, pxd, full_module_name):
def p_module(s, pxd, full_module_name):
pos = s.position()
pos = s.position()
option
_comments = p_compiler_directive_comments(s)
directive
_comments = p_compiler_directive_comments(s)
s.parse_comments = False
s.parse_comments = False
doc = p_doc_string(s)
doc = p_doc_string(s)
...
@@ -2608,7 +2608,7 @@ def p_module(s, pxd, full_module_name):
...
@@ -2608,7 +2608,7 @@ def p_module(s, pxd, full_module_name):
repr(s.sy), repr(s.systring)))
repr(s.sy), repr(s.systring)))
return ModuleNode(pos, doc = doc, body = body,
return ModuleNode(pos, doc = doc, body = body,
full_module_name = full_module_name,
full_module_name = full_module_name,
option_comments = option
_comments)
directive_comments = directive
_comments)
#----------------------------------------------
#----------------------------------------------
#
#
...
...
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