Commit d724cd00 authored by Xavier Thompson's avatar Xavier Thompson

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

parent 4fd45787
...@@ -1636,7 +1636,8 @@ class CppClassNode(CStructOrUnionDefNode, BlockNode): ...@@ -1636,7 +1636,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:
......
...@@ -4178,7 +4178,7 @@ class CypClassType(CppClassType): ...@@ -4178,7 +4178,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)
...@@ -4207,6 +4207,12 @@ class CypClassType(CppClassType): ...@@ -4207,6 +4207,12 @@ class CypClassType(CppClassType):
self._mro = mro_C3_merge(inputs) self._mro = mro_C3_merge(inputs)
return self._mro return self._mro
# 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:
......
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