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
69160834
Commit
69160834
authored
Feb 09, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable non expression-like types for templates.
parent
9baaa6bf
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+15
-5
Cython/Compiler/Tests/TestBuffer.py
Cython/Compiler/Tests/TestBuffer.py
+0
-4
No files found.
Cython/Compiler/Parsing.py
View file @
69160834
...
@@ -1732,6 +1732,8 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
...
@@ -1732,6 +1732,8 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
type_positions and type_keywords specifies which argument
type_positions and type_keywords specifies which argument
positions and/or names which should be interpreted as
positions and/or names which should be interpreted as
types. Other arguments will be treated as expressions.
types. Other arguments will be treated as expressions.
A value of None indicates all positions/keywords
(respectively) will be treated as types.
Returns: (positional_args, keyword_args)
Returns: (positional_args, keyword_args)
"""
"""
...
@@ -1754,8 +1756,11 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
...
@@ -1754,8 +1756,11 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
if
s
.
sy
==
'='
:
if
s
.
sy
==
'='
:
s
.
next
()
s
.
next
()
# Is keyword arg
# Is keyword arg
if
ident
in
type_keywords
:
if
type_keywords
is
None
or
ident
in
type_keywords
:
arg
=
p_c_base_type
(
s
)
base_type
=
p_c_base_type
(
s
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
arg
=
Nodes
.
CComplexBaseTypeNode
(
base_type
.
pos
,
base_type
=
base_type
,
declarator
=
declarator
)
parsed_type
=
True
parsed_type
=
True
else
:
else
:
arg
=
p_simple_expr
(
s
)
arg
=
p_simple_expr
(
s
)
...
@@ -1767,8 +1772,11 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
...
@@ -1767,8 +1772,11 @@ def p_positional_and_keyword_args(s, end_sy_set, type_positions=(), type_keyword
s
.
put_back
(
'IDENT'
,
ident
)
s
.
put_back
(
'IDENT'
,
ident
)
if
not
was_keyword
:
if
not
was_keyword
:
if
pos_idx
in
type_positions
:
if
type_positions
is
None
or
pos_idx
in
type_positions
:
arg
=
p_c_base_type
(
s
)
base_type
=
p_c_base_type
(
s
)
declarator
=
p_c_declarator
(
s
,
empty
=
1
)
arg
=
Nodes
.
CComplexBaseTypeNode
(
base_type
.
pos
,
base_type
=
base_type
,
declarator
=
declarator
)
parsed_type
=
True
parsed_type
=
True
else
:
else
:
arg
=
p_simple_expr
(
s
)
arg
=
p_simple_expr
(
s
)
...
@@ -1890,8 +1898,10 @@ def p_buffer_or_template(s, base_type_node):
...
@@ -1890,8 +1898,10 @@ def p_buffer_or_template(s, base_type_node):
# s.sy == '['
# s.sy == '['
pos
=
s
.
position
()
pos
=
s
.
position
()
s
.
next
()
s
.
next
()
# Note that buffer_positional_options_count=1, so the only positional argument is dtype.
# For templated types, all parameters are types.
positional_args
,
keyword_args
=
(
positional_args
,
keyword_args
=
(
p_positional_and_keyword_args
(
s
,
(
']'
,),
(
0
,)
,
(
'dtype'
,))
p_positional_and_keyword_args
(
s
,
(
']'
,),
None
,
(
'dtype'
,))
)
)
s
.
expect
(
']'
)
s
.
expect
(
']'
)
...
...
Cython/Compiler/Tests/TestBuffer.py
View file @
69160834
...
@@ -36,10 +36,6 @@ class TestBufferParsing(CythonTest):
...
@@ -36,10 +36,6 @@ class TestBufferParsing(CythonTest):
self
.
not_parseable
(
"Expected: expression"
,
self
.
not_parseable
(
"Expected: expression"
,
u"cdef object[foo2=short unsigned int] x"
)
u"cdef object[foo2=short unsigned int] x"
)
def
test_notype_as_expr2
(
self
):
self
.
not_parseable
(
"Expected: expression"
,
u"cdef object[int, short unsigned int] x"
)
def
test_pos_after_key
(
self
):
def
test_pos_after_key
(
self
):
self
.
not_parseable
(
"Non-keyword arg following keyword arg"
,
self
.
not_parseable
(
"Non-keyword arg following keyword arg"
,
u"cdef object[foo=1, 2] x"
)
u"cdef object[foo=1, 2] x"
)
...
...
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