From d6363acffeebcff8d41daa3a33bc161de5966005 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Fri, 26 Aug 2005 08:32:16 +0000 Subject: [PATCH] avoid importing several times the same module git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7396 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/python.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/SWIG/Source/Modules/python.cxx b/SWIG/Source/Modules/python.cxx index d3a71b5f5..32153b32a 100644 --- a/SWIG/Source/Modules/python.cxx +++ b/SWIG/Source/Modules/python.cxx @@ -318,7 +318,7 @@ public: Swig_register_filebyname("python",f_shadow); Printv(f_shadow_py, - "# This file was created automatically by SWIG.\n", + "# This file was created automatically by SWIG ", PACKAGE_VERSION, ".\n", "# Don't modify this file, modify the SWIG interface instead.\n", NIL); @@ -477,7 +477,7 @@ public: String *modname = Getattr(n,"module"); if (modname) { - Printf(f_shadow_imports,"import "); + String *import = NewString("import "); // Find the module node for this imported module. It should be the // first child but search just in case. @@ -491,11 +491,16 @@ public: Node *options = Getattr(mod, "options"); String* pkg = options ? Getattr(options, "package") : 0; if (pkg && (!package || Strcmp(pkg, package) != 0)) { - Printf(f_shadow_imports, "%s.", pkg); + Printf(import, "%s.", pkg); } // finally, output the name of the imported module - Printf(f_shadow_imports, "%s\n", modname); + Printf(import, "%s\n", modname); + + if (!Strstr(f_shadow_imports, import)) { + Printf(f_shadow_imports, "%s", import); + } + Delete(import); } } return Language::importDirective(n);