Commit 29e245d4 authored by Xavier Thompson's avatar Xavier Thompson

Synthesize wrapper classes for forward-declared cypclasses also

parent 943dbd7d
...@@ -151,10 +151,6 @@ class CypclassWrapperInjection(CythonTransform): ...@@ -151,10 +151,6 @@ class CypclassWrapperInjection(CythonTransform):
# whether the is declared with ':' and a suite, or just a forward declaration # whether the is declared with ':' and a suite, or just a forward declaration
node_has_suite = node.attributes is not None node_has_suite = node.attributes is not None
# TODO: forward declare wrapper classes too ?
if not node_has_suite:
return None
# TODO: take nesting into account for the name # TODO: take nesting into account for the name
# TODO: check that there is no collision with another name # TODO: check that there is no collision with another name
cclass_name = EncodedString("%s_cyp_wrapper" % node.name) cclass_name = EncodedString("%s_cyp_wrapper" % node.name)
...@@ -181,6 +177,7 @@ class CypclassWrapperInjection(CythonTransform): ...@@ -181,6 +177,7 @@ class CypclassWrapperInjection(CythonTransform):
cclass_bases = TupleNode(node.pos, args=bases_args) cclass_bases = TupleNode(node.pos, args=bases_args)
if node_has_suite:
stats = [] stats = []
if not bases_args: if not bases_args:
underlying_cyobject = self.synthesize_underlying_cyobject_attribute(node) underlying_cyobject = self.synthesize_underlying_cyobject_attribute(node)
...@@ -189,6 +186,9 @@ class CypclassWrapperInjection(CythonTransform): ...@@ -189,6 +186,9 @@ class CypclassWrapperInjection(CythonTransform):
cclass_doc = EncodedString("Python Object wrapper for underlying cypclass %s" % node.name) cclass_doc = EncodedString("Python Object wrapper for underlying cypclass %s" % node.name)
else:
cclass_body = cclass_doc = None
wrapper = Nodes.CypclassWrapperDefNode( wrapper = Nodes.CypclassWrapperDefNode(
node.pos, node.pos,
visibility = 'private', visibility = 'private',
......
...@@ -5553,6 +5553,8 @@ class CypclassWrapperDefNode(CClassDefNode): ...@@ -5553,6 +5553,8 @@ class CypclassWrapperDefNode(CClassDefNode):
self.insert_cypclass_method_wrappers(env) self.insert_cypclass_method_wrappers(env)
def insert_cypclass_method_wrappers(self, env): def insert_cypclass_method_wrappers(self, env):
if self.wrapped_cypclass.attributes is None:
return
for attr in self.wrapped_cypclass.attributes: for attr in self.wrapped_cypclass.attributes:
if isinstance(attr, CFuncDefNode): if isinstance(attr, CFuncDefNode):
py_method_wrapper = self.synthesize_cypclass_method_wrapper(attr, env) py_method_wrapper = self.synthesize_cypclass_method_wrapper(attr, env)
......
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