# Must pre-call all used types in order not to recurse utility code
# writing.
assert len(fields) > 0
- types = [get_type_information_cname(proto, f.type, maxdepth - 1)
+ types = [get_type_information_cname(code, f.type, maxdepth - 1)
for f in fields]
typecode.putln("static __Pyx_StructField %s[] = {" % structinfo_name, safe=True)
for f, typeinfo in zip(fields, types):
assert writer.globalstate is None
writer.globalstate = self
- for part in self.code_layout:
- self.parts[part] = writer.insertion_point()#new_writer()
+ self.rootwriter = writer
- self.init_writers(writer)
-
+ def initialize_main_c_code(self):
+ rootwriter = self.rootwriter
+ for part in self.code_layout:
+ self.parts[part] = rootwriter.insertion_point()
- def init_writers(self, rootwriter):
self.decls_writer = rootwriter.new_writer()
self.pystring_table = rootwriter.new_writer()
self.init_cached_builtins_writer = rootwriter.new_writer()
(Naming.filetable_cname, Naming.filenames_cname))
code.putln("}")
- def finalize_writers(self):
+ def finalize_main_c_code(self):
self.close_global_decls()
#
emit_linenums = options.emit_linenums
rootwriter = Code.CCodeWriter(emit_linenums=emit_linenums)
globalstate = Code.GlobalState(rootwriter, emit_linenums)
+ globalstate.initialize_main_c_code()
h_code = globalstate['h_code']
self.generate_module_preamble(env, modules, h_code)
for codetup, name in env.utility_code_list:
globalstate.use_utility_code(codetup, name)
- globalstate.finalize_writers()
+ globalstate.finalize_main_c_code()
f = open_new_file(result.c_file)
rootwriter.copyto(f)