[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: lua_popinteger and others
- From: Sean Conner <sean@...>
- Date: Wed, 25 Apr 2012 02:00:08 -0400
It was thus said that the Great Rebel Neurofog once stated:
> On Tue, Apr 24, 2012 at 11:00 AM, Rena <hyperhacker@gmail.com> wrote:
> > Right now if you want to retrieve a field using the C API, it takes
> > three lines per field:
> > lua_getfield(L, index, "field name");
> > lua_Integer val = lua_tointeger(L, -1);
> > lua_pop(L, 1);
>
> static inline lua_Integer get_integer (lua_State *L, int idx, const char *field)
> {
> lua_getfield(L, idx, field);
> lua_Integer val = lua_tointeger(L, -1);
> lua_pop(L, 1);
> return val;
> }
>
> In modern compilers inlining avoids unnecessary data copying so this
> is at least optimal.
> Although inlining isn't ASNI C.
C89. C99 allows inlining of functions. Even though I use Lua, the C code
I write is C99. Works just fine.
-spc