Update of /cvsroot/wxlua/wxLua/samples
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv27235/wxLua/samples
Modified Files:
unittest.wx.lua
Log Message:
Add docs for binding.html for wrapping virtual functions in C++
make it possible to replace nonvirtual functions of wxLua userdata with lua functions, test in unittest
add more docs in wxlprint.cpp to explain what is really going on for the function calls
Index: unittest.wx.lua
===================================================================
RCS file: /cvsroot/wxlua/wxLua/samples/unittest.wx.lua,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** unittest.wx.lua 7 Dec 2006 22:05:53 -0000 1.5
--- unittest.wx.lua 7 Feb 2007 04:56:25 -0000 1.6
***************
*** 36,40 ****
-- ---------------------------------------------------------------------------
! -- Simple bindings tests
-- ---------------------------------------------------------------------------
--- 36,40 ----
-- ---------------------------------------------------------------------------
! print("\nSimple bindings tests.\n")
-- ---------------------------------------------------------------------------
***************
*** 56,60 ****
-- ---------------------------------------------------------------------------
! -- test some class functions
pt = wx.wxPoint(1, 2)
--- 56,61 ----
-- ---------------------------------------------------------------------------
! print("\nTest some binding class functions.\n")
! -- ---------------------------------------------------------------------------
pt = wx.wxPoint(1, 2)
***************
*** 96,97 ****
--- 97,116 ----
pen:SetColour(1, 2, 3)
PrintOk(pen:GetColour():Red() == 1, "%overload function wxPen:SetColourRGB(1, 2, 3)")
+
+ -- ---------------------------------------------------------------------------
+
+ print("\nTest adding a functions to a class object userdata.\n")
+ -- ---------------------------------------------------------------------------
+
+ a = wx.wxRect(1,2,3,4);
+ function a.Print(self) return string.format("%d,%d,%d,%d", self.X, self.Y, self:GetWidth(), self:GetHeight()) end
+ PrintOk(a:Print() == "1,2,3,4", "Add a new lua function to an already created wx.wxRect")
+
+ a = wx.wxRect(1,2,3,4);
+ function a.GetX(self) return "x" end
+ PrintOk(a:GetX() == "x", "Replace wxRect:GetX with a lua function")
+ PrintOk(a:base_GetX() == 1, "Replace wxRect:GetX with a lua function, call wxRect:base_GetX for original function")
+ PrintOk(a:GetX() == "x", "Replace wxRect:GetX with a lua function (test recursion)")
+ PrintOk(a:base_GetX() == 1, "Replace wxRect:GetX with a lua function, call wxRect:base_GetX for original function (rest recursion)")
+
+ print("\n")
|