jmckaskill / luaffi

Standalone FFI library for calling C functions from lua. Compatible with the luajit FFI interface.
469 stars 84 forks source link

I can't seem to set enum values #9

Closed daurnimator closed 12 years ago

daurnimator commented 12 years ago

Setting enums in a struct doesn't seem to work; Same error if you do it in the constructor; or afterwards.

A test case:

ffi = require"ffi"

ffi.cdef [[
    typedef enum {
    foo,
    } an_enum;

    typedef struct {
    an_enum x;
    } a_struct;
]]

local new = ffi.typeof ( "a_struct" )
new(ffi.C.foo)

ERROR: lua: unable to convert argument 2 from lua to cdata<struct 2>

jmckaskill commented 12 years ago

Thanks for the report. I thought I had an enum test in the test suite.... but apparently not.