[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: converting a relative stack index into an absolute stack index: a little someting missing in the C API?
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 3 May 2010 15:26:57 -0400
Hi Benoit,
On Mon, May 3, 2010 at 12:52 PM, Benoit Germain <bgermain@ubisoft.fr> wrote:
> When I code a binding, I find myself having helper functions manipulating
> items on the stack whose index is provided by the caller. Often enough, this
> index is relative to the stack top.
The usual approach to tackling this problem is pushing the index first
thing before doing any other operations:
static void example (lua_State *L, int idx)
{
lua_pushvalue(L, idx);
// do stuff with relative index -1
}
Naturally this won't work if you provide more than one index (other
solutions are needed).
--
- Patrick Donnelly