From: Robert Bradshaw Date: Sun, 16 Aug 2009 01:40:03 +0000 (-0700) Subject: Working stl vector example. X-Git-Tag: 0.13.beta0~353^2~46 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=f77650eb54eb90812eb6a52557306fca58acd295;p=cython.git Working stl vector example. --- diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index 54387934..6d7b305d 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -393,7 +393,6 @@ class Scope(object): entry.type.scope = scope self.type_entries.append(entry) if not scope and not entry.type.scope: - print pos self.check_for_illegal_incomplete_ctypedef(typedef_flag, pos) return entry diff --git a/tests/run/cpp_stl.pyx b/tests/run/cpp_stl.pyx new file mode 100644 index 00000000..4b8af28a --- /dev/null +++ b/tests/run/cpp_stl.pyx @@ -0,0 +1,34 @@ +__doc__ = u""" + >>> test_vector([1,10,100]) + 1 + 10 + 100 +""" + +cdef extern from "vector" namespace std: + + cdef cppclass iterator[T]: + pass + + cdef cppclass vector[T]: + #constructors + __init__() + + T at(int) + void push_back(T t) + void assign(int, T) + void clear() + + iterator end() + iterator begin() + + int size() + +def test_vector(L): + cdef vector[int] *V = new vector[int]() + for a in L: + V.push_back(a) + cdef int i + for i in range(len(L)): + print V.at(i) + del V