diff options
author | Mattes D <github@xoft.cz> | 2016-06-05 17:20:50 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2016-06-05 17:20:50 +0200 |
commit | fbe98665245af8a552177d4a82ca0ba41b52a625 (patch) | |
tree | 7819551f10a4ffd9d6a6c97908e8e1b5a86633ae /src | |
parent | Merge pull request #3219 from QUSpilPrgm/master (diff) | |
download | cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.tar cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.tar.gz cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.tar.bz2 cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.tar.lz cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.tar.xz cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.tar.zst cuberite-fbe98665245af8a552177d4a82ca0ba41b52a625.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/Bindings/BindingsProcessor.lua | 15 | ||||
-rw-r--r-- | src/Bindings/LuaState.cpp | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/Bindings/BindingsProcessor.lua b/src/Bindings/BindingsProcessor.lua index a398f5026..e7b909ded 100644 --- a/src/Bindings/BindingsProcessor.lua +++ b/src/Bindings/BindingsProcessor.lua @@ -85,6 +85,7 @@ local function OutputLuaStateHelpers(a_Package) f:write("\n\n\n\n\n") for _, item in ipairs(types) do f:write("typedef " .. item.name .. " * Ptr" .. item.lname .. ";\n") + f:write("typedef const " .. item.name .. " * ConstPtr" .. item.lname .. ";\n") end f:write("\n\n\n\n\n") f:close() @@ -104,6 +105,7 @@ local function OutputLuaStateHelpers(a_Package) end for _, item in ipairs(types) do f:write("bool GetStackValue(int a_StackPos, Ptr" .. item.lname .. " & a_ReturnedVal);\n") + f:write("bool GetStackValue(int a_StackPos, ConstPtr" .. item.lname .. " & a_ReturnedVal);\n") end f:write("\n\n\n\n\n") f:close() @@ -139,6 +141,19 @@ local function OutputLuaStateHelpers(a_Package) f:write("\t}\n") f:write("\treturn false;\n") f:write("}\n\n\n\n\n\n") + + f:write("bool cLuaState::GetStackValue(int a_StackPos, ConstPtr" .. item.lname .. " & a_ReturnedVal)\n{\n\tASSERT(IsValid());\n") + f:write("\tif (lua_isnil(m_LuaState, a_StackPos))\n\t{\n") + f:write("\t\ta_ReturnedVal = nullptr;\n") + f:write("\t\treturn false;\n\t}\n") + f:write("\ttolua_Error err;\n") + f:write("\tif (tolua_isusertype(m_LuaState, a_StackPos, \"const " .. item.name .. "\", false, &err))\n") + f:write("\t{\n") + f:write("\t\ta_ReturnedVal = *(reinterpret_cast<const " .. item.name .. " **>(lua_touserdata(m_LuaState, a_StackPos)));\n") + f:write("\t\treturn true;\n"); + f:write("\t}\n") + f:write("\treturn false;\n") + f:write("}\n\n\n\n\n\n") end f:close() end diff --git a/src/Bindings/LuaState.cpp b/src/Bindings/LuaState.cpp index e0551c550..f11e74e75 100644 --- a/src/Bindings/LuaState.cpp +++ b/src/Bindings/LuaState.cpp @@ -1656,6 +1656,7 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header) case LUA_TNUMBER: Printf(Value, "%f", static_cast<double>(lua_tonumber(a_LuaState, i))); break; case LUA_TSTRING: Printf(Value, "%s", lua_tostring(a_LuaState, i)); break; case LUA_TTABLE: Printf(Value, "%p", lua_topointer(a_LuaState, i)); break; + case LUA_TUSERDATA: Printf(Value, "%p (%s)", lua_touserdata(a_LuaState, i), tolua_typename(a_LuaState, i)); break; default: break; } LOGD(" Idx %d: type %d (%s) %s", i, Type, lua_typename(a_LuaState, Type), Value.c_str()); |