lua-users home
lua-l archive

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


On Thu, May 23, 2013 at 3:28 PM, Satz Klauer <satzklauer@googlemail.com> wrote:
> Hi,
>
> I have a pointer to some user data available during initialisation,
> means before the LUA-script is started. This pointer has to be
> available during execution of the script, since it is a multithreaded,
> explicitely linked shared library environment I can't use just a
> global variable that stores these data.

It looks like you could use the registry. It's a table-like object
that's only accessible from C, using the Lua API. A kind of C-side
global store for C-functions.

Put the userdata in the registry when you initialize the interpreter,
and get it from there in the C-functions.

http://www.lua.org/pil/27.3.1.html

-- Pierre-Yves