[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] luaffi (ffi library ala luajit's for the standard lua vm)
- From: James McKaskill <james@...>
- Date: Mon, 18 Jul 2011 09:22:30 -0400
On Mon, Jul 18, 2011 at 01:33, Geoff Leyland <geoff_leyland@fastmail.fm> wrote:
> On 18/07/2011, at 5:01 PM, Daurnimator wrote:
>
>> On 18 July 2011 14:21, James McKaskill <james@foobar.co.nz> wrote:
>>> Also vararg callbacks aren't supported and never will be as there
>>> isn't enough information to figure out how to push the arguments into
>>> lua.
>>
>> Can you just pass them as void*s, and we can cast them as we want?
>
> Would the problem be that the ffi doesn't know either of the size of each argument, nor how many arguments there are?
It's even more fun then that. In order to even find a given argument
you need to know the c type of all preceding arguments (not only the
size but also int vs float). For example posix X64 essentially has 3
different argument stores (int registers, float registers, and the
stack). The int registers and float registers are consumed
independently but start sharing the stack as each runs out.
If you wanted to be able to unpack varargs, you would have to copy a
va_list into lua as well as reimplementing the va_arg algorithm. All
up its not worth it.
It may however be reasonable to push an opaque va_list which can then
be handed back into C.
-- James