-- automatically generated by the FlatBuffers compiler, do not modify

-- namespace: ppx

local flatbuffers = require('flatbuffers')

local Sample = {} -- the module
local Sample_mt = {} -- the class metatable

function Sample.New()
    local o = {}
    setmetatable(o, {__index = Sample_mt})
    return o
end
function Sample.GetRootAsSample(buf, offset)
    if type(buf) == "string" then
        buf = flatbuffers.binaryArray.New(buf)
    end
    local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
    local o = Sample.New()
    o:Init(buf, n + offset)
    return o
end
function Sample_mt:Init(buf, pos)
    self.view = flatbuffers.view.New(buf, pos)
end
function Sample_mt:Address()
    local o = self.view:Offset(4)
    if o ~= 0 then
        return self.view:String(o + self.view.pos)
    end
end
function Sample_mt:Name()
    local o = self.view:Offset(6)
    if o ~= 0 then
        return self.view:String(o + self.view.pos)
    end
end
function Sample_mt:DistributionType()
    local o = self.view:Offset(8)
    if o ~= 0 then
        return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
    end
    return 0
end
function Sample_mt:Distribution()
    local o = self.view:Offset(10)
    if o ~= 0 then
        local obj = flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)
        self.view:Union(obj, o)
        return obj
    end
end
function Sample_mt:Control()
    local o = self.view:Offset(12)
    if o ~= 0 then
        return (self.view:Get(flatbuffers.N.Bool, o + self.view.pos) ~= 0)
    end
    return true
end
function Sample.Start(builder) builder:StartObject(5) end
function Sample.AddAddress(builder, address) builder:PrependUOffsetTRelativeSlot(0, address, 0) end
function Sample.AddName(builder, name) builder:PrependUOffsetTRelativeSlot(1, name, 0) end
function Sample.AddDistributionType(builder, distributionType) builder:PrependUint8Slot(2, distributionType, 0) end
function Sample.AddDistribution(builder, distribution) builder:PrependUOffsetTRelativeSlot(3, distribution, 0) end
function Sample.AddControl(builder, control) builder:PrependBoolSlot(4, control, 1) end
function Sample.End(builder) return builder:EndObject() end

return Sample -- return the module