[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 | } |
---|
[8051] | 54 | |
---|
| 55 | |
---|
[9727] | 56 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 57 | { |
---|
| 58 | (dynamic_cast<T*>(object)->*(functionPointer))(); |
---|
| 59 | } |
---|
[8051] | 60 | |
---|
[9727] | 61 | /** |
---|
| 62 | * @returns a _new_ Copy of this Executor |
---|
| 63 | */ |
---|
| 64 | virtual Executor<lua_State*>* clone () const |
---|
| 65 | { |
---|
| 66 | return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); |
---|
| 67 | } |
---|
| 68 | private: |
---|
| 69 | void (T::*functionPointer)(); |
---|
[8051] | 70 | }; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | /////////// |
---|
| 75 | //// 1 //// |
---|
| 76 | /////////// |
---|
[8271] | 77 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 78 | template<class T, typename type0> class ExecutorLua1 : public Executor<lua_State*> |
---|
[8051] | 79 | { |
---|
[9727] | 80 | public: |
---|
| 81 | /** |
---|
| 82 | * @brief Constructor of a ExecutorXML |
---|
| 83 | * @param function a Function to call |
---|
| 84 | */ |
---|
| 85 | ExecutorLua1(void(T::*function)(type0)) |
---|
| 86 | : Executor<lua_State*>(false, ExecutorParamType<type0>()) |
---|
| 87 | { |
---|
| 88 | this->functionPointer = function; |
---|
| 89 | } |
---|
[5164] | 90 | |
---|
[9727] | 91 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 92 | { |
---|
| 93 | (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1)); |
---|
| 94 | } |
---|
[8057] | 95 | |
---|
[9727] | 96 | /** |
---|
| 97 | * @returns a _new_ Copy of this Executor |
---|
| 98 | */ |
---|
| 99 | virtual Executor<lua_State*>* clone () const |
---|
| 100 | { |
---|
| 101 | return new ExecutorLua1<T, type0>((this->functionPointer)); |
---|
| 102 | } |
---|
| 103 | private: |
---|
| 104 | void (T::*functionPointer)(type0); |
---|
[8057] | 105 | }; |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | /////////// |
---|
| 110 | //// 2 //// |
---|
| 111 | /////////// |
---|
[8271] | 112 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 113 | template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor<lua_State*> |
---|
[8057] | 114 | { |
---|
[9727] | 115 | public: |
---|
| 116 | /** |
---|
| 117 | * @brief Constructor of a ExecutorXML |
---|
| 118 | * @param function a Function to call |
---|
| 119 | */ |
---|
| 120 | ExecutorLua2(void(T::*function)(type0, type1)) |
---|
| 121 | : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>()) |
---|
| 122 | { |
---|
| 123 | this->functionPointer = function; |
---|
| 124 | } |
---|
[8057] | 125 | |
---|
[9727] | 126 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 127 | { |
---|
| 128 | (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 129 | fromLua<type0>(state, 1), |
---|
[9006] | 130 | fromLua<type1>(state, 2) ); |
---|
[9727] | 131 | } |
---|
[8035] | 132 | |
---|
[9727] | 133 | /** |
---|
| 134 | * @returns a _new_ Copy of this Executor |
---|
| 135 | */ |
---|
| 136 | virtual Executor<lua_State*>* clone () const |
---|
| 137 | { |
---|
| 138 | return new ExecutorLua2<T, type0, type1>(this->functionPointer); |
---|
| 139 | } |
---|
| 140 | private: |
---|
| 141 | void (T::*functionPointer)(type0, type1); |
---|
[8051] | 142 | }; |
---|
[5632] | 143 | |
---|
[5326] | 144 | |
---|
[8711] | 145 | /////////// |
---|
| 146 | //// 3 //// |
---|
| 147 | /////////// |
---|
| 148 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 149 | template<class T, typename type0, typename type1, typename type2> class ExecutorLua3 : public Executor<lua_State*> |
---|
[8711] | 150 | { |
---|
[9727] | 151 | public: |
---|
| 152 | /** |
---|
| 153 | * @brief Constructor of a ExecutorXML |
---|
| 154 | * @param function a Function to call |
---|
| 155 | */ |
---|
| 156 | ExecutorLua3(void(T::*function)(type0, type1, type2)) |
---|
| 157 | : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) |
---|
| 158 | { |
---|
| 159 | this->functionPointer = function; |
---|
| 160 | } |
---|
[8057] | 161 | |
---|
[8271] | 162 | |
---|
[9727] | 163 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 164 | { |
---|
| 165 | (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 166 | fromLua<type0>(state, 1), |
---|
[9006] | 167 | fromLua<type1>(state, 2), |
---|
| 168 | fromLua<type2>(state, 3) ); |
---|
[9727] | 169 | } |
---|
[8271] | 170 | |
---|
[9727] | 171 | /** |
---|
| 172 | * @returns a _new_ Copy of this Executor |
---|
| 173 | */ |
---|
| 174 | virtual Executor<lua_State*>* clone () const |
---|
| 175 | { |
---|
| 176 | return new ExecutorLua3<T, type0, type1, type2>(this->functionPointer); |
---|
| 177 | } |
---|
| 178 | private: |
---|
| 179 | void (T::*functionPointer)(type0, type1, type2); |
---|
[8711] | 180 | }; |
---|
[8271] | 181 | |
---|
[8711] | 182 | |
---|
[8894] | 183 | /////////// |
---|
| 184 | //// 4 //// |
---|
| 185 | /////////// |
---|
| 186 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 187 | template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor<lua_State*> |
---|
[8894] | 188 | { |
---|
[9727] | 189 | public: |
---|
| 190 | /** |
---|
| 191 | * @brief Constructor of a ExecutorXML |
---|
| 192 | * @param function a Function to call |
---|
| 193 | */ |
---|
| 194 | ExecutorLua4(void(T::*function)(type0, type1, type2, type3)) |
---|
| 195 | : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) |
---|
| 196 | { |
---|
| 197 | this->functionPointer = function; |
---|
| 198 | } |
---|
[8711] | 199 | |
---|
[9727] | 200 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 201 | { |
---|
| 202 | (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 203 | fromLua<type0>(state, 1), |
---|
[9006] | 204 | fromLua<type1>(state, 2), |
---|
| 205 | fromLua<type2>(state, 3), |
---|
| 206 | fromLua<type3>(state, 4) ); |
---|
[9727] | 207 | } |
---|
[8711] | 208 | |
---|
[9727] | 209 | /** |
---|
| 210 | * @returns a _new_ Copy of this Executor |
---|
| 211 | */ |
---|
| 212 | virtual Executor<lua_State*>* clone () const |
---|
| 213 | { |
---|
| 214 | return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer); |
---|
| 215 | } |
---|
| 216 | private: |
---|
| 217 | void (T::*functionPointer)(type0, type1, type2, type3); |
---|
[8894] | 218 | }; |
---|
| 219 | |
---|
| 220 | |
---|
| 221 | |
---|
| 222 | |
---|
[8271] | 223 | //////////////////// |
---|
| 224 | ///// WITH RET ///// |
---|
| 225 | //////////////////// |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | /////////// |
---|
| 229 | //// 0 //// |
---|
| 230 | /////////// |
---|
| 231 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 232 | template<class T, typename ret> class ExecutorLua0ret : public Executor<lua_State*> |
---|
[8271] | 233 | { |
---|
[9727] | 234 | public: |
---|
| 235 | /** |
---|
| 236 | * @brief Constructor of a ExecutorXML |
---|
| 237 | * @param function a Function to call |
---|
| 238 | */ |
---|
| 239 | ExecutorLua0ret(ret (T::*function)()) |
---|
| 240 | : Executor<lua_State*>(true) |
---|
| 241 | { |
---|
| 242 | this->functionPointer = function; |
---|
| 243 | } |
---|
[8271] | 244 | |
---|
[9727] | 245 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 246 | { |
---|
| 247 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))()); |
---|
| 248 | } |
---|
[8271] | 249 | |
---|
[9727] | 250 | /** |
---|
| 251 | * @returns a _new_ Copy of this Executor |
---|
| 252 | */ |
---|
| 253 | virtual Executor<lua_State*>* clone () const |
---|
| 254 | { |
---|
| 255 | return new ExecutorLua0ret<T, ret>(this->functionPointer); |
---|
| 256 | } |
---|
| 257 | private: |
---|
| 258 | ret (T::*functionPointer)(); |
---|
[8271] | 259 | }; |
---|
| 260 | |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | /////////// |
---|
| 264 | //// 1 //// |
---|
| 265 | /////////// |
---|
| 266 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 267 | template<class T, typename ret, typename type0> class ExecutorLua1ret : public Executor<lua_State*> |
---|
[8271] | 268 | { |
---|
[9727] | 269 | public: |
---|
| 270 | /** |
---|
| 271 | * @brief Constructor of a ExecutorXML |
---|
| 272 | * @param function a Function to call |
---|
| 273 | */ |
---|
| 274 | ExecutorLua1ret(ret (T::*function)(type0)) |
---|
| 275 | : Executor<lua_State*>(true, ExecutorParamType<type0>()) |
---|
| 276 | { |
---|
| 277 | this->functionPointer = function; |
---|
| 278 | } |
---|
[8271] | 279 | |
---|
[9727] | 280 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 281 | { |
---|
| 282 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 283 | fromLua<type0>(state, 1))); |
---|
| 284 | } |
---|
[8271] | 285 | |
---|
[9727] | 286 | /** |
---|
| 287 | * @returns a _new_ Copy of this Executor |
---|
| 288 | */ |
---|
| 289 | virtual Executor<lua_State*>* clone () const |
---|
| 290 | { |
---|
| 291 | return new ExecutorLua1ret<T, ret, type0>(this->functionPointer); |
---|
| 292 | } |
---|
| 293 | private: |
---|
| 294 | ret (T::*functionPointer)(type0); |
---|
[8271] | 295 | }; |
---|
| 296 | |
---|
| 297 | /////////// |
---|
| 298 | //// 2 //// |
---|
| 299 | /////////// |
---|
| 300 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 301 | template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor<lua_State*> |
---|
[8271] | 302 | { |
---|
[9727] | 303 | public: |
---|
| 304 | /** |
---|
| 305 | * @brief Constructor of a ExecutorXML |
---|
| 306 | * @param function a Function to call |
---|
| 307 | */ |
---|
| 308 | ExecutorLua2ret(ret (T::*function)(type0, type1)) |
---|
| 309 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>()) |
---|
| 310 | { |
---|
| 311 | this->functionPointer = function; |
---|
| 312 | } |
---|
[8271] | 313 | |
---|
[9727] | 314 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 315 | { |
---|
| 316 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 317 | fromLua<type0>(state, 1), |
---|
| 318 | fromLua<type1>(state, 2) )); |
---|
| 319 | } |
---|
[8271] | 320 | |
---|
[9727] | 321 | /** |
---|
| 322 | * @returns a _new_ Copy of this Executor |
---|
| 323 | */ |
---|
| 324 | virtual Executor<lua_State*>* clone () const |
---|
| 325 | { |
---|
| 326 | return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer); |
---|
| 327 | } |
---|
| 328 | private: |
---|
| 329 | ret (T::*functionPointer)(type0, type1); |
---|
[8271] | 330 | }; |
---|
| 331 | |
---|
[8894] | 332 | |
---|
| 333 | /////////// |
---|
| 334 | //// 3 //// |
---|
| 335 | /////////// |
---|
| 336 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 337 | template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor<lua_State*> |
---|
[8894] | 338 | { |
---|
[9727] | 339 | public: |
---|
| 340 | /** |
---|
| 341 | * @brief Constructor of a ExecutorXML |
---|
| 342 | * @param function a Function to call |
---|
| 343 | */ |
---|
| 344 | ExecutorLua3ret(ret (T::*function)(type0, type1, type2)) |
---|
| 345 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) |
---|
| 346 | { |
---|
| 347 | this->functionPointer = function; |
---|
| 348 | } |
---|
[8894] | 349 | |
---|
[9727] | 350 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 351 | { |
---|
| 352 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 353 | fromLua<type0>(state, 1), |
---|
| 354 | fromLua<type1>(state, 2), |
---|
| 355 | fromLua<type2>(state, 3) )); |
---|
| 356 | } |
---|
[8894] | 357 | |
---|
[9727] | 358 | /** |
---|
| 359 | * @returns a _new_ Copy of this Executor |
---|
| 360 | */ |
---|
| 361 | virtual Executor<lua_State*>* clone () const |
---|
| 362 | { |
---|
| 363 | return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer); |
---|
| 364 | } |
---|
| 365 | private: |
---|
| 366 | ret (T::*functionPointer)(type0, type1, type2); |
---|
[8894] | 367 | }; |
---|
| 368 | |
---|
| 369 | |
---|
| 370 | /////////// |
---|
| 371 | //// 4 //// |
---|
| 372 | /////////// |
---|
| 373 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 374 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor<lua_State*> |
---|
[8894] | 375 | { |
---|
[9727] | 376 | public: |
---|
| 377 | /** |
---|
| 378 | * @brief Constructor of a ExecutorXML |
---|
| 379 | * @param function a Function to call |
---|
| 380 | */ |
---|
| 381 | ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3)) |
---|
| 382 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) |
---|
| 383 | { |
---|
| 384 | this->functionPointer = function; |
---|
| 385 | } |
---|
[8894] | 386 | |
---|
[9727] | 387 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 388 | { |
---|
| 389 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 390 | fromLua<type0>(state, 1), |
---|
| 391 | fromLua<type1>(state, 2), |
---|
| 392 | fromLua<type2>(state, 3), |
---|
| 393 | fromLua<type3>(state, 4) )); |
---|
| 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 ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer); |
---|
| 402 | } |
---|
| 403 | private: |
---|
| 404 | ret (T::*functionPointer)(type0, type1, type2, type3); |
---|
[8894] | 405 | }; |
---|
| 406 | |
---|
| 407 | /////////// |
---|
| 408 | //// 5 //// |
---|
| 409 | /////////// |
---|
| 410 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 411 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor<lua_State*> |
---|
[8894] | 412 | { |
---|
[9727] | 413 | public: |
---|
| 414 | /** |
---|
| 415 | * @brief Constructor of a ExecutorXML |
---|
| 416 | * @param function a Function to call |
---|
| 417 | */ |
---|
| 418 | ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4)) |
---|
| 419 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) |
---|
| 420 | { |
---|
| 421 | this->functionPointer = function; |
---|
| 422 | } |
---|
[8894] | 423 | |
---|
[9727] | 424 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 425 | { |
---|
| 426 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 427 | fromLua<type0>(state, 1), |
---|
| 428 | fromLua<type1>(state, 2), |
---|
| 429 | fromLua<type2>(state, 3), |
---|
| 430 | fromLua<type3>(state, 4), |
---|
| 431 | fromLua<type4>(state, 5) )); |
---|
| 432 | } |
---|
[8894] | 433 | |
---|
[9727] | 434 | /** |
---|
| 435 | * @returns a _new_ Copy of this Executor |
---|
| 436 | */ |
---|
| 437 | virtual Executor<lua_State*>* clone () const |
---|
| 438 | { |
---|
| 439 | return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer); |
---|
| 440 | } |
---|
| 441 | private: |
---|
| 442 | ret (T::*functionPointer)(type0, type1, type2, type3, type4); |
---|
[8894] | 443 | }; |
---|
| 444 | |
---|
| 445 | /////////// |
---|
| 446 | //// 6 //// |
---|
| 447 | /////////// |
---|
| 448 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 449 | template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor<lua_State*> |
---|
[8894] | 450 | { |
---|
[9727] | 451 | public: |
---|
| 452 | /** |
---|
| 453 | * @brief Constructor of a ExecutorXML |
---|
| 454 | * @param function a Function to call |
---|
| 455 | */ |
---|
| 456 | ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5)) |
---|
| 457 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), |
---|
| 458 | ExecutorParamType<type2>(), ExecutorParamType<type3>(), |
---|
| 459 | ExecutorParamType<type4>(), ExecutorParamType<type5>()) |
---|
| 460 | { |
---|
| 461 | this->functionPointer = function; |
---|
| 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 | fromLua<type5>(state, 6) )); |
---|
| 473 | } |
---|
[8894] | 474 | |
---|
[9727] | 475 | /** |
---|
| 476 | * @returns a _new_ Copy of this Executor |
---|
| 477 | */ |
---|
| 478 | virtual Executor<lua_State*>* clone () const |
---|
| 479 | { |
---|
| 480 | return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer); |
---|
| 481 | } |
---|
| 482 | private: |
---|
| 483 | ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5); |
---|
[8894] | 484 | }; |
---|
| 485 | |
---|
| 486 | /////////// |
---|
| 487 | //// 7 //// |
---|
| 488 | /////////// |
---|
| 489 | //! Executes a Function with a lua_State* parameter. |
---|
[9727] | 490 | 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] | 491 | { |
---|
[9727] | 492 | public: |
---|
| 493 | /** |
---|
| 494 | * @brief Constructor of a ExecutorXML |
---|
| 495 | * @param function a Function to call |
---|
| 496 | */ |
---|
| 497 | ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6)) |
---|
| 498 | : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), |
---|
| 499 | ExecutorParamType<type2>(), ExecutorParamType<type3>(), |
---|
| 500 | ExecutorParamType<type4>(), ExecutorParamType<type5>(), |
---|
| 501 | ExecutorParamType<type6>()) |
---|
| 502 | { |
---|
| 503 | this->functionPointer = function; |
---|
| 504 | } |
---|
[8894] | 505 | |
---|
[9727] | 506 | virtual void operator()(BaseObject* object, lua_State*& state) const |
---|
| 507 | { |
---|
| 508 | toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( |
---|
| 509 | fromLua<type0>(state, 1), |
---|
| 510 | fromLua<type1>(state, 2), |
---|
| 511 | fromLua<type2>(state, 3), |
---|
| 512 | fromLua<type3>(state, 4), |
---|
| 513 | fromLua<type4>(state, 5), |
---|
| 514 | fromLua<type5>(state, 6), |
---|
| 515 | fromLua<type6>(state, 7) )); |
---|
| 516 | } |
---|
[8894] | 517 | |
---|
[9727] | 518 | /** |
---|
| 519 | * @returns a _new_ Copy of this Executor |
---|
| 520 | */ |
---|
| 521 | virtual Executor<lua_State*>* clone () const |
---|
| 522 | { |
---|
| 523 | return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer); |
---|
| 524 | } |
---|
| 525 | private: |
---|
| 526 | ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6); |
---|
[8894] | 527 | }; |
---|
| 528 | |
---|
| 529 | |
---|
[8271] | 530 | #endif /* _EXECUTOR_LUA_H */ |
---|