Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1230


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

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

Location:
code/branches/console
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/cmake/FindBoost.cmake

    r790 r1230  
    101101# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
    102102SET(SUFFIX_FOR_PATH
     103 boost-1_35_0
     104 boost-1_35
    103105 boost-1_34_1
    104106 boost-1_34_0
     
    112114#
    113115IF(WIN32)
    114   SET(Boost_INCLUDE_DIR ../libs/boost_1_33_1)
     116  SET(Boost_INCLUDE_DIR
     117#    ../libs/boost_1_33_1
     118    ../libs/boost_1_35_0
     119  )
    115120ELSE(WIN32)
    116121  FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp PATH_SUFFIXES ${SUFFIX_FOR_PATH} PATHS
     
    187192  gcc-1_33_1
    188193  gcc-mt-1_33_1
     194  mgw34-mt-1_35
    189195)
    190196
  • code/branches/console/src/core/CMakeLists.txt

    r1151 r1230  
    2727  Script.cc
    2828  TclBind.cc
     29  TclThreadManager.cc
    2930)
    3031
     
    3738  ${Lua_LIBRARIES}
    3839  ${OIS_LIBRARIES}
     40  ${Boost_thread_LIBRARIES}
    3941)
  • code/branches/console/src/core/CommandExecutor.cc

    r1198 r1230  
    5050    ConsoleCommandShortcutExtern(exec, AccessLevel::None);
    5151    ConsoleCommandShortcutExtern(echo, AccessLevel::None);
     52    ConsoleCommandShortcutExtern(puts, AccessLevel::None);
    5253
    5354    ConsoleCommandShortcutExtern(read, AccessLevel::None);
     
    9293    std::string echo(const std::string& text)
    9394    {
     95        std::cout << text << std::endl;
    9496        return text;
     97    }
     98
     99    void puts(bool newline, const std::string& text)
     100    {
     101        if (newline)
     102            std::cout << text << std::endl;
     103        else
     104            std::cout << text;
    95105    }
    96106
     
    384394        if (useTcl)
    385395        {
    386             return TclBind::eval(command);
    387         }
    388         else
    389         {
    390             if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
    391                 CommandExecutor::parse(command);
    392 
    393             return CommandExecutor::execute(CommandExecutor::getEvaluation());
    394         }
     396            std::string temp = getLowercase(removeTrailingWhitespaces(command));
     397            if (!(temp.find("tclthread") == 0 || temp.find("tclthreadmanager") == 0))
     398                return TclBind::eval(command);
     399        }
     400
     401        if ((CommandExecutor::getEvaluation().processedCommand_ != command) || (CommandExecutor::getEvaluation().state_ == CS_Uninitialized))
     402            CommandExecutor::parse(command);
     403
     404        return CommandExecutor::execute(CommandExecutor::getEvaluation());
    395405    }
    396406
  • code/branches/console/src/core/CommandExecutor.h

    r1198 r1230  
    6565    void exec(const std::string& filename);
    6666    std::string echo(const std::string& text);
     67    void puts(bool newline, const std::string& test);
    6768
    6869    void write(const std::string& filename, const std::string& text);
  • code/branches/console/src/core/InputBuffer.cc

    r1151 r1230  
    3939    {
    4040        //this->bActivated_ = false;
    41         this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^";
     41        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~";
    4242        this->keyboard_ = InputManager::getSingleton().getKeyboard();
    4343        this->buffer_ = "";
  • code/branches/console/src/core/OutputHandler.cc

    r1062 r1230  
    3838namespace orxonox
    3939{
    40     ConsoleCommandShortcutGeneric(log, createExecutor(createFunctor(&OutputHandler::log), "log", AccessLevel::None));
     40    ConsoleCommandShortcutGeneric(log,     createExecutor(createFunctor(&OutputHandler::log),     "log",     AccessLevel::None));
     41    ConsoleCommandShortcutGeneric(error,   createExecutor(createFunctor(&OutputHandler::error),   "error",   AccessLevel::None));
     42    ConsoleCommandShortcutGeneric(warning, createExecutor(createFunctor(&OutputHandler::warning), "warning", AccessLevel::None));
     43    ConsoleCommandShortcutGeneric(info,    createExecutor(createFunctor(&OutputHandler::info),    "info",    AccessLevel::None));
     44    ConsoleCommandShortcutGeneric(debug,   createExecutor(createFunctor(&OutputHandler::debug),   "debug",   AccessLevel::None));
    4145
    4246    /**
  • code/branches/console/src/core/OutputHandler.h

    r1064 r1230  
    6363            static inline std::string log(const std::string& text)
    6464                { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text + "\n"); return text; }
     65
     66            /** @brief Puts an error on the outstream. @param text The text */
     67            static inline std::string error(const std::string& text)
     68                { OutputHandler::getOutStream().setOutputLevel(1); OutputHandler::getOutStream().output(text + "\n"); return text; }
     69
     70            /** @brief Puts a warning on the outstream. @param text The text */
     71            static inline std::string warning(const std::string& text)
     72                { OutputHandler::getOutStream().setOutputLevel(2); OutputHandler::getOutStream().output(text + "\n"); return text; }
     73
     74            /** @brief Puts an info on the outstream. @param text The text */
     75            static inline std::string info(const std::string& text)
     76                { OutputHandler::getOutStream().setOutputLevel(3); OutputHandler::getOutStream().output(text + "\n"); return text; }
     77
     78            /** @brief Puts some debug output on the outstream. @param text The text */
     79            static inline std::string debug(const std::string& text)
     80                { OutputHandler::getOutStream().setOutputLevel(4); OutputHandler::getOutStream().output(text + "\n"); return text; }
    6581
    6682            /** @brief Returns a reference to the logfile. @return The logfile */
  • 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)
  • code/branches/console/src/core/TclBind.h

    r1216 r1230  
    3636namespace orxonox
    3737{
    38     class TclBind
     38    class _CoreExport TclBind
    3939    {
    4040        public:
    4141            static TclBind& getInstance();
    4242
     43            static std::string tcl(const std::string& tclcode);
     44
    4345            void setDataPath(const std::string& datapath);
     46            std::string getTclLibPath() const { return this->tclLibPath_; }
    4447            void createTclInterpreter();
    4548            void createNewTclInterpreter();
    4649
    47             static void puts(Tcl::object const &args);
    48             static void execute(Tcl::object const &args);
    49             static std::string orxonox(Tcl::object const &args);
    50             static std::string tcl(const std::string& tclcode);
     50            static void tcl_puts(Tcl::object const &args);
     51
     52            static void tcl_execute(Tcl::object const &args);
     53            static std::string tcl_orxonox(Tcl::object const &args);
     54
    5155            static bool eval(const std::string& tclcode);
    5256
Note: See TracChangeset for help on using the changeset viewer.