From: John L. <jr...@us...> - 2009-10-01 04:21:32
|
Update of /cvsroot/wxlua/wxLua/bindings In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv4255/wxLua/bindings Modified Files: genwxbind.lua Log Message: Removed %encapsulate and %noclassinfo tags for %classes in the bindings. No longer encapsulating non wxObjects in a wxObject class for deletion. We now provide delete functions for each class in the wxLuaBindClass structs to be called on the void* we get from Lua. Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.183 retrieving revision 1.184 diff -C2 -d -r1.183 -r1.184 *** genwxbind.lua 27 Sep 2009 03:13:51 -0000 1.183 --- genwxbind.lua 1 Oct 2009 04:21:00 -0000 1.184 *************** *** 18,22 **** -- --------------------------------------------------------------------------- ! WXLUA_BINDING_VERSION = 28 -- 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 = 29 -- Used to verify that the bindings are updated -- This must match modules/wxlua/include/wxldefs.h -- otherwise a compile time error will be generated. *************** *** 51,55 **** classTypeBindingTable = {} classIncludeBindingTable = {} - encapsulationBindingTable = {} overrideTable = {} -- binding code from override file as a table indexed by C function name --- 51,54 ---- *************** *** 204,208 **** Abstract = abstract, Condition = nil, -- conditions for this data type, eg. wxLUA_USE_xxx - ["%encapsulate"] = nil, -- Non wxObject derived class } end --- 203,206 ---- *************** *** 1211,1216 **** -- keywords that 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 --- 1209,1212 ---- *************** *** 1639,1644 **** Members = {}, ["%delete"] = false, - ["%noclassinfo"] = false, - ["%encapsulate"] = false, Condition = nil, } --- 1635,1638 ---- *************** *** 1963,1969 **** lineState.ActionMandatory = true lineState.ActionAttributes["%delete"] = true - lineState.ActionAttributes["%noclassinfo"] = true lineState.ActionAttributes["%abstract"] = true - lineState.ActionAttributes["%encapsulate"] = true elseif tag == "%endclass" then --- 1957,1961 ---- *************** *** 1990,2000 **** end - elseif tag == "%noclassinfo" then -- tag for %class - parseState.ObjectStack[1]["%noclassinfo"] = true - - if (parseState.ObjectStack[1].ObjType ~= "objtype_%class") and (parseState.ObjectStack[1].ObjType ~= "objtype_%struct") then - print("ERROR: %noclassinfo is not used for a %class. "..LineTableErrString(lineTable)) - end - elseif tag == "%abstract" then -- tag for %class parseState.ObjectStack[1]["%abstract"] = true --- 1982,1985 ---- *************** *** 2004,2014 **** end - elseif tag == "%encapsulate" then -- tag for %class - parseState.ObjectStack[1]["%encapsulate"] = true - - if (parseState.ObjectStack[1].ObjType ~= "objtype_%class") and (parseState.ObjectStack[1].ObjType ~= "objtype_%struct") then - print("ERROR: %encapsulate is not used for a %class. "..LineTableErrString(lineTable)) - end - -- ------------------------------------------------------- elseif tag == "%protected" then -- skip %protected functions --- 1989,1992 ---- *************** *** 2062,2067 **** table.insert(parseState.ObjectStack, 1, parseObject) lineState.ParseObjectDeclaration = true - parseState.ObjectStack[1]["%noclassinfo"] = true - parseState.ObjectStack[1]["%encapsulate"] = true lineState.DefType = "deftype_%struct" --- 2040,2043 ---- *************** *** 2069,2075 **** lineState.ActionMandatory = true lineState.ActionAttributes["%delete"] = true - lineState.ActionAttributes["%noclassinfo"] = true lineState.ActionAttributes["%abstract"] = true - lineState.ActionAttributes["%encapsulate"] = true elseif tag == "%endstruct" then --- 2045,2049 ---- *************** *** 2738,2746 **** end - -- Set if this data type should be Encapsulated - if dataTypeTable[parseState.ObjectStack[1].Name] and parseState.ObjectStack[1]["%encapsulate"] then - dataTypeTable[parseState.ObjectStack[1].Name]["%encapsulate"] = parseState.ObjectStack[1]["%encapsulate"] - end - -- pop inline condition onto condition stack if not lineState.IsBlockCondition and lineState.Condition then --- 2712,2715 ---- *************** *** 2864,2893 **** end - -- ------------------------------------------------------------------- - -- encapsulate non-wxObject objects with a tracked wxObject - if parseObject["%encapsulate"] then - - local encapcondition = FixCondition(parseObject.Condition) - local encapsulationBinding = - { - Declaration = "wxLUA_DECLARE_ENCAPSULATION("..output_cpp_impexpsymbol..", "..parseObject.Name..", "..MakeVar(parseObject.Name)..")\n", - Implementation = "wxLUA_IMPLEMENT_ENCAPSULATION("..parseObject.Name..", "..MakeVar(parseObject.Name)..")\n", - Condition = encapcondition - } - - if IsDerivedClass(parseObject.Name, "wxGridCellWorker") or - IsDerivedClass(parseObject.Name, "wxGridCellAttr") then - encapsulationBinding.Implementation = "wxLUA_IMPLEMENT_wxGridCellWorker_ENCAPSULATION("..parseObject.Name..", "..MakeVar(parseObject.Name)..")\n" - end - - if not encapsulationBindingTable[encapcondition] then - encapsulationBindingTable[encapcondition] = {} - end - - if parseObject["%encapsulate"] then - encapsulationBindingTable[encapcondition][parseObject.Name] = encapsulationBinding - end - end - -- parseObject member binding for m = 1, #parseObject.Members do --- 2833,2836 ---- *************** *** 2915,2922 **** end - if parseObject["%encapsulate"] then - --funcType = AddOredValue(funcType, "WXLUAMETHOD_ENCAPSULATE") FIXME - end - local memberPtr = member.DataTypePointer[1] local indirectionCount = #member.DataTypePointer --- 2858,2861 ---- *************** *** 3479,3487 **** if param.GC then ! if dataTypeTable[argType]["%encapsulate"] then ! table.insert(gcList, " if (!wxluaO_isgcobject(L, "..argName..")) wxluaO_addgcobject(L, (void*)"..argName..", new wxLua_wxObject_"..MakeVar(argType).."("..argName.."));\n") ! else ! table.insert(gcList, " if (!wxluaO_isgcobject(L, "..argName..")) wxluaO_addgcobject(L, "..argName..");\n") ! end elseif param.UnGC then table.insert(gcList, " if (wxluaO_isgcobject(L, "..argName..")) wxluaO_undeletegcobject(L, "..argName..");\n") --- 3418,3422 ---- if param.GC then ! table.insert(gcList, " if (!wxluaO_isgcobject(L, "..argName..")) wxluaO_addgcobject(L, "..argName..", wxluatype_"..MakeVar(argType)..");\n") elseif param.UnGC then table.insert(gcList, " if (wxluaO_isgcobject(L, "..argName..")) wxluaO_undeletegcobject(L, "..argName..");\n") *************** *** 3655,3662 **** if not funcNameBase then funcNameBase = funcName end - if parseObject["%encapsulate"] then - --funcType = AddOredValue(funcType, "WXLUAMETHOD_ENCAPSULATE") FIXME - end - -- if they declared this, the conditions must be exclusive -- since the functions will have the same names --- 3590,3593 ---- *************** *** 3807,3816 **** end ! if parseObject["%encapsulate"] then ! table.insert(codeList, " wxluaO_addgcobject(L, (void*)returns, new wxLua_wxObject_"..MakeVar(parseObject.Name).."(("..returnCast..")returns));\n") ! else ! table.insert(codeList, " wxluaO_addgcobject(L, returns);\n") ! end ! elseif not parseObject["%noclassinfo"] then CommentBindingTable(codeList, " // add to tracked window list, it will check validity\n") table.insert(codeList, " wxluaW_addtrackedwindow(L, returns);\n") --- 3738,3743 ---- end ! table.insert(codeList, " wxluaO_addgcobject(L, returns, wxluatype_"..MakeVar(parseObject.Name)..");\n") ! elseif IsDerivedClass(parseObject.Name, "wxWindow") then CommentBindingTable(codeList, " // add to tracked window list, it will check validity\n") table.insert(codeList, " wxluaW_addtrackedwindow(L, returns);\n") *************** *** 3837,3845 **** table.insert(codeList, " wxluaO_undeletegcobject(L, self);\n") elseif parseObject["%gc_this"] then ! if parseObject["%encapsulate"] then ! table.insert(codeList, " if (!wxluaO_isgcobject(L, self)) wxluaO_addgcobject(L, (void*)self, new wxLua_wxObject_"..MakeClassVar(parseObject.Name).."(self));\n") ! else ! table.insert(codeList, " wxluaO_addgcobject(L, self);\n") ! end end --- 3764,3768 ---- table.insert(codeList, " wxluaO_undeletegcobject(L, self);\n") elseif parseObject["%gc_this"] then ! table.insert(codeList, " wxluaO_addgcobject(L, self, wxluatype_"..MakeClassVar(parseObject.Name)..");\n") end *************** *** 3924,3932 **** local member_DataType = GetDataTypedefBase(memberType) ! if member_DataType["%encapsulate"] then ! table.insert(codeList, " wxluaO_addgcobject(L, (void*)returns, new wxLua_wxObject_"..MakeVar(member_DataType.Name).."(("..returnCast..")returns));\n") ! else ! table.insert(codeList, " wxluaO_addgcobject(L, ("..returnCast..")returns);\n") ! end elseif (not member["%operator"]) and (memberPtr == "&") and string.find(memberTypeWithAttrib, "*") and (memberType ~= "wxString") then --- 3847,3851 ---- local member_DataType = GetDataTypedefBase(memberType) ! table.insert(codeList, " wxluaO_addgcobject(L, returns, wxluatype_"..MakeVar(member_DataType.Name)..");\n") elseif (not member["%operator"]) and (memberPtr == "&") and string.find(memberTypeWithAttrib, "*") and (memberType ~= "wxString") then *************** *** 3936,3944 **** if member.GC then ! if dataTypeTable[memberType]["%encapsulate"] then ! table.insert(codeList, " if (!wxluaO_isgcobject(L, returns)) wxluaO_addgcobject(L, (void*)returns, new wxLua_wxObject_"..MakeVar(memberType).."(returns));\n") ! else ! table.insert(codeList, " if (!wxluaO_isgcobject(L, returns)) wxluaO_addgcobject(L, returns);\n") ! end elseif member.UnGC then table.insert(codeList, " if (wxluaO_isgcobject(L, returns)) wxluaO_undeletegcobject(L, returns);\n") --- 3855,3859 ---- if member.GC then ! table.insert(codeList, " if (!wxluaO_isgcobject(L, returns)) wxluaO_addgcobject(L, returns, wxluatype_"..MakeVar(memberType)..");\n") elseif member.UnGC then table.insert(codeList, " if (wxluaO_isgcobject(L, returns)) wxluaO_undeletegcobject(L, returns);\n") *************** *** 4058,4079 **** end - - -- Extern Class Tag Declaration - local tagcondition = FixCondition(parseObject.Condition) - local classTypeBinding = - { - ExternDeclaration = "extern "..MakeImpExpData("int").." wxluatype_"..MakeClassVar(parseObject.Name)..";\n", - --ExternMethodDeclaration = "extern "..output_cpp_impexpsymbol.." wxLuaBindMethod "..MakeVar(parseObject.Name).."_methods[];\n", - --ExternMethodCountDeclaration = "extern "..MakeImpExpData("int").." "..MakeVar(parseObject.Name).."_methodCount;\n", - ExternMethodDeclaration = "extern wxLuaBindMethod "..MakeVar(parseObject.Name).."_methods[];\n", - ExternMethodCountDeclaration = "extern int "..MakeVar(parseObject.Name).."_methodCount;\n", - ExternEnumDeclaration = ExternEnumDeclaration, - ExternEnumCountDeclaration = ExternEnumCountDeclaration, - Condition = tagcondition - } - - if not classTypeBindingTable[tagcondition] then classTypeBindingTable[tagcondition] = {} end - classTypeBindingTable[tagcondition][parseObject.Name] = classTypeBinding - -- Class Tag Declaration local decl = ""; --- 3973,3976 ---- *************** *** 4135,4141 **** end local classinfo = "NULL" ! if not parseObject["%noclassinfo"] then classinfo = "CLASSINFO("..parseObject.Name..")" end --- 4032,4062 ---- end + local wxlua_delete_function_name = "wxLua_"..MakeVar(parseObject.Name).."_delete_function" + + -- Extern Class Tag Declaration + local tagcondition = FixCondition(parseObject.Condition) + local classTypeBinding = + { + LuaName = MakeVar(parseObject.Name), + ExternDeclaration = "extern "..MakeImpExpData("int").." wxluatype_"..MakeClassVar(parseObject.Name)..";\n", + --ExternMethodDeclaration = "extern "..output_cpp_impexpsymbol.." wxLuaBindMethod "..MakeVar(parseObject.Name).."_methods[];\n", + --ExternMethodCountDeclaration = "extern "..MakeImpExpData("int").." "..MakeVar(parseObject.Name).."_methodCount;\n", + ExternMethodDeclaration = "extern wxLuaBindMethod "..MakeVar(parseObject.Name).."_methods[];\n", + ExternMethodCountDeclaration = "extern int "..MakeVar(parseObject.Name).."_methodCount;\n", + ExternEnumDeclaration = ExternEnumDeclaration, + ExternEnumCountDeclaration = ExternEnumCountDeclaration, + BaseClassTypes = baseclassTypes, + BaseClassVtableOffsets = baseclassVtableOffsets, + ExternDeleteFunction = "extern void "..wxlua_delete_function_name.."(void** p);\n", + Condition = tagcondition + } + + if not classTypeBindingTable[tagcondition] then classTypeBindingTable[tagcondition] = {} end + classTypeBindingTable[tagcondition][parseObject.Name] = classTypeBinding local classinfo = "NULL" ! local is_wxObject = IsDerivedClass(parseObject.Name, "wxObject") ! ! if is_wxObject then classinfo = "CLASSINFO("..parseObject.Name..")" end *************** *** 4163,4170 **** local funcType = "WXLUAMETHOD_METHOD" - if parseObject["%encapsulate"] then - --funcType = AddOredValue(funcType, "WXLUAMETHOD_ENCAPSULATE") FIXME - end - local delMethodBinding = { --- 4084,4087 ---- *************** *** 4191,4194 **** --- 4108,4112 ---- table.insert(interface.objectData[o].BindTable, delMethodBinding) end + local classcondition = FixCondition(parseObject.Condition) *************** *** 4207,4214 **** ..enumArrayName..", " ..enumArrayCountName..", " .."}, \n", BaseClasses = dataTypeTable[parseObject.Name].BaseClasses, - BaseClassTypes = baseclassTypes, - BaseClassVtableOffsets = baseclassVtableOffsets, Condition = classcondition } --- 4125,4131 ---- ..enumArrayName..", " ..enumArrayCountName..", " + .."&"..wxlua_delete_function_name..", " .."}, \n", BaseClasses = dataTypeTable[parseObject.Name].BaseClasses, Condition = classcondition } *************** *** 4421,4453 **** table.insert(fileData, "\n") - -- ------------------------------------------------------------------------ - -- Encapsulation Declarations - sorted by condition for the C++ compiler - -- ------------------------------------------------------------------------ - - table.insert(fileData, "// ---------------------------------------------------------------------------\n") - table.insert(fileData, "// Encapsulation Declarations - need to be public for other bindings.\n") - table.insert(fileData, "// ---------------------------------------------------------------------------\n\n") - - for condition, encapsulationBindingList in pairs_sort(encapsulationBindingTable) do - local indent = "" - - if HasCondition(condition) then - indent = " " - table.insert(fileData, "#if "..condition.."\n") - end - - for idx, encapsulationBinding in pairs_sort(encapsulationBindingList) do - if encapsulationBinding and encapsulationBinding.Declaration then - table.insert(fileData, indent..encapsulationBinding.Declaration) - end - end - - if HasCondition(condition) then - table.insert(fileData, "#endif // "..condition.."\n\n") - else - table.insert(fileData, "\n") - end - end - table.insert(fileData, "\n") table.insert(fileData, "#endif // __HOOK_WXLUA_"..hook_cpp_namespace.."_H__\n\n") --- 4338,4341 ---- *************** *** 4541,4549 **** table.insert(fileData, s.." NULL };\n") table.insert(fileData, "static wxLuaBindClass* wxluabaseclassbinds_"..sortedBindings[n][i].LuaName.."[] = { "..string.sub(string.rep("NULL, ", bc_n), 1, -3).." };\n") - - if sortedBindings[n][i].BaseClassVtableOffsets then - table.insert(fileData, "static wxLuaArgType wxluabaseclass_wxluatypes_"..sortedBindings[n][i].LuaName.."[] = "..sortedBindings[n][i].BaseClassTypes.."\n") - table.insert(fileData, "static int wxluabaseclass_vtable_offsets_"..sortedBindings[n][i].LuaName.."[] = "..sortedBindings[n][i].BaseClassVtableOffsets.."\n") - end end end --- 4429,4432 ---- *************** *** 4575,4578 **** --- 4458,4468 ---- table.insert(fileData, indent..classTypeBinding.ExternEnumCountDeclaration) end + + if classTypeBinding.BaseClassVtableOffsets then + table.insert(fileData, indent.."static wxLuaArgType wxluabaseclass_wxluatypes_"..classTypeBinding.LuaName.."[] = "..classTypeBinding.BaseClassTypes.."\n") + table.insert(fileData, indent.."static int wxluabaseclass_vtable_offsets_"..classTypeBinding.LuaName.."[] = "..classTypeBinding.BaseClassVtableOffsets.."\n") + end + + table.insert(fileData, indent..classTypeBinding.ExternDeleteFunction) end *************** *** 4640,4662 **** end - -- ------------------------------------------------------------------------ - -- Encapsulation Implementation - -- ------------------------------------------------------------------------ - for condition, encapsulationBindingList in pairs_sort(encapsulationBindingTable) do - if HasCondition(condition) then - table.insert(fileData, "\n#if "..condition.."\n") - end - - for idx, encapsulationBinding in pairs_sort(encapsulationBindingList) do - if encapsulationBinding and encapsulationBinding.Declaration then - table.insert(fileData, encapsulationBinding.Implementation) - end - end - - if HasCondition(condition) then - table.insert(fileData, "#endif // "..condition.."\n\n") - end - end - table.insert(fileData, "\n") --- 4530,4533 ---- *************** *** 5036,5039 **** --- 4907,4927 ---- GenerateMap(fileData, overloadBindings, " ", writeFunc, true, object.Condition) + -- Generate the C++ delete function + + local wxlua_delete_function_name = "wxLua_"..MakeClassVar(ObjectName).."_delete_function" + local wxlua_delete_function_code = "" + + if overrideTable[wxlua_delete_function_name] then + overrideTableUsed[wxlua_delete_function_name] = true + wxlua_delete_function_code = table.concat(overrideTable[wxlua_delete_function_name]) + else + wxlua_delete_function_code = + "void "..wxlua_delete_function_name.."(void** p)\n{\n".. + " "..ObjectName.."* o = ("..ObjectName.."*)(*p);\n".. + " delete o;\n}\n\n" + end + + table.insert(fileData, wxlua_delete_function_code); + -- Output Method Map Table |