Changeset 1187 for code/branches/console/src/core/TclBind.cc
- Timestamp:
- Apr 25, 2008, 12:51:29 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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;
Note: See TracChangeset
for help on using the changeset viewer.