lua-users home
lua-l archive

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


On Thu, Jun 13, 2002 at 02:37:59AM -0700, Alex Bilyk wrote:
> I had considered this but could not use statics and wanted to avoid
> searching for that state done by the map. My C++ class is hidden behind
> COM-like interface.

Unfortunately you ultimately need the relationship which you have for
cLuaState->lua_State to work back the other way for lua_State->cLuaState

Your choices really are:
     1. Alter lua_State to include a cLuaState*
     2. Create a static mapping somewhere from lua_State* to cLuaState*

unfortunately that's it. Now either you map it inside the cLuaState object,
or you'll have to map it elsewhere.

The only other option is to make all the functions which need the cLuaState
pointer use a userdata to pass that in as a closure value.

The last option is perhaps what you'll end up doing, but isn't the most
elegant due to a need to remember to do that for each function you register

D.

-- 
Daniel Silverstone                               http://www.digital-scurf.org/
Hostmaster, Webmaster, and Chief Code Wibbler          Digital-Scurf Unlimited
GPG Public key available from keyring.debian.org               KeyId: 20687895
You will be winged by an anti-aircraft battery.