Commit 827fff94 authored by Lisandro Dalcin's avatar Lisandro Dalcin

C++ fixes (parsing and scope lookup), working libcpp pxd's, more tests

parent bcb29869
......@@ -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)
......
......@@ -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,
......
......@@ -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
......
......@@ -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&)
bool operator==(deque&, deque&)
bool operator!=(deque&, deque&)
bool operator<(deque&, deque&)
bool operator>(deque&, deque&)
bool operator<=(deque&, deque&)
bool operator>=(deque&, deque&)
void assign(size_t, TYPE&)
bint operator==(deque&, deque&)
bint operator!=(deque&, deque&)
bint operator<(deque&, deque&)
bint operator>(deque&, deque&)
bint operator<=(deque&, deque&)
bint 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()
bool empty()
bint 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&)
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&)
bool operator==(list&, list&)
bool operator!=(list&, list&)
bool operator<(list&, list&)
bool operator>(list&, list&)
bool operator<=(list&, list&)
bool operator>=(list&, list&)
bint operator==(list&, list&)
bint operator!=(list&, list&)
bint operator<(list&, list&)
bint operator>(list&, list&)
bint operator<=(list&, list&)
bint operator>=(list&, list&)
void assign(size_t, T&)
T& back()
iterator begin()
const_iterator begin()
bool empty()
#const_iterator begin()
bint 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&)
#voide 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()
......
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()
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&)
from pair cimport pair
cdef extern from "<queue>" namespace "std":
cdef cppclass queue[T]:
queue()
queue(queue&)
#queue(Container&)
T& back()
bool empty()
bint 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()
......@@ -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&)
bool operator==(set&, set&)
bool operator!=(set&, set&)
bool operator<(set&, set&)
bool operator>(set&, set&)
bool operator<=(set&, set&)
bool operator>=(set&, set&)
bint operator==(set&, set&)
bint operator!=(set&, set&)
bint operator<(set&, set&)
bint operator>(set&, set&)
bint operator<=(set&, set&)
bint operator>=(set&, set&)
iterator begin()
const_iterator begin()
#const_iterator begin()
void clear()
#size_t count(key_type&)
bool empty()
size_t count(T&)
bint 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()
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()
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&)
bool operator==(vector&, vector&)
bool operator!=(vector&, vector&)
bool operator<(vector&, vector&)
bool operator>(vector&, vector&)
bool operator<=(vector&, vector&)
bool operator>=(vector&, vector&)
bint operator==(vector&, vector&)
bint operator!=(vector&, vector&)
bint operator<(vector&, vector&)
bint operator>(vector&, vector&)
bint operator<=(vector&, vector&)
bint 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()
bool empty()
bint 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&)
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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment