better #include ordering
authorRobert Bradshaw <robertwb@math.washington.edu>
Fri, 16 Jan 2009 08:52:34 +0000 (00:52 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Fri, 16 Jan 2009 08:52:34 +0000 (00:52 -0800)
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Compiler/Symtab.py

index 697881fc06c860de5d069fc8c2666fd378d8c70a..683606dc069bfe485eda774181ff72a0face3335 100644 (file)
@@ -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):
index d2cf0b5193c99556bbe6e37e5f62a7f978dc53c0..b2e3019c3998e804818860fb15dcc187bdbd19ef 100644 (file)
@@ -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:
index ee9e8b7eaf68753edf08d97014948572ac051764..594561e3acbf2c0bfb0c0afbc46f0336f32767cc 100644 (file)
@@ -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,