Commit 0917c169 authored by Xavier Thompson's avatar Xavier Thompson

Allow conversion to PyObject only when supported (e.g. not for templated cypclasses)

parent e2775a7a
...@@ -1637,7 +1637,8 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode): ...@@ -1637,7 +1637,8 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode):
cclass_bases = TupleNode(self.pos, args=[]) cclass_bases = TupleNode(self.pos, args=[])
if self.templates: if self.templates:
print("Quick warning: Python wrappers for templated cypclasses are not supported yet") # Python wrapper for templated cypclasses not supported yet
# this is signaled to the compiler by not doing what is below
return return
if self.attributes is not None: if self.attributes is not None:
......
...@@ -3963,7 +3963,7 @@ class CypClassType(CppClassType): ...@@ -3963,7 +3963,7 @@ class CypClassType(CppClassType):
# wrapper_type PyExtensionType or None the type of the cclass wrapper # wrapper_type PyExtensionType or None the type of the cclass wrapper
is_cyp_class = 1 is_cyp_class = 1
to_py_function = "__Pyx_PyObject_FromCyObject" to_py_function = None
def __init__(self, name, scope, cname, base_classes, templates=None, template_type=None, nogil=0, lock_mode=None, activable=False): def __init__(self, name, scope, cname, base_classes, templates=None, template_type=None, nogil=0, lock_mode=None, activable=False):
CppClassType.__init__(self, name, scope, cname, base_classes, templates, template_type, nogil) CppClassType.__init__(self, name, scope, cname, base_classes, templates, template_type, nogil)
...@@ -4026,6 +4026,13 @@ class CypClassType(CppClassType): ...@@ -4026,6 +4026,13 @@ class CypClassType(CppClassType):
self._left_path_to_base[base] = path self._left_path_to_base[base] = path
return path return path
# allow conversion to Python only when wrapping is supported
def create_to_py_utility_code(self, env):
if not self.wrapper_type:
return False
self.to_py_function = "__Pyx_PyObject_FromCyObject"
return True
def empty_declaration_code(self): def empty_declaration_code(self):
if self._empty_declaration is None: if self._empty_declaration is None:
self._empty_declaration = self.declaration_code('', deref=1) self._empty_declaration = self.declaration_code('', deref=1)
......
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