Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 24, 2009, 6:00:36 PM (15 years ago)
Author:
landauf
Message:

tcl uses it's native library, orxonox adds new features later (defined in media/tcl/init.tcl)

File:
1 edited

Legend:

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

    r3318 r3344  
    3838#include "ConsoleCommand.h"
    3939#include "TclThreadManager.h"
     40#include "SpecialConfig.h"
    4041
    4142namespace orxonox
     
    5152        singletonRef_s = this;
    5253        this->interpreter_ = 0;
    53         this->bSetTclLibPath_ = false;
     54        this->bSetTclDataPath_ = false;
    5455        this->setDataPath(datapath);
    5556    }
     
    6566    {
    6667        // String has POSIX slashes
    67         this->tclLibPath_ = datapath + "tcl" + TCL_VERSION + '/';
    68         this->bSetTclLibPath_ = true;
     68        this->tclDataPath_ = datapath + "tcl" + '/';
     69        this->bSetTclDataPath_ = true;
    6970
    70         this->createTclInterpreter();
     71        this->initializeTclInterpreter();
    7172    }
    7273
    73     void TclBind::createTclInterpreter()
     74    void TclBind::initializeTclInterpreter()
    7475    {
    75         if (this->bSetTclLibPath_ && !this->interpreter_)
     76        if (this->bSetTclDataPath_ && !this->interpreter_)
    7677        {
    77             this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
     78            this->interpreter_ = this->createTclInterpreter();
     79
    7880            this->interpreter_->def("orxonox::query", TclBind::tcl_query, Tcl::variadic());
    7981            this->interpreter_->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
     
    8890                this->interpreter_->eval("set id 0");
    8991                this->interpreter_->eval("rename exit tcl::exit; proc exit {} { execute exit }");
    90                 this->interpreter_->eval("redef_puts");
    9192            }
    9293            catch (Tcl::tcl_error const &e)
     
    9495            catch (std::exception const &e)
    9596            {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
     97            catch (...)
     98            {   COUT(1) << "Error while creating Tcl-interpreter." << std::endl;   }
    9699        }
    97100    }
    98101
    99     void TclBind::createNewTclInterpreter()
     102    Tcl::interpreter* TclBind::createTclInterpreter()
    100103    {
    101         if (this->interpreter_)
     104#ifdef DEPENDENCY_PACKAGE_ENABLE
     105        Tcl::interpreter* interpreter = new Tcl::interpreter(ORXONOX_TCL_LIBRARY_PATH);
     106#else
     107        Tcl::interpreter* interpreter = new Tcl::interpreter();
     108#endif
     109        try
    102110        {
    103             delete this->interpreter_;
    104             this->interpreter_ = 0;
     111            interpreter->eval("source " + TclBind::getInstance().tclDataPath_ + "/init.tcl");
    105112        }
     113        catch (Tcl::tcl_error const &e)
     114        {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
     115        catch (std::exception const &e)
     116        {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
     117        catch (...)
     118        {   COUT(1) << "Error while creating Tcl-interpreter." << std::endl;   }
    106119
    107         this->createTclInterpreter();
     120        return interpreter;
    108121    }
    109122
Note: See TracChangeset for help on using the changeset viewer.