[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: How to call a Lua object method fom a function in C?
- From: "Michael Cumming" <Mike.C@...>
- Date: Tue, 1 Mar 2005 08:05:45 -0600
Follow question to below...
How does one pass an object method to C so the C can call the object method back?
Ie.
Lobject = { callback = function (self...) .... end}
PassObjectCallbacktoC (Lobject.callback) -- note Lobject:callback cannot be passed.
Adam, Rici,
Thank you for the replys... so a quick guess at the code would be...
if (lua_isfunction (L,1)) // we have a function
luacallbackfunction = luaL_ref(L, LUA_REGISTRYINDEX);
When I want to use the function I can do
lua_rawgeti(L, LUA_REGISTRYINDEX, luacallbackfunction);
lua_pushxxx for the params
lua_pcall (xxx)
Thanks again,
Mike
<<winmail.dat>>