Changeset 8092 in orxonox.OLD for branches/script_engine/src/lib
- Timestamp:
- Jun 1, 2006, 6:15:11 PM (18 years ago)
- Location:
- branches/script_engine/src/lib
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/gui/gl_gui/signal_connector.cc
r8048 r8092 92 92 { 93 93 if (this->isValid()) 94 (*this->exec)(this->object, 0, NULL); 94 { 95 static int count = 0; 96 (*this->exec)(this->object, count, NULL); 97 } 95 98 } 96 99 … … 102 105 { 103 106 if (exec != NULL && object != NULL) 104 (*this->exec)(this->object, 1, (void*)&value0); 107 { 108 static int count = 1; 109 (*this->exec)(this->object, count, (void*)&value0); 110 } 105 111 } 106 112 … … 114 120 if (exec != NULL && object != NULL) 115 121 { 122 static int count = 2; 116 123 MultiType mt[] = { value0, value1 }; 117 (*this->exec)(this->object, 2, mt);124 (*this->exec)(this->object, count, mt); 118 125 } 119 126 } … … 129 136 if (exec != NULL && object != NULL) 130 137 { 138 static int count = 3; 131 139 MultiType mt[] = { value0, value1, value2 }; 132 (*this->exec)(this->object, 3, mt);140 (*this->exec)(this->object, count, mt); 133 141 } 134 142 } … … 145 153 if (exec != NULL && object != NULL) 146 154 { 155 static int count = 4; 147 156 MultiType mt[] = { value0, value1, value2, value3 }; 148 (*this->exec)(this->object, 4, mt);157 (*this->exec)(this->object, count, mt); 149 158 } 150 159 } … … 162 171 if (exec != NULL && object != NULL) 163 172 { 173 static int count = 5; 164 174 MultiType mt[] = { value0, value1, value2, value3, value4 }; 165 (*this->exec)(this->object, 5, mt);175 (*this->exec)(this->object, count, mt); 166 176 } 167 177 } -
branches/script_engine/src/lib/script_engine/lunar.h
r8073 r8092 6 6 7 7 #include "luaincl.h" 8 #include "executor/executor_lua.h" 8 9 9 10 -
branches/script_engine/src/lib/util/executor/executor.h
r8048 r8092 53 53 // EXECUTE 54 54 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 55 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const = 0;55 virtual void operator()(BaseObject* object, int& count, void* values) const = 0; 56 56 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 57 57 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; -
branches/script_engine/src/lib/util/executor/executor_functional.h
r8048 r8092 123 123 124 124 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 125 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const125 virtual void operator()(BaseObject* object, int& count, void* values) const 126 126 { 127 127 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); … … 163 163 164 164 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 165 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const165 virtual void operator()(BaseObject* object, int& count, void* values) const 166 166 { 167 167 const MultiType* mt = (const MultiType*)values; … … 227 227 228 228 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 229 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const229 virtual void operator()(BaseObject* object, int& count, void* values) const 230 230 { 231 231 const MultiType* mt = (const MultiType*)values; … … 282 282 283 283 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 284 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const284 virtual void operator()(BaseObject* object, int& count, void* values) const 285 285 { 286 286 const MultiType* mt = (const MultiType*)values; … … 340 340 341 341 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 342 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const342 virtual void operator()(BaseObject* object, int& count, void* values) const 343 343 { 344 344 const MultiType* mt = (const MultiType*)values; … … 400 400 401 401 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 402 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const402 virtual void operator()(BaseObject* object, int& count, void* values) const 403 403 { 404 404 const MultiType* mt = (const MultiType*)values; -
branches/script_engine/src/lib/util/executor/executor_lua.cc
r8057 r8092 18 18 #include "executor_lua.h" 19 19 20 template<> bool fromLua<bool>(lua_ state* state, int index) { return lua_toboolean(state, index); };21 template<> int fromLua<int>(lua_ state* state, int index) { return (int)lua_toumber(state, index); };22 template<> unsigned int fromLua<unsigned int>(lua_ state* state, int index) { return (unsigned int)lua_tonumber(state, index); };23 template<> float fromLua<float>(lua_ state* state, int index) { return (float)lua_tonumber(state, index); };24 template<> char fromLua<char>(lua_ state* state, int index) { reutnr (char)lua_tonumber(state, index); };25 template<> const std::string& fromLua<const std::string&>(lua_ state* state, int index) { return lua_tostring(state, index); };20 template<> bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); }; 21 template<> int fromLua<int>(lua_State* state, int index) { return (int)lua_toumber(state, index); }; 22 template<> unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); }; 23 template<> float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); }; 24 template<> char fromLua<char>(lua_State* state, int index) { reutnr (char)lua_tonumber(state, index); }; 25 template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { return lua_tostring(state, index); }; 26 26 27 27 28 28 29 template<> void toLua<bool>(lua_ state* state, bool value) { lua_pushboolean(state, (int) value); };30 template<> void toLua<int>(lua_ state* state, int value) { lua_pushnumber(state, (lua_Number) value); };31 template<> void toLua<unsigned int>(lua_ state* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); };32 template<> void toLua<float>(lua_ state* state, float value) { lua_pushnumber(state, (lua_Number) value); };33 template<> void toLua<char>(lua_ state* state, char value) { lua_pushnumber(state, (lua_Number) value); };34 template<> void toLua<const std::string&>(lua_ state* state, const std::string& value) {lua_pushstring (state, value.c_str()); }29 template<> void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); }; 30 template<> void toLua<int>(lua_State* state, int value) { lua_pushnumber(state, (lua_Number) value); }; 31 template<> void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); }; 32 template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); }; 33 template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); }; 34 template<> void toLua<const std::string&>(lua_State* state, const std::string& value) {lua_pushstring (state, value.c_str()); } -
branches/script_engine/src/lib/util/executor/executor_lua.h
r8057 r8092 9 9 #include "executor.h" 10 10 #include "compiler.h" 11 11 #include "debug.h" 12 12 #include "luaincl.h" 13 13 14 14 15 15 16 template<typename type> type fromLua(lua_ state* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); };17 template<> bool fromLua<bool>(lua_ state* state, int index);18 template<> int fromLua<int>(lua_ state* state, int index);19 template<> unsigned int fromLua<unsigned int>(lua_ state* state, int index);20 template<> float fromLua<float>(lua_ state* state, int index);21 template<> char fromLua<char>(lua_ state* state, int index);22 template<> const std::string& fromLua<const std::string&>(lua_ state* state, int index);23 24 25 template<typename type> void toLua(lua_ state* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); };26 template<> void toLua<bool>(lua_ state* state, bool value);27 template<> void toLua<int>(lua_ state* state, int value);28 template<> void toLua<unsigned int>(lua_ state* state, unsigned int value);29 template<> void toLua<float>(lua_ state* state, float value);30 template<> void toLua<char>(lua_ state* state, char value);31 template<> void toLua<const std::string&>(lua_ state* state, const std::string& value);16 template<typename type> type fromLua(lua_State* state, int index) { PRINTF(1)("NOT IMPLEMENTED\n"); }; 17 template<> bool fromLua<bool>(lua_State* state, int index); 18 template<> int fromLua<int>(lua_State* state, int index); 19 template<> unsigned int fromLua<unsigned int>(lua_State* state, int index); 20 template<> float fromLua<float>(lua_State* state, int index); 21 template<> char fromLua<char>(lua_State* state, int index); 22 template<> const std::string& fromLua<const std::string&>(lua_State* state, int index); 23 24 25 template<typename type> void toLua(lua_State* state, type value) { PRINTF(1)("NOT IMPLEMENTED\n"); }; 26 template<> void toLua<bool>(lua_State* state, bool value); 27 template<> void toLua<int>(lua_State* state, int value); 28 template<> void toLua<unsigned int>(lua_State* state, unsigned int value); 29 template<> void toLua<float>(lua_State* state, float value); 30 template<> void toLua<char>(lua_State* state, char value); 31 template<> void toLua<const std::string&>(lua_State* state, const std::string& value); 32 32 33 33 // FORWARD DECLARATION … … 37 37 //// 0 //// 38 38 /////////// 39 //! Executes a Function with a lua_ state* parameter.39 //! Executes a Function with a lua_State* parameter. 40 40 template<class T> class ExecutorLua0 : public Executor 41 41 { … … 62 62 } 63 63 64 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const64 virtual void operator()(BaseObject* object, int& count, void* values) const 65 65 { 66 66 (dynamic_cast<T*>(object)->*(functionPointer))(); 67 count = 0; 67 68 } 68 69 … … 72 73 virtual Executor* clone () const 73 74 { 74 return =new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));75 return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 75 76 } 76 77 }; … … 81 82 //// 1 //// 82 83 /////////// 83 //! Executes a Function with a lua_ state* parameter.84 //! Executes a Function with a lua_State* parameter. 84 85 template<class T, typename type0> class ExecutorLua1 : public Executor 85 86 { … … 89 90 * @param function a Function to call 90 91 */ 91 ExecutorLua 0(void(T::*function)(type0))92 ExecutorLua1(void(T::*function)(type0)) 92 93 : Executor(ExecutorParamType<type0>()) 93 94 { … … 106 107 } 107 108 108 virtual void operator()(BaseObject* object, unsigned int count, void* values) const 109 { 110 lua_state* state = (lua_state*)values; 109 virtual void operator()(BaseObject* object, int& count, void* values) const 110 { 111 lua_State* state = (lua_State*)values; 112 count = 0; 111 113 112 114 (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1)); … … 118 120 virtual Executor* clone () const 119 121 { 120 return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer));122 return new ExecutorLua1<T, type0>((this->functionPointer)); 121 123 } 122 124 }; … … 127 129 //// 2 //// 128 130 /////////// 129 //! Executes a Function with a lua_ state* parameter.130 template<class T, typename type0, typename type1> class ExecutorLua 1: public Executor131 { 132 public: 133 /** 134 * @brief Constructor of a ExecutorXML 135 * @param function a Function to call 136 */ 137 ExecutorLua 0(void(T::*function)(type0, type1))131 //! Executes a Function with a lua_State* parameter. 132 template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor 133 { 134 public: 135 /** 136 * @brief Constructor of a ExecutorXML 137 * @param function a Function to call 138 */ 139 ExecutorLua2(void(T::*function)(type0, type1)) 138 140 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) 139 141 { … … 152 154 } 153 155 154 virtual void operator()(BaseObject* object, unsigned int count, void* values) const 155 { 156 lua_state* state = (lua_state*)values; 156 virtual void operator()(BaseObject* object, int& count, void* values) const 157 { 158 lua_State* state = (lua_State*)values; 159 count = 0; 157 160 158 161 (dynamic_cast<T*>(object)->*(functionPointer))( … … 166 169 virtual Executor* clone () const 167 170 { 168 return = new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 169 } 170 }; 171 return new ExecutorLua2<T, type0, type1>(this->functionPointer); 172 } 173 }; 174 175 176 177 178 179 180 181 //////////////////// 182 ///// WITH RET ///// 183 //////////////////// 184 185 /////////// 186 //// 2 //// 187 /////////// 188 //! Executes a Function with a lua_State* parameter. 189 template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor 190 { 191 public: 192 /** 193 * @brief Constructor of a ExecutorXML 194 * @param function a Function to call 195 */ 196 ExecutorLua2ret(ret (T::*function)(type0, type1)) 197 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) 198 { 199 this->functionPointer = function; 200 this->functorType = Executor_Objective | Executor_NoLoadString; 201 } 202 203 /** 204 * @brief executes the Command on BaseObject 205 * @param object the BaseObject to execute this Executor on 206 * @param loadString ignored in this case 207 */ 208 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 209 { 210 PRINTF(1)("no usefull executor\n"); 211 } 212 213 virtual void operator()(BaseObject* object, int& count, void* values) const 214 { 215 lua_State* state = (lua_State*)values; 216 count = 1; 217 218 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 219 fromLua<type0>(state, 1), 220 fromLua<type1>(state, 2) )); 221 } 222 223 /** 224 * @returns a _new_ Copy of this Executor 225 */ 226 virtual Executor* clone () const 227 { 228 return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer); 229 } 230 }; 231 232 233 234 171 235 172 236 -
branches/script_engine/src/lib/util/executor/executor_xml.h
r8051 r8092 65 65 } 66 66 67 virtual void operator()(BaseObject* object, unsigned intcount, void* values) const67 virtual void operator()(BaseObject* object, int& count, void* values) const 68 68 { 69 69 PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n");
Note: See TracChangeset
for help on using the changeset viewer.