lua-users home
lua-l archive

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

On Tue, Aug 19, 2003 at 10:55:13PM -0300, Jose Marin wrote:
> Hi.
> I'm trying to create a C function  that has a Lua function as parameter, using tolua.
> Like this:
> In the file funcs.pkg I define this function
> void SetFunc(lua_Object fnc);
> as the tolua docs says, but the compiler doesn't find the lua_Object definition.
> I know that this was used in lua 3.2 and doens't exists anynore after version 4.0 .

lua_Object is dead.  Good riddance!

> So, how to use tolua, with Lua 5.0, to declare a C function that accepts  
> a Lua function as a parameter???

The vibe I get from the tolua documentation it that is really all
about exporting *existing* C interfaces (which make no mention of lua
because they were not designed with lua in mind) rather than designed
a specific lua/C interface.  So it makes no allowances for
lua-specific types.

Some ways which you could do this:

Pass a string which is the name of a global variable which is the

Pass a string or number which an index into some 'callback table'
which your application uses to store callbacks.

Bypass tolua and interface this function by hand.