[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: absolute stack index
- From: "Wim Couwenberg" <w.couwenberg@...>
- Date: Mon, 30 Jun 2003 12:38:31 +0200
> Wow, just found by chance that this IS in the standard distribution,
> just not public ;-) [..snip snip..]
>
> [lauxlib.c]
> /* convert a stack index to positive */
> #define abs_index(L, i) ((i) > 0 || (i) <= LUA_REGISTRYINDEX ? (i) :
> \ lua_gettop(L) + (i) + 1)
Note that this is not safe (see previous mail.) I think it would have been
phrased differently if it was public. To be on the safe side, make it a
function. If call speed is a concern then you could declare it as inline in
C++, or in C you could declare and define it as static in some header and
rely on the compiler to inline it (or give it a hint.)
--
Wim