cname = cname, visibility = visibility, is_cdef = 1)
if need_property:
self.need_properties.append(entry)
+ entry.needs_property = 1
class CStructOrUnionDefNode(StatNode):
self.put_stararg_decrefs(code)
if acquire_gil:
code.putln("PyGILState_Release(_save);")
- code.putln("/* TODO: decref scope object */")
+ # code.putln("/* TODO: decref scope object */")
# ----- Return
if not self.return_type.is_void:
code.putln("return %s;" % Naming.retval_cname)
if self.doc and Options.docstrings:
scope.doc = embed_position(self.pos, self.doc)
+
+ if has_body and not self.in_pxd:
+ # transforms not yet run on pxd files
+ from ParseTreeTransforms import AnalyseDeclarationsTransform
+ transform = AnalyseDeclarationsTransform(None)
+ for entry in scope.var_entries:
+ if hasattr(entry, 'needs_property'):
+ property = transform.create_Property(entry)
+ self.body.stats.append(property)
if has_body:
self.body.analyse_declarations(scope)
# mechanism for them.
stats = []
for entry in node.need_properties:
- property = self.basic_property.substitute({
- u"ATTR": AttributeNode(pos=entry.pos, obj=NameNode(pos=entry.pos, name="self"), attribute=entry.name),
- }, pos=entry.pos)
- property.stats[0].name = entry.name
+ property = self.create_Property(entry)
property.analyse_declarations(node.dest_scope)
self.visit(property)
stats.append(property)
return StatListNode(pos=node.pos, stats=stats)
else:
return None
+
+ def create_Property(self, entry):
+ property = self.basic_property.substitute({
+ u"ATTR": AttributeNode(pos=entry.pos,
+ obj=NameNode(pos=entry.pos, name="self"),
+ attribute=entry.name),
+ }, pos=entry.pos).stats[0]
+ property.name = entry.name
+ return property
class AnalyseExpressionsTransform(CythonTransform):
def visit_ModuleNode(self, node):