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
827fff94
Commit
827fff94
authored
Apr 09, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
C++ fixes (parsing and scope lookup), working libcpp pxd's, more tests
parent
bcb29869
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
263 additions
and
109 deletions
+263
-109
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+1
-3
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+3
-2
Cython/Includes/libcpp/__init__.pxd
Cython/Includes/libcpp/__init__.pxd
+1
-0
Cython/Includes/libcpp/__init__.pyx
Cython/Includes/libcpp/__init__.pyx
+1
-0
Cython/Includes/libcpp/deque.pxd
Cython/Includes/libcpp/deque.pxd
+30
-24
Cython/Includes/libcpp/list.pxd
Cython/Includes/libcpp/list.pxd
+24
-21
Cython/Includes/libcpp/map.pxd
Cython/Includes/libcpp/map.pxd
+62
-0
Cython/Includes/libcpp/pair.pxd
Cython/Includes/libcpp/pair.pxd
+2
-2
Cython/Includes/libcpp/queue.pxd
Cython/Includes/libcpp/queue.pxd
+11
-3
Cython/Includes/libcpp/set.pxd
Cython/Includes/libcpp/set.pxd
+34
-29
Cython/Includes/libcpp/stack.pxd
Cython/Includes/libcpp/stack.pxd
+10
-0
Cython/Includes/libcpp/vector.pxd
Cython/Includes/libcpp/vector.pxd
+28
-25
tests/compile/libcpp_all.pyx
tests/compile/libcpp_all.pyx
+55
-0
No files found.
Cython/Compiler/Nodes.py
View file @
827fff94
...
...
@@ -1022,10 +1022,8 @@ class CppClassNode(CStructOrUnionDefNode):
def
analyse_declarations
(
self
,
env
):
scope
=
None
if
self
.
attributes
:
if
self
.
attributes
is
not
None
:
scope
=
CppClassScope
(
self
.
name
,
env
)
else
:
self
.
attributes
=
None
base_class_types
=
[]
for
base_class_name
in
self
.
base_classes
:
base_class_entry
=
env
.
lookup
(
base_class_name
)
...
...
Cython/Compiler/Parsing.py
View file @
827fff94
...
...
@@ -2650,6 +2650,7 @@ def p_cpp_class_definition(s, pos, ctx):
s.expect_newline("
Expected
a
newline
")
s.expect_dedent()
else:
attributes = None
s.expect_newline("
Syntax
error
in
C
++
class
definition
")
return Nodes.CppClassNode(pos,
name = class_name,
...
...
Cython/Compiler/Symtab.py
View file @
827fff94
...
...
@@ -408,7 +408,7 @@ class Scope(object):
error(pos, "
C
++
classes
may
only
be
extern
")
if cname is None:
cname = name
entry = self.lookup(name)
entry = self.lookup
_here
(name)
if not entry:
type = PyrexTypes.CppClassType(
name, scope, cname, base_classes, templates = templates)
...
...
@@ -432,6 +432,7 @@ class Scope(object):
for base_class in base_classes:
declare_inherited_attributes(entry, base_class.base_classes)
entry.type.scope.declare_inherited_cpp_attributes(base_class.scope)
if entry.type.scope:
declare_inherited_attributes(entry, base_classes)
if self.is_cpp_class_scope:
entry.type.namespace = self.outer_scope.lookup(self.name).type
...
...
Cython/Includes/libcpp/__init__.pxd
0 → 100644
View file @
827fff94
# empty file
Cython/Includes/libcpp/__init__.pyx
0 → 100644
View file @
827fff94
# empty file
Cython/Includes/libcpp/deque.pxd
View file @
827fff94
...
...
@@ -3,39 +3,44 @@ from pair cimport pair
cdef
extern
from
"<deque>"
namespace
"std"
:
cdef
cppclass
deque
[
T
]:
cppclass
iterator
:
T
operator
*
()
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
const_iterator
(
iterator
):
pass
cppclass
reverse_iterator
(
iterator
):
pass
cppclass
const_reverse_iterator
(
iterator
):
pass
cppclass
reverse_iterator
:
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
#cppclass const_iterator(iterator):
# pass
#cppclass const_reverse_iterator(reverse_iterator):
# pass
deque
()
deque
(
deque
&
)
deque
(
size_t
,
T
&
val
=
T
()
)
#deque(input_iterator, input_iterator
)
TYPE
&
operator
[](
size_type
index
)
const
TYPE
&
operator
[](
size_type
index
)
const
deque
(
size_t
)
deque
(
size_t
,
T
&
)
#deque[input_iterator](input_iterator, input_iterator
)
T
&
operator
[](
size_t
)
#deque& operator=(deque&)
b
ool
operator
==
(
deque
&
,
deque
&
)
b
ool
operator
!=
(
deque
&
,
deque
&
)
b
ool
operator
<
(
deque
&
,
deque
&
)
b
ool
operator
>
(
deque
&
,
deque
&
)
b
ool
operator
<=
(
deque
&
,
deque
&
)
b
ool
operator
>=
(
deque
&
,
deque
&
)
void
assign
(
size_t
,
T
YPE
&
)
b
int
operator
==
(
deque
&
,
deque
&
)
b
int
operator
!=
(
deque
&
,
deque
&
)
b
int
operator
<
(
deque
&
,
deque
&
)
b
int
operator
>
(
deque
&
,
deque
&
)
b
int
operator
<=
(
deque
&
,
deque
&
)
b
int
operator
>=
(
deque
&
,
deque
&
)
void
assign
(
size_t
,
T
&
)
void
assign
(
input_iterator
,
input_iterator
)
T
&
at
(
size_t
)
T
&
back
()
iterator
begin
()
const_iterator
begin
()
#
const_iterator begin()
void
clear
()
b
ool
empty
()
b
int
empty
()
iterator
end
()
const_iterator
end
()
#
const_iterator end()
iterator
erase
(
iterator
)
iterator
erase
(
iterator
,
iterator
)
T
&
front
()
...
...
@@ -48,9 +53,10 @@ cdef extern from "<deque>" namespace "std":
void
push_back
(
T
&
)
void
push_front
(
T
&
)
reverse_iterator
rbegin
()
const_reverse_iterator
rbegin
()
#
const_reverse_iterator rbegin()
reverse_iterator
rend
()
const_reverse_iterator
rend
()
void
resize
(
size_t
,
T
val
=
T
())
#const_reverse_iterator rend()
void
resize
(
size_t
)
void
resize
(
size_t
,
T
&
)
size_t
size
()
void
swap
(
deque
&
)
Cython/Includes/libcpp/list.pxd
View file @
827fff94
from
pair
cimport
pair
cdef
extern
from
"<list>"
namespace
"std"
:
cdef
cppclass
list
[
T
]:
cppclass
iterator
:
T
operator
*
()
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
const_iterator
(
iterator
):
pass
cppclass
reverse_iterator
(
iterator
):
pass
cppclass
const_reverse_iterator
(
iterator
):
pass
cppclass
reverse_iterator
:
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
#cppclass const_iterator(iterator):
# pass
#cppclass const_reverse_iterator(reverse_iterator):
# pass
list
()
list
(
list
&
)
list
(
size_t
,
T
&
)
#list operator=(list&)
b
ool
operator
==
(
list
&
,
list
&
)
b
ool
operator
!=
(
list
&
,
list
&
)
b
ool
operator
<
(
list
&
,
list
&
)
b
ool
operator
>
(
list
&
,
list
&
)
b
ool
operator
<=
(
list
&
,
list
&
)
b
ool
operator
>=
(
list
&
,
list
&
)
b
int
operator
==
(
list
&
,
list
&
)
b
int
operator
!=
(
list
&
,
list
&
)
b
int
operator
<
(
list
&
,
list
&
)
b
int
operator
>
(
list
&
,
list
&
)
b
int
operator
<=
(
list
&
,
list
&
)
b
int
operator
>=
(
list
&
,
list
&
)
void
assign
(
size_t
,
T
&
)
T
&
back
()
iterator
begin
()
const_iterator
begin
()
b
ool
empty
()
#
const_iterator begin()
b
int
empty
()
iterator
end
()
const_iterator
end
()
#
const_iterator end()
iterator
erase
(
iterator
)
iterator
erase
(
iterator
,
iterator
)
T
&
front
()
...
...
@@ -37,17 +40,17 @@ cdef extern from "<list>" namespace "std":
void
insert
(
iterator
,
size_t
,
T
&
)
size_t
max_size
()
void
merge
(
list
&
)
#void
e
merge(list&, BinPred)
#void merge(list&, BinPred)
void
pop_back
()
void
pop_front
()
void
push_back
(
T
&
)
void
push_front
(
T
&
)
reverse_iterator
rbegin
()
const_reverse_iterator
rbegin
()
#
const_reverse_iterator rbegin()
void
remove
(
T
&
)
#void remove_if(UnPred)
reverse_iterator
rend
()
const_reverse_iterator
rend
()
#
const_reverse_iterator rend()
void
resize
(
size_t
,
T
&
)
void
reverse
()
size_t
size
()
...
...
Cython/Includes/libcpp/map.pxd
0 → 100644
View file @
827fff94
from
pair
cimport
pair
cdef
extern
from
"<map>"
namespace
"std"
:
cdef
cppclass
map
[
T
,
U
]:
cppclass
iterator
:
pair
[
T
,
U
]
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
reverse_iterator
:
pair
[
T
,
U
]
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
#cppclass const_iterator(iterator):
# pass
#cppclass const_reverse_iterator(reverse_iterator):
# pass
map
()
map
(
map
&
)
#map(key_compare&)
U
&
operator
[](
T
&
)
#map& operator=(map&)
bint
operator
==
(
map
&
,
map
&
)
bint
operator
!=
(
map
&
,
map
&
)
bint
operator
<
(
map
&
,
map
&
)
bint
operator
>
(
map
&
,
map
&
)
bint
operator
<=
(
map
&
,
map
&
)
bint
operator
>=
(
map
&
,
map
&
)
U
&
at
(
T
&
)
iterator
begin
()
#const_iterator begin()
void
clear
()
size_t
count
(
T
&
)
bint
empty
()
iterator
end
()
#const_iterator end()
pair
[
iterator
,
iterator
]
equal_range
(
T
&
)
#pair[const_iterator, const_iterator] equal_range(key_type&)
void
erase
(
iterator
)
void
erase
(
iterator
,
iterator
)
size_t
erase
(
T
&
)
iterator
find
(
T
&
)
#const_iterator find(key_type&)
pair
[
iterator
,
bint
]
insert
(
pair
[
T
,
U
])
# XXX pair[T,U]&
iterator
insert
(
iterator
,
pair
[
T
,
U
])
# XXX pair[T,U]&
#void insert(input_iterator, input_iterator)
#key_compare key_comp()
iterator
lower_bound
(
T
&
)
#const_iterator lower_bound(key_type&)
size_t
max_size
()
reverse_iterator
rbegin
()
#const_reverse_iterator rbegin()
reverse_iterator
rend
()
#const_reverse_iterator rend()
size_t
size
()
void
swap
(
map
&
)
iterator
upper_bound
(
T
&
)
#const_iterator upper_bound(key_type&)
#value_compare value_comp()
Cython/Includes/libcpp/pair.pxd
View file @
827fff94
cdef
extern
from
"
pair.h
"
:
cdef
extern
from
"
<utility>"
namespace
"std
"
:
cdef
cppclass
pair
[
T
,
U
]:
T
first
U
second
pair
()
pair
(
pair
&
)
pair
(
T
&
,
U
&
)
Cython/Includes/libcpp/queue.pxd
View file @
827fff94
from
pair
cimport
pair
cdef
extern
from
"<queue>"
namespace
"std"
:
cdef
cppclass
queue
[
T
]:
queue
()
queue
(
queue
&
)
#queue(Container&)
T
&
back
()
b
ool
empty
()
b
int
empty
()
T
&
front
()
void
pop
()
void
push
(
T
&
)
size_t
size
()
cdef
cppclass
priority_queue
[
T
]:
priority_queue
()
priority_queue
(
priority_queue
&
)
#priority_queue(Container&)
bint
empty
()
void
pop
()
void
push
(
T
&
)
size_t
size
()
T
&
top
()
Cython/Includes/libcpp/set.pxd
View file @
827fff94
...
...
@@ -5,51 +5,56 @@ cdef extern from "<set>" namespace "std":
cppclass
iterator
:
T
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
const_iterator
(
iterator
):
pass
cppclass
reverse_iterator
(
iterator
):
pass
cppclass
const_reverse_iterator
(
iterator
):
pass
cppclass
reverse_iterator
:
T
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
#cppclass const_iterator(iterator):
# pass
#cppclass const_reverse_iterator(reverse_iterator):
# pass
set
()
set
(
set
&
)
#set
set
(key_compare&)
#set(key_compare&)
#set& operator=(set&)
b
ool
operator
==
(
set
&
,
set
&
)
b
ool
operator
!=
(
set
&
,
set
&
)
b
ool
operator
<
(
set
&
,
set
&
)
b
ool
operator
>
(
set
&
,
set
&
)
b
ool
operator
<=
(
set
&
,
set
&
)
b
ool
operator
>=
(
set
&
,
set
&
)
b
int
operator
==
(
set
&
,
set
&
)
b
int
operator
!=
(
set
&
,
set
&
)
b
int
operator
<
(
set
&
,
set
&
)
b
int
operator
>
(
set
&
,
set
&
)
b
int
operator
<=
(
set
&
,
set
&
)
b
int
operator
>=
(
set
&
,
set
&
)
iterator
begin
()
const_iterator
begin
()
#
const_iterator begin()
void
clear
()
#size_t count(key_type
&)
b
ool
empty
()
size_t
count
(
T
&
)
b
int
empty
()
iterator
end
()
const_iterator
end
()
#pair[iterator, iterator] equal_range(key_type
&)
#pair[const_iterator, const_iterator] equal_range(
key_type
&)
#
const_iterator end()
pair
[
iterator
,
iterator
]
equal_range
(
T
&
)
#pair[const_iterator, const_iterator] equal_range(
T
&)
void
erase
(
iterator
)
void
erase
(
iterator
,
iterator
)
#size_t erase(key_type
&)
#iterator find(key_type
&)
#const_iterator find(
key_type
&)
#pair[iterator, bool
] insert(T&)
size_t
erase
(
T
&
)
iterator
find
(
T
&
)
#const_iterator find(
T
&)
pair
[
iterator
,
bint
]
insert
(
T
&
)
iterator
insert
(
iterator
,
T
&
)
#void insert(input_iterator, input_iterator)
#key_compare key_comp()
#iterator lower_bound(key_type
&)
#const_iterator lower_bound(
key_type
&)
iterator
lower_bound
(
T
&
)
#const_iterator lower_bound(
T
&)
size_t
max_size
()
reverse_iterator
rbegin
()
const_reverse_iterator
rbegin
()
#
const_reverse_iterator rbegin()
reverse_iterator
rend
()
const_reverse_iterator
rend
()
#
const_reverse_iterator rend()
size_t
size
()
void
swap
(
set
&
)
#iterator upper_bound(key_type
&)
#const_iterator upper_bound(
key_type
&)
iterator
upper_bound
(
T
&
)
#const_iterator upper_bound(
T
&)
#value_compare value_comp()
Cython/Includes/libcpp/stack.pxd
0 → 100644
View file @
827fff94
cdef
extern
from
"<stack>"
namespace
"std"
:
cdef
cppclass
stack
[
T
]:
stack
()
stack
(
stack
&
)
#stack(Container&)
bint
empty
()
void
pop
()
void
push
(
T
&
)
size_t
size
()
T
&
top
()
Cython/Includes/libcpp/vector.pxd
View file @
827fff94
from
pair
cimport
pair
cdef
extern
from
"<vector>"
namespace
"std"
:
cdef
cppclass
vector
[
T
]:
cppclass
iterator
:
T
operator
*
()
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
cppclass
const_iterator
(
iterator
):
pass
cppclass
reverse_iterator
(
iterator
):
pass
cppclass
const_reverse_iterator
(
iterator
):
pass
#cppclass input_iterator(iterator):
cppclass
reverse_iterator
:
T
&
operator
*
()
iterator
operator
++
()
iterator
operator
--
()
bint
operator
==
(
iterator
)
bint
operator
!=
(
iterator
)
#cppclass const_iterator(iterator):
# pass
#cppclass const_reverse_iterator(reverse_iterator):
# pass
vector
()
#vector(vector&)
#vector(size_t, T&)
vector
(
vector
&
)
vector
(
size_t
)
vector
(
size_t
,
T
&
)
#vector[input_iterator](input_iterator, input_iterator)
T
&
operator
[](
size_t
)
#vector& operator=(vector&)
b
ool
operator
==
(
vector
&
,
vector
&
)
b
ool
operator
!=
(
vector
&
,
vector
&
)
b
ool
operator
<
(
vector
&
,
vector
&
)
b
ool
operator
>
(
vector
&
,
vector
&
)
b
ool
operator
<=
(
vector
&
,
vector
&
)
b
ool
operator
>=
(
vector
&
,
vector
&
)
b
int
operator
==
(
vector
&
,
vector
&
)
b
int
operator
!=
(
vector
&
,
vector
&
)
b
int
operator
<
(
vector
&
,
vector
&
)
b
int
operator
>
(
vector
&
,
vector
&
)
b
int
operator
<=
(
vector
&
,
vector
&
)
b
int
operator
>=
(
vector
&
,
vector
&
)
void
assign
(
size_t
,
T
&
)
#void assign(input_iterator, input_iterator)
#void assign
[input_iterator]
(input_iterator, input_iterator)
T
&
at
(
size_t
)
T
&
back
()
iterator
begin
()
const_iterator
begin
()
#
const_iterator begin()
size_t
capacity
()
void
clear
()
b
ool
empty
()
b
int
empty
()
iterator
end
()
const_iterator
end
()
#
const_iterator end()
iterator
erase
(
iterator
)
iterator
erase
(
iterator
,
iterator
)
T
&
front
()
...
...
@@ -48,10 +50,11 @@ cdef extern from "<vector>" namespace "std":
void
pop_back
()
void
push_back
(
T
&
)
reverse_iterator
rbegin
()
const_reverse_iterator
rbegin
()
#
const_reverse_iterator rbegin()
reverse_iterator
rend
()
const_reverse_iterator
rend
()
#
const_reverse_iterator rend()
void
reserve
(
size_t
)
void
resize
(
size_t
,
T
)
void
resize
(
size_t
)
void
resize
(
size_t
,
T
&
)
size_t
size
()
void
swap
(
vector
&
)
tests/compile/libcpp_all.pyx
0 → 100644
View file @
827fff94
cimport
libcpp
cimport
libcpp.deque
cimport
libcpp.list
cimport
libcpp.map
cimport
libcpp.pair
cimport
libcpp.queue
cimport
libcpp.set
cimport
libcpp.stack
cimport
libcpp.vector
from
libcpp.deque
cimport
*
from
libcpp.list
cimport
*
from
libcpp.map
cimport
*
from
libcpp.pair
cimport
*
from
libcpp.queue
cimport
*
from
libcpp.set
cimport
*
from
libcpp.stack
cimport
*
from
libcpp.vector
cimport
*
cdef
libcpp
.
deque
.
deque
[
int
]
d1
=
deque
[
int
]()
cdef
libcpp
.
list
.
list
[
int
]
l1
=
list
[
int
]()
cdef
libcpp
.
map
.
map
[
int
,
int
]
m1
=
map
[
int
,
int
]()
cdef
libcpp
.
pair
.
pair
[
int
,
int
]
p1
=
pair
[
int
,
int
](
1
,
2
)
cdef
libcpp
.
queue
.
queue
[
int
]
q1
=
queue
[
int
]()
cdef
libcpp
.
set
.
set
[
int
]
s1
=
set
[
int
]()
cdef
libcpp
.
stack
.
stack
[
int
]
t1
=
stack
[
int
]()
cdef
libcpp
.
vector
.
vector
[
int
]
v1
=
vector
[
int
]()
cdef
deque
[
int
].
iterator
id1
=
d1
.
begin
()
cdef
deque
[
int
].
iterator
id2
=
d1
.
end
()
cdef
deque
[
int
].
reverse_iterator
rid1
=
d1
.
rbegin
()
cdef
deque
[
int
].
reverse_iterator
rid2
=
d1
.
rend
()
cdef
list
[
int
].
iterator
il1
=
l1
.
begin
()
cdef
list
[
int
].
iterator
il2
=
l1
.
end
()
cdef
list
[
int
].
reverse_iterator
ril1
=
l1
.
rbegin
()
cdef
list
[
int
].
reverse_iterator
ril2
=
l1
.
rend
()
cdef
map
[
int
,
int
].
iterator
im1
=
m1
.
begin
()
cdef
map
[
int
,
int
].
iterator
im2
=
m1
.
end
()
cdef
map
[
int
,
int
].
reverse_iterator
rim1
=
m1
.
rbegin
()
cdef
map
[
int
,
int
].
reverse_iterator
rim2
=
m1
.
rend
()
cdef
pair
[
map
[
int
,
int
].
iterator
,
bint
]
pimb
=
m1
.
insert
(
p1
)
cdef
set
[
int
].
iterator
is1
=
s1
.
begin
()
cdef
set
[
int
].
iterator
is2
=
s1
.
end
()
cdef
set
[
int
].
reverse_iterator
ris1
=
s1
.
rbegin
()
cdef
set
[
int
].
reverse_iterator
ris2
=
s1
.
rend
()
cdef
pair
[
set
[
int
].
iterator
,
bint
]
pisb
=
s1
.
insert
(
4
)
cdef
vector
[
int
].
iterator
iv1
=
v1
.
begin
()
cdef
vector
[
int
].
iterator
iv2
=
v1
.
end
()
cdef
vector
[
int
].
reverse_iterator
riv1
=
v1
.
rbegin
()
cdef
vector
[
int
].
reverse_iterator
riv2
=
v1
.
rend
()
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