[Orxonox-commit 825] r3344 - in branches/resource: cmake src src/core

landauf at orxonox.net landauf at orxonox.net
Fri Jul 24 18:00:36 CEST 2009


Author: landauf
Date: 2009-07-24 18:00:36 +0200 (Fri, 24 Jul 2009)
New Revision: 3344

Modified:
   branches/resource/cmake/PackageConfig.cmake
   branches/resource/src/SpecialConfig.h.in
   branches/resource/src/core/TclBind.cc
   branches/resource/src/core/TclBind.h
   branches/resource/src/core/TclThreadManager.cc
Log:
tcl uses it's native library, orxonox adds new features later (defined in media/tcl/init.tcl)

Modified: branches/resource/cmake/PackageConfig.cmake
===================================================================
--- branches/resource/cmake/PackageConfig.cmake	2009-07-24 14:25:33 UTC (rev 3343)
+++ branches/resource/cmake/PackageConfig.cmake	2009-07-24 16:00:36 UTC (rev 3344)
@@ -41,9 +41,11 @@
 SET(ENV{OGRE_HOME}             ${DEP_INCLUDE_DIR}/ogre-1.4.9)
 SET(ENV{OGRE_PLUGIN_DIR}       ${DEP_BINARY_DIR})
 SET(ENV{OPENALDIR}             ${DEP_INCLUDE_DIR}/openal-1.1)
-LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.2/include)
+LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.7/include)
 LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib-1.2.3/include)
 
+SET(TCL_LIBRARY_DIR ${DEPENDENCY_PACKAGE_DIR}/tcl)
+
 ### INSTALL ###
 # On Windows, DLLs have to be in the executable folder, install them
 IF(WIN32 AND DEP_BINARY_DIR)

Modified: branches/resource/src/SpecialConfig.h.in
===================================================================
--- branches/resource/src/SpecialConfig.h.in	2009-07-24 14:25:33 UTC (rev 3343)
+++ branches/resource/src/SpecialConfig.h.in	2009-07-24 16:00:36 UTC (rev 3344)
@@ -87,7 +87,7 @@
     const char ORXONOX_CONFIG_DEV_PATH[]      = "@CMAKE_CONFIG_OUTPUT_DIRECTORY@";
     const char ORXONOX_LOG_DEV_PATH[]         = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
 #endif
-    
+
     /* OGRE Plugins */
 #ifdef NDEBUG
     const char ORXONOX_OGRE_PLUGINS[] = "@OGRE_PLUGINS_RELEASE@";
@@ -104,6 +104,11 @@
     const char ORXONOX_OGRE_PLUGINS_FOLDER[] = "@OGRE_PLUGINS_FOLDER_DEBUG@";
 #  endif
 #endif
