On 2/6/07, Ryan Pusztai <[EMAIL PROTECTED]> wrote: > On 2/6/07, Ryan Pusztai <[EMAIL PROTECTED]> wrote: > > Well I am still a bit lost. > > > > First, here is the documentation for the function I want to wrap. > > /*! > > The constructor creates an timer object with the given > > properties. The timer at this moment is not started. This > > will be done with the start() member function. > > \param msec time interval after that the the variable > > pointed by exitflag is setting to one. > > \param exitflag the adress of an integer, which was set > > to one after the given time interval. > > \warning The integer variable shouldn't leave it's valid > > range, before the timer was finished. So never take a > > local variable. > > \param exitfnc A function, which was called after msec. > > If you don't want this, refer a NULL pointer. > > */ > > timer(unsigned int msec,int* exitflag,void*(*exitfnc)(void*)); > > > > I am willing to take the last parameter out for now, at least until I > > understand Lua/wxLua better. I still don't know how to just re-wrap > > the call to the function using 'NULL' as the third parameter and > > passing whatever the user wanted for the rest of the parameters. > > > > Here is a example, notice I just want to remove the third parameter > > and then write a function to override the default. > > > > Interface file: (.i) > > > > //----------------------------------------------------------------------------- > > // Timer class > > > > %class %delete %noclassinfo %encapsulate timer > > timer(unsigned int msec,int* exitflag) > > int start() > > int stop() > > %endclass > > > > I just don't know where to start on the overrides.hpp. I am sorry if > > my questions are simple. I just want to use wxLua without integrating > > it into an application for my first exercise. I have plans to, but as > > you can see I don't get the whole integrating wxLua with C++. Thanks > > for your patients. > > > > I don't know anything about the wxLua and C++ connection, so I don't > > understand the function > > > > "...new wxLuaObject(wxlState, 3);" > > > > What is the 3? > > I worked on a piece of code from looking at examples and this is the > best I could come up with. Most of it is sudo-code to give you an idea > of what I want to do.
Do you need to know when the exitFlag is 1? From the docs it looks like in C++ you'd take an integer, set it to 0, call the timer(msec, &exitFlag, NULL) and could then check exitFlag periodically to see if the timer is done. A really lame hack could use a wxPoint (or better yet your own minimal C++ class that has only an int member). Alternatively if you will only make one timer call at a time you can use "static int exitFlag" in the function, see below. Lua code: exitFlag = wx.wxPoint(0,0) -- not local since it MUST exist for the life of the timer function call timer(1000, exitFlag) > %override wxLua_function_timer > // %function timer(unsigned int msec, int* exitflag) > static int LUACALL wxLua_function_timer(lua_State *L) > { > wxLuaState wxlState(L); > int mSec = 0; // int* exitFlag = NULL; (could make this a static var if only one timer call at a time) wxPoint *exitFlag = (wxPoint *)wxlState.GetUserDataType(3, s_wxluatag_wxPoint); > > timer* returns; > > // get the lua passed in parameters int y = (int)wxlState.GetNumberType(3); > mSec = wxlState.getInt(1); > exitFlag = wxlState.getIntPrt(2); > > // call timer constructor > returns = new timer(mSec, exitFlag, NULL); > > // push the result datatype > wxlState.PushUserDataType(s_wxluatag_timer, returns); > > // return the number of parameters > return 0; > } > %end ------------------------------------------------------------------------- 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