Commit 8443607d authored by Stefan Behnel's avatar Stefan Behnel

determine buffer typegroup of integer dtypes based on signedness at C compile time

parent c527279f
...@@ -680,32 +680,25 @@ def get_type_information_cname(code, dtype, maxdepth=None): ...@@ -680,32 +680,25 @@ def get_type_information_cname(code, dtype, maxdepth=None):
rep = str(dtype) rep = str(dtype)
flags = "0" flags = "0"
is_unsigned = "0"
if dtype.is_int: if dtype.is_int:
if dtype.signed == 0: is_unsigned = "IS_UNSIGNED(%s)" % declcode
typegroup = 'U' typegroup = "%s ? 'U' : 'I'" % is_unsigned
else:
typegroup = 'I'
elif complex_possible or dtype.is_complex: elif complex_possible or dtype.is_complex:
typegroup = 'C' typegroup = "'C'"
elif dtype.is_float: elif dtype.is_float:
typegroup = 'R' typegroup = "'R'"
elif dtype.is_struct: elif dtype.is_struct:
typegroup = 'S' typegroup = "'S'"
if dtype.packed: if dtype.packed:
flags = "__PYX_BUF_FLAGS_PACKED_STRUCT" flags = "__PYX_BUF_FLAGS_PACKED_STRUCT"
elif dtype.is_pyobject: elif dtype.is_pyobject:
typegroup = 'O' typegroup = "'O'"
else: else:
assert False assert False
if dtype.is_int:
is_unsigned = "IS_UNSIGNED(%s)" % declcode
else:
is_unsigned = "0"
typeinfo = ('static __Pyx_TypeInfo %s = ' typeinfo = ('static __Pyx_TypeInfo %s = '
'{ "%s", %s, sizeof(%s), { %s }, %s, \'%s\', %s, %s };') '{ "%s", %s, sizeof(%s), { %s }, %s, %s, %s, %s };')
tup = (name, rep, structinfo_name, declcode, tup = (name, rep, structinfo_name, declcode,
', '.join([str(x) for x in arraysizes]) or '0', len(arraysizes), ', '.join([str(x) for x in arraysizes]) or '0', len(arraysizes),
typegroup, is_unsigned, flags) typegroup, is_unsigned, flags)
......
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