From: John L. <jla...@gm...> - 2006-02-06 20:50:51
|
On 2/6/06, k. holwerda <kla...@nl...> wrote: > Hi John, > > John Labenski wrote: > > >You can have your C function just call lua code directly. > >m_wxlState.RunString(wxString::Format(wxT("hittest(%f, %f)"), x, y))); > >in the lua code you can then set variables back to C++ through the bindi= ng. > > > > > But i need to call a function in Lua which gets as a parameter a wxDC > pointer from C++. > So i think i need to push things on the lua stack, and call a function ne= xt? Take a look at this, it tells you how to call lua functions from C. http://www.lua.org/pil/25.2.html > Also the functions to call are part of the m_script string stored inside > each luacanvas object. > And for each such object that script would be different in general, but > the function is called the same ( Draw and HitTest ). > Just reporting the functions to lua (using runstring() ) is not enough, > as i think they must be unique. So you'll have a wxLuaState for every object? Maybe you can just create a table in lua to store each object (as a sub table). In each object's table you can put the functions to call. > But on the other hand wrapping the luacanvas object to lua does not help > too, since the instance of the object is in the C++ canvas. > So i do not want to create the instance inside lua code. > Eventually i think i need to push the current (to draw/hit ) luacanvas > object as a (this) pointer on the stack, and next the parameters to the > member function to call on that object. And when that is ready call the > function. Humm, I don't think I understand. I haven't looked at the code for wxluacan yet however. -John |