lua-users home
lua-l archive

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


> I think something like this is more flexible.
>
> id = lua_registercontext(L);
> lua_setcontextdata(L,id,data);
>
> ...
>
> data = lua_getcontextdata(L,id);

What's wrong with:

    class MyData
    {
    public:
        SomeType GetData(SomeType id);
        void SetData(SomeType id, SomeType data);
    Private:
        SomeDataStructure allthedata;
    };

    #define LUA_USERSTATE MyData mydata;
    
    ...
    
    L.mydata.SetData(id, data);
    
    ...
    
    Data = L.GetData(id);
    
? 

Or of course a struct instead of a class for C users. I like the
ultimate flexibility the way it is.

Curt