From: John L. <jr...@us...> - 2007-06-07 03:35:39
|
Update of /cvsroot/wxlua/wxLua/bindings In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv22306/wxLua/bindings Modified Files: genwxbind.lua Log Message: Use dummy wxLuaBindDefine for class member enums if they don't have any Some formatting fixes for the generated bindings Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** genwxbind.lua 6 Jun 2007 23:42:53 -0000 1.114 --- genwxbind.lua 7 Jun 2007 03:21:59 -0000 1.115 *************** *** 2757,2761 **** CommentBindingTable(codeList, " // return the number of values\n") table.insert(codeList, " return 1;\n") ! table.insert(codeList, "}\n\n") local overload_argListName = "s_wxluatagArray_".. funcName --- 2757,2761 ---- CommentBindingTable(codeList, " // return the number of values\n") table.insert(codeList, " return 1;\n") ! table.insert(codeList, "}\n") local overload_argListName = "s_wxluatagArray_".. funcName *************** *** 2846,2850 **** CommentBindingTable(codeList, " // return the number of values\n") table.insert(codeList, " return 0;\n") ! table.insert(codeList, "}\n\n") local overload_argListName = "s_wxluatagArray_".. funcName --- 2846,2850 ---- CommentBindingTable(codeList, " // return the number of values\n") table.insert(codeList, " return 0;\n") ! table.insert(codeList, "}\n") local overload_argListName = "s_wxluatagArray_".. funcName *************** *** 3464,3468 **** table.insert(codeList, "\n return 1;\n") ! table.insert(codeList, "}\n\n") else -- how we call c-function --- 3464,3468 ---- table.insert(codeList, "\n return 1;\n") ! table.insert(codeList, "}\n") else -- how we call c-function *************** *** 3513,3517 **** table.insert(codeList, " "..functor..";\n") table.insert(codeList, "\n return 0;\n") ! table.insert(codeList, "}\n\n") else -- call function, get return value --- 3513,3517 ---- table.insert(codeList, " "..functor..";\n") table.insert(codeList, "\n return 0;\n") ! table.insert(codeList, "}\n") else -- call function, get return value *************** *** 3563,3567 **** table.insert(codeList, "\n return 1;\n") ! table.insert(codeList, "}\n\n") end end --- 3563,3567 ---- table.insert(codeList, "\n return 1;\n") ! table.insert(codeList, "}\n") end end *************** *** 3617,3620 **** --- 3617,3621 ---- FuncMapName = funcMapName, Map = methodMap, + NotOverload = member.NotOverload, Condition = methodcondition, PreDefineCode = nil, -- set later if necessary *************** *** 3649,3652 **** --- 3650,3667 ---- end + -- Figure out if we really need to have member enums for the class + local enumArrayName = MakeVar(parseObject.Name).."_enums" + local enumArrayCountName = MakeVar(parseObject.Name).."_enumCount" + local ExternEnumDeclaration = "extern "..output_cpp_impexpsymbol.." wxLuaBindDefine "..enumArrayName.."[];\n" + local ExternEnumCountDeclaration = "extern "..MakeImpExpData("int").." "..enumArrayCountName..";\n" + + if enumClassBindingTable[MakeVar(parseObject.Name)] == nil then + enumArrayName = "s_wxluadefineArray_None" + enumArrayCountName = 0 + ExternEnumDeclaration = "" + ExternEnumCountDeclaration = "" + end + + -- Extern Class Tag Declaration local tagcondition = FixCondition(parseObject.Condition) *************** *** 3656,3661 **** ExternMethodDeclaration = "extern "..output_cpp_impexpsymbol.." wxLuaBindMethod "..MakeVar(parseObject.Name).."_methods[];\n", ExternMethodCountDeclaration = "extern "..MakeImpExpData("int").." "..MakeVar(parseObject.Name).."_methodCount;\n", ! ExternEnumDeclaration = "extern "..output_cpp_impexpsymbol.." wxLuaBindDefine "..MakeVar(parseObject.Name).."_enums[];\n", ! ExternEnumCountDeclaration = "extern "..MakeImpExpData("int").." "..MakeVar(parseObject.Name).."_enumCount;\n", Condition = tagcondition } --- 3671,3676 ---- ExternMethodDeclaration = "extern "..output_cpp_impexpsymbol.." wxLuaBindMethod "..MakeVar(parseObject.Name).."_methods[];\n", ExternMethodCountDeclaration = "extern "..MakeImpExpData("int").." "..MakeVar(parseObject.Name).."_methodCount;\n", ! ExternEnumDeclaration = ExternEnumDeclaration, ! ExternEnumCountDeclaration = ExternEnumCountDeclaration, Condition = tagcondition } *************** *** 3699,3703 **** table.insert(codeList, " }\n") table.insert(codeList, " return 0;\n") ! table.insert(codeList, "}\n\n") local funcMapName = "s_wxluafunc_"..funcName --- 3714,3718 ---- table.insert(codeList, " }\n") table.insert(codeList, " return 0;\n") ! table.insert(codeList, "}\n") local funcMapName = "s_wxluafunc_"..funcName *************** *** 3738,3743 **** ..MakeVar(baseclass)..", " .."NULL ," ! ..MakeVar(parseObject.Name).."_enums, " ! ..MakeVar(parseObject.Name).."_enumCount, " .."}, \n", Condition = classcondition --- 3753,3758 ---- ..MakeVar(baseclass)..", " .."NULL ," ! ..enumArrayName..", " ! ..enumArrayCountName..", " .."}, \n", Condition = classcondition *************** *** 3942,3947 **** table.insert(fileData, indent..classTagBinding.ExternMethodDeclaration) table.insert(fileData, indent..classTagBinding.ExternMethodCountDeclaration) ! table.insert(fileData, indent..classTagBinding.ExternEnumDeclaration) ! table.insert(fileData, indent..classTagBinding.ExternEnumCountDeclaration) end --- 3957,3964 ---- table.insert(fileData, indent..classTagBinding.ExternMethodDeclaration) table.insert(fileData, indent..classTagBinding.ExternMethodCountDeclaration) ! if string.len(classTagBinding.ExternEnumCountDeclaration) > 0 then ! table.insert(fileData, indent..classTagBinding.ExternEnumDeclaration) ! table.insert(fileData, indent..classTagBinding.ExternEnumCountDeclaration) ! end end *************** *** 4362,4369 **** --- 4379,4392 ---- local funcType = methodBindings[1].FuncType + local not_overload = 0 + for i = 1, #methodBindings do if methodBindings[i].Method then -- ignore properties overload_count = overload_count + 1 + if methodBindings[i].NotOverload == true then + not_overload = not_overload + 1 + end + if methodBindings[i].ParamCount and (paramCount < methodBindings[i].ParamCount) then paramCount = methodBindings[i].ParamCount *************** *** 4381,4385 **** end ! if overload_count > 1 then --print(n, #methodBindings, methodBindings[1].Map) --- 4404,4408 ---- end ! if (overload_count > 1) and (not_overload < overload_count) then --print(n, #methodBindings, methodBindings[1].Map) *************** *** 4579,4586 **** if functionBinding.FuncMapName then table.insert(fileData, "static int LUACALL "..functionBinding.CFunctionName.."(lua_State *L);\n") ! table.insert(fileData, "static wxLuaBindCFunc "..functionBinding.FuncMapName.."[1] = {"..functionBinding.FuncMap.."};\n\n") end ! table.insert(fileData, table.concat(functionBinding.Method)) end end --- 4602,4609 ---- if functionBinding.FuncMapName then table.insert(fileData, "static int LUACALL "..functionBinding.CFunctionName.."(lua_State *L);\n") ! table.insert(fileData, "static wxLuaBindCFunc "..functionBinding.FuncMapName.."[1] = {"..functionBinding.FuncMap.."};\n") end ! table.insert(fileData, table.concat(functionBinding.Method).."\n") end end *************** *** 4604,4610 **** GenerateProperties(sortedBindings) - - - -- Output Method Map Table CommentBindingTable(fileData, "// Map Lua Class Methods to C Binding Functions\n") --- 4627,4630 ---- *************** *** 4616,4626 **** -- since there may be conditions count them up afterwards ! table.insert(fileData, "int "..MakeVar(ObjectName).."_methodCount = sizeof("..MakeClassVar(ObjectName).."_methods)/sizeof(wxLuaBindMethod) - 1;\n") ! table.insert(fileData, "\n\n") ! ! ! table.insert(fileData, "wxLuaBindDefine "..MakeClassVar(ObjectName).."_enums[] = {\n") -- FIXME use dummy for empty if enumClassBindingTable[MakeClassVar(ObjectName)] then local namedBindingTable = {} GenerateLuaNameFromIndexedTable(enumClassBindingTable[MakeClassVar(ObjectName)], namedBindingTable) --- 4636,4643 ---- -- since there may be conditions count them up afterwards ! table.insert(fileData, "int "..MakeVar(ObjectName).."_methodCount = sizeof("..MakeClassVar(ObjectName).."_methods)/sizeof(wxLuaBindMethod) - 1;\n\n") if enumClassBindingTable[MakeClassVar(ObjectName)] then + table.insert(fileData, "wxLuaBindDefine "..MakeClassVar(ObjectName).."_enums[] = {\n") local namedBindingTable = {} GenerateLuaNameFromIndexedTable(enumClassBindingTable[MakeClassVar(ObjectName)], namedBindingTable) *************** *** 4628,4637 **** local sortedBindings = TableSort(namedBindingTable) GenerateMap(fileData, sortedBindings) - end table.insert(fileData, " { NULL, 0, },\n") ! table.insert(fileData, "};\n\n") -- since there may be conditions count them up afterwards table.insert(fileData, "int "..MakeVar(ObjectName).."_enumCount = sizeof("..MakeClassVar(ObjectName).."_enums)/sizeof(wxLuaBindDefine) - 1;\n") if object.Condition then --- 4645,4654 ---- local sortedBindings = TableSort(namedBindingTable) GenerateMap(fileData, sortedBindings) table.insert(fileData, " { NULL, 0, },\n") ! table.insert(fileData, "};\n") -- since there may be conditions count them up afterwards table.insert(fileData, "int "..MakeVar(ObjectName).."_enumCount = sizeof("..MakeClassVar(ObjectName).."_enums)/sizeof(wxLuaBindDefine) - 1;\n") + end if object.Condition then |