Re: ffi type of pointer to

  • From: Henk Boom <henk@xxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 12 Jun 2012 16:06:42 -0400

On 12 June 2012 10:27, Mike Pall <mike-1206@xxxxxxxxxx> wrote:
> Justin Cormack wrote:
>> Would it be possible to add an ffi function that takes a ctype and returns
>> the ctype of a pointer to that type? (ffi.ptrtype(ct) or something?
>
> Well, it's not that difficult to do for the pointer case. But I'd
> rather go for parameterized types, e.g.
>
>  ffi.typeof("$ *", foo_t)
>  ffi.typeof("struct { $ k; $ v; }[?]", foo_t, bar_t)

I have to say I've run into this too, but for array types. It would be
nice to be able to create an array of a previously created struct type
without cdef'ing it into the global scope. To be able to do something
functionally like this would be handy:

operator = ffi.typeof("struct { float phase, frequency; }")

synth = ffi.typeof("struct { ? operators[?]; /*...*/ } ", operator, 7)

    henk

Other related posts: