Commit 0846423a authored by Robert Bradshaw's avatar Robert Bradshaw

Cleanup.

parent fbcf1901
......@@ -2652,6 +2652,7 @@ class CFuncType(CType):
import re
safe_typename = re.sub('[^a-zA-Z0-9]', '__', self.declaration_code("", pyrex=1))
self.to_py_function = "__Pyx_CFunc_%s_to_py" % safe_typename
for arg in self.args:
if not arg.type.is_pyobject and not arg.type.create_from_py_utility_code(env):
return False
......@@ -2671,12 +2672,8 @@ class CFuncType(CType):
else:
self.type_convert = '%s_to_py' % self.type_name
def declare_type_def(self):
if self.type.is_extension_type or self.type.is_builtin_type:
if self.type.is_extension_type or self.type.is_builtin_type or not self.type.is_pyobject:
return 'ctypedef void* %s "%s"' % (self.type_name, self.type_cname)
elif self.type.is_pyobject:
return ''
else:
return 'ctypedef struct %s "%s"' % (self.type_name, self.type_cname)
def declare_type_convert(self):
if self.type.is_extension_type or self.type.is_builtin_type:
return 'cdef PyTypeObject* %s_TYPE "%s"' % (self.type_name, self.type.typeptr_cname)
......@@ -2687,26 +2684,27 @@ class CFuncType(CType):
def check_type(self):
if self.type.is_extension_type or self.type.is_builtin_type:
return '__Pyx_TypeTest(<PyObject*>%s, %s_TYPE)' % (self.name, self.type_name)
if self.return_type is c_void_type:
return_type = 'void'
declare_return_type = ''
declare_return_type_convert = ''
maybe_return = ''
except_clause = 'except *'
elif self.return_type.is_pyobject:
return_type = 'RETURN_TYPE'
declare_return_type = 'ctypedef void* RETURN_TYPE "%s"' % self.return_type.declaration_code('')
declare_return_type_convert = 'cdef object RETURN_TYPE_from_py "(PyObject*)" (RETURN_TYPE)'
maybe_return = 'return RETURN_TYPE_from_py'
else:
if self.return_type.is_pyobject:
to_py = '(PyObject*)'
except_clause = ''
else:
if not self.return_type.create_to_py_utility_code(env):
return False
to_py = self.return_type.to_py_function
except_clause = 'except *'
return_type = 'RETURN_TYPE'
declare_return_type = 'ctypedef struct RETURN_TYPE "%s"' % self.return_type.declaration_code('')
declare_return_type_convert = 'cdef object RETURN_TYPE_from_py "%s" (RETURN_TYPE)' % self.return_type.to_py_function
declare_return_type = 'ctypedef void* RETURN_TYPE "%s"' % self.return_type.declaration_code('')
declare_return_type_convert = 'cdef object RETURN_TYPE_from_py "%s" (RETURN_TYPE)' % to_py
maybe_return = 'return RETURN_TYPE_from_py'
except_clause = 'except *'
context = {
'cname': self.to_py_function,
'args': [Arg(ix, arg.type) for ix, arg in enumerate(self.args)],
......
......@@ -99,7 +99,6 @@ class CythonUtilityCode(Code.UtilityCodeBase):
context.prefix = self.prefix
context.cython_scope = cython_scope
#context = StringParseContext(self.name)
print self.impl
tree = parse_from_strings(self.name, self.impl, context=context,
allow_struct_enum_decorator=True)
pipeline = Pipeline.create_pipeline(context, 'pyx', exclude_classes=excludes)
......
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