[4744] | 1 | /* |
---|
[1853] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
[1855] | 10 | |
---|
| 11 | ### File Specific: |
---|
| 12 | main-programmer: ... |
---|
| 13 | co-programmer: ... |
---|
[1853] | 14 | */ |
---|
| 15 | |
---|
[3955] | 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ |
---|
[1853] | 17 | |
---|
[8051] | 18 | #include "executor_lua.h" |
---|
[1853] | 19 | |
---|
[8408] | 20 | #include "lunar.h" |
---|
[1853] | 21 | |
---|
[8894] | 22 | std::string temp[7]; |
---|
[8408] | 23 | |
---|
[8527] | 24 | template<typename type> type fromLua(lua_State* state, int index) { type *obj = Lunar<type>::check(state, 1); lua_remove(state, 1); return obj;}; |
---|
[8271] | 25 | template<> bool fromLua<bool>(lua_State* state, int index) { return lua_toboolean(state, index); }; |
---|
| 26 | template<> int fromLua<int>(lua_State* state, int index) { return (int)lua_tonumber(state, index); }; |
---|
| 27 | template<> unsigned int fromLua<unsigned int>(lua_State* state, int index) { return (unsigned int)lua_tonumber(state, index); }; |
---|
| 28 | template<> float fromLua<float>(lua_State* state, int index) { return (float)lua_tonumber(state, index); }; |
---|
| 29 | template<> char fromLua<char>(lua_State* state, int index) { return (char)lua_tonumber(state, index); }; |
---|
[8408] | 30 | template<> const std::string& fromLua<const std::string&>(lua_State* state, int index) { temp[index] = lua_tostring(state, index); return temp[index]; }; |
---|
[8057] | 31 | |
---|
| 32 | |
---|
[8408] | 33 | template<typename type> void toLua(lua_State* state, type value) { Lunar<type>::push(state, value, false); }; |
---|
[8271] | 34 | template<> void toLua<bool>(lua_State* state, bool value) { lua_pushboolean(state, (int) value); }; |
---|
| 35 | template<> void toLua<int>(lua_State* state, int value) { lua_pushnumber(state, (lua_Number) value); }; |
---|
| 36 | template<> void toLua<unsigned int>(lua_State* state, unsigned int value){ lua_pushnumber(state, (lua_Number) value); }; |
---|
| 37 | template<> void toLua<float>(lua_State* state, float value) { lua_pushnumber(state, (lua_Number) value); }; |
---|
| 38 | template<> void toLua<char>(lua_State* state, char value) { lua_pushnumber(state, (lua_Number) value); }; |
---|
| 39 | template<> void toLua<const std::string&>(lua_State* state, const std::string& value) {lua_pushstring (state, value.c_str()); } |
---|