Changeset 1198 for code/branches/console/src/core/TclBind.cc
- Timestamp:
- Apr 27, 2008, 10:22:32 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/TclBind.cc
r1194 r1198 71 71 this->interpreter_ = new Tcl::interpreter(this->tclLibPath_); 72 72 this->interpreter_->def("puts", TclBind::puts, Tcl::variadic()); 73 this->interpreter_->def("orxonox", TclBind::orxonox, Tcl::variadic()); 73 74 this->interpreter_->def("execute", TclBind::execute, Tcl::variadic()); 74 this->interpreter_->eval("proc unknown {args} { return [execute $args] }"); 75 this->interpreter_->eval("proc unknown {args} { return [orxonox $args] }"); 76 this->interpreter_->eval("rename exit tclexit; proc exit {} { orxonox exit }"); 75 77 } 76 78 } … … 92 94 } 93 95 94 std::string TclBind:: execute(Tcl::object const &args)96 std::string TclBind::orxonox(Tcl::object const &args) 95 97 { 96 98 std::cout << "Tcl_execute: args: " << args.get() << std::endl; … … 100 102 command = command.substr(1, command.size() - 2); 101 103 102 if (!CommandExecutor::execute(command ))104 if (!CommandExecutor::execute(command, false)) 103 105 COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl; 104 106 … … 107 109 108 110 return ""; 111 } 112 113 void TclBind::execute(Tcl::object const &args) 114 { 109 115 } 110 116 … … 129 135 return ""; 130 136 } 137 138 bool TclBind::eval(const std::string& tclcode) 139 { 140 try 141 { 142 TclBind::getInstance().interpreter_->eval(tclcode); 143 return true; 144 } 145 catch (Tcl::tcl_error const &e) 146 { 147 COUT(1) << "Error: " << e.what() << std::endl; 148 } 149 catch (std::exception const &e) 150 { 151 COUT(1) << "Error while executing tcl: " << e.what() << std::endl; 152 } 153 154 return false; 155 } 131 156 }
Note: See TracChangeset
for help on using the changeset viewer.