Re: FFI enums are now always boxed

  • From: Justin Cormack <justin@xxxxxxxxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 18 Jul 2012 16:12:52 +0100

On 18 Jul 2012 11:35, "Mike Pall" <mike-1207@xxxxxxxxxx> wrote:
>
> Daurnimator wrote:
> > print(ffi.new("MyType",ffi.C.bar)) -- cdata<enum 95>: 1
> >
> > Is there any way it could show "cdata<enum 95>: bar"?
> > (or even "cdata<MyType>: bar")
>
> That's a bit expensive, since there's no inverse table for that.
> Also, enum constant keys are unique, but values are not.
>

Can you put metatypes on enums now they are boxed? Then you could add a
tostring anyway by hand.

Justin

Other related posts: