From: John L. <jr...@us...> - 2007-06-25 03:20:11
|
Update of /cvsroot/wxlua/wxLua/bindings In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv32516/wxLua/bindings Modified Files: genidocs.lua genwxbind.lua Log Message: Add %gc, %ungc, %gc_this, and %ungc_this for fine tuning of tracking or releasing the garbage collection of userdata objects that become owned or released by something other than wxLua. Added %delete to many more classes using the above tags to control when and if they should be deleted. Index: genidocs.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genidocs.lua,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** genidocs.lua 20 Jun 2007 22:57:33 -0000 1.8 --- genidocs.lua 25 Jun 2007 03:19:37 -0000 1.9 *************** *** 342,346 **** if not in_blk_comment then print("ERROR mismatched /* */ in :", filename, line_n, line) end in_blk_comment = false ! out_line = string.sub(out_line, 1, t[n].s-1).."</font>"..string.sub(out_line, t[n].s) end end --- 342,346 ---- if not in_blk_comment then print("ERROR mismatched /* */ in :", filename, line_n, line) end in_blk_comment = false ! out_line = string.sub(out_line, 1, t[n].s+1).."</font>"..string.sub(out_line, t[n].s+2) end end Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.132 retrieving revision 1.133 diff -C2 -d -r1.132 -r1.133 *** genwxbind.lua 20 Jun 2007 22:57:33 -0000 1.132 --- genwxbind.lua 25 Jun 2007 03:19:37 -0000 1.133 *************** *** 65,69 **** end ! -- make these string.XXX functions local so there's table lookup local string_sub = string.sub local string_len = string.len --- 65,69 ---- end ! -- make these string.XXX functions local so there's no table lookup local string_sub = string.sub local string_len = string.len *************** *** 77,84 **** -- --------------------------------------------------------------------------- function CheckRules() ! assert(type(interface_filepath) == "string", "Rules file ERROR: 'interface_filepath' is not a string") ! assert(type(output_cpp_filepath) == "string", "Rules file ERROR: 'output_cpp_filepath' is not a string") assert(type(output_cpp_header_filepath) == "string", "Rules file ERROR: 'output_cpp_header_filepath' is not a string") ! assert(type(output_cpp_impexpsymbol) == "string", "Rules file ERROR: 'output_cpp_impexpsymbol' is not a string") assert(type(output_cpp_impexpdatasymbol) == "string", "Rules file ERROR: 'output_cpp_impexpdatasymbol' is not a string") --- 77,84 ---- -- --------------------------------------------------------------------------- function CheckRules() ! assert(type(interface_filepath) == "string", "Rules file ERROR: 'interface_filepath' is not a string") ! assert(type(output_cpp_filepath) == "string", "Rules file ERROR: 'output_cpp_filepath' is not a string") assert(type(output_cpp_header_filepath) == "string", "Rules file ERROR: 'output_cpp_header_filepath' is not a string") ! assert(type(output_cpp_impexpsymbol) == "string", "Rules file ERROR: 'output_cpp_impexpsymbol' is not a string") assert(type(output_cpp_impexpdatasymbol) == "string", "Rules file ERROR: 'output_cpp_impexpdatasymbol' is not a string") *************** *** 277,280 **** --- 277,283 ---- dataTypeAttribTable["const"] = true + dataTypeAttribTable["%gc"] = true -- this object will be gc by lua + dataTypeAttribTable["%ungc"] = true -- this object won't be gc by lua + -- attributes that can precede a function (must set equal to true) functionAttribTable["static"] = true *************** *** 297,301 **** for i = 1, #typeData do if cast < 0 then ! print("Error in casting data type, mismatched () '"..decl.."'") end --- 300,304 ---- for i = 1, #typeData do if cast < 0 then ! print("ERROR: Mismatched () in casting data type: '"..decl.."'") end *************** *** 320,324 **** if not data_type then ! print("Cannot find data type: '"..decl.."'") end --- 323,327 ---- if not data_type then ! print("ERROR: Cannot find data type: '"..decl.."'") end *************** *** 388,392 **** elseif typedefTable[datatype] then if not dataTypeTable[typedefTable[datatype]] then ! print("Error - supposed datatype: '"..datatype.."' has typedef = '"..typedefTable[datatype].."' which is not a data type either") end --- 391,395 ---- elseif typedefTable[datatype] then if not dataTypeTable[typedefTable[datatype]] then ! print("ERROR: Supposed datatype: '"..tostring(datatype).."' has typedef = '"..typedefTable[datatype].."' which is not a data type either") end *************** *** 436,440 **** end ! print("Error: Missing data type '"..datatype.."' in GetDataTypeBase.") return nil --- 439,443 ---- end ! print("Error: Missing data type '"..tostring(datatype).."' in GetDataTypeBase.") return nil *************** *** 463,467 **** return dtype.IsNumber else ! print("Error: Missing data type '"..datatype.."' in IsDataTypeNumeric.") end --- 466,470 ---- return dtype.IsNumber else ! print("Error: Missing data type '"..tostring(datatype).."' in IsDataTypeNumeric.") end *************** *** 477,481 **** return (dtype.DefType == "enum") else ! print("Error: Missing data type '"..datatype.."' in IsDataTypeEnum.") end --- 480,484 ---- return (dtype.DefType == "enum") else ! print("Error: Missing data type '"..tostring(datatype).."' in IsDataTypeEnum.") end *************** *** 1115,1118 **** --- 1118,1124 ---- bindingKeywordTable["%includefile"] = true + bindingKeywordTable["%gc_this"] = true + bindingKeywordTable["%ungc_this"] = true + bindingKeywordTable["%define"] = true bindingKeywordTable["%define_string"] = true *************** *** 1145,1149 **** -- keepTable - list of delimiters that will be kept in return list -- stringliterals - bool - true to not tokenise string literals ! -- lineTable - table w/ .File name and .LineNumber for error messages -- --------------------------------------------------------------------------- function SplitString(str, delimTable, keepTable, stringliterals, lineTable) --- 1151,1155 ---- -- keepTable - list of delimiters that will be kept in return list -- stringliterals - bool - true to not tokenise string literals ! -- lineTable - table w/ .FileName name and .LineNumber for error messages -- --------------------------------------------------------------------------- function SplitString(str, delimTable, keepTable, stringliterals, lineTable) *************** *** 1358,1362 **** -- --------------------------------------------------------------------------- ! -- Load an interface file creating a table {filename, line number, tags, line} -- --------------------------------------------------------------------------- function ReadInterfaceFile(filename) --- 1364,1368 ---- -- --------------------------------------------------------------------------- ! -- Load an interface file creating a table {FileName, LineNumber, Tags, Line} -- --------------------------------------------------------------------------- function ReadInterfaceFile(filename) *************** *** 1366,1370 **** for line in io.lines(filename) do linenumber = linenumber + 1 ! local lineTable = { File=filename, LineNumber=linenumber, Tags=nil, Line=line } lineTable.Tags = SplitString(line, bindingDelimiters, bindingDelimsToKeep, true, lineTable) table.insert(filedata, lineTable) --- 1372,1376 ---- for line in io.lines(filename) do linenumber = linenumber + 1 ! local lineTable = { FileName=filename, LineNumber=linenumber, Tags=nil, LineText=line } lineTable.Tags = SplitString(line, bindingDelimiters, bindingDelimsToKeep, true, lineTable) table.insert(filedata, lineTable) *************** *** 1380,1384 **** function LineTableErrString(lineTable) if lineTable then ! return "File: '"..lineTable.File.."':(line "..lineTable.LineNumber..")\n '"..lineTable.Line.."'" else return "" --- 1386,1390 ---- function LineTableErrString(lineTable) if lineTable then ! return "File: '"..lineTable.FileName.."':(line "..lineTable.LineNumber..")\n '"..lineTable.LineText.."'" else return "" *************** *** 1405,1409 **** BuildDataTypeTable(interfaceFileData) ! table.insert(interfaceFileDataList, { File=filename, Data=interfaceFileData }) else print("ERROR : Interface file does not exist : '"..filename.."'") --- 1411,1415 ---- BuildDataTypeTable(interfaceFileData) ! table.insert(interfaceFileDataList, { FileName=filename, Data=interfaceFileData }) else print("ERROR : Interface file does not exist : '"..filename.."'") *************** *** 1416,1420 **** for i = 1, #interfaceFileDataList do ! local filename = interfaceFileDataList[i].File local interfaceFileData = interfaceFileDataList[i].Data --- 1422,1426 ---- for i = 1, #interfaceFileDataList do ! local filename = interfaceFileDataList[i].FileName local interfaceFileData = interfaceFileDataList[i].Data *************** *** 1509,1514 **** AltName = lineState.AltName, Value = lineState.Value, - PropertyRead = lineState.PropertyRead, - PropertyWrite = lineState.PropertyWrite, IsCFunction = lineState.IsCFunction, IsConstructor = lineState.IsConstructor, --- 1515,1518 ---- *************** *** 1520,1530 **** IsPureVirtualFunction = lineState.IsPureVirtualFunction, NotOverload = lineState.NotOverload, ! OverrideName = lineState.OverrideName, Condition = lineState.Condition, ExtraCondition = extraCondition, Params = lineState.Params, ! File = lineState.File, LineNumber = lineState.LineNumber, ! LineData = lineState.LineData, } --- 1524,1536 ---- IsPureVirtualFunction = lineState.IsPureVirtualFunction, NotOverload = lineState.NotOverload, ! override_name = lineState.override_name, Condition = lineState.Condition, ExtraCondition = extraCondition, Params = lineState.Params, ! FileName = lineState.FileName, LineNumber = lineState.LineNumber, ! LineText = lineState.LineText, ! GCThis = lineState.GCThis, ! UnGCThis = lineState.UnGCThis, } *************** *** 1688,1693 **** AltName = nil, Value = nil, ! PropertyRead = false, ! PropertyWrite = false, IsCFunction = nil, IsConstructor = nil, --- 1694,1699 ---- AltName = nil, Value = nil, ! GCThis = nil, ! UnGCThis = nil, IsCFunction = nil, IsConstructor = nil, *************** *** 1698,1708 **** IsVirtualFunction = nil, IsPureVirtualFunction = nil, ! OverrideName = nil, NotOverload = nil, Condition = nil, Params = {}, ! File = lineTable.File, LineNumber = lineTable.LineNumber, ! LineData = lineTable.Line, } --- 1704,1714 ---- IsVirtualFunction = nil, IsPureVirtualFunction = nil, ! override_name = nil, NotOverload = nil, Condition = nil, Params = {}, ! FileName = lineTable.FileName, LineNumber = lineTable.LineNumber, ! LineText = lineTable.LineText, } *************** *** 1757,1760 **** --- 1763,1780 ---- lineState.IsCFunction = true + elseif tag == "%gc_this" then + lineState.GCThis = true + + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %gc_this is not used for a %class member function. "..LineTableErrString(lineTable)) + end + + elseif tag == "%ungc_this" then + lineState.UnGCThis= true + + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %ungc_this is not used for a %class member function. "..LineTableErrString(lineTable)) + end + -- ------------------------------------------------------- elseif tag == "%class" then *************** *** 1790,1802 **** --- 1810,1838 ---- parseState.ObjectStack[1].DeleteRequired = true + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %delete is not used for a %class. "..LineTableErrString(lineTable)) + end + elseif tag == "%noclassinfo" then -- tag for %class parseState.ObjectStack[1].HasClassInfo = false + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %noclassinfo is not used for a %class. "..LineTableErrString(lineTable)) + end + elseif tag == "%abstract" then -- tag for %class parseState.ObjectStack[1].IsAbstract = true + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %abstract is not used for a %class. "..LineTableErrString(lineTable)) + end + elseif tag == "%encapsulate" then -- tag for %class parseState.ObjectStack[1].Encapsulate = true + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %encapsulate is not used for a %class. "..LineTableErrString(lineTable)) + end + -- ------------------------------------------------------- elseif tag == "%protected" then -- skip %protected functions *************** *** 1812,1818 **** print("WARNING: the %property tag is ignored and properties are generated at runtime.") break - --lineState.DefType = "property" - --lineState.Action = "property" - --lineState.ActionMandatory = true elseif tag == "%member" then --- 1848,1851 ---- *************** *** 1821,1830 **** --- 1854,1875 ---- lineState.ActionMandatory = true + if (parseState.ObjectStack[1].DefType ~= "class") and (parseState.ObjectStack[1].DefType ~= "struct") then + print("Error: %member is not used for a %class or %struct. "..LineTableErrString(lineTable)) + end + elseif tag == "%constructor" then lineState.IsConstructor = true + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %constructor is not used for a %class. "..LineTableErrString(lineTable)) + end + elseif tag == "%operator" then lineState.IsOperator = true + if parseState.ObjectStack[1].DefType ~= "class" then + print("Error: %operator is not used for a %class. "..LineTableErrString(lineTable)) + end + -- ------------------------------------------------------- elseif tag == "%struct" then *************** *** 2126,2130 **** lineState.ActionMandatory = false elseif lineState.Action == "override_name" then ! lineState.OverrideName = tag lineState.Action = nil --- 2171,2175 ---- lineState.ActionMandatory = false elseif lineState.Action == "override_name" then ! lineState.override_name = tag lineState.Action = nil *************** *** 2140,2173 **** lineState.Action = "typedefvalue" lineState.ActionMandatory = false - elseif lineState.Action == "property" then - if tag ~= "=" then - print("Error: %property expected '='. "..LineTableErrString(lineTable)) - end - - lineState.Action = "propertyname" - lineState.ActionMandatory = true - elseif lineState.Action == "propertyname" then - lineState.Name = tag - - lineState.Action = "propertycomma" - lineState.ActionMandatory = false - elseif lineState.Action == "propertycomma" then - if tag ~= "," then - print("Error: %property expected ','. "..LineTableErrString(lineTable)) - end - - lineState.Action = "propertyallow" - lineState.ActionMandatory = true - elseif lineState.Action == "propertyallow" then - if tag == "read" then - lineState.PropertyRead = true - elseif tag == "write" then - lineState.PropertyWrite = true - else - print("Error: %property expected 'read' or 'write' attribute. "..LineTableErrString(lineTable)) - end - - lineState.Action = "propertycomma" - lineState.ActionMandatory = false elseif lineState.Action == "rename" then --- 2185,2188 ---- *************** *** 2485,2491 **** table.insert(parseState.ConditionStack, lineState.Condition) - elseif lineState.DefType == "property" then - table.insert(parseState.ObjectStack[1].Members, AllocMember(lineState, BuildCondition(parseState.ConditionStack))) - elseif lineState.DefType == "member" then table.insert(parseState.ObjectStack[1].Members, AllocMember(lineState, BuildCondition(parseState.ConditionStack))) --- 2500,2503 ---- *************** *** 2525,2529 **** 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 --- 2537,2541 ---- end ! -- Set if this data type shoulntpdate pool.ntp.orgd be Encapsulated if dataTypeTable[parseState.ObjectStack[1].Name] and parseState.ObjectStack[1].Encapsulate then dataTypeTable[parseState.ObjectStack[1].Name].Encapsulate = parseState.ObjectStack[1].Encapsulate *************** *** 2663,2727 **** -- --------------------------------------------------------------- - -- property binding - -- --------------------------------------------------------------- - if member.DefType == "property" then - -- conditions for member are dependent on return type, argument types, and inline conditions - local dependConditions = {} - - if HasCondition(fullcondition) then - dependConditions[fullcondition] = fullcondition - end - - -- find return condition on property Get function - local getMemberName = "Get"..member.Name - for get = 1, #parseObject.Members do - local getMember = parseObject.Members[get] - if getMember.Name == getMemberName then - local returnCondition = GetDataTypeCondition(getMember.DataType) - if returnCondition then - dependConditions[returnCondition] = returnCondition - end - - break - end - end - - -- build property condition - local propertycondition = nil - for idx, condition in pairs(dependConditions) do - propertycondition = AddCondition(propertycondition, condition) - end - propertycondition = FixCondition(propertycondition) - - -- read property - if member.PropertyRead then - local propertyBinding = - { - LuaName = member.Name, - FuncType = "WXLUAMETHOD_GETPROP", - Map = " { \""..member.Name.."\", WXLUAMETHOD_GETPROP, s_wxluafunc_wxLua_"..MakeVar(parseObject.Name).."_Get"..member.Name..", 1 },\n", - Condition = propertycondition - } - - table.insert(interface.objectData[o].BindTable, propertyBinding) - end - - -- write property - if member.PropertyWrite then - local propertyBinding = - { - LuaName = member.Name, - FuncType = "WXLUAMETHOD_SETPROP", - Map = " { \""..member.Name.."\", WXLUAMETHOD_SETPROP, s_wxluafunc_wxLua_"..MakeVar(parseObject.Name).."_Set"..member.Name..", 1 },\n", - Condition = propertycondition - } - - table.insert(interface.objectData[o].BindTable, propertyBinding) - end - - -- --------------------------------------------------------------- -- member binding -- --------------------------------------------------------------- ! elseif member.DefType == "member" then local memberType = GetTypeDef(member.DataType) local memberGetFunc = "Get_"..member.Name --- 2675,2681 ---- -- --------------------------------------------------------------- -- member binding -- --------------------------------------------------------------- ! if member.DefType == "member" then local memberType = GetTypeDef(member.DataType) local memberGetFunc = "Get_"..member.Name *************** *** 2759,2763 **** local overload_argList = "" local funcName = "wxLua_"..MakeVar(parseObject.Name).."_"..memberGetFunc ! CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].Line.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") table.insert(codeList, " wxLuaState wxlState(L);\n") --- 2713,2717 ---- local overload_argList = "" local funcName = "wxLua_"..MakeVar(parseObject.Name).."_"..memberGetFunc ! CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].LineText.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") table.insert(codeList, " wxLuaState wxlState(L);\n") *************** *** 2839,2843 **** overload_argList = "" local funcName = "wxLua_"..MakeVar(parseObject.Name).."_"..memberSetFunc ! CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].Line.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") table.insert(codeList, " wxLuaState wxlState(L);\n") --- 2793,2797 ---- overload_argList = "" local funcName = "wxLua_"..MakeVar(parseObject.Name).."_"..memberSetFunc ! CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].LineText.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") table.insert(codeList, " wxLuaState wxlState(L);\n") *************** *** 3058,3061 **** --- 3012,3016 ---- local argList = "" local overload_argList = "" + local gcList = {} local arg = 0 *************** *** 3064,3067 **** --- 3019,3034 ---- local param = member.Params[arg] + -- See if we're supposed to track or untrack the parameter + local a = string.find(param.DataTypeWithAttrib, "%gc", 1, 1) + if a then + param.DataTypeWithAttrib = string.sub(param.DataTypeWithAttrib, 1, a-1)..string.sub(param.DataTypeWithAttrib, a+4) + param.GC = true + end + local a = string.find(param.DataTypeWithAttrib, "%ungc", 1, 1) + if a then + param.DataTypeWithAttrib = string.sub(param.DataTypeWithAttrib, 1, a-1)..string.sub(param.DataTypeWithAttrib, a+6) + param.UnGC = true + end + local declare = nil local argType = param.DataType *************** *** 3112,3116 **** ! -- the function take (void*), but we just pass an int if argType == "voidptr_long" then argType = "long" --- 3079,3083 ---- ! -- the function takes (void*), but we just pass a long if argType == "voidptr_long" then argType = "long" *************** *** 3219,3222 **** --- 3186,3200 ---- argItem = "("..argTypeWithAttrib..")wxlState.ttouserdata("..argNum..")" end + + if param.GC then + if dataTypeTable[argType].Encapsulate then + table.insert(gcList, " if (!wxlState.IsTrackedObject("..argName..")) wxlState.AddTrackedObject((long)"..argName..", new wxLua_wxObject_"..MakeVar(argType).."("..argName.."));\n") + else + table.insert(gcList, " if (!wxlState.IsTrackedObject("..argName..")) wxlState.AddTrackedObject("..argName..");\n") + end + elseif param.UnGC then + table.insert(gcList, " if (wxlState.IsTrackedObject("..argName..")) wxlState.RemoveTrackedObject("..argName..", false);\n") + end + end elseif (indirectionCount == 2) and (argPtr == "*") then *************** *** 3305,3309 **** if not param.Name then ! print("Error: No Param Name: "..member.LineData.." "..LineTableErrString(member)) end --- 3283,3287 ---- if not param.Name then ! print("Error: No Param Name: "..member.LineText.." "..LineTableErrString(member)) end *************** *** 3392,3396 **** -- function ! CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].Line.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") if member.IsConstructor then --- 3370,3374 ---- -- function ! CommentBindingTable(codeList, "// "..interface.lineData[member.LineNumber].LineText.."\n") table.insert(codeList, "static int LUACALL "..funcName.."(lua_State *L)\n{\n") if member.IsConstructor then *************** *** 3399,3402 **** --- 3377,3392 ---- table.insert(codeList, " wxLuaState wxlState(L);\n") + -- See if we're supposed to track or untrack the return value + local a = string.find(member.DataTypeWithAttrib, "%gc", 1, 1) + if a then + member.DataTypeWithAttrib = string.sub(member.DataTypeWithAttrib, 1, a-1)..string.sub(member.DataTypeWithAttrib, a+4) + member.GC = true + end + local a = string.find(member.DataTypeWithAttrib, "%ungc", 1, 1) + if a then + member.DataTypeWithAttrib = string.sub(member.DataTypeWithAttrib, 1, a-1)..string.sub(member.DataTypeWithAttrib, a+6) + member.UnGC = true + end + -- determine function return type local memberType = member.DataType *************** *** 3494,3497 **** --- 3484,3491 ---- end + for i = 1, #gcList do + table.insert(codeList, gcList[i]) + end + -- constructor? if member.IsConstructor then *************** *** 3499,3503 **** table.insert(codeList, " returns = new "..parseObject.Name.."("..argList..");\n") ! if parseObject.DeleteRequired then CommentBindingTable(codeList, " // add to tracked memory list\n") --- 3493,3497 ---- table.insert(codeList, " returns = new "..parseObject.Name.."("..argList..");\n") ! if parseObject.GCThis or (parseObject.DeleteRequired and (not parseObject.UnGCThis)) then CommentBindingTable(codeList, " // add to tracked memory list\n") *************** *** 3535,3538 **** --- 3529,3542 ---- overload_argList = "&s_wxluatag_"..MakeClassVar(parseObject.Name)..", "..overload_argList + if parseObject.UnGCThis then + table.insert(codeList, " wxlState.RemoveTrackedObject(self, false);\n") + elseif parseObject.GCThis then + if parseObject.Encapsulate then + table.insert(codeList, " if (!wxlState.IsTrackedObject(self)) wxlState.AddTrackedObject((long)self, new wxLua_wxObject_"..MakeClassVar(parseObject.Name).."(self));\n") + else + table.insert(codeList, " wxlState.AddTrackedObject(self);\n") + end + end + requiredParamCount = requiredParamCount + 1 paramCount = paramCount + 1 *************** *** 3598,3601 **** --- 3602,3616 ---- elseif (memberPtr == "*") or (memberType == "voidptr_long") then table.insert(codeList, " returns = ("..memberTypeWithAttrib..")"..functor..";\n") + + if member.GC then + if dataTypeTable[memberType].Encapsulate then + table.insert(codeList, " if (!wxlState.IsTrackedObject(returns)) wxlState.AddTrackedObject((long)returns, new wxLua_wxObject_"..MakeVar(memberType).."(returns));\n") + else + table.insert(codeList, " if (!wxlState.IsTrackedObject(returns)) wxlState.AddTrackedObject(returns);\n") + end + elseif member.UnGC then + table.insert(codeList, " if (wxlState.IsTrackedObject(returns)) wxlState.RemoveTrackedObject(returns, false);\n") + end + else table.insert(codeList, " returns = ("..functor..");\n") *************** *** 3681,3689 **** -- Override Generated Method Code ! if (member.OverrideName and overrideTable[member.OverrideName]) then ! methodBinding.Method = overrideTable[member.OverrideName] ! methodBinding.PreDefineCode = "#define "..funcName.." "..member.OverrideName.."\n" ! overrideTableUsed[member.OverrideName] = true ! elseif ((member.OverrideName == nil) and overrideTable[methodBinding.CFunctionName]) then methodBinding.Method = overrideTable[methodBinding.CFunctionName] overrideTableUsed[methodBinding.CFunctionName] = true --- 3696,3704 ---- -- Override Generated Method Code ! if (member.override_name and overrideTable[member.override_name]) then ! methodBinding.Method = overrideTable[member.override_name] ! methodBinding.PreDefineCode = "#define "..funcName.." "..member.override_name.."\n" ! overrideTableUsed[member.override_name] = true ! elseif ((member.override_name == nil) and overrideTable[methodBinding.CFunctionName]) then methodBinding.Method = overrideTable[methodBinding.CFunctionName] overrideTableUsed[methodBinding.CFunctionName] = true *************** *** 3797,3800 **** --- 3812,3821 ---- } + -- Override Generated Method Code + if overrideTable[delMethodBinding.CFunctionName] then + delMethodBinding.Method = overrideTable[delMethodBinding.CFunctionName] + overrideTableUsed[delMethodBinding.CFunctionName] = true + end + table.insert(interface.objectData[o].BindTable, delMethodBinding) end *************** *** 4542,4614 **** -- --------------------------------------------------------------------------- - -- GenerateProperties - -- --------------------------------------------------------------------------- - - function GenerateProperties(sortedBindings) - local propMethods = {} - - for n = 1, #sortedBindings do - local methodBindings = sortedBindings[n] - - if methodBindings[1].LuaName and (string.len(methodBindings[1].LuaName) > 3) then - - local is_get = 0 -- count of # of matches, all have to work! - local is_set = 0 - - for i = 1, #methodBindings do - if (methodBindings[i].FuncType == "WXLUAMETHOD_METHOD") then - if (string.find(methodBindings[i].LuaName, "Set", 1, 1) == 1) and - (methodBindings[i].ParamCount == 1) and - (methodBindings[i].RequiredParamCount == 1) then - - is_set = is_set + 1 - - elseif (string.find(methodBindings[i].LuaName, "Get", 1, 1) == 1) and - (methodBindings[i].ParamCount == 0) and - (methodBindings[i].RequiredParamCount == 0) then - - --local ret = 1; - --for j = #methodBindings[i].Method, 1, -1 do - -- local r = string.find(methodBindings[i].Method[j], " return ", 1, 1) - -- if r -- FIXME - -- end - --end - - is_get = is_get + 1 - - end - end - end - - local member = methodBindings[1]; - - local name = string.sub(member.LuaName, 4) - - if is_get == #methodBindings then - local propertyBinding = - { - LuaName = name, - Map = " { WXLUAMETHOD_GETPROP, \""..name.."\", "..member.FuncMapName..", 1, 0 },\n", - Condition = member.Condition - } - - --table.insert(methodBindings, propertyBinding) - - elseif is_set == #methodBindings then - local propertyBinding = - { - LuaName = name, - Map = " { WXLUAMETHOD_SETPROP, \""..name.."\", "..member.FuncMapName..", 1, 0 },\n", - Condition = member.Condition - } - - --table.insert(methodBindings, propertyBinding) - end - - end - end - end - - -- --------------------------------------------------------------------------- -- Write Hook file for an interface file -- --------------------------------------------------------------------------- --- 4563,4566 ---- *************** *** 4684,4691 **** GenerateMap(fileData, overloadBindings, " ", writeFunc, true, object.Condition) - -- Generate the properties - GenerateProperties(sortedBindings) - -- Output Method Map Table CommentBindingTable(fileData, "// Map Lua Class Methods to C Binding Functions\n") --- 4636,4641 ---- GenerateMap(fileData, overloadBindings, " ", writeFunc, true, object.Condition) -- Output Method Map Table + CommentBindingTable(fileData, "// Map Lua Class Methods to C Binding Functions\n") |