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)

Location:
code/branches/resource
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/cmake/PackageConfig.cmake

    r3309 r3344  
    4242SET(ENV{OGRE_PLUGIN_DIR}       ${DEP_BINARY_DIR})
    4343SET(ENV{OPENALDIR}             ${DEP_INCLUDE_DIR}/openal-1.1)
    44 LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.2/include)
     44LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/tcl-8.5.7/include)
    4545LIST(APPEND CMAKE_INCLUDE_PATH ${DEP_INCLUDE_DIR}/zlib-1.2.3/include)
     46
     47SET(TCL_LIBRARY_DIR ${DEPENDENCY_PACKAGE_DIR}/tcl)
    4648
    4749### INSTALL ###
  • code/branches/resource/src/SpecialConfig.h.in

    r3196 r3344  
    8888    const char ORXONOX_LOG_DEV_PATH[]         = "@CMAKE_LOG_OUTPUT_DIRECTORY@";
    8989#endif
    90    
     90
    9191    /* OGRE Plugins */
    9292#ifdef NDEBUG
     
    105105#  endif
    106106#endif
     107
     108    /* Tcl */
     109#ifdef DEPENDENCY_PACKAGE_ENABLE
     110    const char ORXONOX_TCL_LIBRARY_PATH[] = "@TCL_LIBRARY_DIR@";
     111#endif
    107112}
    108113
  • 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
  • code/branches/resource/src/core/TclBind.h

    r3196 r3344  
    4949
    5050            void setDataPath(const std::string& datapath);
    51             std::string getTclLibPath() const { return this->tclLibPath_; }
    52             void createTclInterpreter();
    53             void createNewTclInterpreter();
     51            const std::string& getTclDataPath() const { return this->tclDataPath_; }
     52            void initializeTclInterpreter();
     53            static Tcl::interpreter* createTclInterpreter();
    5454            Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; }
    5555
     
    6363
    6464            Tcl::interpreter* interpreter_;
    65             std::string tclLibPath_;
    66             bool bSetTclLibPath_;
     65            std::string tclDataPath_;
     66            bool bSetTclDataPath_;
    6767
    6868            static TclBind* singletonRef_s;
  • code/branches/resource/src/core/TclThreadManager.cc

    r3326 r3344  
    240240        TclInterpreterBundle* newbundle = new TclInterpreterBundle();
    241241        newbundle->id_ = id;
    242         newbundle->interpreter_ = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
     242        newbundle->interpreter_ = TclBind::createTclInterpreter();
    243243
    244244        // Initialize the new interpreter
     
    268268
    269269            // Redefine some native functions
    270             newbundle->interpreter_->eval("redef_puts");
    271 
    272270//            newbundle->interpreter_->eval("rename while tcl::while");
    273271//            newbundle->interpreter_->eval("proc while {test command} { tcl::while {[uplevel 1 expr $test]} {uplevel 1 $command} }"); // (\"$test\" && [orxonox::running " + id + "]])
Note: See TracChangeset for help on using the changeset viewer.