1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
--[[ Universe
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 23.5.26
Declared by : //basic.fbs
Rooting type : Universe (//basic.fbs)
--]]
local __Galaxy = require('Galaxy')
local flatbuffers = require('flatbuffers')
local Universe = {}
local mt = {}
function Universe.New()
local o = {}
setmetatable(o, {__index = mt})
return o
end
function Universe.GetRootAsUniverse(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Universe.New()
o:Init(buf, n + offset)
return o
end
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:Age()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Float64, self.view.pos + o)
end
return 0.0
end
function mt:Galaxies(j)
local o = self.view:Offset(6)
if o ~= 0 then
local x = self.view:Vector(o)
x = x + ((j-1) * 4)
x = self.view:Indirect(x)
local obj = __Galaxy.New()
obj:Init(self.view.bytes, x)
return obj
end
end
function mt:GalaxiesLength()
local o = self.view:Offset(6)
if o ~= 0 then
return self.view:VectorLen(o)
end
return 0
end
function Universe.Start(builder)
builder:StartObject(2)
end
function Universe.AddAge(builder, age)
builder:PrependFloat64Slot(0, age, 0.0)
end
function Universe.AddGalaxies(builder, galaxies)
builder:PrependUOffsetTRelativeSlot(1, galaxies, 0)
end
function Universe.StartGalaxiesVector(builder, numElems)
return builder:StartVector(4, numElems, 4)
end
function Universe.End(builder)
return builder:EndObject()
end
return Universe
|