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
1d5644c7
Commit
1d5644c7
authored
Aug 04, 2008
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug: Empty "[]" is now always treated as array declarator
parent
9262420f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
6 deletions
+21
-6
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+7
-3
Cython/Compiler/Tests/TestBuffer.py
Cython/Compiler/Tests/TestBuffer.py
+1
-3
tests/compile/arrayargs.pyx
tests/compile/arrayargs.pyx
+13
-0
No files found.
Cython/Compiler/Parsing.py
View file @
1d5644c7
...
@@ -1620,15 +1620,19 @@ def p_c_simple_base_type(s, self_flag, nonempty):
...
@@ -1620,15 +1620,19 @@ def p_c_simple_base_type(s, self_flag, nonempty):
# Treat trailing [] on type as buffer access
# Treat trailing [] on type as buffer access
if
not
is_basic
and
s
.
sy
==
'['
:
if
s
.
sy
==
'['
:
return
p_buffer_access
(
s
,
type_node
)
return
p_buffer_access
(
s
,
type_node
)
else
:
else
:
return
type_node
return
type_node
def
p_buffer_access
(
s
,
type_node
):
def
p_buffer_access
(
s
,
base_
type_node
):
# s.sy == '['
# s.sy == '['
pos
=
s
.
position
()
pos
=
s
.
position
()
s
.
next
()
s
.
next
()
if
s
.
sy
==
']'
:
# not buffer, could be [] on C type nameless array arguments
s
.
put_back
(
'['
,
'['
)
return
base_type_node
positional_args
,
keyword_args
=
(
positional_args
,
keyword_args
=
(
p_positional_and_keyword_args
(
s
,
(
']'
,),
(
0
,),
(
'dtype'
,))
p_positional_and_keyword_args
(
s
,
(
']'
,),
(
0
,),
(
'dtype'
,))
)
)
...
@@ -1643,7 +1647,7 @@ def p_buffer_access(s, type_node):
...
@@ -1643,7 +1647,7 @@ def p_buffer_access(s, type_node):
result
=
Nodes
.
CBufferAccessTypeNode
(
pos
,
result
=
Nodes
.
CBufferAccessTypeNode
(
pos
,
positional_args
=
positional_args
,
positional_args
=
positional_args
,
keyword_args
=
keyword_dict
,
keyword_args
=
keyword_dict
,
base_type_node
=
type_node
)
base_type_node
=
base_
type_node
)
return
result
return
result
...
...
Cython/Compiler/Tests/TestBuffer.py
View file @
1d5644c7
...
@@ -58,6 +58,7 @@ class TestBufferOptions(CythonTest):
...
@@ -58,6 +58,7 @@ class TestBufferOptions(CythonTest):
self
.
assert_
(
self
.
expect_error
)
self
.
assert_
(
self
.
expect_error
)
def
parse_opts
(
self
,
opts
,
expect_error
=
False
):
def
parse_opts
(
self
,
opts
,
expect_error
=
False
):
assert
opts
!=
""
s
=
u"def f():
\
n
cdef object[%s] x"
%
opts
s
=
u"def f():
\
n
cdef object[%s] x"
%
opts
self
.
expect_error
=
expect_error
self
.
expect_error
=
expect_error
root
=
self
.
fragment
(
s
,
pipeline
=
[
NormalizeTree
(
self
),
PostParse
(
self
)]).
root
root
=
self
.
fragment
(
s
,
pipeline
=
[
NormalizeTree
(
self
),
PostParse
(
self
)]).
root
...
@@ -89,9 +90,6 @@ class TestBufferOptions(CythonTest):
...
@@ -89,9 +90,6 @@ class TestBufferOptions(CythonTest):
self
.
assert_
(
buf
.
dtype_node
.
signed
==
0
and
buf
.
dtype_node
.
longness
==
-
1
)
self
.
assert_
(
buf
.
dtype_node
.
signed
==
0
and
buf
.
dtype_node
.
longness
==
-
1
)
self
.
assertEqual
(
3
,
buf
.
ndim
)
self
.
assertEqual
(
3
,
buf
.
ndim
)
def
test_dtype
(
self
):
self
.
non_parse
(
ERR_BUF_MISSING
%
'dtype'
,
u""
)
def
test_ndim
(
self
):
def
test_ndim
(
self
):
self
.
parse_opts
(
u"int, 2"
)
self
.
parse_opts
(
u"int, 2"
)
self
.
non_parse
(
ERR_BUF_INT
%
'ndim'
,
u"int, 'a'"
)
self
.
non_parse
(
ERR_BUF_INT
%
'ndim'
,
u"int, 'a'"
)
...
...
tests/compile/arrayargs.pyx
0 → 100644
View file @
1d5644c7
cdef
extern
from
*
:
cdef
void
foo
(
int
[])
ctypedef
int
MyInt
cdef
void
foo
(
MyInt
[])
struct
MyStruct
:
pass
cdef
void
bar
(
MyStruct
[])
ctypedef
MyStruct
*
MyStructP
cdef
void
baz
(
MyStructP
[])
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