code.putln("res = PyDict_New(); if (res == NULL) return NULL;")
for member in self.scope.var_entries:
if member.type.to_py_function and member.type.create_convert_utility_code(env):
+ interned_name = env.get_string_const(member.name, identifier=True)
+ env.add_py_string(interned_name)
code.putln("member = %s(s.%s); if (member == NULL) goto bad;" % (
member.type.to_py_function, member.cname))
- code.putln("if (PyDict_SetItem(res, %s, member) < 0) goto bad;" % member.py_name.pystring_cname)
+ code.putln("if (PyDict_SetItem(res, %s, member) < 0) goto bad;" % interned_name.pystring_cname)
code.putln("Py_DECREF(member);")
else:
self.to_py_function = None
self.type_entries.append(entry)
if not scope and not entry.type.scope:
self.check_for_illegal_incomplete_ctypedef(typedef_flag, pos)
- if scope and self.outer_scope:
- scope.module_scope = self
return entry
def check_previous_typedef_flag(self, entry, typedef_flag, pos):
class StructOrUnionScope(Scope):
# Namespace of a C struct or union.
- module_scope = None
-
def __init__(self, name="?"):
Scope.__init__(self, name, None, None)
type = PyrexTypes.CPtrType(type)
entry = self.declare(name, cname, type, pos, visibility)
entry.is_variable = 1
- if self.module_scope:
- py_name = self.module_scope.get_string_const(name, identifier=True)
- self.module_scope.add_py_string(py_name)
- entry.py_name = py_name
self.var_entries.append(entry)
if type.is_pyobject and not allow_pyobject:
error(pos,