[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua C Functions
- From: Niccolo Medici <niccolomedici@...>
- Date: Sun, 10 Jul 2016 00:57:46 +0300
On 7/9/16, ThePhD <jm3689@columbia.edu> wrote:
> Thank you for the clarification! I was unsure, since almost every
> example I had seen did this
> [...]
> examples I have seen in PIL and other places.
It's likely that you misunderstood the examples. Can you quote two examples?
> On Sat, Jul 9, 2016 at 12:02 PM, Alysson Cunha <alyssonrpg@gmail.com>
> wrote:
>
>> You dont need to pop the arguments from stack to rerurn values....
>>
>> Em 09/07/2016 12:37, "ThePhD" <jm3689@columbia.edu> escreveu:
>>
>> Hello!
>>
>> I have a question regarding the implementation details of the
>> returns
>> for C functions into Lua. As of right now, I use the C API to return one
>> or
>> more values back to Lua, but only after popping all of the arguments
>> given
>> to Lua just before I do this. This seems to be what is necessary, given
>> the
>> examples I have seen in PIL and other places.
[...]
>> Lua (5.1, 5.2, and 5.3), when I pop more than what's on the stack
>> from the stack, seem to protect against me ruining the stack by
>> "overpopping". LuaJIT, however, crashes because the stack is not
>> protected
>> from these over-pops.
Even if this were true, that you need to pop all values before your
function returns, you could simply do "lua_settop(L, 0)". No need to
calculate anything.