From: John L. <jla...@gm...> - 2006-04-13 00:16:07
|
On 4/12/06, Ray Gilbert <ray...@sc...> wrote: > On the stack - the lua function calling c function > 'static int LUACALL My_C_fn(lua_State *L)' Take a look at the code in modules/wxluadebug/src/wxldebug.cpp int wxLuaDebugData::EnumerateTable(const wxLuaState& wxlState_, int tableRef, int nIndex, wxArrayInt& references) switch (lua_type(L, -2)) case LUA_TFUNCTION: if (lua_iscfunction(L, -2)) name.Printf(wxT("%p"), lua_tocfunction(L, -2)); else name.Printf(wxT("%p"), lua_topointer(L, -2)); break; ---------------- You could do lua_getglobal(L, "myfunction"); if (lua_isfunction(L, -1)) { lua_CFunction* fn =3D lua_tocfunction(L, -1); lua_pop(L, -1); if (fn) fn(L); // I forget how to call a pointer fn? } else if (!lua_isnil(L, -1)) lua_pop(-1); -John Labenski > -----Original Message----- > From: wxl...@li... > [mailto:wxl...@li...] On Behalf Of John > Labenski > Sent: Thursday, 13 April 2006 10:02 > To: wxl...@li... > Subject: Re: [Wxlua-users] How to get lua function name while in C > function > > On 4/12/06, Ray Gilbert <ray...@sc...> wrote: > > > > Has anyone got a sample of c code showing how to get lua function name > > Hi, I'm not sure I understand what you mean. A lua function that's on > the stack or just see if the function exists at all? > > To see if it exists I think this should work > > lua_getglobal(L, "myfunction"); > lua_isfunction(L, -1) > > then to run it do > > lua_pcall(L, 0, LUA_MULTRET, 0); > > else pop it off the stack > > lua_pop(L, 1) > > > -John Labenski > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting > language > that extends applications into web and mobile media. Attend the live > webcast > and join the prime developer group breaking into this new coding > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=110944&bid$1720&dat=121642 > _______________________________________________ > Wxlua-users mailing list > Wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmdlnk&kid=110944&bid$1720&dat=121642 > _______________________________________________ > Wxlua-users mailing list > Wxl...@li... > https://lists.sourceforge.net/lists/listinfo/wxlua-users > |