Last change
on this file since 1187 was
1187,
checked in by landauf, 17 years ago
|
some changes in commandexecutor and tclbind, but there's still a bug in the parameter evaluation
|
File size:
1.5 KB
|
Line | |
---|
1 | #include <iostream> |
---|
2 | #include <string> |
---|
3 | |
---|
4 | #include "ConsoleCommand.h" |
---|
5 | #include "CommandExecutor.h" |
---|
6 | #include "Debug.h" |
---|
7 | #include "TclBind.h" |
---|
8 | |
---|
9 | namespace orxonox |
---|
10 | { |
---|
11 | ConsoleCommandShortcutExtern(tcl, AccessLevel::None); |
---|
12 | |
---|
13 | void Tcl_puts(Tcl::object const &args) |
---|
14 | { |
---|
15 | COUT(0) << args.get() << std::endl; |
---|
16 | } |
---|
17 | |
---|
18 | std::string Tcl_unknown(Tcl::object const &a) |
---|
19 | { |
---|
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 ""; |
---|
33 | } |
---|
34 | |
---|
35 | std::string tcl(const std::string& tclcode) |
---|
36 | { |
---|
37 | try |
---|
38 | { |
---|
39 | static Tcl::interpreter i; |
---|
40 | i.def("puts", Tcl_puts, Tcl::variadic()); |
---|
41 | i.def("blub", Tcl_unknown, Tcl::variadic()); |
---|
42 | std::string output = i.eval(tclcode); |
---|
43 | COUT(0) << "tcl> " << output << std::endl; |
---|
44 | return output; |
---|
45 | } |
---|
46 | catch (Tcl::tcl_error const &e) |
---|
47 | { |
---|
48 | COUT(1) << "Error: Tcl: " << e.what() << std::endl; |
---|
49 | } |
---|
50 | catch (std::exception const &e) |
---|
51 | { |
---|
52 | COUT(1) << "Error while executing tcl: " << e.what() << std::endl; |
---|
53 | } |
---|
54 | |
---|
55 | return ""; |
---|
56 | } |
---|
57 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.