[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Getting the callers environment in c
- From: Chris Gagnon <cgagnon@...>
- Date: Tue, 8 Mar 2011 09:23:11 -0800
The ID is just a piece of data important for code on the c side that needs it to track things.
On Mon, Mar 7, 2011 at 6:59 PM, Drake Wilson <firstname.lastname@example.org>
Quoth Chris Gagnon <email@example.com>, on 2011-03-07 17:32:30 -0800:
> All my lua runs in environments that contain an ID.Where is this ID exactly? Could you describe the relation between the
> here is the c:
> int SomeFuncImplementation(lua_State * L)
> // I need the ID
> // How do i get it!?
> // This doesn't work because it's the environment of this c function
> which is useless to me
> lua_getfield(L, "ID", LUA_ENVIRONINDEX);
> // lua_getfenv() is useless cause i can't get the calling function on the
> stack to use this
environments in question (by which I assume you mean environment
tables associated with functions) and the call stack you're looking
at? In particular, is there a reason you can't pass the ID down as an
> - Chris
---> Drake Wilson
You are correct i am referring to environment tables associated with the functions,
i have many environments they act as sandboxes for individual scripts to run in.
The ID is just unique number i use to track things on the c side.
I don't see what the stack really has to do with this, the issue exists anytime lua calls into a c function.
I don't want users to have to pass the ID to every function that needs it. Users shouldn't have to worry about it.
store a pointer to your environment in the registry
How does this even work, there are many environments and only one registry.
I would not know which one was used by the calling code.