From: John L. <jr...@us...> - 2009-05-14 05:06:25
|
Update of /cvsroot/wxlua/wxLua/bindings In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9404/wxLua/bindings Modified Files: genwxbind.lua Log Message: Allow multiple inheritance in the bindings. Index: genwxbind.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/genwxbind.lua,v retrieving revision 1.178 retrieving revision 1.179 diff -C2 -d -r1.178 -r1.179 *** genwxbind.lua 31 Mar 2009 04:23:42 -0000 1.178 --- genwxbind.lua 14 May 2009 05:06:21 -0000 1.179 *************** *** 194,205 **** dataTypeTable[name] = { ! Name = name, -- typename, eg. void, bool, wxInt32 ! ValueType = value_type, -- "number", "enum", "class", "special" (special handling) ! -- determines how to handle the data type ! BaseClass = nil, -- the BaseClass of this, if this is a class ! IsNumber = is_number, -- can this data type be stored as a double (Lua's number type) ! Abstract = abstract, ! Condition = nil, -- conditions for this data type, eg. wxLUA_USE_xxx ! ["%encapsulate"] = nil, -- Non wxObject derived class } end --- 194,205 ---- dataTypeTable[name] = { ! Name = name, -- typename, eg. void, bool, wxInt32 ! ValueType = value_type, -- "number", "enum", "class", "special" (special handling) ! -- determines how to handle the data type ! BaseClasses = nil, -- the BaseClass of this, if this is a class ! IsNumber = is_number, -- can this data type be stored as a double (Lua's number type) ! Abstract = abstract, ! Condition = nil, -- conditions for this data type, eg. wxLUA_USE_xxx ! ["%encapsulate"] = nil, -- Non wxObject derived class } end *************** *** 473,479 **** end ! if dataTypeTable[classname].BaseClass then ! local c = dataTypeTable[dataTypeTable[classname].BaseClass].Name ! return IsDerivedClass(c, base_classname) end --- 473,483 ---- end ! if dataTypeTable[classname].BaseClasses then ! for _, c in ipairs(dataTypeTable[classname].BaseClasses) do ! local c_name = dataTypeTable[c].Name ! if IsDerivedClass(c_name, base_classname) then ! return true ! end ! end end *************** *** 1768,1775 **** -- set class's BaseClass ! if not dataTypeTable[classname].BaseClass then ! dataTypeTable[classname].BaseClass = tag end action = "find_classcomma" elseif action == "find_structname" then --- 1772,1781 ---- -- set class's BaseClass ! if not dataTypeTable[classname].BaseClasses then ! dataTypeTable[classname].BaseClasses = {} end + table.insert(dataTypeTable[classname].BaseClasses, tag) + action = "find_classcomma" elseif action == "find_structname" then *************** *** 4057,4063 **** -- Class Binding ! local baseclass = "NULL" ! if dataTypeTable[parseObject.Name].BaseClass then ! baseclass = "\""..dataTypeTable[parseObject.Name].BaseClass.."\"" end --- 4063,4071 ---- -- Class Binding ! local baseclassNames = "NULL" ! local baseclassBinds = "NULL" ! if dataTypeTable[parseObject.Name].BaseClasses then ! baseclassNames = "wxluabaseclassnames_"..MakeVar(parseObject.Name) ! baseclassBinds = "wxluabaseclassbinds_"..MakeVar(parseObject.Name) end *************** *** 4122,4135 **** { LuaName = MakeVar(parseObject.Name), ! Map = " { \""..MakeVar(parseObject.Name).."\", " ..MakeVar(parseObject.Name).."_methods, " ..MakeVar(parseObject.Name).."_methodCount, " ..classinfo..", " .."&wxluatype_"..MakeClassVar(parseObject.Name)..", " ! ..MakeVar(baseclass)..", " ! .."NULL ," ..enumArrayName..", " ..enumArrayCountName..", " .."}, \n", Condition = classcondition } --- 4130,4144 ---- { LuaName = MakeVar(parseObject.Name), ! Map = " { wxluaclassname_"..MakeVar(parseObject.Name)..", " ..MakeVar(parseObject.Name).."_methods, " ..MakeVar(parseObject.Name).."_methodCount, " ..classinfo..", " .."&wxluatype_"..MakeClassVar(parseObject.Name)..", " ! ..baseclassNames..", " ! ..baseclassBinds..", " ..enumArrayName..", " ..enumArrayCountName..", " .."}, \n", + BaseClasses = dataTypeTable[parseObject.Name].BaseClasses, Condition = classcondition } *************** *** 4440,4451 **** table.insert(fileData, "// ---------------------------------------------------------------------------\n\n") - table.insert(fileData, "wxLuaBindClass* "..hook_cpp_class_funcname.."(size_t &count)\n{\n") - table.insert(fileData, " static wxLuaBindClass classList[] =\n {\n") - local namedBindingTable = {} GenerateLuaNameFromIndexedTable(classBindingTable, namedBindingTable) -- sort the bindings by class name and write them out alphabetically - local sortedBindings = TableSort(namedBindingTable) GenerateMap(fileData, sortedBindings, " ") --- 4449,4498 ---- table.insert(fileData, "// ---------------------------------------------------------------------------\n\n") local namedBindingTable = {} GenerateLuaNameFromIndexedTable(classBindingTable, namedBindingTable) + local sortedBindings = TableSort(namedBindingTable) + + -- Gather up all of the classnames + local classNames = {} + + for n = 1, #sortedBindings do + for i = 1, #sortedBindings[n] do + classNames[sortedBindings[n][i].LuaName] = sortedBindings[n][i].LuaName + for _, bc in ipairs(sortedBindings[n][i].BaseClasses or {}) do + classNames[bc] = bc + end + end + end + + classNames = TableSort(classNames) + + for _, c in pairs(classNames) do + table.insert(fileData, "static const char* wxluaclassname_"..c.." = \""..c.."\";\n") + end + + table.insert(fileData, "\n") + + for n = 1, #sortedBindings do + for i = 1, #sortedBindings[n] do + if sortedBindings[n][i].BaseClasses then + local bc_n = 0 + local s = "static const char* wxluabaseclassnames_"..sortedBindings[n][i].LuaName.."[] = {" + for _, bc in ipairs(sortedBindings[n][i].BaseClasses) do + s = s.." wxluaclassname_"..bc.."," + bc_n = bc_n + 1 + end + + 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") + end + end + end + + table.insert(fileData, "\n\n") + + table.insert(fileData, "wxLuaBindClass* "..hook_cpp_class_funcname.."(size_t &count)\n{\n") + table.insert(fileData, " static wxLuaBindClass classList[] =\n {\n") -- sort the bindings by class name and write them out alphabetically GenerateMap(fileData, sortedBindings, " ") |