lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


LuaJIT implementation is extremely powerful, and so is its FFI library.
I started to use them a new simulator project.
But now I am annoyed by the following small issue :

If in a test.lua file there is a declaration like :

  ffi.cdef [[ enum { FOO, BAR }; ]]

it is impossible to run the test.lua more than once in a single lua_State:

  dofile "test.lua" -- OK
  dofile "test.lua" --> test.lua:1: attempt to redefine 'FOO'

Is there any way to reset the declarations made by ffi.cdef ?
A bit like jit.flush() resets all the JIT traces.
Another (probably much more complicated) way would be to specifically
undefine some symbols.