lua-users home
lua-l archive

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


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

This code (see also luaT_gettmbyobj) looks up entry "__call"
in object's metatable (which has to be a real Lua table),
and checks that this entry is a function.
It doesn't check type of object.
It checks type of metamethod.

You're right, but then you're using lua_call from your __call
metamethod (lightCall),

sorry, my error. Replace those two lines with:

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

that's what happens when typing from memory... :(

and that's the part I don't understand how
it's supposed to work. Once again, to call any function you'd need a
LUA_TFUNCTION object. One per function, to be more precise. Your
lightCall seems like it's trying to call pointers directly.

exactly. Calling CFunction pointers directly. My error in lightCall.