Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 27, 2008, 10:22:32 PM (16 years ago)
Author:
landauf
Message:

CommandExecutor uses Tcl

File:
1 edited

Legend:

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

    r1194 r1198  
    7171            this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
    7272            this->interpreter_->def("puts", TclBind::puts, Tcl::variadic());
     73            this->interpreter_->def("orxonox", TclBind::orxonox, Tcl::variadic());
    7374            this->interpreter_->def("execute", TclBind::execute, Tcl::variadic());
    74             this->interpreter_->eval("proc unknown {args} { return [execute $args] }");
     75            this->interpreter_->eval("proc unknown {args} { return [orxonox $args] }");
     76            this->interpreter_->eval("rename exit tclexit; proc exit {} { orxonox exit }");
    7577        }
    7678    }
     
    9294    }
    9395
    94     std::string TclBind::execute(Tcl::object const &args)
     96    std::string TclBind::orxonox(Tcl::object const &args)
    9597    {
    9698std::cout << "Tcl_execute: args: " << args.get() << std::endl;
     
    100102            command = command.substr(1, command.size() - 2);
    101103
    102         if (!CommandExecutor::execute(command))
     104        if (!CommandExecutor::execute(command, false))
    103105            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
    104106
     
    107109
    108110        return "";
     111    }
     112
     113    void TclBind::execute(Tcl::object const &args)
     114    {
    109115    }
    110116
     
    129135        return "";
    130136    }
     137
     138    bool TclBind::eval(const std::string& tclcode)
     139    {
     140        try
     141        {
     142            TclBind::getInstance().interpreter_->eval(tclcode);
     143            return true;
     144        }
     145        catch (Tcl::tcl_error const &e)
     146        {
     147            COUT(1) << "Error: " << e.what() << std::endl;
     148        }
     149        catch (std::exception const &e)
     150        {
     151            COUT(1) << "Error while executing tcl: " << e.what() << std::endl;
     152        }
     153
     154        return false;
     155    }
    131156}
Note: See TracChangeset for help on using the changeset viewer.