[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: lua_popinteger and others
- From: Rena <hyperhacker@...>
- Date: Tue, 24 Apr 2012 22:57:38 -0600
On Tue, Apr 24, 2012 at 22:50, Rebel Neurofog <rebelneurofog@gmail.com> wrote:
> 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.
>
That's what I've done in my app. I was just proposing that such a
function should be part of the API.
--
Sent from my toaster.