Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/console/src/core/TclBind.cc @ 1187

Last change on this file since 1187 was 1187, checked in by landauf, 16 years ago

some changes in commandexecutor and tclbind, but there's still a bug in the parameter evaluation

File size: 1.5 KB
RevLine 
[1151]1#include <iostream>
2#include <string>
3
4#include "ConsoleCommand.h"
[1187]5#include "CommandExecutor.h"
[1151]6#include "Debug.h"
7#include "TclBind.h"
8
9namespace orxonox
10{
11    ConsoleCommandShortcutExtern(tcl, AccessLevel::None);
12
[1187]13    void Tcl_puts(Tcl::object const &args)
[1151]14    {
[1187]15        COUT(0) << args.get() << std::endl;
[1151]16    }
17
[1187]18    std::string Tcl_unknown(Tcl::object const &a)
[1151]19    {
[1187]20std::cout << "1\n";
21std::cout << a.get() << std::endl;
22        CommandEvaluation evaluation = CommandExecutor::evaluate(std::string(a.get()));
23std::cout << "2\n";
24        CommandExecutor::execute(evaluation);
25std::cout << "3\n";
26        if (evaluation.hasReturnvalue())
27        {
28std::cout << "4\n";
29            return evaluation.getReturnvalue().toString();
30        }
31std::cout << "5\n";
32        return "";
[1151]33    }
34
35    std::string tcl(const std::string& tclcode)
36    {
37        try
38        {
39            static Tcl::interpreter i;
[1187]40            i.def("puts", Tcl_puts, Tcl::variadic());
41            i.def("blub", Tcl_unknown, Tcl::variadic());
[1151]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.