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
Boxiang Sun
cython
Commits
64ad2013
Commit
64ad2013
authored
Feb 21, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parsing fix, vector test.
parent
2031ca09
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+2
-2
tests/run/cpp_stl_vector.pyx
tests/run/cpp_stl_vector.pyx
+21
-4
No files found.
Cython/Compiler/Parsing.py
View file @
64ad2013
...
...
@@ -1853,13 +1853,13 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
# Make sure this is not a declaration of a variable or function.
if
s
.
sy
==
'('
:
s
.
next
()
if
s
.
sy
==
'*'
or
s
.
sy
==
'**'
:
if
s
.
sy
==
'*'
or
s
.
sy
==
'**'
or
s
.
sy
==
'&'
:
s
.
put_back
(
'('
,
'('
)
else
:
s
.
put_back
(
'('
,
'('
)
s
.
put_back
(
'IDENT'
,
name
)
name
=
None
elif
s
.
sy
not
in
(
'*'
,
'**'
,
'['
):
elif
s
.
sy
not
in
(
'*'
,
'**'
,
'['
,
'&'
):
s
.
put_back
(
'IDENT'
,
name
)
name
=
None
...
...
tests/run/cpp_stl_vector.pyx
View file @
64ad2013
from
cython.operator
cimport
dereference
as
d
cdef
extern
from
"<vector>"
namespace
"std"
:
cdef
cppclass
vector
[
T
]:
void
push_back
(
T
)
size_t
size
()
T
operator
[](
size_t
)
T
&
operator
[](
size_t
)
def
simple_test
(
double
x
):
"""
>>> simple_test(55)
3
"""
cdef
vector
[
double
]
*
v
try
:
v
=
new
vector
[
double
]()
v
.
push_back
(
1.0
)
...
...
@@ -30,7 +31,6 @@ def list_test(L):
>>> list_test([-1] * 1000)
(1000, 1000)
"""
cdef
vector
[
int
]
*
v
try
:
v
=
new
vector
[
int
]()
for
a
in
L
:
...
...
@@ -46,7 +46,6 @@ def index_test(L):
>>> index_test([1.25])
(1.25, 1.25)
"""
cdef
vector
[
double
]
*
v
try
:
v
=
new
vector
[
double
]()
for
a
in
L
:
...
...
@@ -54,3 +53,21 @@ def index_test(L):
return
v
[
0
][
0
],
v
[
0
][
len
(
L
)
-
1
]
finally
:
del
v
def
index_set_test
(
L
):
"""
>>> index_set_test([1,2,4,8])
(-1.0, -8.0)
>>> index_set_test([1.25])
(-1.25, -1.25)
"""
try
:
v
=
new
vector
[
double
]()
for
a
in
L
:
v
.
push_back
(
a
)
for
i
in
range
(
v
.
size
()):
d
(
v
)[
i
]
=
-
d
(
v
)[
i
]
return
d
(
v
)[
0
],
d
(
v
)[
v
.
size
()
-
1
]
finally
:
del
v
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