repeat_settings.lua (583B)
1 local base = string.match(..., "(.-)[^%.]+%.[^%.]+$") 2 local ffi = require("ffi") 3 local fh = require(base.."helper.ffi_struct") 4 5 local format = string.format 6 7 -- missing from header 8 ffi.cdef[[ 9 struct inputor_repeat_settings 10 { 11 int delay, period; 12 }; 13 ]] 14 15 local mt, index = {}, {} 16 fh.gen_raw_accessor(index, "delay") 17 fh.gen_raw_accessor(index, "period") 18 19 function index:tostring() 20 return format("repeat_settings{delay=%d, period=%d}", 21 self.delay, self.period) 22 end 23 mt.__tostring = index.tostring 24 25 return fh.base(mt, index, ffi.typeof("struct inputor_repeat_settings"))