+
+    /* Tcl */
+#ifdef DEPENDENCY_PACKAGE_ENABLE
+    const char ORXONOX_TCL_LIBRARY_PATH[] = "@TCL_LIBRARY_DIR@";
+#endif
 }
 
 /**

Modified: branches/resource/src/core/TclBind.cc
===================================================================
--- branches/resource/src/core/TclBind.cc	2009-07-24 14:25:33 UTC (rev 3343)
+++ branches/resource/src/core/TclBind.cc	2009-07-24 16:00:36 UTC (rev 3344)
@@ -37,6 +37,7 @@
 #include "CommandExecutor.h"
 #include "ConsoleCommand.h"
 #include "TclThreadManager.h"
+#include "SpecialConfig.h"
 
 namespace orxonox
 {
@@ -50,7 +51,7 @@
         assert(singletonRef_s == 0);
         singletonRef_s = this;
         this->interpreter_ = 0;
-        this->bSetTclLibPath_ = false;
+        this->bSetTclDataPath_ = false;
         this->setDataPath(datapath);
     }
 
@@ -64,17 +65,18 @@
     void TclBind::setDataPath(const std::string& datapath)
     {
         // String has POSIX slashes
-        this->tclLibPath_ = datapath + "tcl" + TCL_VERSION + '/';
-        this->bSetTclLibPath_ = true;
+        this->tclDataPath_ = datapath + "tcl" + '/';
+        this->bSetTclDataPath_ = true;
 
-        this->createTclInterpreter();
+        this->initializeTclInterpreter();
     }
 
-    void TclBind::createTclInterpreter()
+    void TclBind::initializeTclInterpreter()
     {
-        if (this->bSetTclLibPath_ && !this->interpreter_)
+        if (this->bSetTclDataPath_ && !this->interpreter_)
         {
-            this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
+            this->interpreter_ = this->createTclInterpreter();
+
             this->interpreter_->def("orxonox::query", TclBind::tcl_query, Tcl::variadic());
             this->interpreter_->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
             this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
@@ -87,24 +89,35 @@
                 this->interpreter_->eval("proc crossexecute {id args} { orxonox::crossquery 0 $id [join $args] }");
                 this->interpreter_->eval("set id 0");
                 this->interpreter_->eval("rename exit tcl::exit; proc exit {} { execute exit }");
-                this->interpreter_->eval("redef_puts");
             }
             catch (Tcl::tcl_error const &e)
             {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
             catch (std::exception const &e)
             {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+            catch (...)
+            {   COUT(1) << "Error while creating Tcl-interpreter." << std::endl;   }
         }
     }
 
-    void TclBind::createNewTclInterpreter()
+    Tcl::interpreter* TclBind::createTclInterpreter()
     {
-        if (this->interpreter_)
+#ifdef DEPENDENCY_PACKAGE_ENABLE
+        Tcl::interpreter* interpreter = new Tcl::interpreter(ORXONOX_TCL_LIBRARY_PATH);
+#else
+        Tcl::interpreter* interpreter = new Tcl::interpreter();
+#endif
+        try
         {
-            delete this->interpreter_;
-            this->interpreter_ = 0;
+            interpreter->eval("source " + TclBind::getInstance().tclDataPath_ + "/init.tcl");
         }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+        catch (...)
+        {   COUT(1) << "Error while creating Tcl-interpreter." << std::endl;   }
 
-        this->createTclInterpreter();
+        return interpreter;
     }
 
     std::string TclBind::tcl_query(Tcl::object const &args)

Modified: branches/resource/src/core/TclBind.h
===================================================================
--- branches/resource/src/core/TclBind.h	2009-07-24 14:25:33 UTC (rev 3343)
+++ branches/resource/src/core/TclBind.h	2009-07-24 16:00:36 UTC (rev 3344)
@@ -48,9 +48,9 @@
             static void bgerror(std::string error);
 
             void setDataPath(const std::string& datapath);
-            std::string getTclLibPath() const { return this->tclLibPath_; }
-            void createTclInterpreter();
-            void createNewTclInterpreter();
+            const std::string& getTclDataPath() const { return this->tclDataPath_; }
+            void initializeTclInterpreter();
+            static Tcl::interpreter* createTclInterpreter();
             Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; }
 
             static std::string tcl_query(Tcl::object const &args);
@@ -62,8 +62,8 @@
             TclBind(const TclBind& other);
 
             Tcl::interpreter* interpreter_;
-            std::string tclLibPath_;
-            bool bSetTclLibPath_;
+            std::string tclDataPath_;
+            bool bSetTclDataPath_;
 
             static TclBind* singletonRef_s;
     };

Modified: branches/resource/src/core/TclThreadManager.cc
===================================================================
--- branches/resource/src/core/TclThreadManager.cc	2009-07-24 14:25:33 UTC (rev 3343)
+++ branches/resource/src/core/TclThreadManager.cc	2009-07-24 16:00:36 UTC (rev 3344)
@@ -239,7 +239,7 @@
     {
         TclInterpreterBundle* newbundle = new TclInterpreterBundle();
         newbundle->id_ = id;
-        newbundle->interpreter_ = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
+        newbundle->interpreter_ = TclBind::createTclInterpreter();
 
         // Initialize the new interpreter
         try
@@ -267,8 +267,6 @@
             newbundle->interpreter_->eval("proc exit {} { execute TclThreadManager destroy " + id_string + " }");
 
             // Redefine some native functions
-            newbundle->interpreter_->eval("redef_puts");
-
 //            newbundle->interpreter_->eval("rename while tcl::while");
 //            newbundle->interpreter_->eval("proc while {test command} { tcl::while {[uplevel 1 expr $test]} {uplevel 1 $command} }"); // (\"$test\" && [orxonox::running " + id + "]])
 //            newbundle->interpreter_->eval("rename for tcl::for");




More information about the Orxonox-commit mailing list