Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: corrected code sample

...

 

Code Block
languagelua
-- ffi setuplocalsetup
local ffi = require("ffi")
ffi.cdef[[
    typedef uint64_t UniverseID;
]]

[...]
local myUniverseID = [...]
[...]
local ffiIDType = ffi.typeof("UniverseID")
local isFFIID = ffi.istype(ffiIDType, myUniverseID)
 
-- isFFIID will be true, if myUniverseID is an FFIID, otherwise this will be false

 

In exceptional cases you might also have to create FFI datatypes directly in the Lua script. Normally this is not necessary, since passing certain Lua values to FFI will be converted to the appropriate type directly. However, in cases where you have to construct objects of an FFI type, you can do so using ffi.new

...