lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, 13 Jan 2009 12:57:00 +0200, Bogdan Marinescu <bogdan.marinescu@gmail.com> wrote:

sorry, my error. Replace those two lines with:

lua_remove(L, 1);
return ((lua_CFunction) p)(L);


I understand, but at this point you have an even bigger problem :)
lightuserdatas have a "global" metatable, just like strings and other
elementary types (only "full" userdatas can get per-instance
metatables). So your lightCall function will be called for all your
lightuserdata. And from what I can tell the lightCall function doesn't
get the function name as a parameter, so you won't know what's the
actual function that you need to call.

It gets lightuserdata pointer of type int (*)(struct lua_State *)
as argument 1, because it is metamethod for lightuserdata object.
That is the function it needs to call. That is why it
does lua_remove(L, 1) before forwarding call to actual function.

--j<