[Orxonox-commit 2492] r7199 - in code/branches/consolecommands3/src/libraries/core: . input

landauf at orxonox.net landauf at orxonox.net
Sat Aug 21 22:20:09 CEST 2010


Author: landauf
Date: 2010-08-21 22:20:09 +0200 (Sat, 21 Aug 2010)
New Revision: 7199

Modified:
   code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
   code/branches/consolecommands3/src/libraries/core/LuaState.cc
   code/branches/consolecommands3/src/libraries/core/LuaState.h
   code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc
   code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h
Log:
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.

Modified: code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/CorePrereqs.h	2010-08-21 19:52:13 UTC (rev 7198)
+++ code/branches/consolecommands3/src/libraries/core/CorePrereqs.h	2010-08-21 20:20:09 UTC (rev 7199)
@@ -163,6 +163,7 @@
     template <class T>
     class Iterator;
     class Language;
+    class LuaFunctor;
     class LuaState;
     class MemoryArchive;
     class MemoryArchiveFactory;

Modified: code/branches/consolecommands3/src/libraries/core/LuaState.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/LuaState.cc	2010-08-21 19:52:13 UTC (rev 7198)
+++ code/branches/consolecommands3/src/libraries/core/LuaState.cc	2010-08-21 20:20:09 UTC (rev 7199)
@@ -369,9 +369,8 @@
         this->lua_ = luaState;
     }
 
-    MultiType LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    void LuaFunctor::operator()()
     {
         lua_->doString(this->code_);
-        return MT_Type::Null;
     }
 }

Modified: code/branches/consolecommands3/src/libraries/core/LuaState.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/LuaState.h	2010-08-21 19:52:13 UTC (rev 7198)
+++ code/branches/consolecommands3/src/libraries/core/LuaState.h	2010-08-21 20:20:09 UTC (rev 7199)
@@ -39,29 +39,19 @@
 #include <boost/shared_ptr.hpp>
 
 #include "util/ScopeGuard.h"
-#include "Functor.h"
 #include "ToluaInterface.h"
 
 namespace orxonox // tolua_export
 { // tolua_export
-    class Functor; // tolua_export
+    class LuaFunctor; // tolua_export
 
-    //! Functor subclass that simply executes code with 0 arguments.
-    class _CoreExport LuaFunctor : public Functor
+    //! callback class that executes lua code
+    class _CoreExport LuaFunctor
     {
         public:
             LuaFunctor(const std::string& code, LuaState* luaState);
-            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);
-            void evaluateParam(unsigned int index, MultiType& param) const {}
+            void operator()();
 
-            Functor::Type::Enum getType() const { return Functor::Type::Lua; } \
-            unsigned int getParamCount() const { return 0; }
-            bool hasReturnvalue() const { return 0; }
-            std::string getTypenameParam(unsigned int param) const { return BLANKSTRING; }
-            std::string getTypenameReturnvalue() const { return BLANKSTRING; }
-
-            const std::type_info& getHeaderIdentifier() const { return typeid(this); }
-
         private:
             std::string code_;
             LuaState*   lua_;
@@ -98,7 +88,7 @@
         void setDefaultResourceInfo(const shared_ptr<ResourceInfo>& sourceFileInfo) { this->sourceFileInfo_ = sourceFileInfo; }
         const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
 
-        Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
+        LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
         //! Tells about whether IOConsole was activated. The Lua debugger only works with a normal console.
         bool usingIOConsole() const; // tolua_export
 

Modified: code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc	2010-08-21 19:52:13 UTC (rev 7198)
+++ code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc	2010-08-21 20:20:09 UTC (rev 7199)
@@ -33,6 +33,7 @@
 #include "core/ConfigValueIncludes.h"
 #include "core/ConsoleCommand.h"
 #include "core/CoreIncludes.h"
+#include "core/LuaState.h"
 #include "core/ScopedSingletonManager.h"
 #include "InputManager.h"
 #include "KeyDetector.h"
@@ -186,4 +187,9 @@
         }
         // else: A key was probably pressed within the same tick, ignore it.
     }
+
+    void KeyBinderManager::registerKeybindCallback(LuaFunctor* function)
+    {
+        this->callbackFunction_ = function;
+    }
 }

Modified: code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h	2010-08-21 19:52:13 UTC (rev 7198)
+++ code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.h	2010-08-21 20:20:09 UTC (rev 7199)
@@ -98,7 +98,7 @@
             { this->keybindInternal(command, true); }
         void unbind(const std::string& binding); //tolua_export
         void tunbind(const std::string& binding);
-        inline void registerKeybindCallback(const FunctorPtr& function) { this->callbackFunction_ = function; } // tolua//_//export // <-- FIXME
+        void registerKeybindCallback(LuaFunctor* function); //tolua_export
 
     private:
         KeyBinderManager(const KeyBinderManager&);
@@ -113,7 +113,7 @@
         std::string defaultFilename_;                //! Name of the file with the default key bindings
 
         // keybind command related
-        FunctorPtr callbackFunction_;                //! Function to be called when key was pressed after "keybind" command
+        SharedPtr<LuaFunctor> callbackFunction_;     //! Function to be called when key was pressed after "keybind" command
         bool bBinding_;                              //! Tells whether a key binding process is active
         bool bTemporary_;                            //! Stores tkeybind/keybind value
         std::string command_;                        //! Stores the command received by (t)keybind




More information about the Orxonox-commit mailing list