cython-devel

changeset 1617:84a34fc5c19e

better #include ordering
author Robert Bradshaw <robertwb@math.washington.edu>
date Fri Jan 16 00:52:34 2009 -0800 (3 years ago)
parents a2790103b969
children 5bb6c9eb48f4cbc7ab9f138b
files Cython/Compiler/ModuleNode.py Cython/Compiler/Nodes.py Cython/Compiler/Symtab.py
line diff
1.1 --- a/Cython/Compiler/ModuleNode.py Thu Jan 15 23:52:52 2009 -0800 1.2 +++ b/Cython/Compiler/ModuleNode.py Fri Jan 16 00:52:34 2009 -0800 1.3 @@ -567,14 +567,7 @@ 1.4 1.5 def generate_includes(self, env, cimported_modules, code): 1.6 includes = [] 1.7 - for module in cimported_modules: 1.8 - for filename in module.include_files: 1.9 - if filename not in includes: 1.10 - includes.append(filename) 1.11 for filename in env.include_files: 1.12 - if filename not in includes: 1.13 - includes.append(filename) 1.14 - for filename in includes: 1.15 code.putln('#include "%s"' % filename) 1.16 1.17 def generate_filename_table(self, code):
2.1 --- a/Cython/Compiler/Nodes.py Thu Jan 15 23:52:52 2009 -0800 2.2 +++ b/Cython/Compiler/Nodes.py Fri Jan 16 00:52:34 2009 -0800 2.3 @@ -2545,7 +2545,7 @@ 2.4 if self.module is None: 2.5 self.module = ModuleScope(self.module_name, None, env.context) 2.6 self.module.has_extern_class = 1 2.7 - env.cimported_modules.append(self.module) 2.8 + env.add_imported_module(self.module) 2.9 2.10 if self.base_class_name: 2.11 if self.base_class_module:
3.1 --- a/Cython/Compiler/Symtab.py Thu Jan 15 23:52:52 2009 -0800 3.2 +++ b/Cython/Compiler/Symtab.py Fri Jan 16 00:52:34 2009 -0800 3.3 @@ -905,6 +905,10 @@ 3.4 def add_imported_module(self, scope): 3.5 if scope not in self.cimported_modules: 3.6 self.cimported_modules.append(scope) 3.7 + for m in scope.cimported_modules: 3.8 + self.add_imported_module(m) 3.9 + for filename in scope.include_files: 3.10 + self.add_include_file(filename) 3.11 3.12 def add_imported_entry(self, name, entry, pos): 3.13 if entry not in self.entries: 3.14 @@ -935,7 +939,7 @@ 3.15 else: 3.16 entry = self.declare_var(name, py_object_type, pos) 3.17 entry.as_module = scope 3.18 - self.cimported_modules.append(scope) 3.19 + self.add_imported_module(scope) 3.20 return entry 3.21 3.22 def declare_var(self, name, type, pos,