From: John L. <jr...@us...> - 2007-12-13 00:47:58
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv15370/wxLua/samples Modified Files: unittest.wx.lua Log Message: * Allowed using wxObject:DynamicCast() on an object and be able to use the object as both types. The problem was that wxEvent:GetEventObject() returned a wxObject which overwrote the wxWindow (perhaps) that you had as a userdata in Lua already. Additionally, if you delete an object all of the userdata that wrap it have their metatables cleared for safety. Functions renamed since they didn't do the same thing or behave the same. wxluaO_istrackedobject -> wxluaO_isgcobject wxluaO_addtrackedobject -> wxluaO_addgcobject wxluaO_removetrackedobject -> wxluaO_deletegcobject - Created a central luauserdata:delete() function for the bindings to reduce code. wxLua_wxluabind_delete(L) wxLuaStackDialog: You can expand both key and values of a table and more information is provided about items wxLua knows about. Index: unittest.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/unittest.wx.lua,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** unittest.wx.lua 7 Dec 2007 02:13:16 -0000 1.17 --- unittest.wx.lua 13 Dec 2007 00:47:53 -0000 1.18 *************** *** 224,227 **** --- 224,249 ---- -- --------------------------------------------------------------------------- + print("\nTest wxObject::DynamicCast.\n") + -- --------------------------------------------------------------------------- + + 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") -- --------------------------------------------------------------------------- |