On 2/5/07, John Labenski <[EMAIL PROTECTED]> wrote:
> On 2/5/07, Ryan Pusztai <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I am making good progress towards adding wxSerialPort to wxLua. I
> > think I am down to the last problem. I have a function that takes a
> > callback function as a parameter and I don't know what I can use in
> > the interface file (.i). I have tried to use wxEventHandler as the
> > parameter and it of coarse does not work.
> >
> > Here is the header: (.h)
> >     class timer
> >     {
> >     ...
> >     public:
> >         timer(unsigned int msec,int* exitflag,void*(*exitfnc)(void*));
> >         int start();
> >         int stop();
> >     };
> >
> > Here is the interface file: (.i)
> >     
> > //-----------------------------------------------------------------------------
> >     // Timer class
> >
> >     %class %delete %noclassinfo %encapsulate timer
> >         timer(unsigned int msec,int* exitflag,wxEvtHandler* exitfnc)
> >         int start()
> >         int stop()
> >     %endclass
> >
>
> You need to make your own C function
> void mytimerhandler(void* data)
> {
>     Do something? call a lua function?
> }
>
> I do not know just what you're supposed to do here, but if you really
> need to have a lua function run in this code you can look at
> wxLua_lua_setTableFunc in modules/wxlua/src/wxlbind.cpp. In this
> function we create a wxLuaObject to store the lua function if a person
> creates their own functions so we can call them later.
>
> Example:
> r = wx.wxRect(1,2,3,4)
> r.PrintXY = function(self) print(self:GetX(), self:GetY()) end
> r:PrintXY()
>
> Really all you want to know is how to store a lua function, "...new
> wxLuaObject(wxlState, 3);" where 3 should be the lua function on the
> stack.
>
> If on the other hand you can generically make a C function to handle
> it for your purposes I would do that instead as it's much easier and
> just remove that parameter from the bindings.
>
> In either case you will need to override the function in the .i file,
> see bindings/wxwidgets/overrides.hpp and substitute a fake parameter
> (or remove it) for the void* function in the main .i file, like an int
> parameter, so the generator doesn't complain.

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?
-- 
Regards,
Ryan
RJP Computing

-------------------------------------------------------------------------
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

Reply via email to