Commit 021488a5 authored by Lisandro Dalcin's avatar Lisandro Dalcin

extern ctypedef integral <-> python object conversion (ticket #333)

parent e02c1b0b
......@@ -3933,8 +3933,7 @@ class TypecastNode(NewTempExprNode):
if from_py and not to_py and self.operand.is_ephemeral() and not self.type.is_numeric:
error(self.pos, "Casting temporary Python object to non-numeric non-Python type")
if to_py and not from_py:
if (self.operand.type.to_py_function and
self.operand.type.create_to_py_utility_code(env)):
if self.operand.type.create_to_py_utility_code(env):
self.result_ctype = py_object_type
self.operand = self.operand.coerce_to_pyobject(env)
else:
......@@ -3942,7 +3941,7 @@ class TypecastNode(NewTempExprNode):
warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.operand.type, self.type))
self.operand = self.operand.coerce_to_simple(env)
elif from_py and not to_py:
if self.type.from_py_function:
if self.type.create_from_py_utility_code(env):
self.operand = self.operand.coerce_to(self.type, env)
elif self.type.is_ptr and not (self.type.base_type.is_void or self.type.base_type.is_struct):
error(self.pos, "Python objects cannot be casted to pointers of primitive types")
......
......@@ -1964,8 +1964,9 @@ class DefNode(FuncDefNode):
or self.starstar_arg is not None or has_kwonly_args
for arg in self.args:
if not arg.type.is_pyobject and arg.type.from_py_function is None:
arg.type.create_from_py_utility_code(env)
if not arg.type.is_pyobject:
done = arg.type.create_from_py_utility_code(env)
if not done: pass # will fail later
if not self.signature_has_generic_args():
if has_star_or_kw_args:
......
This diff is collapsed.
This diff is collapsed.
typedef signed char SChar;
typedef unsigned char UChar;
typedef signed short SShort;
typedef unsigned short UShort;
typedef signed int SInt;
typedef unsigned int UInt;
typedef signed long SLong;
typedef unsigned long ULong;
typedef signed long long SLongLong;
typedef unsigned long long ULongLong;
cdef extern from "ctypedef_int_types_chdr_T333.h":
ctypedef int SChar ## "signed char"
ctypedef int UChar ## "unsigned char"
ctypedef int SShort ## "signed short"
ctypedef int UShort ## "unsigned short"
ctypedef int SInt ## "signed int"
ctypedef int UInt ## "unsigned int"
ctypedef int SLong ## "signed long"
ctypedef int ULong ## "unsigned long"
ctypedef int SLongLong ## "signed PY_LONG_LONG"
ctypedef int ULongLong ## "unsigned PY_LONG_LONG"
cdef extern from *:
ctypedef int ExtSInt "signed short"
ctypedef int ExtUInt "unsigned short"
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