[prev in list] [next in list] [prev in thread] [next in thread]
List: lua-l
Subject: Re: Lua C-API - create two tables parallel
From: Ervin =?utf-8?Q?Heged=C3=BCs?= <airween () gmail ! com>
Date: 2023-10-07 13:42:13
Message-ID: 20231007134213.jnveex3annvgmqta () arxnet ! hu
[Download RAW message or body]
Hi Andrew,
On Sat, Oct 07, 2023 at 02:36:09PM +0100, Andrew Gierth wrote:
> >>>>> "Ervin" == Ervin Hegedüs <airween@gmail.com> writes:
>
> Ervin> As you can see I iterate through the list twice, because I don't
> Ervin> know how can I handle in two tables parallel.
>
> I don't see why you think this is a problem - you can easily have
> multiple tables on the stack.
I didn't know how can I access to the tables.
But now I think based on your example:
> lua_newtable(L); // lineerrors
> lua_newtable(L); // lineerrorspos
> lua_pushstring(L, logerr.errmsg);
> // stack: lineerrors \ lineerrorspos \ errmsg
> lua_seti(L, -3, c);
> lua_newtable(L);
> // stack: lineerrors \ lineerrorspos \ subtable
> lua_pushinteger(L, *logerr.startpos);
> lua_seti(L, -2, 1);
> lua_pushinteger(L, *logerr.endpos);
> lua_seti(L, -2, 1);
> // stack: lineerrors \ lineerrorspos \ subtable
> lua_seti(L, -2, c);
I see how does it work (I mean the indexing).
> If you're stuck on Lua 5.1, then you can easily define lua_seti yourself
> (in terms of lua_settable and lua_insert), or rewrite as
There is no plan to support Lua 5.1.
Many thanks,
a.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic