Commit 6e837884 authored by Dag Sverre Seljebotn's avatar Dag Sverre Seljebotn

Fix bug in new buffmt code

parent c3fc785a
...@@ -1329,9 +1329,13 @@ class CStructOrUnionType(CType): ...@@ -1329,9 +1329,13 @@ class CStructOrUnionType(CType):
return self.is_complete() return self.is_complete()
def can_be_complex(self): def can_be_complex(self):
# Does the struct consist of exactly two floats? # Does the struct consist of exactly two identical floats?
fields = self.scope.var_entries fields = self.scope.var_entries
return len(fields) == 2 and fields[0].type.is_float and fields[1].type.is_float if len(fields) != 2: return False
a, b = fields
return (a.type.is_float and b.type.is_float and
a.type.declaration_code("") ==
b.type.declaration_code(""))
def struct_nesting_depth(self): def struct_nesting_depth(self):
child_depths = [x.type.struct_nesting_depth() child_depths = [x.type.struct_nesting_depth()
......
...@@ -254,7 +254,7 @@ def int_and_long_are_same(): ...@@ -254,7 +254,7 @@ def int_and_long_are_same():
longarr = MockBuffer("i", sizeof(int)) longarr = MockBuffer("i", sizeof(int))
cdef struct MixedComplex: cdef struct MixedComplex:
long double real double real
float imag float imag
@testcase @testcase
...@@ -265,9 +265,10 @@ def mixed_complex_struct(): ...@@ -265,9 +265,10 @@ def mixed_complex_struct():
>>> mixed_complex_struct() >>> mixed_complex_struct()
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: Buffer dtype mismatch, expected 'long double' but got 'complex double' in 'MixedComplex.real' ValueError: Buffer dtype mismatch, expected 'double' but got 'complex double' in 'MixedComplex.real'
""" """
cdef object[MixedComplex] buf = MockBuffer("Zd", sizeof(MixedComplex)) cdef object[MixedComplex] buf = MockBuffer("Zd",
sizeof(MixedComplex))
cdef packed struct PackedSubStruct: cdef packed struct PackedSubStruct:
......
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