lua-users home
lua-l archive

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

Upvalues are fine, but they are hackish when all you want to do is directly
call a C++ member function.  If your requirements allow you to work in a
modified Lua distribution, consider this:

The functor extension described above allows you to directly register and
call C++ member functions.

An even better mechanism is available in the C++ LuaPlus distribution
(  Not only can LuaPlus's approach call
lua_State* enabled member functions, it can also call many C++ member
functions directly that don't even require a lua_State*.  On the negative
side, it also modified Lua to work much more efficiently.

If you simply can't modify Lua and can stand longer compile times, consider
LuaBind (  It does some amazing things.


> -----Original Message-----
> From: 
> [] On Behalf Of Tim Conkling
> Sent: Tuesday, October 21, 2003 3:50 PM
> To: Lua list
> Subject: Re: Lua C Functions in C++ class
> Thanks a lot to everyone who replied. Userdata upvalues are 
> exactly what I need.
> Tim
> On Oct 21, 2003, at 2:57 PM, Luiz Henrique de Figueiredo wrote:
> >> there's no way to associate any sort of user data with the 
> exported 
> >> functions
> >
> > Sure there is. You export C closures, not C functions, in 
> fact. So C 
> > function can have upvalues.
> > --lhf
> >