Changeset 1198 for code/branches/console
- Timestamp:
- Apr 27, 2008, 10:22:32 PM (17 years ago)
- Location:
- code/branches/console/src/core
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CommandExecutor.cc
r1194 r1198 36 36 #include "Executor.h" 37 37 #include "ConfigValueContainer.h" 38 #include "TclBind.h" 38 39 39 40 #define COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE "set" … … 379 380 } 380 381 381 bool CommandExecutor::execute(const std::string& command) 382 { 383 if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 384 CommandExecutor::parse(command); 385 386 return CommandExecutor::execute(CommandExecutor::getEvaluation()); 382 bool CommandExecutor::execute(const std::string& command, bool useTcl) 383 { 384 if (useTcl) 385 { 386 return TclBind::eval(command); 387 } 388 else 389 { 390 if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)) 391 CommandExecutor::parse(command); 392 393 return CommandExecutor::execute(CommandExecutor::getEvaluation()); 394 } 387 395 } 388 396 -
code/branches/console/src/core/CommandExecutor.h
r1194 r1198 131 131 { 132 132 public: 133 static bool execute(const std::string& command );133 static bool execute(const std::string& command, bool useTcl = true); 134 134 static bool execute(const CommandEvaluation& evaluation); 135 135 -
code/branches/console/src/core/CorePrereqs.h
r1062 r1198 139 139 template <class T> 140 140 class SubclassIdentifier; 141 class TclBind; 141 142 class Tickable; 142 143 template <class T, class O> -
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 } -
code/branches/console/src/core/TclBind.h
r1194 r1198 30 30 #define _TclBind_H__ 31 31 32 #include "CorePrereqs.h" 33 32 34 #include "cpptcl/CppTcl.h" 33 35 … … 44 46 45 47 static void puts(Tcl::object const &args); 46 static std::string execute(Tcl::object const &args); 48 static void execute(Tcl::object const &args); 49 static std::string orxonox(Tcl::object const &args); 47 50 static std::string tcl(const std::string& tclcode); 51 static bool TclBind::eval(const std::string& tclcode); 48 52 49 53 private:
Note: See TracChangeset
for help on using the changeset viewer.