Hi, John Labenski wrote: > On Nov 30, 2007 2:45 AM, Hakkı Doğusan <[EMAIL PROTECTED]> wrote: >> Hi, >> >> (It seems I can post with this mail address) >> >> In unittest you'll see following lines (at ~229): >> >> a = wx.wxRect(1,2,3,4); >> function a.Print(self) return string.format("%d,%d,%d,%d", self:GetX(), >> self:GetY(), self:GetWidth(), self:GetHeight()) end >> PrintOk(a:Print() == "1,2,3,4", "Add a new lua function to an already >> created wx.wxRect") >> >> I found that usage "trick" from the hard way :) I should have study >> samples carefully.. > > I don't understand your program. Is there something wrong with the > code or are you showing how to make "executable" modules? The > executable module method is nice. >
I hope there is no problem in my code :) I'm trying to apply cpp coding style to my lua code. Before finding that it is possible to attach addidional fields to wxLua's objects, I was using lua tables: o = { wxobj=nil, fun1=function() .. end } But using wxLua's object makes it simple. wxobj.fun1 = function(t) .. end Similar to x.cpp & x.h usage, I now have x.lua for a X class; clean seperation/interface for public and private parts. Using __call method as constructor made my modules very similar to cpp classes: class X : public wxPanel { public: X(wxWindow* parent); DoSomething() { DoPrivateThing(); } private: DoPrivateThing(); } Became; module"X" local function DoPrivateThing(t) end function __call(self, parent) local o=wx.wxPanel(parent) o.DoSomething=function(t) DoPrivateThing(t) end return o end setmetatable(_M, _M) Now both cpp and lua code looks similar: cpp: o = X(p); o.DoSomething(); o.SetSize(..) lua: o = X(p); o:DoSomething(); o:SetSize(..) Hope I successed to explain my thinking.. > Regards, > John > > -- Regards, Hakki Dogusan ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users