...

Text file src/github.com/google/flatbuffers/tests/namespace_test/NamespaceA/TableInFirstNS.lua

Documentation: github.com/google/flatbuffers/tests/namespace_test/NamespaceA

     1-- automatically generated by the FlatBuffers compiler, do not modify
     2
     3-- namespace: NamespaceA
     4
     5local flatbuffers = require('flatbuffers')
     6
     7local TableInFirstNS = {} -- the module
     8local TableInFirstNS_mt = {} -- the class metatable
     9
    10function TableInFirstNS.New()
    11    local o = {}
    12    setmetatable(o, {__index = TableInFirstNS_mt})
    13    return o
    14end
    15function TableInFirstNS.GetRootAsTableInFirstNS(buf, offset)
    16    if type(buf) == "string" then
    17        buf = flatbuffers.binaryArray.New(buf)
    18    end
    19    local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
    20    local o = TableInFirstNS.New()
    21    o:Init(buf, n + offset)
    22    return o
    23end
    24function TableInFirstNS_mt:Init(buf, pos)
    25    self.view = flatbuffers.view.New(buf, pos)
    26end
    27function TableInFirstNS_mt:FooTable()
    28    local o = self.view:Offset(4)
    29    if o ~= 0 then
    30        local x = self.view:Indirect(o + self.view.pos)
    31        local obj = require('NamespaceA.NamespaceB.TableInNestedNS').New()
    32        obj:Init(self.view.bytes, x)
    33        return obj
    34    end
    35end
    36function TableInFirstNS_mt:FooEnum()
    37    local o = self.view:Offset(6)
    38    if o ~= 0 then
    39        return self.view:Get(flatbuffers.N.Int8, o + self.view.pos)
    40    end
    41    return 0
    42end
    43function TableInFirstNS_mt:FooUnionType()
    44    local o = self.view:Offset(8)
    45    if o ~= 0 then
    46        return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
    47    end
    48    return 0
    49end
    50function TableInFirstNS_mt:FooUnion()
    51    local o = self.view:Offset(10)
    52    if o ~= 0 then
    53        local obj = flatbuffers.view.New(require('flatbuffers.binaryarray').New(0), 0)
    54        self.view:Union(obj, o)
    55        return obj
    56    end
    57end
    58function TableInFirstNS_mt:FooStruct()
    59    local o = self.view:Offset(12)
    60    if o ~= 0 then
    61        local x = o + self.view.pos
    62        local obj = require('NamespaceA.NamespaceB.StructInNestedNS').New()
    63        obj:Init(self.view.bytes, x)
    64        return obj
    65    end
    66end
    67function TableInFirstNS.Start(builder) builder:StartObject(5) end
    68function TableInFirstNS.AddFooTable(builder, fooTable) builder:PrependUOffsetTRelativeSlot(0, fooTable, 0) end
    69function TableInFirstNS.AddFooEnum(builder, fooEnum) builder:PrependInt8Slot(1, fooEnum, 0) end
    70function TableInFirstNS.AddFooUnionType(builder, fooUnionType) builder:PrependUint8Slot(2, fooUnionType, 0) end
    71function TableInFirstNS.AddFooUnion(builder, fooUnion) builder:PrependUOffsetTRelativeSlot(3, fooUnion, 0) end
    72function TableInFirstNS.AddFooStruct(builder, fooStruct) builder:PrependStructSlot(4, fooStruct, 0) end
    73function TableInFirstNS.End(builder) return builder:EndObject() end
    74
    75return TableInFirstNS -- return the module

View as plain text