From: John L. <jr...@us...> - 2007-03-16 05:08:26
|
Update of /cvsroot/wxlua/wxLua/bindings In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv8749/wxLua/bindings Modified Files: genwxbind.lua Log Message: cleanup, does not change output from last commit Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** genwxbind.lua 15 Mar 2007 23:24:49 -0000 1.108 --- genwxbind.lua 16 Mar 2007 05:07:57 -0000 1.109 *************** *** 280,283 **** --- 280,284 ---- -- --------------------------------------------------------------------------- -- Decode Declaration of a data type, see DecodeDataType + -- For "const wxDateTime &" returns {"const"}, "wxDateTime", {"&"} -- --------------------------------------------------------------------------- function DecodeDecl(decl) *************** *** 321,335 **** -- --------------------------------------------------------------------------- ! -- Decode DataType, see TranslateDataType -- --------------------------------------------------------------------------- function DecodeDataType(decl) local attribs = {} ! local type = nil local ptrs = {} ! attribs, type, ptrs = DecodeDecl(decl) -- merge typeDef declaration ! if typedefTable[type] then -- build new datatype using typeDef local datatype = nil --- 322,337 ---- -- --------------------------------------------------------------------------- ! -- Decode DataType, also handles typedefs, see TranslateDataType ! -- For "const wxDateTime &" returns {"const"}, "wxDateTime", {"&"} -- --------------------------------------------------------------------------- function DecodeDataType(decl) local attribs = {} ! local data_type = nil local ptrs = {} ! attribs, data_type, ptrs = DecodeDecl(decl) -- merge typeDef declaration ! if typedefTable[data_type] then -- build new datatype using typeDef local datatype = nil *************** *** 338,348 **** end ! datatype = SpaceSeparateStrings(datatype, typedefTable[type]) datatype = datatype..table.concat(ptrs) ! attribs, type, ptrs = DecodeDataType(datatype) end ! return attribs, type, ptrs end --- 340,350 ---- end ! datatype = SpaceSeparateStrings(datatype, typedefTable[data_type]) datatype = datatype..table.concat(ptrs) ! attribs, data_type, ptrs = DecodeDataType(datatype) end ! return attribs, data_type, ptrs end *************** *** 352,356 **** function TranslateDataType(param) local attribs = {} ! local type = nil local ptrs = {} --- 354,358 ---- function TranslateDataType(param) local attribs = {} ! local data_type = nil local ptrs = {} *************** *** 358,362 **** local datatype = param.DataTypeWithAttrib.." "..table.concat(param.DataTypePointer) ! attribs, type, ptrs = DecodeDataType(datatype) -- build new datatype --- 360,364 ---- local datatype = param.DataTypeWithAttrib.." "..table.concat(param.DataTypePointer) ! attribs, data_type, ptrs = DecodeDataType(datatype) -- build new datatype *************** *** 366,372 **** end ! tlstype = SpaceSeparateStrings(tlstype, type) ! param.TypedDataType = type param.TypedDataTypeWithAttrib = tlstype param.TypedDataTypePointer = ptrs --- 368,374 ---- end ! tlstype = SpaceSeparateStrings(tlstype, data_type) ! param.TypedDataType = data_type param.TypedDataTypeWithAttrib = tlstype param.TypedDataTypePointer = ptrs *************** *** 379,385 **** if dataTypeTable[datatype] then return true ! end ! ! if 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") --- 381,385 ---- if dataTypeTable[datatype] then return true ! 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") *************** *** 507,528 **** if not file_handle then return false end -- ok if it doesn't exist ! for i = 1, #fileData do ! local line = fileData[i] ! local len = string.len(line) ! local file_line = file_handle:read(len) ! ! if line ~= file_line then ! io.close(file_handle) ! return false ! end ! end ! ! local cur_file_pos = file_handle:seek("cur") ! local end_file_pos = file_handle:seek("end") io.close(file_handle) ! ! if cur_file_pos ~= end_file_pos then return false end -- file is bigger ! ! return true end --- 507,514 ---- if not file_handle then return false end -- ok if it doesn't exist ! local f = file_handle:read("*a") ! local is_same = (f == table.concat(fileData)) io.close(file_handle) ! return is_same end *************** *** 549,555 **** end ! for i = 1, #fileData do ! outfile:write(fileData[i]) ! end outfile:flush() --- 535,539 ---- end ! outfile:write(table.concat(fileData)) outfile:flush() *************** *** 1642,1646 **** local l = 0 ! while interfaceData[l+1] do l = l + 1 -- get lineData --- 1626,1630 ---- local l = 0 ! while interfaceData[l+1] do -- not for loop so we can adjust l l = l + 1 -- get lineData *************** *** 1730,1743 **** break -- we can stop processing line ! -- skip %protected functions ! elseif tag == "%protected" then ! lineState.Skip = true ! break ! -- skip %private functions ! elseif tag == "%private" then ! lineState.Skip = true ! break elseif tag == "%class" then local parseObject = AllocParseObject("class") --- 1714,1725 ---- break -- we can stop processing line ! elseif tag == "%rename" then ! lineState.Action = "rename" ! lineState.ActionMandatory = true ! elseif tag == "%function" then ! lineState.IsCFunction = true + -- ------------------------------------------------------- elseif tag == "%class" then local parseObject = AllocParseObject("class") *************** *** 1769,1784 **** break -- we can stop processing line ! elseif tag == "%delete" then parseState.ObjectStack[1].DeleteRequired = true ! elseif tag == "%noclassinfo" then parseState.ObjectStack[1].HasClassInfo = false ! elseif tag == "%abstract" then parseState.ObjectStack[1].IsAbstract = true ! elseif tag == "%encapsulate" then parseState.ObjectStack[1].Encapsulate = true elseif tag == "%struct" then local parseObject = AllocParseObject("struct") --- 1751,1814 ---- break -- we can stop processing line ! elseif tag == "%delete" then -- tag for %class parseState.ObjectStack[1].DeleteRequired = true ! elseif tag == "%noclassinfo" then -- tag for %class parseState.ObjectStack[1].HasClassInfo = false ! elseif tag == "%abstract" then -- tag for %class parseState.ObjectStack[1].IsAbstract = true ! elseif tag == "%encapsulate" then -- tag for %class parseState.ObjectStack[1].Encapsulate = true + -- ------------------------------------------------------- + elseif tag == "%protected" then -- skip %protected functions + lineState.Skip = true + break + + elseif tag == "%private" then -- skip %private functions + lineState.Skip = true + break + + elseif tag == "%property" then + lineState.DefType = "property" + lineState.Action = "property" + lineState.ActionMandatory = true + + elseif tag == "%member" then + lineState.DefType = "member" + lineState.Action = "member" + lineState.ActionMandatory = true + + elseif tag == "%constructor" then + lineState.IsConstructor = true + + elseif tag == "%operator" then + lineState.IsOperator = true + + elseif tag == "%static" then + -- means that we will create function ClassName_MemberFunction(...) + -- as opposed to "static" where the generated member function accessed the function as + -- ClassName::MemberFunction(...) + lineState.IsStaticFunction = true + lineState.CreateStaticFunction = 1 + lineState.DefType = "method" + lineState.Action = "method" + lineState.ActionMandatory = true + + elseif tag == "%staticonly" then + -- means that we will ONLY create function ClassName_MemberFunction(...) + -- as opposed to "%static" where we also generate member function + lineState.IsStaticFunction = true + lineState.CreateStaticFunction = 2 + lineState.DefType = "method" + lineState.Action = "method" + lineState.ActionMandatory = true + + elseif tag == "%overload" then + lineState.IsOverload = true + + -- ------------------------------------------------------- elseif tag == "%struct" then local parseObject = AllocParseObject("struct") *************** *** 1805,1808 **** --- 1835,1839 ---- break -- we can stop processing line + -- ------------------------------------------------------- elseif tag == "%enum" then local parseObject = AllocParseObject("enum") *************** *** 1829,1837 **** break -- we can stop processing line ! elseif tag == "%property" then ! lineState.DefType = "property" ! lineState.Action = "property" ! lineState.ActionMandatory = true ! elseif tag == "%include" then local parseObject = AllocParseObject("include") --- 1860,1864 ---- break -- we can stop processing line ! -- ------------------------------------------------------- elseif tag == "%include" then local parseObject = AllocParseObject("include") *************** *** 1856,1864 **** lineState.ActionMandatory = true ! elseif tag == "%member" then ! lineState.DefType = "member" ! lineState.Action = "member" ! lineState.ActionMandatory = true ! elseif tag == "%typedef" then lineState.DefType = "typedef" --- 1883,1887 ---- lineState.ActionMandatory = true ! -- ------------------------------------------------------- elseif tag == "%typedef" then lineState.DefType = "typedef" *************** *** 1866,1908 **** lineState.ActionMandatory = true ! elseif tag == "%rename" then ! lineState.Action = "rename" ! lineState.ActionMandatory = true ! ! elseif tag == "%constructor" then ! lineState.IsConstructor = true ! ! elseif tag == "%overload" then ! lineState.IsOverload = true ! ! elseif tag == "%operator" then ! lineState.IsOperator = true ! ! elseif tag == "%static" then ! -- means that we will create function ClassName_MemberFunction(...) ! -- as opposed to "static" where the generated member function accessed the function as ! -- ClassName::MemberFunction(...) ! lineState.IsStaticFunction = true ! lineState.CreateStaticFunction = 1 ! lineState.DefType = "method" ! lineState.Action = "method" ! lineState.ActionMandatory = true ! ! elseif tag == "%staticonly" then ! -- means that we will ONLY create function ClassName_MemberFunction(...) ! -- as opposed to "%static" where we also generate member function ! lineState.IsStaticFunction = true ! lineState.CreateStaticFunction = 2 ! lineState.DefType = "method" ! lineState.Action = "method" ! lineState.ActionMandatory = true ! ! elseif tag == "%function" then ! lineState.IsCFunction = true ! ! elseif tag == "%builtin" then ! print("Warning %builtin is deprecated, use %function instead.") ! lineState.IsCFunction = true ! elseif tag == "%define" then lineState.DefType = "define" --- 1889,1893 ---- lineState.ActionMandatory = true ! -- ------------------------------------------------------- elseif tag == "%define" then lineState.DefType = "define" *************** *** 1989,2000 **** elseif not skipBindingKeywordTable[tag] then ! -- -- Process Interface Data ! -- if (lineState.Action == "keyword") and lineState.ActionMandatory then print("Error: Invalid Token '"..tag.."'. "..LineTableErrString(lineTable)) end -- add block condition if lineState.DefType == "blockcondition" then if not lineState.Condition then --- 1974,1987 ---- elseif not skipBindingKeywordTable[tag] then ! -- ------------------------------------------------------- -- Process Interface Data ! -- ------------------------------------------------------- if (lineState.Action == "keyword") and lineState.ActionMandatory then print("Error: Invalid Token '"..tag.."'. "..LineTableErrString(lineTable)) end + -- ------------------------------------------------------- -- add block condition + -- ------------------------------------------------------- if lineState.DefType == "blockcondition" then if not lineState.Condition then *************** *** 2013,2017 **** --- 2000,2006 ---- lineState.Condition = lineState.Condition..tag + -- ------------------------------------------------------- -- apply tag to lineState.Action + -- ------------------------------------------------------- else -- end inline conditionals *************** *** 2024,2027 **** --- 2013,2017 ---- -- no actions specified + -- ----------------------------------------------- -- enum parseObject if parseState.ObjectStack[1].DefType == "enum" then *************** *** 2037,2040 **** --- 2027,2031 ---- end + -- ----------------------------------------------- -- class or function parseObject elseif (parseState.ObjectStack[1].DefType == "class") or *************** *** 3609,3621 **** if member.IsCFunction then table.insert(functionBindingTable, methodBinding) ! else if not interface.objectData[o].BindTable[methodcondition] then interface.objectData[o].BindTable[methodcondition] = {} end ! if not (member.IsConstructor and parseObject.IsAbstract) then ! table.insert(interface.objectData[o].BindTable[methodcondition], methodBinding) ! if member.IsOverload then ! table.insert(interface.objectData[o].OverloadTable[overloadName].Map[methodcondition], overloadMap) ! interface.objectData[o].OverloadTable[overloadName].Precode = overloadCode -- ok to overwrite ! end end end --- 3600,3610 ---- if member.IsCFunction then table.insert(functionBindingTable, methodBinding) ! elseif not (member.IsConstructor and parseObject.IsAbstract) then if not interface.objectData[o].BindTable[methodcondition] then interface.objectData[o].BindTable[methodcondition] = {} end ! table.insert(interface.objectData[o].BindTable[methodcondition], methodBinding) ! if member.IsOverload then ! table.insert(interface.objectData[o].OverloadTable[overloadName].Map[methodcondition], overloadMap) ! interface.objectData[o].OverloadTable[overloadName].Precode = overloadCode -- ok to overwrite end end *************** *** 3726,3729 **** --- 3715,3724 ---- -- --------------------------------------------------------------------------- -- Write (typically a Map) to a file + -- fileData is a table to append strings to + -- sortedBindings[i][j] = { Map = , Condition = } the binding table + -- indent is the number of space to indent, may be nil default is "" + -- writeFunc is called with the sortedBindings[i][j] to write whatever, may be nil + -- no_elseif means no #elif and each Condition item if be #ifed + -- ignore_condition is an extra condition to ignore -- --------------------------------------------------------------------------- function GenerateMap(fileData, sortedBindings, indent, writeFunc, no_elseif, ignore_condition) *************** *** 3735,3740 **** --- 3730,3747 ---- local wrote_elseif = false + local duplicatesTable = {} + for i = 1, #sortedBindings[n] do local condition = sortedBindings[n][i].Condition + --[[ + -- FIXME implement duplicate entries check + if duplicatesTable[condition] then + print("Warning: Duplicate entries with the same #if condition! Check bindings") + TableDump(duplicatesTable[condition], "Entry #1: ") + TableDump(sortedBindings[n][i], "Entry #2: ") + else + duplicatesTable[condition] = sortedBindings[n][i] + end + ]] local next_condition = "1" *************** *** 4243,4247 **** -- Don't use #elif to let compiler fail on multiple definitions per condition ! -- since there's an error in the bindings local namedBindingTable = {} --- 4250,4254 ---- -- Don't use #elif to let compiler fail on multiple definitions per condition ! -- since there's a problem with the bindings if that happens local namedBindingTable = {} |