[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua to C (was 4.1 work3 lua_getGlobal)
- From: "Russell Y. Webb" <rw20@...>
- Date: Sun, 20 Jan 2002 12:08:13 -0800
Ah, I get it now. First time I've really worked with 4.0 or later in C
manually.
Since there's a fairly 1:1 correspondence between lua code and the C API
have you ever considered writing a Lua to C compiler? C is presumably a bit
faster, much more easily protected from change, and needed for interfacing
to most external APIs. Perhaps disassembling the bytes codes to C would be
easy?
Russ
> From: Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
> Reply-To: lua-l@tecgraf.puc-rio.br
> Date: Sun, 20 Jan 2002 09:50:48 -0200
> To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
> Subject: Re: 4.1 work3 lua_getGlobal
>
>> The following C code never executes the code inside the condition
>> lua_getglobal(lua, "name");
>> if(lua_istable(lua, 1)){
>> // this code never executes
>> }
>
> Try -1 instead of 1. Very likely you already have things on the stack, and
> the 1 points to the bottom of the stack while -1 points to the top, which
> is where lua_getglobal leaves the value of "name".
> --lhf