Rev | Line | |
---|
[11519] | 1 | |
---|
| 2 | #include "luatb_typed_stack.h" |
---|
[11549] | 3 | #include "luatb.h" |
---|
[11519] | 4 | #include <string> |
---|
| 5 | |
---|
[11552] | 6 | // Holds a list of all current callback references |
---|
| 7 | std::list<std::unique_ptr<int> > LuaTBTypedStack::callbackRefs = {}; |
---|
| 8 | |
---|
[11519] | 9 | // Explicit and full specializations need to be in a .cpp file |
---|
| 10 | |
---|
| 11 | template<> |
---|
[11552] | 12 | int LuaTBTypedStack::getFromLuaStack<int>(lua_State *lua) |
---|
[11519] | 13 | { return lua_tointeger(lua, lua_gettop(lua)); } |
---|
| 14 | |
---|
| 15 | template<> |
---|
[11552] | 16 | double LuaTBTypedStack::getFromLuaStack<double>(lua_State *lua) |
---|
[11519] | 17 | { return lua_tonumber(lua, lua_gettop(lua)); } |
---|
| 18 | |
---|
| 19 | template<> |
---|
[11552] | 20 | std::string LuaTBTypedStack::getFromLuaStack<std::string>(lua_State *lua) |
---|
[11519] | 21 | { return lua_tostring(lua, lua_gettop(lua)); } |
---|
| 22 | |
---|
| 23 | template<> |
---|
| 24 | void LuaTBTypedStack::pushToLuaStack<int>(lua_State *lua, int value) |
---|
| 25 | { lua_pushinteger(lua, value); } |
---|
| 26 | |
---|
| 27 | template<> |
---|
| 28 | void LuaTBTypedStack::pushToLuaStack<double>(lua_State *lua, double value) |
---|
| 29 | { lua_pushnumber(lua, value); } |
---|
| 30 | |
---|
| 31 | template<> |
---|
| 32 | void LuaTBTypedStack::pushToLuaStack<std::string>(lua_State *lua, std::string value) |
---|
| 33 | { lua_pushstring(lua, value.c_str()); } |
---|
Note: See
TracBrowser
for help on using the repository browser.