From: John L. <jr...@us...> - 2007-12-22 06:07:23
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16833/wxLua/samples Modified Files: auidemo.wx.lua bindings.wx.lua controls.wx.lua unittest.wx.lua Log Message: * Updated the naming conventions of the wxLua C/C++ functions to get rid of the term "tag" which dates back to Lua 4. Lua 5 does not use "tags", but rather metatables to attach functions to userdata in Lua. The new term for the C++ objects that wxLua wraps in Lua userdata and assigns a metatable to are wxLua types. wxLua types < 0, the WXLUA_TXXX types, correspond to the LUA_TXXX Lua types. wxLua types > 0 are types from the bindings and denote a class or struct. - Most notably for people who have written their own overrides for their bindings will be that wxLuaState::PushUserTag() is now wxluaT_PushUserDataType(). Those two functions existed before, but basically did the same thing. The calling arguments of PushUserTag() were taken however and were the reverse of what PushUserDataType() had. - wxluaT_new/get/set/tag() are now wxluaT_new/setmetatable() and wxluaT_type() where the latter works just like lua_type(), but returns one of the wxLua types. - Fix crash in wxListCtrl and wxTreeCtrl::AssignImageList() to use the %ungc tag to release wxLua from deleting the input wxImageList. Index: controls.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/controls.wx.lua,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** controls.wx.lua 18 Jul 2007 02:41:33 -0000 1.13 --- controls.wx.lua 22 Dec 2007 06:07:17 -0000 1.14 *************** *** 116,120 **** for i = 1, #wxEVT_Array do wxEVT_TableByType[wxEVT_Array[i].eventType] = wxEVT_Array[i] ! table.insert(wxEVT_List, {wxlua.typename(wxEVT_Array[i].class_tag), wxEVT_Array[i].name}) end table.sort(wxEVT_List, function(t1, t2) return t1[1] > t2[1] end) --- 116,120 ---- for i = 1, #wxEVT_Array do wxEVT_TableByType[wxEVT_Array[i].eventType] = wxEVT_Array[i] ! table.insert(wxEVT_List, {wxlua.typename(wxEVT_Array[i].wxluatype), wxEVT_Array[i].name}) end table.sort(wxEVT_List, function(t1, t2) return t1[1] > t2[1] end) *************** *** 326,330 **** function OnEvent(event) local skip = true ! local evtClassName = wxlua.typename(wxEVT_TableByType[event:GetEventType()].class_tag) local evtTypeStr = wxEVT_TableByType[event:GetEventType()].name --- 326,330 ---- function OnEvent(event) local skip = true ! local evtClassName = wxlua.typename(wxEVT_TableByType[event:GetEventType()].wxluatype) local evtTypeStr = wxEVT_TableByType[event:GetEventType()].name Index: auidemo.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/auidemo.wx.lua,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** auidemo.wx.lua 25 Nov 2007 21:34:05 -0000 1.1 --- auidemo.wx.lua 22 Dec 2007 06:07:17 -0000 1.2 *************** *** 129,141 **** local m_mgr = mgr; ! this:Connect(wx.wxEVT_SIZE, function(event) this:Refresh(); end) ! ! this:Connect(wx.wxEVT_ERASE_BACKGROUND, function(event) --// intentionally empty end) ! ! this:Connect(wx.wxEVT_PAINT, function(event) local dc = wx.wxPaintDC(this) local sizex,sizey = this:GetClientSizeWH(); --- 129,141 ---- local m_mgr = mgr; ! this:Connect(wx.wxEVT_SIZE, function(event) this:Refresh(); end) ! ! this:Connect(wx.wxEVT_ERASE_BACKGROUND, function(event) --// intentionally empty end) ! ! this:Connect(wx.wxEVT_PAINT, function(event) local dc = wx.wxPaintDC(this) local sizex,sizey = this:GetClientSizeWH(); *************** *** 155,159 **** dc:DrawLine(0, sizey, sizex, 0); dc:DrawText(s, (sizex-w)/2, ((sizey-(height*5))/2)); ! if (m_mgr) then local pi = m_mgr:GetPane(this); --- 155,159 ---- dc:DrawLine(0, sizey, sizex, 0); dc:DrawText(s, (sizex-w)/2, ((sizey-(height*5))/2)); ! if (m_mgr) then local pi = m_mgr:GetPane(this); *************** *** 191,195 **** local this = self.this ! this:Connect(wx.wxEVT_SIZE, function(event) self:OnSize(event) end) this:Connect(wx.wxEVT_PAINT, function(event) self:OnPaint(event) end) --- 191,195 ---- local this = self.this ! this:Connect(wx.wxEVT_SIZE, function(event) self:OnSize(event) end) this:Connect(wx.wxEVT_PAINT, function(event) self:OnPaint(event) end) *************** *** 218,222 **** dc:DrawLine(0, sizey, sizex, 0); dc:DrawText(s, (sizex-w)/2, ((sizey-(height*5))/2)); ! local m_mgr = self.m_mgr if (m_mgr) then --- 218,222 ---- dc:DrawLine(0, sizey, sizex, 0); dc:DrawText(s, (sizex-w)/2, ((sizey-(height*5))/2)); ! local m_mgr = self.m_mgr if (m_mgr) then *************** *** 297,303 **** local s1 = wx.wxBoxSizer(wx.wxHORIZONTAL); ! self.m_border_size = wx.wxSpinCtrl(this, self.ID_PaneBorderSize, string.format(wxT("%d"), ! frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_PANE_BORDER_SIZE)), ! wx.wxDefaultPosition, wx.wxSize(50,20), wx.wxSP_ARROW_KEYS, 0, 100, frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_PANE_BORDER_SIZE)); s1:Add(1, 1, 1, wx.wxEXPAND); --- 297,303 ---- local s1 = wx.wxBoxSizer(wx.wxHORIZONTAL); ! self.m_border_size = wx.wxSpinCtrl(this, self.ID_PaneBorderSize, string.format(wxT("%d"), ! frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_PANE_BORDER_SIZE)), ! wx.wxDefaultPosition, wx.wxSize(50,20), wx.wxSP_ARROW_KEYS, 0, 100, frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_PANE_BORDER_SIZE)); s1:Add(1, 1, 1, wx.wxEXPAND); *************** *** 309,315 **** local s2 = wx.wxBoxSizer(wx.wxHORIZONTAL); ! self.m_sash_size = wx.wxSpinCtrl(this, self.ID_SashSize, string.format(wxT("%d"), ! frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_SASH_SIZE)), ! wx.wxDefaultPosition, wx.wxSize(50,20), wx.wxSP_ARROW_KEYS, 0, 100, frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_SASH_SIZE)); s2:Add(1, 1, 1, wx.wxEXPAND); --- 309,315 ---- local s2 = wx.wxBoxSizer(wx.wxHORIZONTAL); ! self.m_sash_size = wx.wxSpinCtrl(this, self.ID_SashSize, string.format(wxT("%d"), ! frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_SASH_SIZE)), ! wx.wxDefaultPosition, wx.wxSize(50,20), wx.wxSP_ARROW_KEYS, 0, 100, frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_SASH_SIZE)); s2:Add(1, 1, 1, wx.wxEXPAND); *************** *** 321,327 **** local s3 = wx.wxBoxSizer(wx.wxHORIZONTAL); ! self.m_caption_size = wx.wxSpinCtrl(this, self.ID_CaptionSize, string.format(wxT("%d"), ! frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_CAPTION_SIZE)), ! wx.wxDefaultPosition, wx.wxSize(50,20), wx.wxSP_ARROW_KEYS, 0, 100, frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_CAPTION_SIZE)); s3:Add(1, 1, 1, wx.wxEXPAND); --- 321,327 ---- local s3 = wx.wxBoxSizer(wx.wxHORIZONTAL); ! self.m_caption_size = wx.wxSpinCtrl(this, self.ID_CaptionSize, string.format(wxT("%d"), ! frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_CAPTION_SIZE)), ! wx.wxDefaultPosition, wx.wxSize(50,20), wx.wxSP_ARROW_KEYS, 0, 100, frame:GetDockArt():GetMetric(wxaui.wxAUI_DOCKART_CAPTION_SIZE)); s3:Add(1, 1, 1, wx.wxEXPAND); *************** *** 530,544 **** local id = event:GetId() ! if id == self.ID_BackgroundColor then var = wxaui.wxAUI_DOCKART_BACKGROUND_COLOUR; ! elseif id == self.ID_SashColor then var = wxaui.wxAUI_DOCKART_SASH_COLOUR; ! elseif id == self.ID_InactiveCaptionColor then var = wxaui.wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR; ! elseif id == self.ID_InactiveCaptionGradientColor then var = wxaui.wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR; ! elseif id == self.ID_InactiveCaptionTextColor then var = wxaui.wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR; ! elseif id == self.ID_ActiveCaptionColor then var = wxaui.wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR; ! elseif id == self.ID_ActiveCaptionGradientColor then var = wxaui.wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR; ! elseif id == self.ID_ActiveCaptionTextColor then var = wxaui.wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR; ! elseif id == self.ID_BorderColor then var = wxaui.wxAUI_DOCKART_BORDER_COLOUR; ! elseif id == self.ID_GripperColor then var = wxaui.wxAUI_DOCKART_GRIPPER_COLOUR; ! else return; end --- 530,544 ---- local id = event:GetId() ! if id == self.ID_BackgroundColor then var = wxaui.wxAUI_DOCKART_BACKGROUND_COLOUR; ! elseif id == self.ID_SashColor then var = wxaui.wxAUI_DOCKART_SASH_COLOUR; ! elseif id == self.ID_InactiveCaptionColor then var = wxaui.wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR; ! elseif id == self.ID_InactiveCaptionGradientColor then var = wxaui.wxAUI_DOCKART_INACTIVE_CAPTION_GRADIENT_COLOUR; ! elseif id == self.ID_InactiveCaptionTextColor then var = wxaui.wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR; ! elseif id == self.ID_ActiveCaptionColor then var = wxaui.wxAUI_DOCKART_ACTIVE_CAPTION_COLOUR; ! elseif id == self.ID_ActiveCaptionGradientColor then var = wxaui.wxAUI_DOCKART_ACTIVE_CAPTION_GRADIENT_COLOUR; ! elseif id == self.ID_ActiveCaptionTextColor then var = wxaui.wxAUI_DOCKART_ACTIVE_CAPTION_TEXT_COLOUR; ! elseif id == self.ID_BorderColor then var = wxaui.wxAUI_DOCKART_BORDER_COLOUR; ! elseif id == self.ID_GripperColor then var = wxaui.wxAUI_DOCKART_GRIPPER_COLOUR; ! else return; end *************** *** 993,999 **** local id = event:GetId() ! if id == self.ID_NoGradient then gradient = wxaui.wxAUI_GRADIENT_NONE; ! elseif id == self.ID_VerticalGradient then gradient = wxaui.wxAUI_GRADIENT_VERTICAL; ! elseif id == self.ID_HorizontalGradient then gradient = wxaui.wxAUI_GRADIENT_HORIZONTAL; end --- 993,999 ---- local id = event:GetId() ! if id == self.ID_NoGradient then gradient = wxaui.wxAUI_GRADIENT_NONE; ! elseif id == self.ID_VerticalGradient then gradient = wxaui.wxAUI_GRADIENT_VERTICAL; ! elseif id == self.ID_HorizontalGradient then gradient = wxaui.wxAUI_GRADIENT_HORIZONTAL; end *************** *** 1022,1026 **** id == self.ID_NoHint) then local flags = self.m_mgr:GetFlags(); ! --[[hd.FIXME --flags &= ~wxAUI_MGR_TRANSPARENT_HINT; --- 1022,1026 ---- id == self.ID_NoHint) then local flags = self.m_mgr:GetFlags(); ! --[[hd.FIXME --flags &= ~wxAUI_MGR_TRANSPARENT_HINT; *************** *** 1031,1046 **** flags = bit.band(flags, bit.bnot(wxaui.wxAUI_MGR_VENETIAN_BLINDS_HINT)); flags = bit.band(flags, bit.bnot(wxaui.wxAUI_MGR_RECTANGLE_HINT)); ! self.m_mgr:SetFlags(flags); end ! if id == self.ID_AllowFloating then flag = wxaui.wxAUI_MGR_ALLOW_FLOATING; ! elseif id == self.ID_TransparentDrag then flag = wxaui.wxAUI_MGR_TRANSPARENT_DRAG; ! elseif id == self.ID_HintFade then flag = wxaui.wxAUI_MGR_HINT_FADE; ! elseif id == self.ID_NoVenetianFade then flag = wxaui.wxAUI_MGR_NO_VENETIAN_BLINDS_FADE; ! elseif id == self.ID_AllowActivePane then flag = wxaui.wxAUI_MGR_ALLOW_ACTIVE_PANE; ! elseif id == self.ID_TransparentHint then flag = wxaui.wxAUI_MGR_TRANSPARENT_HINT; ! elseif id == self.ID_VenetianBlindsHint then flag = wxaui.wxAUI_MGR_VENETIAN_BLINDS_HINT; ! elseif id == self.ID_RectangleHint then flag = wxaui.wxAUI_MGR_RECTANGLE_HINT; end --- 1031,1046 ---- flags = bit.band(flags, bit.bnot(wxaui.wxAUI_MGR_VENETIAN_BLINDS_HINT)); flags = bit.band(flags, bit.bnot(wxaui.wxAUI_MGR_RECTANGLE_HINT)); ! self.m_mgr:SetFlags(flags); end ! if id == self.ID_AllowFloating then flag = wxaui.wxAUI_MGR_ALLOW_FLOATING; ! elseif id == self.ID_TransparentDrag then flag = wxaui.wxAUI_MGR_TRANSPARENT_DRAG; ! elseif id == self.ID_HintFade then flag = wxaui.wxAUI_MGR_HINT_FADE; ! elseif id == self.ID_NoVenetianFade then flag = wxaui.wxAUI_MGR_NO_VENETIAN_BLINDS_FADE; ! elseif id == self.ID_AllowActivePane then flag = wxaui.wxAUI_MGR_ALLOW_ACTIVE_PANE; ! elseif id == self.ID_TransparentHint then flag = wxaui.wxAUI_MGR_TRANSPARENT_HINT; ! elseif id == self.ID_VenetianBlindsHint then flag = wxaui.wxAUI_MGR_VENETIAN_BLINDS_HINT; ! elseif id == self.ID_RectangleHint then flag = wxaui.wxAUI_MGR_RECTANGLE_HINT; end *************** *** 1079,1086 **** case ID_NotebookCloseButtonActive: m_notebook_style |= wxAUI_NB_CLOSE_ON_ACTIVE_TAB; break; --]] ! if id == self.ID_NotebookNoCloseButton then ! elseif id == self.ID_NotebookCloseButton then self.m_notebook_style = bit.bor(self.m_notebook_style, wxaui.wxAUI_NB_CLOSE_BUTTON); ! elseif id == self.ID_NotebookCloseButtonAll then self.m_notebook_style = bit.bor(self.m_notebook_style, wxaui.wxAUI_NB_CLOSE_ON_ALL_TABS); ! elseif id == self.ID_NotebookCloseButtonActive then self.m_notebook_style = bit.bor(self.m_notebook_style, wxaui.wxAUI_NB_CLOSE_ON_ACTIVE_TAB); end --- 1079,1086 ---- case ID_NotebookCloseButtonActive: m_notebook_style |= wxAUI_NB_CLOSE_ON_ACTIVE_TAB; break; --]] ! if id == self.ID_NotebookNoCloseButton then ! elseif id == self.ID_NotebookCloseButton then self.m_notebook_style = bit.bor(self.m_notebook_style, wxaui.wxAUI_NB_CLOSE_BUTTON); ! elseif id == self.ID_NotebookCloseButtonAll then self.m_notebook_style = bit.bor(self.m_notebook_style, wxaui.wxAUI_NB_CLOSE_ON_ALL_TABS); ! elseif id == self.ID_NotebookCloseButtonActive then self.m_notebook_style = bit.bor(self.m_notebook_style, wxaui.wxAUI_NB_CLOSE_ON_ACTIVE_TAB); end *************** *** 1440,1445 **** imglist:Add(wx.wxArtProvider.GetBitmap(wx.wxART_FOLDER, wx.wxART_OTHER, wx.wxSize(16,16))); imglist:Add(wx.wxArtProvider.GetBitmap(wx.wxART_NORMAL_FILE, wx.wxART_OTHER, wx.wxSize(16,16))); ! --hd.FIXME crashes upon exit tree:AssignImageList(imglist); ! tree:SetImageList(imglist); local root = tree:AddRoot(wxT("wxAUI Project"), 0); --- 1440,1444 ---- imglist:Add(wx.wxArtProvider.GetBitmap(wx.wxART_FOLDER, wx.wxART_OTHER, wx.wxSize(16,16))); imglist:Add(wx.wxArtProvider.GetBitmap(wx.wxART_NORMAL_FILE, wx.wxART_OTHER, wx.wxSize(16,16))); ! tree:AssignImageList(imglist); local root = tree:AddRoot(wxT("wxAUI Project"), 0); *************** *** 1560,1565 **** <h3>Welcome to wxAUI</h3> <br/><b>Overview</b><br/> ! <p>wxAUI is an Advanced User Interface library for the wxWidgets toolkit ! that allows developers to create high-quality, cross-platform user interfaces quickly and easily.</p> <p><b>Features</b></p> --- 1559,1564 ---- <h3>Welcome to wxAUI</h3> <br/><b>Overview</b><br/> ! <p>wxAUI is an Advanced User Interface library for the wxWidgets toolkit ! that allows developers to create high-quality, cross-platform user interfaces quickly and easily.</p> <p><b>Features</b></p> Index: bindings.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/bindings.wx.lua,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** bindings.wx.lua 20 Dec 2007 02:26:58 -0000 1.18 --- bindings.wx.lua 22 Dec 2007 06:07:17 -0000 1.19 *************** *** 60,64 **** print("GetClassCount : "..tostring(binding.GetClassCount)) ! print("GetDefineCount : "..tostring(binding.GetDefineCount)) print("GetStringCount : "..tostring(binding.GetStringCount)) print("GetEventCount : "..tostring(binding.GetEventCount)) --- 60,64 ---- print("GetClassCount : "..tostring(binding.GetClassCount)) ! print("GetNumberCount : "..tostring(binding.GetNumberCount)) print("GetStringCount : "..tostring(binding.GetStringCount)) print("GetEventCount : "..tostring(binding.GetEventCount)) *************** *** 68,72 **** if true then print("\nDUMPING binding.GetClassArray ==================================\n") ! local keys = { "name", "methods", "methods_n", "classInfo", "class_tag", "baseclassName", "baseclass", "enums", "enums_n" } ColumnDumpTable(binding.GetClassArray, keys) end --- 68,72 ---- if true then print("\nDUMPING binding.GetClassArray ==================================\n") ! local keys = { "name", "wxluamethods", "wxluamethods_n", "classInfo", "wxluatype", "baseclassName", "baseclass", "enums", "enums_n" } ColumnDumpTable(binding.GetClassArray, keys) end *************** *** 74,85 **** if true then print("\nDUMPING binding.GetFunctionArray ==================================\n") ! local keys = { "name", "type", "funcs", "funcs_n", "basemethod" } ColumnDumpTable(binding.GetFunctionArray, keys) end if true then ! print("\nDUMPING binding.GetDefineArray ==================================\n") local keys = { "name", "value" } ! ColumnDumpTable(binding.GetDefineArray, keys) end --- 74,85 ---- if true then print("\nDUMPING binding.GetFunctionArray ==================================\n") ! local keys = { "name", "type", "wxluacfuncs", "wxluacfuncs_n", "basemethod" } ColumnDumpTable(binding.GetFunctionArray, keys) end if true then ! print("\nDUMPING binding.GetNumberArray ==================================\n") local keys = { "name", "value" } ! ColumnDumpTable(binding.GetNumberArray, keys) end *************** *** 92,96 **** if true then print("\nDUMPING binding.GetEventArray ==================================\n") ! local keys = { "name", "eventType", "class_tag" } ColumnDumpTable(binding.GetEventArray, keys) end --- 92,96 ---- if true then print("\nDUMPING binding.GetEventArray ==================================\n") ! local keys = { "name", "eventType", "wxluatype" } ColumnDumpTable(binding.GetEventArray, keys) end *************** *** 98,102 **** if true then print("\nDUMPING binding.GetObjectArray ==================================\n") ! local keys = { "name", "object", "class_tag" } ColumnDumpTable(binding.GetObjectArray, keys) end --- 98,102 ---- if true then print("\nDUMPING binding.GetObjectArray ==================================\n") ! local keys = { "name", "object", "wxluatype" } ColumnDumpTable(binding.GetObjectArray, keys) end *************** *** 289,293 **** -- subtract values from high to low value ! t = HasBit(t, wxlua.WXLUAMETHOD_OVERLOAD_BASE, nil, nil) -- nobody should care about this t = HasBit(t, wxlua.WXLUAMETHOD_DELETE, s, "Delete") t = HasBit(t, wxlua.WXLUAMETHOD_STATIC, s, "Static") --- 289,293 ---- -- subtract values from high to low value ! t = HasBit(t, wxlua.WXLUAMETHOD_CHECKED_OVERLOAD, nil, nil) -- nobody should care about this t = HasBit(t, wxlua.WXLUAMETHOD_DELETE, s, "Delete") t = HasBit(t, wxlua.WXLUAMETHOD_STATIC, s, "Static") *************** *** 301,305 **** -- remove this, nobody should care and it'll probably be confusing ! t = HasBit(t_, wxlua.WXLUAMETHOD_OVERLOAD_BASE, nil, nil) return string.format("0x%04X (%s)", t, table.concat(s, ", ")) --- 301,305 ---- -- remove this, nobody should care and it'll probably be confusing ! t = HasBit(t_, wxlua.WXLUAMETHOD_CHECKED_OVERLOAD, nil, nil) return string.format("0x%04X (%s)", t, table.concat(s, ", ")) *************** *** 307,311 **** -- ---------------------------------------------------------------------------- ! -- Convert the argtags table into a readable string -- ---------------------------------------------------------------------------- function CreateArgTagsString(args_table, wxlua_type) --- 307,311 ---- -- ---------------------------------------------------------------------------- ! -- Convert the argtypes table into a readable string -- ---------------------------------------------------------------------------- function CreateArgTagsString(args_table, wxlua_type) *************** *** 340,344 **** -- items in table from binding.GetClassArray are these ! -- { "name", "methods", "methods_n", "classInfo", "class_tag", "baseclassName", "baseclass", "enums", "enums_n" } local function GetClassInfoStr(classInfo) --- 340,344 ---- -- items in table from binding.GetClassArray are these ! -- { "name", "wxluamethods", "wxluamethods_n", "classInfo", "wxluatype", "baseclassName", "baseclass", "enums", "enums_n" } local function GetClassInfoStr(classInfo) *************** *** 366,376 **** t.col_numbers[6] = true ! --{ "name"[data], "methods_n", "classInfo", "class_tag", "baseclassName"[data], "enums_n"[data] } for i = 1, #tbl do local item = { tbl[i].name, ! tbl[i].methods_n, GetClassInfoStr(tbl[i].classInfo), ! tbl[i].class_tag, tbl[i].baseclassName or "", tbl[i].enums_n, --- 366,376 ---- t.col_numbers[6] = true ! --{ "name"[data], "wxluamethods_n", "classInfo", "wxluatype", "baseclassName"[data], "enums_n"[data] } for i = 1, #tbl do local item = { tbl[i].name, ! tbl[i].wxluamethods_n, GetClassInfoStr(tbl[i].classInfo), ! tbl[i].wxluatype, tbl[i].baseclassName or "", tbl[i].enums_n, *************** *** 380,386 **** -- This class has methods and can be expanded ! if (type(tbl[i].methods) == "table") then item.icon = list_images.folder ! item.data[1] = tbl[i].methods end --- 380,386 ---- -- This class has methods and can be expanded ! if (type(tbl[i].wxluamethods) == "table") then item.icon = list_images.folder ! item.data[1] = tbl[i].wxluamethods end *************** *** 398,402 **** -- some sanity checks to make sure the bindings are working ! if (tbl[i].methods_n > 0) and (type(tbl[i].methods) ~= "table") then print(tbl[i].name, "is missing methods table, please report this.") end --- 398,402 ---- -- some sanity checks to make sure the bindings are working ! if (tbl[i].wxluamethods_n > 0) and (type(tbl[i].wxluamethods) ~= "table") then print(tbl[i].name, "is missing methods table, please report this.") end *************** *** 420,429 **** local t = { {"..", ["icon"] = list_images.folder}, ! ["col_labels"] = { "name", "type", "funcs_n", "basemethod", "minargs", "maxargs", "argtag_names", "argtags" }, ["object_type"] = "wxLuaBindMethod" } -- items in table are ! -- { "name", "type", "funcs", "funcs_n", "basemethod" } t.col_numbers = {} --- 420,429 ---- local t = { {"..", ["icon"] = list_images.folder}, ! ["col_labels"] = { "name", "method_type", "wxluacfuncs_n", "basemethod", "minargs", "maxargs", "argtype_names", "argtypes" }, ["object_type"] = "wxLuaBindMethod" } -- items in table are ! -- { "name", "type", "wxluacfuncs", "wxluacfuncs_n", "basemethod" } t.col_numbers = {} *************** *** 438,443 **** local item = { class_name..tbl[i].name, ! CreatewxLuaMethod_TypeString(tbl[i].type), ! tbl[i].funcs_n, "", "", --- 438,443 ---- local item = { class_name..tbl[i].name, ! CreatewxLuaMethod_TypeString(tbl[i].method_type), ! tbl[i].wxluacfuncs_n, "", "", *************** *** 462,471 **** -- Add in the CFuncs ! item.data[1] = tbl[i].funcs item.color = wx.wxBLUE table.insert(t, item) ! -- keys for CFunc = { "func", "type", "minargs", "maxargs", "argtag_names", "argtags" } ! local cfunc_t = CreatewxLuaBindCFunc(tbl[i].funcs) for j = 2, #cfunc_t do local cft = {item[1].." func "..j-1, cfunc_t[j][2], "", "", cfunc_t[j][3], cfunc_t[j][4], cfunc_t[j][5], cfunc_t[j][6]} --- 462,471 ---- -- Add in the CFuncs ! item.data[1] = tbl[i].wxluacfuncs item.color = wx.wxBLUE table.insert(t, item) ! -- keys for CFunc = { "lua_cfunc", "type", "minargs", "maxargs", "argtype_names", "argtypes" } ! local cfunc_t = CreatewxLuaBindCFunc(tbl[i].wxluacfuncs) for j = 2, #cfunc_t do local cft = {item[1].." func "..j-1, cfunc_t[j][2], "", "", cfunc_t[j][3], cfunc_t[j][4], cfunc_t[j][5], cfunc_t[j][6]} *************** *** 479,487 **** -- ---------------------------------------------------------------------------- ! -- Create a list table from a wxLuaBindDefine struct table -- ---------------------------------------------------------------------------- ! function CreatewxLuaBindDefine(tbl) local keys = { "name", "value" } ! local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindDefine") t.col_numbers = {} --- 479,487 ---- -- ---------------------------------------------------------------------------- ! -- Create a list table from a wxLuaBindNumber struct table -- ---------------------------------------------------------------------------- ! function CreatewxLuaBindNumber(tbl) local keys = { "name", "value" } ! local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindNumber") t.col_numbers = {} *************** *** 510,514 **** -- ---------------------------------------------------------------------------- function CreatewxLuaBindEvent(tbl) ! local keys = { "name", "eventType", "class_tag" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindEvent") --- 510,514 ---- -- ---------------------------------------------------------------------------- function CreatewxLuaBindEvent(tbl) ! local keys = { "name", "eventType", "wxluatype" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindEvent") *************** *** 529,533 **** -- ---------------------------------------------------------------------------- function CreatewxLuaBindObject(tbl) ! local keys = { "name", "object", "class_tag" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindObject") --- 529,533 ---- -- ---------------------------------------------------------------------------- function CreatewxLuaBindObject(tbl) ! local keys = { "name", "object", "wxluatype" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindObject") *************** *** 544,552 **** -- ---------------------------------------------------------------------------- function CreatewxLuaBindCFunc(tbl) ! local keys = { "func", "type", "minargs", "maxargs", "argtags" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindCFunc") ! t.col_labels[5] ="argtags_names" -- swap these two ! t.col_labels[6] ="argtags" t.col_numbers = {} --- 544,552 ---- -- ---------------------------------------------------------------------------- function CreatewxLuaBindCFunc(tbl) ! local keys = { "lua_cfunc", "method_type", "minargs", "maxargs", "argtypes" } local t = CreatewxLuaBindTable(tbl, keys, "wxLuaBindCFunc") ! t.col_labels[5] ="argtype_names" -- swap these two ! t.col_labels[6] ="argtypes" t.col_numbers = {} *************** *** 757,761 **** {"GetClassArray", "GetClassCount : "..tostring(binding.GetClassCount), ["icon"] = list_images.folder}, {"GetFunctionArray", "GetFunctionCount : "..tostring(binding.GetFunctionCount), ["icon"] = list_images.folder}, ! {"GetDefineArray", "GetDefineCount : "..tostring(binding.GetDefineCount), ["icon"] = list_images.folder}, {"GetStringArray", "GetStringCount : "..tostring(binding.GetStringCount), ["icon"] = list_images.folder}, {"GetEventArray", "GetEventCount : "..tostring(binding.GetEventCount), ["icon"] = list_images.folder}, --- 757,761 ---- {"GetClassArray", "GetClassCount : "..tostring(binding.GetClassCount), ["icon"] = list_images.folder}, {"GetFunctionArray", "GetFunctionCount : "..tostring(binding.GetFunctionCount), ["icon"] = list_images.folder}, ! {"GetNumberArray", "GetNumberCount : "..tostring(binding.GetNumberCount), ["icon"] = list_images.folder}, {"GetStringArray", "GetStringCount : "..tostring(binding.GetStringCount), ["icon"] = list_images.folder}, {"GetEventArray", "GetEventCount : "..tostring(binding.GetEventCount), ["icon"] = list_images.folder}, *************** *** 778,783 **** elseif (itemText == "GetFunctionArray") then t = CreatewxLuaBindMethod(binding.GetFunctionArray) ! elseif (itemText == "GetDefineArray") then ! t = CreatewxLuaBindDefine(binding.GetDefineArray) elseif (itemText == "GetStringArray") then t = CreatewxLuaBindString(binding.GetStringArray) --- 778,783 ---- elseif (itemText == "GetFunctionArray") then t = CreatewxLuaBindMethod(binding.GetFunctionArray) ! elseif (itemText == "GetNumberArray") then ! t = CreatewxLuaBindNumber(binding.GetNumberArray) elseif (itemText == "GetStringArray") then t = CreatewxLuaBindString(binding.GetStringArray) *************** *** 802,806 **** local c = data[data_index].data[5] 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 --- 802,806 ---- local c = data[data_index].data[5] while type(c) == "userdata" do ! local tt = CreatewxLuaBindMethod(c.wxluamethods, c.name) for i = 2, #tt do -- skip ".." if not (string.find(tt[i][2], "Constructor", 1, 1) or *************** *** 816,820 **** t = CreatewxLuaBindClass({data[data_index].data[col+1]}) elseif (col == 5) and (type(data[data_index].data[col+1]) == "table") then ! t = CreatewxLuaBindDefine(data[data_index].data[col+1]) end --- 816,820 ---- t = CreatewxLuaBindClass({data[data_index].data[col+1]}) elseif (col == 5) and (type(data[data_index].data[col+1]) == "table") then ! t = CreatewxLuaBindNumber(data[data_index].data[col+1]) end *************** *** 1150,1165 **** for i = 1, #classTable do ! local methods = classTable[i].methods -- some classes don't have methods, wxBestHelpController for example ! for j = 1, classTable[i].methods_n do ! local m = methods[j] local m_table = {m.name} while m do ! local funcs = m.funcs local s = "" ! for f = 1, m.funcs_n do ! s = s.."("..CreateArgTagsString(funcs[f].argtags, funcs[f].type)..") " end --- 1150,1165 ---- for i = 1, #classTable do ! local wxluamethods = classTable[i].wxluamethods -- some classes don't have methods, wxBestHelpController for example ! for j = 1, classTable[i].wxluamethods_n do ! local m = wxluamethods[j] local m_table = {m.name} while m do ! local wxluacfuncs = m.wxluacfuncs local s = "" ! for f = 1, m.wxluacfuncs_n do ! s = s.."("..CreateArgTagsString(wxluacfuncs[f].argtypes, wxluacfuncs[f].method_type)..") " end Index: unittest.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/unittest.wx.lua,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** unittest.wx.lua 20 Dec 2007 02:26:59 -0000 1.19 --- unittest.wx.lua 22 Dec 2007 06:07:17 -0000 1.20 *************** *** 235,254 **** a = wx.wxCommandEvent() b = a:DynamicCast("wxObject") ! PrintOk((a ~= b) and string.find(tostring(a), "wxCommandEvent", 1, 1) and string.find(tostring(b), "wxObject", 1, 1), "wxObject::DynamicCast a wxCommandEvent to a wxObject") b = b:DynamicCast("wxCommandEvent") ! PrintOk((a == b) and string.find(tostring(a), "wxCommandEvent", 1, 1) and string.find(tostring(b), "wxCommandEvent", 1, 1), "wxObject::DynamicCast the wxObject back to a wxCommandEvent to get original userdata back") ! b = b:DynamicCast("wxCommandEvent") ! PrintOk((a == b) and string.find(tostring(a), "wxCommandEvent", 1, 1) and string.find(tostring(b), "wxCommandEvent", 1, 1), "wxObject::DynamicCast a wxCommandEvent to a wxCommandEvent to get same userdata back") b = b:DynamicCast("wxEvent") b:delete() ! PrintOk((a ~= b) and not (string.find(tostring(a), "wx", 1, 1) or string.find(tostring(b), "wx", 1, 1)), "wxObject::DynamicCast a wxCommandEvent to a wxEvent then delete the wxEvent, both should be deleted") -- --------------------------------------------------------------------------- print("\nTest adding a methods to a class object userdata.\n") --- 235,272 ---- a = wx.wxCommandEvent() b = a:DynamicCast("wxObject") ! ! print(a, b) ! ! PrintOk((a ~= b) and string.find(tostring(a), "wxCommandEvent", 1, 1) and string.find(tostring(b), "wxObject", 1, 1), "wxObject::DynamicCast a wxCommandEvent to a wxObject") + PrintOk((a ~= b) and (string.match(tostring(a), "%([abcdefx%d]*") == string.match(tostring(b), "%([abcdefx%d]*")), + "wxObject::DynamicCast a wxCommandEvent to a wxObject the object pointer stays the same") b = b:DynamicCast("wxCommandEvent") ! PrintOk((a == b) and string.find(tostring(a), "wxCommandEvent", 1, 1) and string.find(tostring(b), "wxCommandEvent", 1, 1), "wxObject::DynamicCast the wxObject back to a wxCommandEvent to get original userdata back") + PrintOk((a == b) and (string.match(tostring(a), "%([abcdefx%d]*") == string.match(tostring(b), "%([abcdefx%d]*")), + "wxObject::DynamicCast the wxObject back to a wxCommandEvent the object pointer stays the same") ! b = b:DynamicCast("wxCommandEvent") -- should do nothing ! PrintOk((a == b) and string.find(tostring(a), "wxCommandEvent", 1, 1) and string.find(tostring(b), "wxCommandEvent", 1, 1), "wxObject::DynamicCast a wxCommandEvent to a wxCommandEvent to get same userdata back") + PrintOk((a == b) and (string.match(tostring(a), "%([abcdefx%d]*") == string.match(tostring(b), "%([abcdefx%d]*")), + "wxObject::DynamicCast a wxCommandEvent to a wxCommandEvent the object pointer stays the same") b = b:DynamicCast("wxEvent") b:delete() ! PrintOk((a ~= b) and not (string.find(tostring(a), "wx", 1, 1) or string.find(tostring(b), "wx", 1, 1)), "wxObject::DynamicCast a wxCommandEvent to a wxEvent then delete the wxEvent, both should be deleted") + -- NOTE! It is probably a mistake in wxWidgets that there are two functions with + -- the same name, but it's good dynamic casting test for wxLua. + -- wxBookCtrlBaseEvent::GetSelection() returns its int m_nSel + -- wxCommandEvent::GetSelection() return its int m_commandInt + a = wx.wxBookCtrlBaseEvent(wx.wxEVT_NULL, 5, 10, 11) + b = a:DynamicCast("wxCommandEvent") + PrintOk((a ~= b) and (a:GetSelection() == 10) and (b:GetSelection() == 0), + "wxObject::DynamicCast a wxBookCtrlBaseEvent to a wxCommandEvent and compare the two GetSelection() functions which use different member vars") + -- --------------------------------------------------------------------------- print("\nTest adding a methods to a class object userdata.\n") *************** *** 294,299 **** --- 312,322 ---- o = wxlua.wxLuaObject("hello"); b = o:GetObject() PrintOk((b == "hello") and (a ~= b), "Test wxLuaObject::GetObject(string).") + o = wxlua.wxLuaObject(10); b = o:GetObject() PrintOk(b == 10, "Test wxLuaObject::GetObject(number).") + + o = wxlua.wxLuaObject(true); b = o:GetObject() + PrintOk(b == true, "Test wxLuaObject::GetObject(boolean).") + a = {"hello"}; o = wxlua.wxLuaObject(a); b = o:GetObject() PrintOk((a == b) and (b[1] == "hello"), "Test wxLuaObject::GetObject(table).") |