Commit fbcf1901 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix C warnings and C++ errors.

parent b604debb
......@@ -2664,27 +2664,29 @@ class CFuncType(CType):
self.type = type
self.type_name = 'TYPE%s' % ix
self.type_cname = type.declaration_code("")
if type.is_pyobject:
self.type_name = 'object'
if self.type.is_extension_type or self.type.is_builtin_type:
self.type_convert = '<%s>' % self.type_name
elif type.is_pyobject:
self.type_convert = ''
else:
self.type_name = 'TYPE%s' % ix
self.type_convert = '%s_to_py' % self.type_name
def declare_type_def(self):
if self.type.is_extension_type:
return 'cdef PyTypeObject* TYPE%s "%s"' % (self.ix, self.type.typeptr_cname)
if self.type.is_extension_type or self.type.is_builtin_type:
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 not self.type.is_pyobject:
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)
elif self.type.is_pyobject:
return ''
else:
return 'cdef %s %s "%s"(object) except *' % (self.type_name, self.type_convert, self.type.from_py_function)
def check_type(self):
if self.type.is_extension_type:
return '__Pyx_TypeTest(%s, TYPE%s)' % (self.name, self.ix)
elif self.type.is_builtin_type:
return '__Pyx_TypeTest(%s, <PyTypeObject*>%s)' % (self.name, self.type.name)
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 = ''
......@@ -2692,19 +2694,19 @@ class CFuncType(CType):
maybe_return = ''
except_clause = 'except *'
elif self.return_type.is_pyobject:
return_type = 'object'
declare_return_type = ''
declare_return_type_convert = ''
maybe_return = 'return '
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'
except_clause = ''
else:
if not self.return_type.create_to_py_utility_code(env):
return False
except_clause = 'except *'
return_type = 'RETURN_TYPE'
declare_return_type = 'ctypedef struct RETURN_TYPE "%s"' % self.return_type.declaration_code("")
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
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,6 +99,7 @@ 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