From: John L. <jr...@us...> - 2006-12-17 07:47:47
|
Update of /cvsroot/wxlua/wxLua/bindings In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv28504/wxLua/bindings Modified Files: genwxbind.lua Log Message: separate out the wxluatag arrays and use pointer in WXLUAMETHOD Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** genwxbind.lua 14 Dec 2006 22:02:57 -0000 1.92 --- genwxbind.lua 17 Dec 2006 07:47:14 -0000 1.93 *************** *** 18,23 **** -- --------------------------------------------------------------------------- ! WXLUA_BINDING_VERSION = 3 -- Used to verify that the bindings are updated ! -- see modules/wxlua/include/wxldefs.h bindingKeywordTable = {} -- Binding keywords used by the generator %XXX --- 18,23 ---- -- --------------------------------------------------------------------------- ! WXLUA_BINDING_VERSION = 4 -- Used to verify that the bindings are updated ! -- This must match modules/wxlua/include/wxldefs.h bindingKeywordTable = {} -- Binding keywords used by the generator %XXX *************** *** 29,42 **** preprocOperatorTable = {} -- Preprocessor operators ! typedefTable = {} -- all typedefs read from the interface files dataTypeTable = {} -- all datatypes; int, double, class names, see AllocDataType dataTypeAttribTable = {} -- attributes for data types; unsigned, const functionAttribTable = {} -- attributes for functions; static, virtual ! enumBindingTable = {} -- table[#if condition][enum name] = { map, condition } ! defineBindingTable = {} -- table[#if condition][define name] = { map, condition } ! defineIncludeBindingTable = {} ! stringBindingTable = {} -- table[#if condition][string name] = { map, condition } ! objectBindingTable = {} -- table[#if condition][object name] = { map, condition } objectTagBindingTable = {} objectIncludeBindingTable = {} --- 29,42 ---- preprocOperatorTable = {} -- Preprocessor operators ! typedefTable = {} -- all %typedefs read from the interface files dataTypeTable = {} -- all datatypes; int, double, class names, see AllocDataType dataTypeAttribTable = {} -- attributes for data types; unsigned, const functionAttribTable = {} -- attributes for functions; static, virtual ! enumBindingTable = {} -- table[#if condition][enum name] = { Map, Condition } ! defineBindingTable = {} -- table[#if condition][define name] = { Map, Condition } ! defineIncludeBindingTable = {} -- table[#if condition][define name] = { Map, Condition } ! stringBindingTable = {} -- table[#if condition][string name] = { Map, Condition } ! objectBindingTable = {} -- table[#if condition][object name] = { Map, Condition } objectTagBindingTable = {} objectIncludeBindingTable = {} *************** *** 147,153 **** -- --------------------------------------------------------------------------- -- Add a value to the table at any number of keys into it ! -- TableAdd(a, value, "b", 2, 5) = a["b"][2][5] = value -- --------------------------------------------------------------------------- ! function TableAdd(atable, value, ...) local t = atable for n = 1, #arg-1 do --- 147,153 ---- -- --------------------------------------------------------------------------- -- Add a value to the table at any number of keys into it ! -- TableAdd(value, atable, "b", 2, 5) = atable["b"][2][5] = value -- --------------------------------------------------------------------------- ! function TableAdd(value, atable, ...) local t = atable for n = 1, #arg-1 do *************** *** 1063,1069 **** bindingKeywordTable["%rename"] = true bindingKeywordTable["%class"] = true ! bindingKeywordTable["%delete"] = true -- keywords that go with %class bindingKeywordTable["%noclassinfo"] = true bindingKeywordTable["%encapsulate"] = true bindingKeywordTable["%constructor"] = true bindingKeywordTable["%static"] = true --- 1063,1071 ---- bindingKeywordTable["%rename"] = true bindingKeywordTable["%class"] = true ! -- keywords come after %class tag ! bindingKeywordTable["%delete"] = true bindingKeywordTable["%noclassinfo"] = true bindingKeywordTable["%encapsulate"] = true + -- keywords that can only be used within %class tag bindingKeywordTable["%constructor"] = true bindingKeywordTable["%static"] = true *************** *** 1610,1613 **** --- 1612,1621 ---- end + -- --------------------------------------------------------------------------- + -- Parse the interface file tags + -- This uses a stack of AllocParseObjects with the top most one the globals + -- classes and enums are temporarily pushed onto it and removed at the end. + -- --------------------------------------------------------------------------- + function ParseData(interfaceData) local objectList = {} *************** *** 1615,1619 **** { ObjectStack = {}, ! ConditionStack = {}, IsBlockComment = false, } --- 1623,1627 ---- { ObjectStack = {}, ! ConditionStack = {}, -- stack of conditions IsBlockComment = false, } *************** *** 1698,1702 **** -- end inline conditionals ! if lineState.InLineConditionIf and not lineState.InLineConditionEndIf then lineState.InLineConditionIf = false lineState.IsLineConditionEndIf = true --- 1706,1710 ---- -- end inline conditionals ! if lineState.InLineConditionIf and not lineState.InLineConditionEndIf then lineState.InLineConditionIf = false lineState.IsLineConditionEndIf = true *************** *** 1712,1717 **** elseif tag == "%endif" then - local condition = parseState.ConditionStack[1] - table.remove(parseState.ConditionStack, 1) -- pop last %if break -- we can stop processing line --- 1720,1723 ---- *************** *** 1979,1983 **** -- Process Interface Data -- ! if lineState.Action == "keyword" and lineState.ActionMandatory then print("Error: Invalid Token '"..tag.."'. "..LineTableErrString(lineTable)) end --- 1985,1989 ---- -- Process Interface Data -- ! if (lineState.Action == "keyword") and lineState.ActionMandatory then print("Error: Invalid Token '"..tag.."'. "..LineTableErrString(lineTable)) end *************** *** 2213,2223 **** lineState.ActionMandatory = true ! elseif (tag == "*") or (tag == "&") then ! table.insert(lineState.DataTypePointer, tag) ! ! lineState.Action = "method" ! lineState.ActionMandatory = true ! ! elseif tag == "[]" then table.insert(lineState.DataTypePointer, tag) --- 2219,2223 ---- lineState.ActionMandatory = true ! elseif (tag == "*") or (tag == "&") or (tag == "[]") then table.insert(lineState.DataTypePointer, tag) *************** *** 2257,2261 **** lineState.DataTypeWithAttrib = lineState.DataType ! if IsDataType(lineState.Name) and lineState.Name ~= parseState.ObjectStack[1].Name then if not IsDataTypeEnum(lineState.Name) then print("Error: Constructor Name ("..lineState.Name..") conflicts with datatype definition. "..LineTableErrString(lineTable)) --- 2257,2261 ---- lineState.DataTypeWithAttrib = lineState.DataType ! if IsDataType(lineState.Name) and (lineState.Name ~= parseState.ObjectStack[1].Name) then if not IsDataTypeEnum(lineState.Name) then print("Error: Constructor Name ("..lineState.Name..") conflicts with datatype definition. "..LineTableErrString(lineTable)) *************** *** 2291,2307 **** elseif lineState.Action == "methodbracket" then if tag ~= '(' then ! local msg = "" ! if lineState.Name then ! msg = "(Name="..lineState.Name.."; " ! else ! msg = "(Undefined Name; " ! end ! ! if lineState.DataType then ! msg = msg.."DataType="..lineState.DataType..")" ! else ! msg = msg.."Undefined DataType)" ! end ! print("Error: Expected Method Tag '(', got Tag='"..tag.."'. "..msg.." "..LineTableErrString(lineTable)) end --- 2291,2295 ---- elseif lineState.Action == "methodbracket" then if tag ~= '(' then ! local msg = "(Name="..tostring(lineState.Name).."; DataType="..tostring(lineState.DataType)..")" print("Error: Expected Method Tag '(', got Tag='"..tag.."'. "..msg.." "..LineTableErrString(lineTable)) end *************** *** 2327,2337 **** lineState.ActionMandatory = true ! elseif (tag == "*") or (tag == "&") then ! table.insert(lineState.ParamState.DataTypePointer, tag) ! ! lineState.Action = "methodparam" ! lineState.ActionMandatory = true ! ! elseif tag == "[]" then table.insert(lineState.ParamState.DataTypePointer, tag) --- 2315,2319 ---- lineState.ActionMandatory = true ! elseif (tag == "*") or (tag == "&") or (tag == "[]") then table.insert(lineState.ParamState.DataTypePointer, tag) *************** *** 2441,2457 **** else ! local msg = "" ! if lineState.ParamState.Name then ! msg = "(Name="..lineState.ParamState.Name.."; " ! else ! msg = "(Undefined Name; " ! end ! ! if lineState.ParamState.DataType then ! msg = msg.."DataType="..lineState.ParamState.DataType..")" ! else ! msg = msg.."Undefined DataType)" ! end ! print("Error: Expected Parameter '=', ')', or ',' got Tag='"..tag.."'. "..msg.." "..LineTableErrString(lineTable)) end --- 2423,2428 ---- else ! local msg = "(Name="..tostring(lineState.ParamState.Name).. ! "; DataType="..tostring(lineState.ParamState.DataType)..")" print("Error: Expected Parameter '=', ')', or ',' got Tag='"..tag.."'. "..msg.." "..LineTableErrString(lineTable)) end *************** *** 2579,2583 **** -- --------------------------------------------------------------------------- ! -- Make a variable from a data type that may contain namespace::var -- --------------------------------------------------------------------------- function MakeVar(type) --- 2550,2555 ---- -- --------------------------------------------------------------------------- ! -- Make a variable from a data type that may contain namespace::var and ! -- convert it to namespace_var -- --------------------------------------------------------------------------- function MakeVar(type) *************** *** 2714,2718 **** local propertyBinding = { ! Map = " { LuaGetProp, \""..member.Name.."\", wxLua_"..MakeVar(parseObject.Name).."_Get"..member.Name..", 0, 0, {0} },\n", Condition = propertycondition } --- 2686,2690 ---- local propertyBinding = { ! Map = " { LuaGetProp, \""..member.Name.."\", wxLua_"..MakeVar(parseObject.Name).."_Get"..member.Name..", 0, 0, s_wxluaargArray_None },\n", Condition = propertycondition } *************** *** 2726,2730 **** local propertyBinding = { ! Map = " { LuaSetProp, \""..member.Name.."\", wxLua_"..MakeVar(parseObject.Name).."_Set"..member.Name..", 1, 1, {0} },\n", Condition = propertycondition } --- 2698,2702 ---- local propertyBinding = { ! Map = " { LuaSetProp, \""..member.Name.."\", wxLua_"..MakeVar(parseObject.Name).."_Set"..member.Name..", 1, 1, s_wxluaargArray_None },\n", Condition = propertycondition } *************** *** 2808,2812 **** { Method = codeList, ! Map = " { LuaMethod, \""..memberGetFunc.."\", "..funcName..", 0, 0, {0} },\n", Condition = membercondition } --- 2780,2784 ---- { Method = codeList, ! Map = " { LuaMethod, \""..memberGetFunc.."\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = membercondition } *************** *** 2815,2819 **** local propertyBinding = { ! Map = " { LuaGetProp, \""..member.Name.."\", "..funcName..", 0, 0, {0} },\n", Condition = membercondition } --- 2787,2791 ---- local propertyBinding = { ! Map = " { LuaGetProp, \""..member.Name.."\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = membercondition } *************** *** 2850,2854 **** table.insert(codeList, " "..parseObject.Name.." *self = ("..parseObject.Name.." *)wxlState.GetUserDataType(1, s_wxluatag_"..MakeClassVar(parseObject.Name)..");\n") ! if not numeric and (not memberPtr or (memberPtr == "&")) then table.insert(codeList, " self->"..member.Name.." = *val;\n") else --- 2822,2826 ---- table.insert(codeList, " "..parseObject.Name.." *self = ("..parseObject.Name.." *)wxlState.GetUserDataType(1, s_wxluatag_"..MakeClassVar(parseObject.Name)..");\n") ! if not numeric and (not memberPtr or (memberPtr == "&")) then table.insert(codeList, " self->"..member.Name.." = *val;\n") else *************** *** 2864,2868 **** { Method = codeList, ! Map = " { LuaMethod, \""..memberSetFunc.."\", "..funcName..", 0, 0, {0} },\n", Condition = membercondition } --- 2836,2840 ---- { Method = codeList, ! Map = " { LuaMethod, \""..memberSetFunc.."\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = membercondition } *************** *** 2871,2875 **** propertyBinding = { ! Map = " { LuaSetProp, \""..member.Name.."\", "..funcName..", 0, 0, {0} },\n", Condition = fullcondition } --- 2843,2847 ---- propertyBinding = { ! Map = " { LuaSetProp, \""..member.Name.."\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = fullcondition } *************** *** 3471,3474 **** --- 3443,3449 ---- end + local overload_argListName = "s_wxluatagArray_".. funcName + overload_argList = overload_argList.."0 }" + -- add function map only once for the base function name overload local funcMap = nil *************** *** 3476,3482 **** local f = funcNameBase if member.AltName and (member.AltName ~= member.Name) then f = funcName end ! funcMap = " { "..funcType..", \""..funcLuaCall.."\", "..f..", "..paramCount..", "..requiredParamCount..", "..overload_argList.."0 } },\n" end ! local overloadMap = " { "..funcType..", \""..funcLuaCall.."\", "..funcName..", "..paramCount..", "..requiredParamCount..", "..overload_argList.."0 } },\n" --print(parseObject.Name, member.Name, member.IsOverload, overload_argList) --- 3451,3457 ---- local f = funcNameBase if member.AltName and (member.AltName ~= member.Name) then f = funcName end ! funcMap = " { "..funcType..", \""..funcLuaCall.."\", "..f..", "..paramCount..", "..requiredParamCount..", "..overload_argListName.." },\n" end ! local overloadMap = " { "..funcType..", \""..funcLuaCall.."\", "..funcName..", "..paramCount..", "..requiredParamCount..", "..overload_argListName.." },\n" --print(parseObject.Name, member.Name, member.IsOverload, overload_argList) *************** *** 3610,3613 **** --- 3585,3590 ---- CFunctionName = funcName, Method = codeList, + ArgArray = overload_argList, + ArgArrayName = overload_argListName, Map = funcMap, ArgList = overload_argList, *************** *** 3732,3736 **** { Method = codeList, ! Map = " { LuaDelete, \""..MakeVar(parseObject.Name).."\", "..funcName..", 0, 0, {0} },\n", Condition = condition } --- 3709,3713 ---- { Method = codeList, ! Map = " { LuaDelete, \""..MakeVar(parseObject.Name).."\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = condition } *************** *** 3760,3764 **** { Method = codeList, ! Map = " { LuaMethod, \"Delete\", "..funcName..", 0, 0, {0} },\n", Condition = condition } --- 3737,3741 ---- { Method = codeList, ! Map = " { LuaMethod, \"Delete\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = condition } *************** *** 3778,3782 **** { Method = codeList, ! Map = " { LuaDelete, \""..MakeVar(parseObject.Name).."\", "..funcName..", 0, 0, {0} },\n", Condition = condition } --- 3755,3759 ---- { Method = codeList, ! Map = " { LuaDelete, \""..MakeVar(parseObject.Name).."\", "..funcName..", 0, 0, s_wxluaargArray_None },\n", Condition = condition } *************** *** 4367,4372 **** for i, functionBinding in pairs_sort(functionBindingList) do if functionBinding.Method then ! local lineCount = #functionBinding.Method ! for line=1, lineCount do table.insert(fileData, functionBinding.Method[line]) end --- 4344,4352 ---- for i, functionBinding in pairs_sort(functionBindingList) do if functionBinding.Method then ! if functionBinding.ArgArrayName then ! table.insert(fileData, "static wxLuaArgTag "..functionBinding.ArgArrayName.."[] = "..functionBinding.ArgArray..";\n") ! end ! ! for line = 1, #functionBinding.Method do table.insert(fileData, functionBinding.Method[line]) end *************** *** 4406,4410 **** end ! table.insert(fileData, " { LuaGlobal, 0, 0, 0, 0, {0} }, \n") table.insert(fileData, " };\n") table.insert(fileData, " count = (sizeof(functionList)/sizeof(functionList[0])) - 1;\n") --- 4386,4390 ---- end ! table.insert(fileData, " { LuaGlobal, 0, 0, 0, 0, s_wxluaargArray_None }, \n") table.insert(fileData, " };\n") table.insert(fileData, " count = (sizeof(functionList)/sizeof(functionList[0])) - 1;\n") *************** *** 4426,4431 **** table.insert(fileData, "\n") ! local objectCount = #interface.objectData ! for o = 1, objectCount do local object = interface.objectData[o] --- 4406,4410 ---- table.insert(fileData, "\n") ! for o = 1, #interface.objectData do local object = interface.objectData[o] *************** *** 4457,4465 **** end ! local bindCount = #BindTableList ! for i = 1, bindCount do if BindTableList[i].Method then ! local lineCount = #BindTableList[i].Method ! for line=1, lineCount do table.insert(fileData, BindTableList[i].Method[line]) end --- 4436,4446 ---- end ! for i = 1, #BindTableList do ! if BindTableList[i].Method then ! if BindTableList[i].ArgArrayName then ! table.insert(fileData, "static wxLuaArgTag "..BindTableList[i].ArgArrayName.."[] = "..BindTableList[i].ArgArray..";\n") ! end ! for line = 1, #BindTableList[i].Method do table.insert(fileData, BindTableList[i].Method[line]) end *************** *** 4541,4546 **** end ! local bindCount = #BindTableList ! for i=1,bindCount do if BindTableList[i].Map then table.insert(fileData, BindTableList[i].Map) --- 4522,4526 ---- end ! for i = 1, #BindTableList do if BindTableList[i].Map then table.insert(fileData, BindTableList[i].Map) |