Changeset 1187 for code/branches/console/src/core
- Timestamp:
- Apr 25, 2008, 12:51:29 AM (17 years ago)
- Location:
- code/branches/console/src/core
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CommandExecutor.cc
r1149 r1187 270 270 } 271 271 272 bool CommandEvaluation::hasReturnvalue() const 273 { 274 if (this->state_ == CS_Shortcut_Params || this->state_ == CS_Shortcut_Finished) 275 { 276 if (this->shortcut_) 277 return this->shortcut_->hasReturnvalue(); 278 } 279 else if (this->state_ == CS_Function_Params || this->state_ == CS_Function_Finished) 280 { 281 if (this->function_) 282 return this->function_->hasReturnvalue(); 283 } 284 285 return MT_null; 286 } 287 272 288 MultiTypeMath CommandEvaluation::getReturnvalue() const 273 289 { -
code/branches/console/src/core/CommandExecutor.h
r1064 r1187 95 95 void evaluateParams(); 96 96 97 bool hasReturnvalue() const; 97 98 MultiTypeMath getReturnvalue() const; 98 99 -
code/branches/console/src/core/TclBind.cc
r1151 r1187 3 3 4 4 #include "ConsoleCommand.h" 5 #include "CommandExecutor.h" 5 6 #include "Debug.h" 6 #include "cpptcl/CppTcl.h"7 7 #include "TclBind.h" 8 8 9 9 namespace orxonox 10 10 { 11 ConsoleCommandShortcutExtern(test, AccessLevel::None);12 11 ConsoleCommandShortcutExtern(tcl, AccessLevel::None); 13 12 14 void hello()13 void Tcl_puts(Tcl::object const &args) 15 14 { 16 std::cout << "Hello C++/Tcl!"<< std::endl;15 COUT(0) << args.get() << std::endl; 17 16 } 18 17 19 void test()18 std::string Tcl_unknown(Tcl::object const &a) 20 19 { 21 Tcl::interpreter i; 22 i.def("hello", hello); 23 24 std::string script = "for {set i 0} {$i != 4} {incr i} { hello }"; 25 26 i.eval(script); 20 std::cout << "1\n"; 21 std::cout << a.get() << std::endl; 22 CommandEvaluation evaluation = CommandExecutor::evaluate(std::string(a.get())); 23 std::cout << "2\n"; 24 CommandExecutor::execute(evaluation); 25 std::cout << "3\n"; 26 if (evaluation.hasReturnvalue()) 27 { 28 std::cout << "4\n"; 29 return evaluation.getReturnvalue().toString(); 30 } 31 std::cout << "5\n"; 32 return ""; 27 33 } 28 34 … … 32 38 { 33 39 static Tcl::interpreter i; 40 i.def("puts", Tcl_puts, Tcl::variadic()); 41 i.def("blub", Tcl_unknown, Tcl::variadic()); 34 42 std::string output = i.eval(tclcode); 35 43 COUT(0) << "tcl> " << output << std::endl; -
code/branches/console/src/core/TclBind.h
r1151 r1187 2 2 #define _TclBind_H__ 3 3 4 #include "cpptcl/CppTcl.h" 5 4 6 namespace orxonox 5 7 { 6 void hello(); 7 void test(); 8 Tcl::interpreter* createNewInterpreter(); 9 void Tcl_puts(Tcl::object const &c); 10 std::string Tcl_unknown(Tcl::object const &c); 8 11 std::string tcl(const std::string& tclcode); 9 12 }
Note: See TracChangeset
for help on using the changeset viewer.