From a6071116298b7a1be8da1d708302f26d624ead9b Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 16 Jan 2009 00:52:34 -0800 Subject: [PATCH] better #include ordering --- Cython/Compiler/ModuleNode.py | 7 ------- Cython/Compiler/Nodes.py | 2 +- Cython/Compiler/Symtab.py | 6 +++++- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 697881fc..683606dc 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -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): diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index d2cf0b51..b2e3019c 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -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: diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index ee9e8b7e..594561e3 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -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, -- 2.26.2