Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 4, 2008, 4:44:24 PM (16 years ago)
Author:
landauf
Message:

added a tcl-thread, but there are still some bugs and problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/TclBind.cc

    r1198 r1230  
    7070        {
    7171            this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
    72             this->interpreter_->def("puts", TclBind::puts, Tcl::variadic());
    73             this->interpreter_->def("orxonox", TclBind::orxonox, Tcl::variadic());
    74             this->interpreter_->def("execute", TclBind::execute, Tcl::variadic());
    75             this->interpreter_->eval("proc unknown {args} { return [orxonox $args] }");
     72            this->interpreter_->def("orxonox", TclBind::tcl_orxonox, Tcl::variadic());
     73            this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
    7674            this->interpreter_->eval("rename exit tclexit; proc exit {} { orxonox exit }");
     75            this->interpreter_->eval("redef_puts");
    7776        }
    7877    }
     
    8988    }
    9089
    91     void TclBind::puts(Tcl::object const &args)
     90    void TclBind::tcl_puts(Tcl::object const &args)
    9291    {
    9392        COUT(0) << args.get() << std::endl;
    9493    }
    9594
    96     std::string TclBind::orxonox(Tcl::object const &args)
     95    std::string TclBind::tcl_orxonox(Tcl::object const &args)
    9796    {
    98 std::cout << "Tcl_execute: args: " << args.get() << std::endl;
     97std::cout << "Tcl_orxonox: args: " << args.get() << std::endl;
    9998        std::string command = args.get();
    10099
     
    111110    }
    112111
    113     void TclBind::execute(Tcl::object const &args)
     112    void TclBind::tcl_execute(Tcl::object const &args)
    114113    {
     114std::cout << "Tcl_execute: args: " << args.get() << std::endl;
     115        std::string command = args.get();
     116
     117        if (command.size() >= 2 && command[0] == '{' && command[command.size() - 1] == '}')
     118            command = command.substr(1, command.size() - 2);
     119
     120        if (!CommandExecutor::execute(command, false))
     121            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
    115122    }
    116123
     
    145152        catch (Tcl::tcl_error const &e)
    146153        {
    147             COUT(1) << "Error: " << e.what() << std::endl;
     154            COUT(1) << "Tcl error: " << e.what() << std::endl;
    148155        }
    149156        catch (std::exception const &e)
Note: See TracChangeset for help on using the changeset viewer.