Commit 1a3b1fba authored by Robert Bradshaw's avatar Robert Bradshaw

More struct cleanup.

parent 6049280b
......@@ -953,9 +953,11 @@ class CStructOrUnionType(CType):
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
......
......@@ -359,8 +359,6 @@ class Scope:
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):
......@@ -1207,8 +1205,6 @@ class GeneratorLocalScope(LocalScope):
class StructOrUnionScope(Scope):
# Namespace of a C struct or union.
module_scope = None
def __init__(self, name="?"):
Scope.__init__(self, name, None, None)
......@@ -1221,10 +1217,6 @@ class StructOrUnionScope(Scope):
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,
......
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