Commit 770acb7d authored by Robert Bradshaw's avatar Robert Bradshaw

Fixed stl container conversion with typedef element types.

parent d6719b66
...@@ -93,6 +93,8 @@ Bugs fixed ...@@ -93,6 +93,8 @@ Bugs fixed
runtime but not as global module names. Trying both lookups helps with runtime but not as global module names. Trying both lookups helps with
globals() manipulation. globals() manipulation.
* Fixed stl container conversion for typedef element types.
* ``obj.pop(x)`` truncated large C integer values of x to ``Py_ssize_t``. * ``obj.pop(x)`` truncated large C integer values of x to ``Py_ssize_t``.
* ``__init__.pyc`` is recognised as marking a package directory * ``__init__.pyc`` is recognised as marking a package directory
......
...@@ -3023,12 +3023,30 @@ class CppClassType(CType): ...@@ -3023,12 +3023,30 @@ class CppClassType(CType):
return False return False
tags.append(T.specialization_name()) tags.append(T.specialization_name())
if T.exception_value is not None: if T.exception_value is not None:
except_clause = T.exception_value # This is a hack due to the except value clause
# requiring a const (literal) value of the right
# (visible) type.
def guess_type(value):
if not T.is_typedef and (T.is_numeric or T.is_ptr):
return T
try:
int(value)
return c_longlong_type
except ValueError:
pass
try:
float(value)
return c_double_type
except ValueError:
pass
return T
except_type = guess_type(T.exception_value)
except_clause = "%s " % T.exception_value
if T.exception_check: if T.exception_check:
except_clause = "? %s" % except_clause except_clause = "? %s" % except_clause
declarations.append( declarations.append(
" ctypedef %s %s '%s'" % ( " ctypedef %s %s '%s'" % (
T.declaration_code("", for_display=True), X[ix], T.declaration_code(""))) except_type.declaration_code("", for_display=True), X[ix], T.declaration_code("")))
else: else:
except_clause = "*" except_clause = "*"
declarations.append( declarations.append(
......
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