[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Accessing functions from C
- From: David Bhowmik <david.bhowmik@...>
- Date: Tue, 2 Apr 2002 10:41:17 +0100
bool GetFunction(lua_State *L, char functionName, lua_TObject &function,
function = *luaH_getstr(L->gt, luaS_new(L, functionName));
if(ttype(&function) != LUA_TFUNCTION)
// check arguments
Closure *cl = clvalue(&function);
const Proto *const tf = cl->f.l;
argsExpected = tf->numparams;
From: firstname.lastname@example.org [mailto:email@example.com]
Sent: 02 April 2002 10:23
To: Multiple recipients of list
Subject: Accessing functions from C
I have what I think is an obvious question, that I cant find the answer to.
Here is a code fragment:
xxx("string", function () ...whatever... end)
Function xxx(), a C function, takes two parameters, namely a string,
and a function, either named or anonymous. This function needs to store
both parameters. It does so in a mechanism outside of lua. The first
parameter, a string, is trivial. How do I retreive a persistent
reference to the second, the function? The list of provided
access functions does not seem to include a lua function retreiver,
only a C function retreiver.
The reason for this is so that the stored functions can be called
later from another C function. Thuis I need a persistent "pointer"
I can use at a random time.