Changeset 3344 for code/branches/resource/src/core/TclBind.cc
- Timestamp:
- Jul 24, 2009, 6:00:36 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource/src/core/TclBind.cc
r3318 r3344 38 38 #include "ConsoleCommand.h" 39 39 #include "TclThreadManager.h" 40 #include "SpecialConfig.h" 40 41 41 42 namespace orxonox … … 51 52 singletonRef_s = this; 52 53 this->interpreter_ = 0; 53 this->bSetTcl LibPath_ = false;54 this->bSetTclDataPath_ = false; 54 55 this->setDataPath(datapath); 55 56 } … … 65 66 { 66 67 // String has POSIX slashes 67 this->tcl LibPath_ = datapath + "tcl" + TCL_VERSION+ '/';68 this->bSetTcl LibPath_ = true;68 this->tclDataPath_ = datapath + "tcl" + '/'; 69 this->bSetTclDataPath_ = true; 69 70 70 this-> createTclInterpreter();71 this->initializeTclInterpreter(); 71 72 } 72 73 73 void TclBind:: createTclInterpreter()74 void TclBind::initializeTclInterpreter() 74 75 { 75 if (this->bSetTcl LibPath_ && !this->interpreter_)76 if (this->bSetTclDataPath_ && !this->interpreter_) 76 77 { 77 this->interpreter_ = new Tcl::interpreter(this->tclLibPath_); 78 this->interpreter_ = this->createTclInterpreter(); 79 78 80 this->interpreter_->def("orxonox::query", TclBind::tcl_query, Tcl::variadic()); 79 81 this->interpreter_->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic()); … … 88 90 this->interpreter_->eval("set id 0"); 89 91 this->interpreter_->eval("rename exit tcl::exit; proc exit {} { execute exit }"); 90 this->interpreter_->eval("redef_puts");91 92 } 92 93 catch (Tcl::tcl_error const &e) … … 94 95 catch (std::exception const &e) 95 96 { COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl; } 97 catch (...) 98 { COUT(1) << "Error while creating Tcl-interpreter." << std::endl; } 96 99 } 97 100 } 98 101 99 void TclBind::createNewTclInterpreter()102 Tcl::interpreter* TclBind::createTclInterpreter() 100 103 { 101 if (this->interpreter_) 104 #ifdef DEPENDENCY_PACKAGE_ENABLE 105 Tcl::interpreter* interpreter = new Tcl::interpreter(ORXONOX_TCL_LIBRARY_PATH); 106 #else 107 Tcl::interpreter* interpreter = new Tcl::interpreter(); 108 #endif 109 try 102 110 { 103 delete this->interpreter_; 104 this->interpreter_ = 0; 111 interpreter->eval("source " + TclBind::getInstance().tclDataPath_ + "/init.tcl"); 105 112 } 113 catch (Tcl::tcl_error const &e) 114 { COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; } 115 catch (std::exception const &e) 116 { COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl; } 117 catch (...) 118 { COUT(1) << "Error while creating Tcl-interpreter." << std::endl; } 106 119 107 this->createTclInterpreter();120 return interpreter; 108 121 } 109 122
Note: See TracChangeset
for help on using the changeset viewer.