From: John L. <jr...@us...> - 2007-12-20 02:27:28
|
Update of /cvsroot/wxlua/wxLua/bindings In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv8597/wxLua/bindings Modified Files: genwxbind.lua Log Message: - Removed wxluabind_removetableforcall(L) used in the bindings to determine if the function was called from the tables used for class constructors. It makes more sense to call an intermediatary function to remove the table before calling the real function. - Removed the wxLuaFunction class since we no longer need it. It was a userdata with a __call metatable to call the real function we want. We now push the actual function or an overload function helper with the wxLuaBindMethod struct as an upvalue to give better error messages. The new way should be faster since it doesn't generate as much garbage. - Added wxlua_argerror(L, stack_idx, type_str) to give a far more informative message from the bindings when the wrong type is an arg to a function. - Renamed WXLUAARG_XXX to WXLUA_TXXX to match LUA_TXXX. * Do not create a separate overload function in the bindings since we can just as easily check for multiple functions using the wxLuaBindMethod and call the generic overload function or just the single function. Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** genwxbind.lua 13 Dec 2007 06:23:53 -0000 1.155 --- genwxbind.lua 20 Dec 2007 02:26:54 -0000 1.156 *************** *** 18,22 **** -- --------------------------------------------------------------------------- ! WXLUA_BINDING_VERSION = 19 -- Used to verify that the bindings are updated -- This must match modules/wxlua/include/wxldefs.h -- otherwise a compile time error will be generated. --- 18,22 ---- -- --------------------------------------------------------------------------- ! WXLUA_BINDING_VERSION = 20 -- Used to verify that the bindings are updated -- This must match modules/wxlua/include/wxldefs.h -- otherwise a compile time error will be generated. *************** *** 3435,3442 **** CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].LineText.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") - if member.IsConstructor then - table.insert(codeList, " wxluabind_removetableforcall(L);\n") - end - table.insert(codeList, " wxLuaState wxlState(L);\n") -- See if we're supposed to track or untrack the return value --- 3435,3438 ---- *************** *** 3829,3833 **** if not overrideTable[funcName] then ! funcName_ = "wxLua_wxluabind_delete" end --- 3825,3829 ---- if not overrideTable[funcName] then ! funcName_ = "wxlua_userdata_delete" end *************** *** 4549,4553 **** CommentBindingTable(funcMap, "// function overload table\n") table.insert(funcMap, "static wxLuaBindCFunc "..funcMapName.."[] =\n{\n") ! table.insert(funcMap, " { "..funcName..", WXLUAMETHOD_METHOD|WXLUAMETHOD_OVERLOAD, "..tostring(requiredParamCount)..", "..tostring(paramCount)..", s_wxluaargArray_None },\n") for i = 1, #methodBindings do if HasCondition(methodBindings[i].Condition) and (methodBindings[i].Condition ~= object.Condition) then --- 4545,4549 ---- CommentBindingTable(funcMap, "// function overload table\n") table.insert(funcMap, "static wxLuaBindCFunc "..funcMapName.."[] =\n{\n") ! -- table.insert(funcMap, " { "..funcName..", WXLUAMETHOD_METHOD|WXLUAMETHOD_OVERLOAD, "..tostring(requiredParamCount)..", "..tostring(paramCount)..", s_wxluaargArray_None },\n") for i = 1, #methodBindings do if HasCondition(methodBindings[i].Condition) and (methodBindings[i].Condition ~= object.Condition) then *************** *** 4563,4567 **** table.insert(funcMap, "};\n") ! table.insert(funcMap, "static int "..funcMapName.."_count = sizeof("..funcMapName..")/sizeof(wxLuaBindCFunc);\n") local methodMap = " { \""..methodBindings[1].LuaName.."\", "..funcType..", "..funcMapName..", "..funcMapName.."_count, 0 }" --- 4559,4563 ---- table.insert(funcMap, "};\n") ! table.insert(funcMap, "static int "..funcMapName.."_count = sizeof("..funcMapName..")/sizeof(wxLuaBindCFunc);\n\n") local methodMap = " { \""..methodBindings[1].LuaName.."\", "..funcType..", "..funcMapName..", "..funcMapName.."_count, 0 }" *************** *** 4569,4578 **** local codeList = {} ! CommentBindingTable(codeList, "// Overloaded function for "..methodBindings[1].ClassName.."::"..methodBindings[1].LuaName.."\n") ! table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") ! table.insert(codeList, " static wxLuaBindMethod overload_method = \n") ! table.insert(codeList, " "..methodMap..";\n") ! table.insert(codeList, " return wxlua_CallOverloadedFunction(L, &overload_method);\n") ! table.insert(codeList, "}\n") local methodBinding = --- 4565,4574 ---- local codeList = {} ! -- CommentBindingTable(codeList, "// Overloaded function for "..methodBindings[1].ClassName.."::"..methodBindings[1].LuaName.."\n") ! -- table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") ! -- table.insert(codeList, " static wxLuaBindMethod overload_method = \n") ! -- table.insert(codeList, " "..methodMap..";\n") ! -- table.insert(codeList, " return wxlua_CallOverloadedFunction(L, &overload_method);\n") ! -- table.insert(codeList, "}\n") local methodBinding = *************** *** 4652,4656 **** end if functionBinding.FuncMapName then ! if functionBinding.CFunctionName ~= "wxLua_wxluabind_delete" then table.insert(fileData, "static int LUACALL "..functionBinding.CFunctionName.."(lua_State *L);\n") end --- 4648,4652 ---- end if functionBinding.FuncMapName then ! if functionBinding.CFunctionName ~= "wxlua_userdata_delete" then table.insert(fileData, "static int LUACALL "..functionBinding.CFunctionName.."(lua_State *L);\n") end *************** *** 4670,4674 **** local function writeFunc(functionBinding) if functionBinding.IsOverload then ! table.insert(fileData, "static int LUACALL "..functionBinding.CFunctionName.."(lua_State *L);\n") table.insert(fileData, table.concat(functionBinding.FuncMap)) table.insert(fileData, table.concat(functionBinding.Method)) --- 4666,4670 ---- local function writeFunc(functionBinding) if functionBinding.IsOverload then ! -- table.insert(fileData, "static int LUACALL "..functionBinding.CFunctionName.."(lua_State *L);\n") table.insert(fileData, table.concat(functionBinding.FuncMap)) table.insert(fileData, table.concat(functionBinding.Method)) |