[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Unique object references
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Fri, 8 Dec 2006 19:39:49 -0500
Chris wrote:
> Is there any way to get a state-wide unique reference to any
> particular object in the state?
>
> I know there is the luaL_ref stuff but that's only unique to
> a specific table. I'm looking for something that can return
> a unique reference (eg. memory pointer or something) to any
> object in the entire state. Something that doesn't change
> and always refers to the same object.
>
> I don't necessarily need to get a unique reference for basic
> types but I would like to get them for functions and tables.
> rawequal must be using something similar to what I am talking
> about. I see it is using
> some garbage collector pointer or something like that. Is there
> currently a way to pull that out as a lightuserdata or some
> other way to get that unique reference?
I think you can use tostring to get a unique string identifier to any
Lua value. You can also put a reference to the values you're interested
in in the registry, which is unique per Lua master state (use luaL_ref
and luaL_unref with LUA_REGISTRYINDEX as second parameter).