Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7199


Ignore:
Timestamp:
Aug 21, 2010, 10:20:09 PM (14 years ago)
Author:
landauf
Message:

LuaFunctor better doesn't inherit from Functor since it's used completely differently. Saves us the hassle of exporting FunctorPtr to Lua and a bunch of useless functions.

Location:
code/branches/consolecommands3/src/libraries/core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/CorePrereqs.h

    r7197 r7199  
    164164    class Iterator;
    165165    class Language;
     166    class LuaFunctor;
    166167    class LuaState;
    167168    class MemoryArchive;
  • code/branches/consolecommands3/src/libraries/core/LuaState.cc

    r7189 r7199  
    370370    }
    371371
    372     MultiType LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
     372    void LuaFunctor::operator()()
    373373    {
    374374        lua_->doString(this->code_);
    375         return MT_Type::Null;
    376375    }
    377376}
  • code/branches/consolecommands3/src/libraries/core/LuaState.h

    r7189 r7199  
    4040
    4141#include "util/ScopeGuard.h"
    42 #include "Functor.h"
    4342#include "ToluaInterface.h"
    4443
    4544namespace orxonox // tolua_export
    4645{ // tolua_export
    47     class Functor; // tolua_export
     46    class LuaFunctor; // tolua_export
    4847
    49     //! Functor subclass that simply executes code with 0 arguments.
    50     class _CoreExport LuaFunctor : public Functor
     48    //! callback class that executes lua code
     49    class _CoreExport LuaFunctor
    5150    {
    5251        public:
    5352            LuaFunctor(const std::string& code, LuaState* luaState);
    54             MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
    55             void evaluateParam(unsigned int index, MultiType& param) const {}
    56 
    57             Functor::Type::Enum getType() const { return Functor::Type::Lua; } \
    58             unsigned int getParamCount() const { return 0; }
    59             bool hasReturnvalue() const { return 0; }
    60             std::string getTypenameParam(unsigned int param) const { return BLANKSTRING; }
    61             std::string getTypenameReturnvalue() const { return BLANKSTRING; }
    62 
    63             const std::type_info& getHeaderIdentifier() const { return typeid(this); }
     53            void operator()();
    6454
    6555        private:
     
    9989        const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
    10090
    101         Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
     91        LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
    10292        //! Tells about whether IOConsole was activated. The Lua debugger only works with a normal console.
    10393        bool usingIOConsole() const; // tolua_export
  • code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc

    r7198 r7199  
    3434#include "core/ConsoleCommand.h"
    3535#include "core/CoreIncludes.h"
     36#include "core/LuaState.h"
    3637#include "core/ScopedSingletonManager.h"
    3738#include "InputManager.h"
     
    187188        // else: A key was probably pressed within the same tick, ignore it.
    188189    }
     190
     191    void KeyBinderManager::registerKeybindCallback(LuaFunctor* function)
     192    {
     193        this->callbackFunction_ = function;
     194    }
    189195}
  • code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h

    r7198 r7199  
    9999        void unbind(const std::string& binding); //tolua_export
    100100        void tunbind(const std::string& binding);
    101         inline void registerKeybindCallback(const FunctorPtr& function) { this->callbackFunction_ = function; } // tolua//_//export // <-- FIXME
     101        void registerKeybindCallback(LuaFunctor* function); //tolua_export
    102102
    103103    private:
     
    114114
    115115        // keybind command related
    116         FunctorPtr callbackFunction_;                //! Function to be called when key was pressed after "keybind" command
     116        SharedPtr<LuaFunctor> callbackFunction_;     //! Function to be called when key was pressed after "keybind" command
    117117        bool bBinding_;                              //! Tells whether a key binding process is active
    118118        bool bTemporary_;                            //! Stores tkeybind/keybind value
Note: See TracChangeset for help on using the changeset viewer.