Commit a6071116 authored by Robert Bradshaw's avatar Robert Bradshaw

better #include ordering

parent 11901f05
......@@ -567,14 +567,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_includes(self, env, cimported_modules, code):
includes = []
for module in cimported_modules:
for filename in module.include_files:
if filename not in includes:
includes.append(filename)
for filename in env.include_files:
if filename not in includes:
includes.append(filename)
for filename in includes:
code.putln('#include "%s"' % filename)
def generate_filename_table(self, code):
......
......@@ -2545,7 +2545,7 @@ class CClassDefNode(ClassDefNode):
if self.module is None:
self.module = ModuleScope(self.module_name, None, env.context)
self.module.has_extern_class = 1
env.cimported_modules.append(self.module)
env.add_imported_module(self.module)
if self.base_class_name:
if self.base_class_module:
......
......@@ -905,6 +905,10 @@ class ModuleScope(Scope):
def add_imported_module(self, scope):
if scope not in self.cimported_modules:
self.cimported_modules.append(scope)
for m in scope.cimported_modules:
self.add_imported_module(m)
for filename in scope.include_files:
self.add_include_file(filename)
def add_imported_entry(self, name, entry, pos):
if entry not in self.entries:
......@@ -935,7 +939,7 @@ class ModuleScope(Scope):
else:
entry = self.declare_var(name, py_object_type, pos)
entry.as_module = scope
self.cimported_modules.append(scope)
self.add_imported_module(scope)
return entry
def declare_var(self, name, type, 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