Commit 4bf8b9b2 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix typedef vector bool fix.

parent 1f9fa1c1
...@@ -3486,8 +3486,8 @@ class CppClassType(CType): ...@@ -3486,8 +3486,8 @@ class CppClassType(CType):
# Here we pretend that the various methods return bool values # Here we pretend that the various methods return bool values
# (as the actual returned values are coercable to such, and # (as the actual returned values are coercable to such, and
# we don't support call expressions as lvalues). # we don't support call expressions as lvalues).
T = values[self.templates[0]] T = values.get(self.templates[0], None)
if not T.is_fused and T.empty_declaration_code() == 'bool': if T and not T.is_fused and T.empty_declaration_code() == 'bool':
for bit_ref_returner in ('at', 'back', 'front'): for bit_ref_returner in ('at', 'back', 'front'):
if bit_ref_returner in specialized.scope.entries: if bit_ref_returner in specialized.scope.entries:
specialized.scope.entries[bit_ref_returner].type.return_type = T specialized.scope.entries[bit_ref_returner].type.return_type = T
......
...@@ -177,3 +177,21 @@ def test_bool_vector_get_set(): ...@@ -177,3 +177,21 @@ def test_bool_vector_get_set():
v[0] = True v[0] = True
v[1] = False v[1] = False
assert <object>v == [True, False, True, True, True] assert <object>v == [True, False, True, True, True]
ctypedef vector[cbool] vector_bool
ctypedef vector[int] vector_int
def test_typedef_vector(L):
"""
>>> test_typedef_vector([0, 1, True])
([0, 1, 1, 0, 1, 1], 0, [False, True, True, False, True, True], False)
"""
cdef vector_int vi = L
cdef vector_int vi2 = vi
vi.insert(vi.begin(), vi2.begin(), vi2.end())
cdef vector_bool vb = L
cdef vector_bool vb2 = vb
vb.insert(vb.begin(), vb2.begin(), vb2.end())
return vi, vi.at(0), vb, vb.at(0)
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