[4838] | 1 | /*! |
---|
[5632] | 2 | * @file executor.h |
---|
[5068] | 3 | * Definition of a on-screen-shell |
---|
[5391] | 4 | */ |
---|
[1853] | 5 | |
---|
[8271] | 6 | #ifndef _EXECUTOR_LUA_H |
---|
| 7 | #define _EXECUTOR_LUA_H |
---|
[1853] | 8 | |
---|
[5651] | 9 | #include "executor.h" |
---|
[7711] | 10 | #include "compiler.h" |
---|
[8271] | 11 | #include "debug.h" |
---|
[8051] | 12 | #include "luaincl.h" |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | |
---|
[8408] | 16 | template<typename type> type fromLua(lua_State* state, int index); |
---|
[8271] | 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); |
---|
[8051] | 23 | |
---|
[8408] | 24 | template<typename type> void toLua(lua_State* state, type value); |
---|
[8271] | 25 | template<> void toLua<bool>(lua_State* state, bool value); |
---|
| 26 | template<> void toLua<int>(lua_State* state, int value); |
---|
| 27 | template<> void toLua<unsigned int>(lua_State* state, unsigned int value); |
---|
| 28 | template<> void toLua<float>(lua_State* state, float value); |
---|
| 29 | template<> void toLua<char>(lua_State* state, char value); |
---|
| 30 | template<> void toLua<const std::string&>(lua_State* state, const std::string& value); |
---|
[8057] | 31 | |
---|
[4838] | 32 | // FORWARD DECLARATION |
---|
[3543] | 33 | |
---|
[8271] | 34 | /////////////////////// |
---|
| 35 | ///// WITHOUT RET ///// |
---|
| 36 | /////////////////////// |
---|
[8051] | 37 | |
---|
| 38 | /////////// |
---|
| 39 | //// 0 //// |
---|
| 40 | /////////// |
---|
[8271] | 41 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 42 | template<class T> class ExecutorLua0 : public Executor<lua_State*> |
---|
[5170] | 43 | { |
---|
[9727] | 44 | public: |
---|
| 45 | /** |
---|
| 46 | * @brief Constructor of a ExecutorXML |
---|
| 47 | * @param function a Function to call |
---|
| 48 | */ |
---|
| 49 | ExecutorLua0(void(T::*function)()) |
---|
| 50 | : Executor<lua_State*>(false) |
---|
| 51 | { |
---|
| 52 | this->functionPointer = function; |
---|
| 53 | this->functorType = Executor_Objective; |
---|
| 54 | } |
---|
[8051] | 55 | |
---|
| 56 | |
---|
[9727] | 57 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 58 | { |
---|
| 59 | (dynamic_cast<T*>(object)->*(functionPointer))(); |
---|
| 60 | } |
---|
[8051] | 61 | |
---|
[9727] | 62 | /** |
---|
| 63 | * @returns a _new_ Copy of this Executor |
---|
| 64 | */ |
---|
| 65 | virtual Executor<lua_State*>* clone () const |
---|
| 66 | { |
---|
| 67 | return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); |
---|
| 68 | } |
---|
| 69 | private: |
---|
| 70 | void (T::*functionPointer)(); |
---|
[8051] | 71 | }; |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | /////////// |
---|
| 76 | //// 1 //// |
---|
| 77 | /////////// |
---|
[8271] | 78 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 79 | template<class T, typename type0> class ExecutorLua1 : public Executor<lua_State*> |
---|
[8051] | 80 | { |
---|
[9727] | 81 | public: |
---|
| 82 | /** |
---|
| 83 | * @brief Constructor of a ExecutorXML |
---|
| 84 | * @param function a Function to call |
---|
| 85 | */ |
---|
| 86 | ExecutorLua1(void(T::*function)(type0)) |
---|
| 87 | : Executor<lua_State*>(false, ExecutorParamType<type0>()) |
---|
| 88 | { |
---|
| 89 | this->functionPointer = function; |
---|
| 90 | this->functorType = Executor_Objective; |
---|
| 91 | } |
---|
[5164] | 92 | |
---|
[9727] | 93 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 94 | { |
---|
| 95 | (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1)); |
---|
| 96 | } |
---|
[8057] | 97 | |
---|
[9727] | 98 | /** |
---|
| 99 | * @returns a _new_ Copy of this Executor |
---|
| 100 | */ |
---|
| 101 | virtual Executor<lua_State*>* clone () const |
---|
| 102 | { |
---|
| 103 | return new ExecutorLua1<T, type0>((this->functionPointer)); |
---|
| 104 | } |
---|
| 105 | private: |
---|
| 106 | void (T::*functionPointer)(type0); |
---|
[8057] | 107 | }; |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | /////////// |
---|
| 112 | //// 2 //// |
---|
| 113 | /////////// |
---|
[8271] | 114 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 115 | template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor<lua_State*> |
---|
[8057] | 116 | { |
---|
[9727] | 117 | public: |
---|
| 118 | /** |
---|
| 119 | * @brief Constructor of a ExecutorXML |
---|
| 120 | * @param function a Function to call |
---|
| 121 | */ |
---|
| 122 | ExecutorLua2(void(T::*function)(type0, type1)) |
---|
| 123 | : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>()) |
---|
| 124 | { |
---|
| 125 | this->functionPointer = function; |
---|
| 126 | this->functorType = Executor_Objective; |
---|
| 127 | } |
---|
[8057] | 128 | |
---|
[9727] | 129 | /** |
---|
| 130 | * @brief executes the Command on BaseObject |
---|
| 131 | * @param object the BaseObject to execute this Executor on |
---|
| 132 | * @param loadString ignored in this case |
---|
| 133 | */ |
---|
| 134 | virtual void operator()(BaseObject* object, const SubString& = SubString()) const |
---|
| 135 | { |
---|
| 136 | PRINTF(1)("no usefull executor\n"); |
---|
| 137 | } |
---|
[5113] | 138 | |
---|
[9727] | 139 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 140 | { |
---|
| 141 | (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 142 | fromLua<type0>(state, 1), |
---|
[9006] | 143 | fromLua<type1>(state, 2) ); |
---|
[9727] | 144 | } |
---|
[8035] | 145 | |
---|
[9727] | 146 | /** |
---|
| 147 | * @returns a _new_ Copy of this Executor |
---|
| 148 | */ |
---|
| 149 | virtual Executor<lua_State*>* clone () const |
---|
| 150 | { |
---|
| 151 | return new ExecutorLua2<T, type0, type1>(this->functionPointer); |
---|
| 152 | } |
---|
| 153 | private: |
---|
| 154 | void (T::*functionPointer)(type0, type1); |
---|
[8051] | 155 | }; |
---|
[5632] | 156 | |
---|
[5326] | 157 | |
---|
[8711] | 158 | /////////// |
---|
| 159 | //// 3 //// |
---|
| 160 | /////////// |
---|
| 161 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 162 | template<class T, typename type0, typename type1, typename type2> class ExecutorLua3 : public Executor<lua_State*> |
---|
[8711] | 163 | { |
---|
[9727] | 164 | public: |
---|
| 165 | /** |
---|
| 166 | * @brief Constructor of a ExecutorXML |
---|
| 167 | * @param function a Function to call |
---|
| 168 | */ |
---|
| 169 | ExecutorLua3(void(T::*function)(type0, type1, type2)) |
---|
| 170 | : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) |
---|
| 171 | { |
---|
| 172 | this->functionPointer = function; |
---|
| 173 | this->functorType = Executor_Objective; |
---|
| 174 | } |
---|
[8057] | 175 | |
---|
[9727] | 176 | /** |
---|
| 177 | * @brief executes the Command on BaseObject |
---|
| 178 | * @param object the BaseObject to execute this Executor on |
---|
| 179 | * @param loadString ignored in this case |
---|
| 180 | */ |
---|
| 181 | virtual void operator()(BaseObject* object, const SubString& = SubString()) const |
---|
| 182 | { |
---|
| 183 | PRINTF(1)("no usefull executor\n"); |
---|
| 184 | } |
---|
[8271] | 185 | |
---|
[9727] | 186 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 187 | { |
---|
| 188 | (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 189 | fromLua<type0>(state, 1), |
---|
[9006] | 190 | fromLua<type1>(state, 2), |
---|
| 191 | fromLua<type2>(state, 3) ); |
---|
[9727] | 192 | } |
---|
[8271] | 193 | |
---|
[9727] | 194 | /** |
---|
| 195 | * @returns a _new_ Copy of this Executor |
---|
| 196 | */ |
---|
| 197 | virtual Executor<lua_State*>* clone () const |
---|
| 198 | { |
---|
| 199 | return new ExecutorLua3<T, type0, type1, type2>(this->functionPointer); |
---|
| 200 | } |
---|
| 201 | private: |
---|
| 202 | void (T::*functionPointer)(type0, type1, type2); |
---|
[8711] | 203 | }; |
---|
[8271] | 204 | |
---|
[8711] | 205 | |
---|
[8894] | 206 | /////////// |
---|
| 207 | //// 4 //// |
---|
| 208 | /////////// |
---|
| 209 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 210 | template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor<lua_State*> |
---|
[8894] | 211 | { |
---|
[9727] | 212 | public: |
---|
| 213 | /** |
---|
| 214 | * @brief Constructor of a ExecutorXML |
---|
| 215 | * @param function a Function to call |
---|
| 216 | */ |
---|
| 217 | ExecutorLua4(void(T::*function)(type0, type1, type2, type3)) |
---|
| 218 | : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) |
---|
| 219 | { |
---|
| 220 | this->functionPointer = function; |
---|
| 221 | this->functorType = Executor_Objective; |
---|
| 222 | } |
---|
[8711] | 223 | |
---|
[9727] | 224 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 225 | { |
---|
| 226 | (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 227 | fromLua<type0>(state, 1), |
---|
[9006] | 228 | fromLua<type1>(state, 2), |
---|
| 229 | fromLua<type2>(state, 3), |
---|
| 230 | fromLua<type3>(state, 4) ); |
---|
[9727] | 231 | } |
---|
[8711] | 232 | |
---|
[9727] | 233 | /** |
---|
| 234 | * @returns a _new_ Copy of this Executor |
---|
| 235 | */ |
---|
| 236 | virtual Executor<lua_State*>* clone () const |
---|
| 237 | { |
---|
| 238 | return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer); |
---|
| 239 | } |
---|
| 240 | private: |
---|
| 241 | void (T::*functionPointer)(type0, type1, type2, type3); |
---|
[8894] | 242 | }; |
---|
| 243 | |
---|
| 244 | |
---|
| 245 | |
---|
| 246 | |
---|
[8271] | 247 | //////////////////// |
---|
| 248 | ///// WITH RET ///// |
---|
| 249 | //////////////////// |
---|
| 250 | |
---|
| 251 | |
---|
| 252 | /////////// |
---|
| 253 | //// 0 //// |
---|
| 254 | /////////// |
---|
| 255 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 256 | template<class T, typename ret> class ExecutorLua0ret : public Executor<lua_State*> |
---|
[8271] | 257 | { |
---|
[9727] | 258 | public: |
---|
| 259 | /** |
---|
| 260 | * @brief Constructor of a ExecutorXML |
---|
| 261 | * @param function a Function to call |
---|
| 262 | */ |
---|
| 263 | ExecutorLua0ret(ret (T::*function)()) |
---|
| 264 | : Executor<lua_State*>(true) |
---|
| 265 | { |
---|
| 266 | this->functionPointer = function; |
---|
| 267 | this->functorType = Executor_Objective; |
---|
| 268 | } |
---|
[8271] | 269 | |
---|
[9727] | 270 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 271 | { |
---|
| 272 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))()); |
---|
| 273 | } |
---|
[8271] | 274 | |
---|
[9727] | 275 | /** |
---|
| 276 | * @returns a _new_ Copy of this Executor |
---|
| 277 | */ |
---|
| 278 | virtual Executor<lua_State*>* clone () const |
---|
| 279 | { |
---|
| 280 | return new ExecutorLua0ret<T, ret>(this->functionPointer); |
---|
| 281 | } |
---|
| 282 | private: |
---|
| 283 | ret (T::*functionPointer)(); |
---|
[8271] | 284 | }; |
---|
| 285 | |
---|
| 286 | |
---|
| 287 | |
---|
| 288 | /////////// |
---|
| 289 | //// 1 //// |
---|
| 290 | /////////// |
---|
| 291 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 292 | template<class T, typename ret, typename type0> class ExecutorLua1ret : public Executor<lua_State*> |
---|
[8271] | 293 | { |
---|
[9727] | 294 | public: |
---|
| 295 | /** |
---|
| 296 | * @brief Constructor of a ExecutorXML |
---|
| 297 | * @param function a Function to call |
---|
| 298 | */ |
---|
| 299 | ExecutorLua1ret(ret (T::*function)(type0)) |
---|
| 300 | : Executor<lua_State*>(true, ExecutorParamType<type0>()) |
---|
| 301 | { |
---|
| 302 | this->functionPointer = function; |
---|
| 303 | this->functorType = Executor_Objective; |
---|
| 304 | } |
---|
[8271] | 305 | |
---|
[9727] | 306 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 307 | { |
---|
| 308 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 309 | fromLua<type0>(state, 1))); |
---|
| 310 | } |
---|
[8271] | 311 | |
---|
[9727] | 312 | /** |
---|
| 313 | * @returns a _new_ Copy of this Executor |
---|
| 314 | */ |
---|
| 315 | virtual Executor<lua_State*>* clone () const |
---|
| 316 | { |
---|
| 317 | return new ExecutorLua1ret<T, ret, type0>(this->functionPointer); |
---|
| 318 | } |
---|
| 319 | private: |
---|
| 320 | ret (T::*functionPointer)(type0); |
---|
[8271] | 321 | }; |
---|
| 322 | |
---|
| 323 | /////////// |
---|
| 324 | //// 2 //// |
---|
| 325 | /////////// |
---|
| 326 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 327 | template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor<lua_State*> |
---|
[8271] | 328 | { |
---|
[9727] | 329 | public: |
---|
| 330 | /** |
---|
| 331 | * @brief Constructor of a ExecutorXML |
---|
| 332 | * @param function a Function to call |
---|
| 333 | */ |
---|
| 334 | ExecutorLua2ret(ret (T::*function)(type0, type1)) |
---|
| 335 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>()) |
---|
| 336 | { |
---|
| 337 | this->functionPointer = function; |
---|
| 338 | this->functorType = Executor_Objective; |
---|
| 339 | } |
---|
[8271] | 340 | |
---|
[9727] | 341 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 342 | { |
---|
| 343 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 344 | fromLua<type0>(state, 1), |
---|
| 345 | fromLua<type1>(state, 2) )); |
---|
| 346 | } |
---|
[8271] | 347 | |
---|
[9727] | 348 | /** |
---|
| 349 | * @returns a _new_ Copy of this Executor |
---|
| 350 | */ |
---|
| 351 | virtual Executor<lua_State*>* clone () const |
---|
| 352 | { |
---|
| 353 | return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer); |
---|
| 354 | } |
---|
| 355 | private: |
---|
| 356 | ret (T::*functionPointer)(type0, type1); |
---|
[8271] | 357 | }; |
---|
| 358 | |
---|
[8894] | 359 | |
---|
| 360 | /////////// |
---|
| 361 | //// 3 //// |
---|
| 362 | /////////// |
---|
| 363 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 364 | template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor<lua_State*> |
---|
[8894] | 365 | { |
---|
[9727] | 366 | public: |
---|
| 367 | /** |
---|
| 368 | * @brief Constructor of a ExecutorXML |
---|
| 369 | * @param function a Function to call |
---|
| 370 | */ |
---|
| 371 | ExecutorLua3ret(ret (T::*function)(type0, type1, type2)) |
---|
| 372 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) |
---|
| 373 | { |
---|
| 374 | this->functionPointer = function; |
---|
| 375 | this->functorType = Executor_Objective; |
---|
| 376 | } |
---|
[8894] | 377 | |
---|
[9727] | 378 | /** |
---|
| 379 | * @brief executes the Command on BaseObject |
---|
| 380 | * @param object the BaseObject to execute this Executor on |
---|
| 381 | * @param loadString ignored in this case |
---|
| 382 | */ |
---|
| 383 | virtual void operator()(BaseObject* object, const SubString& = SubString()) const |
---|
| 384 | { |
---|
| 385 | PRINTF(1)("no usefull executor\n"); |
---|
| 386 | } |
---|
[8894] | 387 | |
---|
[9727] | 388 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 389 | { |
---|
| 390 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 391 | fromLua<type0>(state, 1), |
---|
| 392 | fromLua<type1>(state, 2), |
---|
| 393 | fromLua<type2>(state, 3) )); |
---|
| 394 | } |
---|
[8894] | 395 | |
---|
[9727] | 396 | /** |
---|
| 397 | * @returns a _new_ Copy of this Executor |
---|
| 398 | */ |
---|
| 399 | virtual Executor<lua_State*>* clone () const |
---|
| 400 | { |
---|
| 401 | return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer); |
---|
| 402 | } |
---|
| 403 | private: |
---|
| 404 | ret (T::*functionPointer)(type0, type1, type2); |
---|
[8894] | 405 | }; |
---|
| 406 | |
---|
| 407 | |
---|
| 408 | /////////// |
---|
| 409 | //// 4 //// |
---|
| 410 | /////////// |
---|
| 411 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 412 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor<lua_State*> |
---|
[8894] | 413 | { |
---|
[9727] | 414 | public: |
---|
| 415 | /** |
---|
| 416 | * @brief Constructor of a ExecutorXML |
---|
| 417 | * @param function a Function to call |
---|
| 418 | */ |
---|
| 419 | ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3)) |
---|
| 420 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) |
---|
| 421 | { |
---|
| 422 | this->functionPointer = function; |
---|
| 423 | this->functorType = Executor_Objective; |
---|
| 424 | } |
---|
[8894] | 425 | |
---|
[9727] | 426 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 427 | { |
---|
| 428 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 429 | fromLua<type0>(state, 1), |
---|
| 430 | fromLua<type1>(state, 2), |
---|
| 431 | fromLua<type2>(state, 3), |
---|
| 432 | fromLua<type3>(state, 4) )); |
---|
| 433 | } |
---|
[8894] | 434 | |
---|
[9727] | 435 | /** |
---|
| 436 | * @returns a _new_ Copy of this Executor |
---|
| 437 | */ |
---|
| 438 | virtual Executor<lua_State*>* clone () const |
---|
| 439 | { |
---|
| 440 | return new ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer); |
---|
| 441 | } |
---|
| 442 | private: |
---|
| 443 | ret (T::*functionPointer)(type0, type1, type2, type3); |
---|
[8894] | 444 | }; |
---|
| 445 | |
---|
| 446 | /////////// |
---|
| 447 | //// 5 //// |
---|
| 448 | /////////// |
---|
| 449 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 450 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor<lua_State*> |
---|
[8894] | 451 | { |
---|
[9727] | 452 | public: |
---|
| 453 | /** |
---|
| 454 | * @brief Constructor of a ExecutorXML |
---|
| 455 | * @param function a Function to call |
---|
| 456 | */ |
---|
| 457 | ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4)) |
---|
| 458 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) |
---|
| 459 | { |
---|
| 460 | this->functionPointer = function; |
---|
| 461 | this->functorType = Executor_Objective; |
---|
| 462 | } |
---|
[8894] | 463 | |
---|
[9727] | 464 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 465 | { |
---|
| 466 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 467 | fromLua<type0>(state, 1), |
---|
| 468 | fromLua<type1>(state, 2), |
---|
| 469 | fromLua<type2>(state, 3), |
---|
| 470 | fromLua<type3>(state, 4), |
---|
| 471 | fromLua<type4>(state, 5) )); |
---|
| 472 | } |
---|
[8894] | 473 | |
---|
[9727] | 474 | /** |
---|
| 475 | * @returns a _new_ Copy of this Executor |
---|
| 476 | */ |
---|
| 477 | virtual Executor<lua_State*>* clone () const |
---|
| 478 | { |
---|
| 479 | return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer); |
---|
| 480 | } |
---|
| 481 | private: |
---|
| 482 | ret (T::*functionPointer)(type0, type1, type2, type3, type4); |
---|
[8894] | 483 | }; |
---|
| 484 | |
---|
| 485 | /////////// |
---|
| 486 | //// 6 //// |
---|
| 487 | /////////// |
---|
| 488 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 489 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor<lua_State*> |
---|
[8894] | 490 | { |
---|
[9727] | 491 | public: |
---|
| 492 | /** |
---|
| 493 | * @brief Constructor of a ExecutorXML |
---|
| 494 | * @param function a Function to call |
---|
| 495 | */ |
---|
| 496 | ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5)) |
---|
| 497 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), |
---|
| 498 | ExecutorParamType<type2>(), ExecutorParamType<type3>(), |
---|
| 499 | ExecutorParamType<type4>(), ExecutorParamType<type5>()) |
---|
| 500 | { |
---|
| 501 | this->functionPointer = function; |
---|
| 502 | this->functorType = Executor_Objective; |
---|
| 503 | } |
---|
[8894] | 504 | |
---|
[9727] | 505 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 506 | { |
---|
| 507 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 508 | fromLua<type0>(state, 1), |
---|
| 509 | fromLua<type1>(state, 2), |
---|
| 510 | fromLua<type2>(state, 3), |
---|
| 511 | fromLua<type3>(state, 4), |
---|
| 512 | fromLua<type4>(state, 5), |
---|
| 513 | fromLua<type5>(state, 6) )); |
---|
| 514 | } |
---|
[8894] | 515 | |
---|
[9727] | 516 | /** |
---|
| 517 | * @returns a _new_ Copy of this Executor |
---|
| 518 | */ |
---|
| 519 | virtual Executor<lua_State*>* clone () const |
---|
| 520 | { |
---|
| 521 | return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer); |
---|
| 522 | } |
---|
| 523 | private: |
---|
| 524 | ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5); |
---|
[8894] | 525 | }; |
---|
| 526 | |
---|
| 527 | /////////// |
---|
| 528 | //// 7 //// |
---|
| 529 | /////////// |
---|
| 530 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 531 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor<lua_State*> |
---|
[8894] | 532 | { |
---|
[9727] | 533 | public: |
---|
| 534 | /** |
---|
| 535 | * @brief Constructor of a ExecutorXML |
---|
| 536 | * @param function a Function to call |
---|
| 537 | */ |
---|
| 538 | ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6)) |
---|
| 539 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), |
---|
| 540 | ExecutorParamType<type2>(), ExecutorParamType<type3>(), |
---|
| 541 | ExecutorParamType<type4>(), ExecutorParamType<type5>(), |
---|
| 542 | ExecutorParamType<type6>()) |
---|
| 543 | { |
---|
| 544 | this->functionPointer = function; |
---|
| 545 | this->functorType = Executor_Objective; |
---|
| 546 | } |
---|
[8894] | 547 | |
---|
[9727] | 548 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 549 | { |
---|
| 550 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 551 | fromLua<type0>(state, 1), |
---|
| 552 | fromLua<type1>(state, 2), |
---|
| 553 | fromLua<type2>(state, 3), |
---|
| 554 | fromLua<type3>(state, 4), |
---|
| 555 | fromLua<type4>(state, 5), |
---|
| 556 | fromLua<type5>(state, 6), |
---|
| 557 | fromLua<type6>(state, 7) )); |
---|
| 558 | } |
---|
[8894] | 559 | |
---|
[9727] | 560 | /** |
---|
| 561 | * @returns a _new_ Copy of this Executor |
---|
| 562 | */ |
---|
| 563 | virtual Executor<lua_State*>* clone () const |
---|
| 564 | { |
---|
| 565 | return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer); |
---|
| 566 | } |
---|
| 567 | private: |
---|
| 568 | ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6); |
---|
[8894] | 569 | }; |
---|
| 570 | |
---|
| 571 | |
---|
[8271] | 572 | #endif /* _EXECUTOR_LUA_H */ |
---|