From 480052c058f3a8ebc70f024933ba5deb6baf0b08 Mon Sep 17 00:00:00 2001 From: tycho Date: Tue, 19 May 2015 15:25:18 +0100 Subject: Added LuaState support for all integral types All so added error handling for out of range values --- src/Bindings/BindingsProcessor.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/Bindings/BindingsProcessor.lua') diff --git a/src/Bindings/BindingsProcessor.lua b/src/Bindings/BindingsProcessor.lua index f86be6c6d..fba992082 100644 --- a/src/Bindings/BindingsProcessor.lua +++ b/src/Bindings/BindingsProcessor.lua @@ -101,7 +101,7 @@ local function OutputLuaStateHelpers(a_Package) f:write("void Push(" .. item.name .. " * a_Value);\n") end for _, item in ipairs(types) do - f:write("void GetStackValue(int a_StackPos, Ptr" .. item.lname .. " & a_ReturnedVal);\n") + f:write("bool GetStackValue(int a_StackPos, Ptr" .. item.lname .. " & a_ReturnedVal);\n") end f:write("\n\n\n\n\n") f:close() @@ -125,15 +125,17 @@ local function OutputLuaStateHelpers(a_Package) end end for _, item in ipairs(types) do - f:write("void cLuaState::GetStackValue(int a_StackPos, Ptr" .. item.lname .. " & a_ReturnedVal)\n{\n\tASSERT(IsValid());\n") + f:write("bool cLuaState::GetStackValue(int a_StackPos, Ptr" .. item.lname .. " & a_ReturnedVal)\n{\n\tASSERT(IsValid());\n") f:write("\tif (lua_isnil(m_LuaState, a_StackPos))\n\t{\n") - f:write("\t a_ReturnedVal = nullptr;\n") - f:write("\t return;\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, \"" .. item.name .. "\", false, &err))\n") f:write("\t{\n") - f:write("\t a_ReturnedVal = *(reinterpret_cast<" .. item.name .. " **>(lua_touserdata(m_LuaState, a_StackPos)));\n") + f:write("\t\ta_ReturnedVal = *(reinterpret_cast<" .. 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() -- cgit v1.2.3