From: John L. <jr...@us...> - 2007-06-13 04:15:32
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv9645/wxLua/samples Modified Files: bindings.wx.lua Log Message: Remove class member functions that are duplicates of their baseclass functions Fix wxClassInfo is NOT a wxObject Add more capability to bindings.wx.lua Index: bindings.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/bindings.wx.lua,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** bindings.wx.lua 13 Jun 2007 00:09:04 -0000 1.5 --- bindings.wx.lua 13 Jun 2007 04:15:29 -0000 1.6 *************** *** 117,120 **** --- 117,121 ---- listCtrl = nil ID_LISTCTRL = 1000 -- id of the listctrl + ID_VIEW_BASECLASS_FUNCTIONS = 1001 img_normal = 0 -- a "file" image in the listctrl img_folder = 1 -- a "folder" image in the listctrl *************** *** 359,363 **** return t end ! function CreatewxLuaBindMethod(tbl) local keys = { "name", "type", "funcs", "funcs_n", "basemethod" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindMethod") --- 360,364 ---- return t end ! function CreatewxLuaBindMethod(tbl, classname) local keys = { "name", "type", "funcs", "funcs_n", "basemethod" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindMethod") *************** *** 371,374 **** --- 372,379 ---- i = i + 1 + if classname then + t[i][1] = classname.."::"..t[i][1] + end + t[i][2] = CreatewxLuaMethod_TypeString(t[i][2]) *************** *** 461,476 **** end ! function CreatewxLuaBindTable(tbl, keys, object_type) local t = { {"..", ["icon"] = img_folder}, ! ["col_labels"] = keys, ["object_type"] = object_type } for i = 1, #tbl do local item = {} ! for k = 1, #keys do -- we need to force there to be something in each col, use "" ! local val = tbl[i][keys[k]] if val ~= nil then table.insert(item, val) --- 466,483 ---- end ! function CreatewxLuaBindTable(tbl, cols, object_type) local t = { {"..", ["icon"] = img_folder}, ! ["col_labels"] = cols, ["object_type"] = object_type } + local keys = {} + for i = 1, #tbl do local item = {} ! for c = 1, #cols do -- we need to force there to be something in each col, use "" ! local val = tbl[i][cols[c]] if val ~= nil then table.insert(item, val) *************** *** 479,482 **** --- 486,493 ---- end end + + --if keys[tbl[i]] then item.color = wx.wxRED end -- check dup keys + --keys[tbl[i]] = true + table.insert(t, item) end *************** *** 659,667 **** listData[list_level] = t GotoBindingLevel(listCtrl, list_level) ! elseif itemText == "Base Classes" then local t = { {"..", ["icon"] = img_folder}, ! ["col_labels"] = {"Class Name - wxClassInfo Name (wxClassInfo Base Name)"}, ! ["object_type"] = "Base Classes" } --- 670,678 ---- listData[list_level] = t GotoBindingLevel(listCtrl, list_level) ! elseif itemText == "All Classes" then local t = { {"..", ["icon"] = img_folder}, ! ["col_labels"] = {"wxLua Class Name - wxClassInfo Name (wxClassInfo Base Name)"}, ! ["object_type"] = "All Classes" } *************** *** 694,704 **** for i = 1, #t1 do local c = t1[i] ! local c_table = {c.name..GetClassInfoStr(c.classInfo)} -- traverse through the base classes local bc = c.baseclass while bc do ! table.insert(c_table, bc.name..GetClassInfoStr(bc.classInfo)) bc = bc.baseclass end --- 705,717 ---- for i = 1, #t1 do + local a = string.format("%s%03d. ", string.char(string.byte('a')+b-1), i) + local c = t1[i] ! local c_table = {a..c.name, ["color"] = wx.wxBLUE} -- GetClassInfoStr(c.classInfo) -- traverse through the base classes local bc = c.baseclass while bc do ! table.insert(c_table, bc.name) -- ..GetClassInfoStr(bc.classInfo) bc = bc.baseclass end *************** *** 706,709 **** --- 719,747 ---- if max_cols < #c_table then max_cols = #c_table end table.insert(t, c_table) + + -- now do wxWidgets base class info + if c.classInfo then + local ci = c.classInfo + local c_table2 = {a..ci:GetClassName()} + if ci:GetBaseClass2() then print(ci:GetClassName(), "Has two bases!") end + ci = ci:GetBaseClass1() -- FIXME handle two base classes, maybe? + while ci do + -- we don't bind wxWindowBase since we'd never need it + if ci:GetClassName() == "wxWindowBase" then + c_table2[#c_table2] = c_table2[#c_table2].."("..ci:GetClassName()..")" + else + table.insert(c_table2, ci:GetClassName()) + if c_table[#c_table2] ~= c_table2[#c_table2] then + c_table2.color = wx.wxRED + end + end + + if ci:GetBaseClass2() then print(ci:GetClassName(), "Has two bases!") end + ci = ci:GetBaseClass1() -- FIXME handle two base classes, maybe? + end + + if max_cols < #c_table2 then max_cols = #c_table2 end + table.insert(t, c_table2) + end end end *************** *** 793,799 **** else local binding = _G ! for i = 1, #listData[1][data_index] do ! binding = binding[listData[1][data_index][i]] ! end listData[2] = { --- 831,836 ---- else local binding = _G ! binding = binding[listData[1][data_index][2]] ! binding = binding[listData[1][data_index][1]] listData[2] = { *************** *** 845,849 **** if ((col == 0) or (col == 1)) and (type(listData[list_level][data_index][2]) == "table") then ! t = CreatewxLuaBindMethod(listData[list_level][data_index][2]) elseif (col == 6) and (type(listData[list_level][data_index][col+1]) == "userdata") then t = CreatewxLuaBindClass({listData[list_level][data_index][col+1]}) --- 882,901 ---- if ((col == 0) or (col == 1)) and (type(listData[list_level][data_index][2]) == "table") then ! t = CreatewxLuaBindMethod(listData[list_level][data_index][2], listData[list_level][data_index][1]) ! ! if frame:GetMenuBar():IsChecked(ID_VIEW_BASECLASS_FUNCTIONS) then ! local c = listData[list_level][data_index][7] ! while type(c) == "userdata" do ! local tt = CreatewxLuaBindMethod(c.methods, c.name) ! for i = 2, #tt do -- skip ".." ! if not (string.find(tt[i][2], "Constructor", 1, 1) or ! string.find(t[i][1], "Delete", 1, 1) or ! string.find(t[i][1], "::"..c.name, 1, 1)) then ! table.insert(t, tt[i]) ! end ! end ! c = c.baseclass ! end ! end elseif (col == 6) and (type(listData[list_level][data_index][col+1]) == "userdata") then t = CreatewxLuaBindClass({listData[list_level][data_index][col+1]}) *************** *** 893,896 **** --- 945,951 ---- fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program") + local viewMenu = wx.wxMenu() + viewMenu:AppendCheckItem(ID_VIEW_BASECLASS_FUNCTIONS, "View baseclass functions", "View all baseclass functions for class methods") + local helpMenu = wx.wxMenu() helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua Binding Application") *************** *** 899,902 **** --- 954,958 ---- local menuBar = wx.wxMenuBar() menuBar:Append(fileMenu, "&File") + menuBar:Append(viewMenu, "&View") menuBar:Append(helpMenu, "&Help") frame:SetMenuBar(menuBar) *************** *** 954,968 **** listData[1] = { {"wxLua Types", "Compare Lua's type to wxLua's type", ["icon"] = img_folder }, ! {"Base Classes", "See base classes for all binding classes", ["icon"] = img_folder }, {"Overloaded Baseclass Functions", "See all functions that also have a baseclass function", ["icon"] = img_folder }, ! ["col_labels"] = { "Lua Namespace", "Binding userdata" }, ["object_type"] = " " } ! -- Add the binding that are installed {"wx", "wxLuaBinding_wx", ["icon"] = img_folder }, for i = 1, #bindingList do ! table.insert(listData[1], {bindingList[i][1], bindingList[i][2], ["icon"] = img_folder }) end --- 1010,1024 ---- listData[1] = { {"wxLua Types", "Compare Lua's type to wxLua's type", ["icon"] = img_folder }, ! {"All Classes", "Classes and their base classes (red may not indicate error)", ["icon"] = img_folder }, {"Overloaded Baseclass Functions", "See all functions that also have a baseclass function", ["icon"] = img_folder }, ! ["col_labels"] = { "Item to View", "Information"}, ["object_type"] = " " } ! -- Add the binding that are installed {"wxLuaBinding_wx", "wx", ["icon"] = img_folder }, for i = 1, #bindingList do ! table.insert(listData[1], {bindingList[i][2], bindingList[i][1], ["icon"] = img_folder }) end |