From: John L. <jr...@us...> - 2008-10-22 05:31:53
|
Update of /cvsroot/wxlua/wxLua/bindings In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9558/wxLua/bindings Modified Files: genwxbind.lua Log Message: Swap parameters to the %typedef tag to follow C/C++ nomenclature Call AllocDataType in genwxbind.lua for the %typedef automatically. Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.169 retrieving revision 1.170 diff -C2 -d -r1.169 -r1.170 *** genwxbind.lua 21 Oct 2008 04:23:18 -0000 1.169 --- genwxbind.lua 22 Oct 2008 05:31:45 -0000 1.170 *************** *** 18,22 **** -- --------------------------------------------------------------------------- ! WXLUA_BINDING_VERSION = 23 -- 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 = 24 -- Used to verify that the bindings are updated -- This must match modules/wxlua/include/wxldefs.h -- otherwise a compile time error will be generated. *************** *** 395,406 **** -- --------------------------------------------------------------------------- - -- Get base type for a data type that is a typedef - -- --------------------------------------------------------------------------- - function GetTypeDef(datatype) - -- if typedef is found, replace type with replacement typedef - return typedefTable[datatype] or datatype - end - - -- --------------------------------------------------------------------------- -- Get the dataTypeTable[typedefinition] from a string after removing delimiters -- --------------------------------------------------------------------------- --- 395,398 ---- *************** *** 420,424 **** -- Get the base dataTypeTable[typedefinition] by translating typedefs -- --------------------------------------------------------------------------- ! function GetDataTypeBase(datatype) if dataTypeTable[datatype] then return dataTypeTable[datatype] --- 412,416 ---- -- Get the base dataTypeTable[typedefinition] by translating typedefs -- --------------------------------------------------------------------------- ! function GetDataTypedefBase(datatype) if dataTypeTable[datatype] then return dataTypeTable[datatype] *************** *** 433,437 **** end ! print("ERROR: Missing data type '"..tostring(datatype).."' in GetDataTypeBase.") return nil --- 425,429 ---- end ! print("ERROR: Missing data type '"..tostring(datatype).."' in GetDataTypedefBase.") return nil *************** *** 465,469 **** -- --------------------------------------------------------------------------- function GetDataTypeCondition(datatype) ! local dtype = GetDataTypeBase(datatype) if dtype then return dtype.Condition --- 457,461 ---- -- --------------------------------------------------------------------------- function GetDataTypeCondition(datatype) ! local dtype = GetDataTypedefBase(datatype) if dtype then return dtype.Condition *************** *** 479,483 **** -- --------------------------------------------------------------------------- function IsDataTypeNumeric(datatype) ! local dtype = GetDataTypeBase(datatype) if dtype then return dtype.IsNumber --- 471,475 ---- -- --------------------------------------------------------------------------- function IsDataTypeNumeric(datatype) ! local dtype = GetDataTypedefBase(datatype) if dtype then return dtype.IsNumber *************** *** 493,497 **** -- --------------------------------------------------------------------------- function IsDataTypeEnum(datatype) ! local dtype = GetDataTypeBase(datatype) if dtype then return (dtype.ValueType == "enum") --- 485,489 ---- -- --------------------------------------------------------------------------- function IsDataTypeEnum(datatype) ! local dtype = GetDataTypedefBase(datatype) if dtype then return (dtype.ValueType == "enum") *************** *** 1656,1659 **** --- 1648,1653 ---- local action = nil -- what to look for next + local typedefTable = {} + for t = 1, #lineTags do local tag = lineTags[t] *************** *** 1682,1685 **** --- 1676,1681 ---- elseif tag == "%enum" then action = "find_enumname" + elseif tag == "%typedef" then + action = "find_typedef" end end *************** *** 1723,1729 **** --- 1719,1743 ---- action = nil + elseif action == "find_typedef" then + table.insert(typedefTable, tag) + + end + end + end + + if #typedefTable > 0 then + local typedef_name = typedefTable[#typedefTable] + local typedef_type = table.concat(typedefTable, " ", 1, #typedefTable-1) + local dt = false + for i = 1,#typedefTable-1 do + -- increment forward until we know the type, skipping const and other attribs + dt = dataTypeTable[table.concat(typedefTable, " ", i, #typedefTable-1)] + if dt then + AllocDataType(typedef_name, dt.ValueType, dt.IsNumber) + break end end end + end end *************** *** 2278,2286 **** elseif lineState.Action == "action_typedef" then lineState.Name = tag lineState.Action = "action_typedefvalue" lineState.ActionMandatory = true elseif lineState.Action == "action_typedefvalue" then ! lineState.RValue = SpaceSeparateStrings(lineState.RValue, tag) lineState.Action = "action_typedefvalue" -- allow more than one word --- 2292,2303 ---- elseif lineState.Action == "action_typedef" then lineState.Name = tag + lineState.RValue = {} + table.insert(lineState.RValue, tag) lineState.Action = "action_typedefvalue" lineState.ActionMandatory = true elseif lineState.Action == "action_typedefvalue" then ! --lineState.RValue = SpaceSeparateStrings(lineState.RValue, tag) ! table.insert(lineState.RValue, tag) lineState.Action = "action_typedefvalue" -- allow more than one word *************** *** 2597,2602 **** -- set line definition data if lineState.DefType == "deftype_%typedef" then ! -- line is a typedef ! typedefTable[lineState.Name] = lineState.RValue elseif lineState.DefType == "deftype_%if" then --- 2614,2622 ---- -- set line definition data if lineState.DefType == "deftype_%typedef" then ! -- line is in the form: typedef [unsigned int] wxUInt32 ! local typedef_name = lineState.RValue[#lineState.RValue] ! local typedef_type = table.concat(lineState.RValue, " ", 1, #lineState.RValue-1) ! ! typedefTable[typedef_name] = typedef_type elseif lineState.DefType == "deftype_%if" then *************** *** 2803,2807 **** -- --------------------------------------------------------------- if (member.DefType == "deftype_%member") or (member.DefType == "deftype_%member_func") then ! local memberType = GetTypeDef(member.DataType) local memberGetFunc = "Get_"..member.Name local memberSetFunc = "Set_"..member.Name --- 2823,2827 ---- -- --------------------------------------------------------------- if (member.DefType == "deftype_%member") or (member.DefType == "deftype_%member_func") then ! local memberType = member.DataType local memberGetFunc = "Get_"..member.Name local memberSetFunc = "Set_"..member.Name *************** *** 3772,3777 **** end ! if dataTypeTable[memberType]["%encapsulate"] then ! table.insert(codeList, " wxluaO_addgcobject(L, (void*)returns, new wxLua_wxObject_"..MakeVar(memberType).."(("..returnCast..")returns));\n") else table.insert(codeList, " wxluaO_addgcobject(L, ("..returnCast..")returns);\n") --- 3792,3799 ---- end ! 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") |