From f77650eb54eb90812eb6a52557306fca58acd295 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 15 Aug 2009 18:40:03 -0700 Subject: [PATCH] Working stl vector example. --- Cython/Compiler/Symtab.py | 1 - tests/run/cpp_stl.pyx | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/run/cpp_stl.pyx 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 -- 2.26.2