[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: How to get Lua functions address?
- From: Benoit Germain <bgermain@...>
- Date: Fri, 10 Jan 2003 17:28:57 +0100
this should do the trick ?
// get the handleKey function
lua_pushliteral ( L , "handleKey" ) ;
lua_getglobal ( L , -1 ) ;
// push whatever argument that describes the key
...
// and call the function
lua_call(L,1,0);
or, if you don't want to intern the function name each time, do this once:
lua_pushliteral ( L , "handleKey" ) ;
lua_getglobal ( L , -1 ) ;
someVar = lua_ref ( L , true ) ;
and then you can just:
// get the handleKey function
lua_getref ( L , someVar ) ;
// push whatever argument that describes the key
...
// and call the function
lua_call(L,1,0);
Cheers,
Benoit.
-----Message d'origine-----
De : jose_marin2 <jose_marin2@yahoo.com.br>
[mailto:jose_marin2@yahoo.com.br]
Envoyé : vendredi 10 janvier 2003 17:14
À : Multiple recipients of list
Objet : Re: How to get Lua functions address?
Sorry, but I don´t understand!
All I need is to store a reference/point to a lua function
and call it when I need!
For example
In setkey.lua
function handleKey(key)
.
.
.
end
-- My C function
SetKeyFunction(handleKey)
In setkey.c, I must store the address of handleKey, and
call it when the user press a key...
The answer is: How SetFunctionKey gets the reference/address
of handleKey???
Thanks for any tip!