On 8/27/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I am trying to make a easiest way to implement virtual method. Something like > wxLuaPrintout of howto override HasPage() etc.. method, but actually I did > not quite get it > the how (as it touches some HasDerivedMethod() and some tag definition which > I do not > have time to look at it yet). Is there a fast explanation and howto step, to > do it? >
It's fairly easy, but maybe not so obvious. The binding files (*.i) just contain the functions as for any other class, don't be fooled by wxLuaPrintout seemingly not having any functions, they are defined in the base wxPrintout binding. The c++ class has to implement the code to check to see if there is a lua function overriding it. See modules/wxbind/src/wxlprint.cpp for some examples. Note that we've decided to add a ref counted wxLuaState to the c++ class and then have to override the constructor, see bindings/wxwidgets/overrides.cpp wxLua_wxLuaPrintout_constructor instead of trying to lookup what lua_State we're coming from on the fly each time a function is called. Once inside the c++ function, see any of the wxLuaPrintout functions, you handle the args and do whatever is necessary then always call SetCallBaseClassFunction(false), otherwise you'll get recursion, if you call base_SOMEFUNCNAME() you always should get the base class function. If you can think of a way to automate this a little better that'd be great. There is one change I've been meaning to make however, we need a way to make naming wxLuaPrintout just wxPrintout in lua since the lua code doesn't need to know or care that it's really a wxLuaPrintout. Hope this helps, John Labenski ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Wxlua-users mailing list Wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users