Commit 3f884a1c authored by Robert Bradshaw's avatar Robert Bradshaw

STL class value types.

parent 17e2f2c5
......@@ -389,6 +389,15 @@ class CTypedefType(BaseType):
else:
return BaseType.cast_code(self, expr_code)
def specialize(self, values):
base_type = self.typedef_base_type.specialize(values)
namespace = self.typedef_namespace.specialize(values) if self.typedef_namespace else None
if base_type is self.typedef_base_type and namespace is self.typedef_namespace:
return self
else:
return CTypedefType(self.typedef_name, base_type, self.typedef_cname,
self.typedef_is_external, namespace)
def __repr__(self):
return "<CTypedefType %s>" % self.typedef_cname
......
cdef extern from "<list>" namespace "std" nogil:
cdef cppclass list[T,ALLOCATOR=*]:
ctypedef T value_type
ctypedef ALLOCATOR allocator_type
cppclass iterator:
iterator()
iterator(iterator &)
......
from .utility cimport pair
cdef extern from "<map>" namespace "std" nogil:
cdef cppclass map[T, U,COMPARE=*,ALLOCATOR=*]:
cdef cppclass map[T, U, COMPARE=*, ALLOCATOR=*]:
ctypedef T key_type
ctypedef U mapped_type
ctypedef pair[const T, U] value_type
ctypedef COMPARE key_compare
ctypedef ALLOCATOR allocator_type
cppclass iterator:
pair[T, U]& operator*()
iterator operator++()
......
......@@ -2,6 +2,7 @@ from .utility cimport pair
cdef extern from "<set>" namespace "std" nogil:
cdef cppclass set[T]:
ctypedef T value_type
cppclass iterator:
T& operator*()
iterator operator++()
......
cdef extern from "<stack>" namespace "std" nogil:
ctypedef T value_type
cdef cppclass stack[T]:
stack() except +
stack(stack&) except +
......
......@@ -2,6 +2,9 @@ from .utility cimport pair
cdef extern from "<unordered_map>" namespace "std" nogil:
cdef cppclass unordered_map[T, U]:
ctypedef T key_type
ctypedef U mapped_type
ctypedef pair[const T, U] value_type
cppclass iterator:
pair[T, U]& operator*()
iterator operator++()
......
......@@ -2,6 +2,7 @@ from .utility cimport pair
cdef extern from "<unordered_set>" namespace "std" nogil:
cdef cppclass unordered_set[T,HASH=*,PRED=*,ALLOCATOR=*]:
ctypedef T value_type
cppclass iterator:
T& operator*()
iterator operator++()
......
cdef extern from "<utility>" namespace "std" nogil:
cdef cppclass pair[T, U]:
ctypedef T first_type
ctypedef U second_type
T first
U second
pair() except +
......
cdef extern from "<vector>" namespace "std" nogil:
cdef cppclass vector[T,ALLOCATOR=*]:
ctypedef T value_type
ctypedef ALLOCATOR allocator_type
cppclass iterator:
T& operator*()
iterator operator++()
......
......@@ -136,3 +136,13 @@ def item_ptr_test(L, int i, int x):
cdef int* vi_ptr = &v[i]
vi_ptr[0] = x
return v
def test_value_type(x):
"""
>>> test_value_type(2)
2.0
>>> test_value_type(2.5)
2.5
"""
cdef vector[double].value_type val = x
return val
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