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.

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

Reply via email to