Lua Generator using IR. (#6940)

* initial hack to get new Lua generator into flatc

* Starting to output enum defs for Lua

* Continue to work on table generation for Lua

* Finished basic getter access for Lua

* Added ability to get object by index

* Finished struct builder

* aliased reflection to r

* finish table builder generation

* register requiring files

* better generated header info

* Tying up loose ends

* Updated reflection to handle struct padding

* Addd type sizes to reflection

* Fixed some vector indirect issues

* Lua tests passed

* Misc cleanup

* ci fixes 1

* ci fixes 2

* renaming

* up size of type sizes

* manually ran clang-format-11 -i src/idl_parser.cpp

* fixed some windows casting

* remove stupid auto import

* more static_casting

* remove std

* update other build environments

* remove scoped enums

* replaced std::to_string with NumToString

* more win fixes

* more win fixes

* replaced old lua with new

* removed auto import

* review responses

* more style fixes

* refactor bfbs_gen_len to use code +=

* added consts

* fix lambda capture for windows

* remove unused return type
This commit is contained in:
Derek Bailey
2021-12-02 21:29:19 -08:00
committed by GitHub
parent cffe0c4546
commit 061d61f3f8
43 changed files with 3461 additions and 1725 deletions

View File

@@ -1,31 +1,43 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Ability
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local Ability = {} -- the module
local Ability_mt = {} -- the class metatable
local Ability = {}
local mt = {}
function Ability.New()
local o = {}
setmetatable(o, {__index = Ability_mt})
return o
end
function Ability_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function Ability_mt:Id()
return self.view:Get(flatbuffers.N.Uint32, self.view.pos + 0)
end
function Ability_mt:Distance()
return self.view:Get(flatbuffers.N.Uint32, self.view.pos + 4)
end
function Ability.CreateAbility(builder, id, distance)
builder:Prep(4, 8)
builder:PrependUint32(distance)
builder:PrependUint32(id)
return builder:Offset()
local o = {}
setmetatable(o, {__index = mt})
return o
end
return Ability -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:Id()
return self.view:Get(flatbuffers.N.Uint32, self.view.pos + 0)
end
function mt:Distance()
return self.view:Get(flatbuffers.N.Uint32, self.view.pos + 4)
end
function Ability.CreateAbility(builder, id, distance)
builder:Prep(4, 8)
builder:PrependUint32(distance)
builder:PrependUint32(id)
return builder:Offset()
end
return Ability

View File

@@ -1,12 +1,20 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Any
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local Any = {
NONE = 0,
Monster = 1,
TestSimpleTableWithEnum = 2,
MyGame_Example2_Monster = 3,
NONE = 0,
Monster = 1,
TestSimpleTableWithEnum = 2,
MyGame_Example2_Monster = 3,
}
return Any -- return the module
return Any

View File

@@ -1,12 +1,20 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.AnyAmbiguousAliases
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local AnyAmbiguousAliases = {
NONE = 0,
M1 = 1,
M2 = 2,
M3 = 3,
NONE = 0,
M1 = 1,
M2 = 2,
M3 = 3,
}
return AnyAmbiguousAliases -- return the module
return AnyAmbiguousAliases

View File

@@ -1,12 +1,20 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.AnyUniqueAliases
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local AnyUniqueAliases = {
NONE = 0,
M = 1,
TS = 2,
M2 = 3,
NONE = 0,
M = 1,
TS = 2,
M2 = 3,
}
return AnyUniqueAliases -- return the module
return AnyUniqueAliases

View File

@@ -1,15 +1,23 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Color
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
-- Composite components of Monster color.
local Color = {
Red = 1,
-- \brief color Green
-- Green is bit_flag with value (1u << 1)
Green = 2,
-- \brief color Blue (1u << 3)
Blue = 8,
Red = 1,
-- \brief color Green
-- Green is bit_flag with value (1u << 1)
Green = 2,
-- \brief color Blue (1u << 3)
Blue = 8,
}
return Color -- return the module
return Color

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,20 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Race
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local Race = {
None = -1,
Human = 0,
Dwarf = 1,
Elf = 2,
None = -1,
Human = 0,
Dwarf = 1,
Elf = 2,
}
return Race -- return the module
return Race

View File

@@ -1,38 +1,48 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Referrable
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local Referrable = {} -- the module
local Referrable_mt = {} -- the class metatable
local Referrable = {}
local mt = {}
function Referrable.New()
local o = {}
setmetatable(o, {__index = Referrable_mt})
return o
local o = {}
setmetatable(o, {__index = mt})
return o
end
function Referrable.GetRootAsReferrable(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Referrable.New()
o:Init(buf, n + offset)
return o
end
function Referrable_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function Referrable_mt:Id()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint64, o + self.view.pos)
end
return 0
end
function Referrable.Start(builder) builder:StartObject(1) end
function Referrable.AddId(builder, id) builder:PrependUint64Slot(0, id, 0) end
function Referrable.End(builder) return builder:EndObject() end
return Referrable -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:Id()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint64, self.view.pos + o)
end
return 0
end
function Referrable.Start(builder)
builder:StartObject(1)
end
function Referrable.AddId(builder, id)
builder:PrependUint64Slot(0, id, 0)
end
function Referrable.End(builder)
return builder:EndObject()
end
return Referrable

View File

@@ -1,53 +1,71 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Stat
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local Stat = {} -- the module
local Stat_mt = {} -- the class metatable
local Stat = {}
local mt = {}
function Stat.New()
local o = {}
setmetatable(o, {__index = Stat_mt})
return o
local o = {}
setmetatable(o, {__index = mt})
return o
end
function Stat.GetRootAsStat(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = Stat.New()
o:Init(buf, n + offset)
return o
end
function Stat_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function Stat_mt:Id()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:String(o + self.view.pos)
end
end
function Stat_mt:Val()
local o = self.view:Offset(6)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int64, o + self.view.pos)
end
return 0
end
function Stat_mt:Count()
local o = self.view:Offset(8)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint16, o + self.view.pos)
end
return 0
end
function Stat.Start(builder) builder:StartObject(3) end
function Stat.AddId(builder, id) builder:PrependUOffsetTRelativeSlot(0, id, 0) end
function Stat.AddVal(builder, val) builder:PrependInt64Slot(1, val, 0) end
function Stat.AddCount(builder, count) builder:PrependUint16Slot(2, count, 0) end
function Stat.End(builder) return builder:EndObject() end
return Stat -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:Id()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:String(self.view.pos + o)
end
end
function mt:Val()
local o = self.view:Offset(6)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int64, self.view.pos + o)
end
return 0
end
function mt:Count()
local o = self.view:Offset(8)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint16, self.view.pos + o)
end
return 0
end
function Stat.Start(builder)
builder:StartObject(3)
end
function Stat.AddId(builder, id)
builder:PrependUOffsetTRelativeSlot(0, id, 0)
end
function Stat.AddVal(builder, val)
builder:PrependInt64Slot(1, val, 0)
end
function Stat.AddCount(builder, count)
builder:PrependUint16Slot(2, count, 0)
end
function Stat.End(builder)
return builder:EndObject()
end
return Stat

View File

@@ -1,45 +1,58 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.StructOfStructs
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local StructOfStructs = {} -- the module
local StructOfStructs_mt = {} -- the class metatable
local StructOfStructs = {}
local mt = {}
function StructOfStructs.New()
local o = {}
setmetatable(o, {__index = StructOfStructs_mt})
return o
end
function StructOfStructs_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function StructOfStructs_mt:A(obj)
obj:Init(self.view.bytes, self.view.pos + 0)
return obj
end
function StructOfStructs_mt:B(obj)
obj:Init(self.view.bytes, self.view.pos + 8)
return obj
end
function StructOfStructs_mt:C(obj)
obj:Init(self.view.bytes, self.view.pos + 12)
return obj
end
function StructOfStructs.CreateStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance)
builder:Prep(4, 20)
builder:Prep(4, 8)
builder:PrependUint32(c_distance)
builder:PrependUint32(c_id)
builder:Prep(2, 4)
builder:Pad(1)
builder:PrependInt8(b_b)
builder:PrependInt16(b_a)
builder:Prep(4, 8)
builder:PrependUint32(a_distance)
builder:PrependUint32(a_id)
return builder:Offset()
local o = {}
setmetatable(o, {__index = mt})
return o
end
return StructOfStructs -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:A(obj)
obj:Init(self.view.bytes, self.view.pos + 0)
return obj
end
function mt:B(obj)
obj:Init(self.view.bytes, self.view.pos + 8)
return obj
end
function mt:C(obj)
obj:Init(self.view.bytes, self.view.pos + 12)
return obj
end
function StructOfStructs.CreateStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance)
builder:Prep(4, 20)
builder:Prep(4, 8)
builder:PrependUint32(c_distance)
builder:PrependUint32(c_id)
builder:Prep(2, 4)
builder:Pad(1)
builder:PrependInt8(b_b)
builder:PrependInt16(b_a)
builder:Prep(4, 8)
builder:PrependUint32(a_distance)
builder:PrependUint32(a_id)
return builder:Offset()
end
return StructOfStructs

View File

@@ -1,32 +1,44 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Test
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local Test = {} -- the module
local Test_mt = {} -- the class metatable
local Test = {}
local mt = {}
function Test.New()
local o = {}
setmetatable(o, {__index = Test_mt})
return o
end
function Test_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function Test_mt:A()
return self.view:Get(flatbuffers.N.Int16, self.view.pos + 0)
end
function Test_mt:B()
return self.view:Get(flatbuffers.N.Int8, self.view.pos + 2)
end
function Test.CreateTest(builder, a, b)
builder:Prep(2, 4)
builder:Pad(1)
builder:PrependInt8(b)
builder:PrependInt16(a)
return builder:Offset()
local o = {}
setmetatable(o, {__index = mt})
return o
end
return Test -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:A()
return self.view:Get(flatbuffers.N.Int16, self.view.pos + 0)
end
function mt:B()
return self.view:Get(flatbuffers.N.Int8, self.view.pos + 2)
end
function Test.CreateTest(builder, a, b)
builder:Prep(2, 4)
builder:Pad(1)
builder:PrependInt8(b)
builder:PrependInt16(a)
return builder:Offset()
end
return Test

View File

@@ -1,38 +1,48 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.TestSimpleTableWithEnum
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local TestSimpleTableWithEnum = {} -- the module
local TestSimpleTableWithEnum_mt = {} -- the class metatable
local TestSimpleTableWithEnum = {}
local mt = {}
function TestSimpleTableWithEnum.New()
local o = {}
setmetatable(o, {__index = TestSimpleTableWithEnum_mt})
return o
local o = {}
setmetatable(o, {__index = mt})
return o
end
function TestSimpleTableWithEnum.GetRootAsTestSimpleTableWithEnum(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = TestSimpleTableWithEnum.New()
o:Init(buf, n + offset)
return o
end
function TestSimpleTableWithEnum_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function TestSimpleTableWithEnum_mt:Color()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
end
return 2
end
function TestSimpleTableWithEnum.Start(builder) builder:StartObject(1) end
function TestSimpleTableWithEnum.AddColor(builder, color) builder:PrependUint8Slot(0, color, 2) end
function TestSimpleTableWithEnum.End(builder) return builder:EndObject() end
return TestSimpleTableWithEnum -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:Color()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint8, self.view.pos + o)
end
return 2
end
function TestSimpleTableWithEnum.Start(builder)
builder:StartObject(1)
end
function TestSimpleTableWithEnum.AddColor(builder, color)
builder:PrependUint8Slot(0, color, 2)
end
function TestSimpleTableWithEnum.End(builder)
return builder:EndObject()
end
return TestSimpleTableWithEnum

View File

@@ -1,147 +1,210 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.TypeAliases
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local TypeAliases = {} -- the module
local TypeAliases_mt = {} -- the class metatable
local TypeAliases = {}
local mt = {}
function TypeAliases.New()
local o = {}
setmetatable(o, {__index = TypeAliases_mt})
return o
local o = {}
setmetatable(o, {__index = mt})
return o
end
function TypeAliases.GetRootAsTypeAliases(buf, offset)
if type(buf) == "string" then
buf = flatbuffers.binaryArray.New(buf)
end
local n = flatbuffers.N.UOffsetT:Unpack(buf, offset)
local o = TypeAliases.New()
o:Init(buf, n + offset)
return o
end
function TypeAliases_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function TypeAliases_mt:I8()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int8, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:U8()
local o = self.view:Offset(6)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint8, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:I16()
local o = self.view:Offset(8)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int16, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:U16()
local o = self.view:Offset(10)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint16, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:I32()
local o = self.view:Offset(12)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int32, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:U32()
local o = self.view:Offset(14)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint32, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:I64()
local o = self.view:Offset(16)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int64, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:U64()
local o = self.view:Offset(18)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint64, o + self.view.pos)
end
return 0
end
function TypeAliases_mt:F32()
local o = self.view:Offset(20)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Float32, o + self.view.pos)
end
return 0.0
end
function TypeAliases_mt:F64()
local o = self.view:Offset(22)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Float64, o + self.view.pos)
end
return 0.0
end
function TypeAliases_mt:V8(j)
local o = self.view:Offset(24)
if o ~= 0 then
local a = self.view:Vector(o)
return self.view:Get(flatbuffers.N.Int8, a + ((j-1) * 1))
end
return 0
end
function TypeAliases_mt:V8AsString(start, stop)
return self.view:VectorAsString(24, start, stop)
end
function TypeAliases_mt:V8Length()
local o = self.view:Offset(24)
if o ~= 0 then
return self.view:VectorLen(o)
end
return 0
end
function TypeAliases_mt:Vf64(j)
local o = self.view:Offset(26)
if o ~= 0 then
local a = self.view:Vector(o)
return self.view:Get(flatbuffers.N.Float64, a + ((j-1) * 8))
end
return 0
end
function TypeAliases_mt:Vf64Length()
local o = self.view:Offset(26)
if o ~= 0 then
return self.view:VectorLen(o)
end
return 0
end
function TypeAliases.Start(builder) builder:StartObject(12) end
function TypeAliases.AddI8(builder, i8) builder:PrependInt8Slot(0, i8, 0) end
function TypeAliases.AddU8(builder, u8) builder:PrependUint8Slot(1, u8, 0) end
function TypeAliases.AddI16(builder, i16) builder:PrependInt16Slot(2, i16, 0) end
function TypeAliases.AddU16(builder, u16) builder:PrependUint16Slot(3, u16, 0) end
function TypeAliases.AddI32(builder, i32) builder:PrependInt32Slot(4, i32, 0) end
function TypeAliases.AddU32(builder, u32) builder:PrependUint32Slot(5, u32, 0) end
function TypeAliases.AddI64(builder, i64) builder:PrependInt64Slot(6, i64, 0) end
function TypeAliases.AddU64(builder, u64) builder:PrependUint64Slot(7, u64, 0) end
function TypeAliases.AddF32(builder, f32) builder:PrependFloat32Slot(8, f32, 0.0) end
function TypeAliases.AddF64(builder, f64) builder:PrependFloat64Slot(9, f64, 0.0) end
function TypeAliases.AddV8(builder, v8) builder:PrependUOffsetTRelativeSlot(10, v8, 0) end
function TypeAliases.StartV8Vector(builder, numElems) return builder:StartVector(1, numElems, 1) end
function TypeAliases.AddVf64(builder, vf64) builder:PrependUOffsetTRelativeSlot(11, vf64, 0) end
function TypeAliases.StartVf64Vector(builder, numElems) return builder:StartVector(8, numElems, 8) end
function TypeAliases.End(builder) return builder:EndObject() end
return TypeAliases -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:I8()
local o = self.view:Offset(4)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int8, self.view.pos + o)
end
return 0
end
function mt:U8()
local o = self.view:Offset(6)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint8, self.view.pos + o)
end
return 0
end
function mt:I16()
local o = self.view:Offset(8)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int16, self.view.pos + o)
end
return 0
end
function mt:U16()
local o = self.view:Offset(10)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint16, self.view.pos + o)
end
return 0
end
function mt:I32()
local o = self.view:Offset(12)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int32, self.view.pos + o)
end
return 0
end
function mt:U32()
local o = self.view:Offset(14)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint32, self.view.pos + o)
end
return 0
end
function mt:I64()
local o = self.view:Offset(16)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Int64, self.view.pos + o)
end
return 0
end
function mt:U64()
local o = self.view:Offset(18)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Uint64, self.view.pos + o)
end
return 0
end
function mt:F32()
local o = self.view:Offset(20)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Float32, self.view.pos + o)
end
return 0.0
end
function mt:F64()
local o = self.view:Offset(22)
if o ~= 0 then
return self.view:Get(flatbuffers.N.Float64, self.view.pos + o)
end
return 0.0
end
function mt:V8(j)
local o = self.view:Offset(24)
if o ~= 0 then
local a = self.view:Vector(o)
return self.view:Get(flatbuffers.N.Int8, a + ((j-1) * 1))
end
return 0
end
function mt:V8AsString(start, stop)
return self.view:VectorAsString(24, start, stop)
end
function mt:V8Length()
local o = self.view:Offset(24)
if o ~= 0 then
return self.view:VectorLen(o)
end
return 0
end
function mt:Vf64(j)
local o = self.view:Offset(26)
if o ~= 0 then
local a = self.view:Vector(o)
return self.view:Get(flatbuffers.N.Float64, a + ((j-1) * 8))
end
return 0
end
function mt:Vf64Length()
local o = self.view:Offset(26)
if o ~= 0 then
return self.view:VectorLen(o)
end
return 0
end
function TypeAliases.Start(builder)
builder:StartObject(12)
end
function TypeAliases.AddI8(builder, i8)
builder:PrependInt8Slot(0, i8, 0)
end
function TypeAliases.AddU8(builder, u8)
builder:PrependUint8Slot(1, u8, 0)
end
function TypeAliases.AddI16(builder, i16)
builder:PrependInt16Slot(2, i16, 0)
end
function TypeAliases.AddU16(builder, u16)
builder:PrependUint16Slot(3, u16, 0)
end
function TypeAliases.AddI32(builder, i32)
builder:PrependInt32Slot(4, i32, 0)
end
function TypeAliases.AddU32(builder, u32)
builder:PrependUint32Slot(5, u32, 0)
end
function TypeAliases.AddI64(builder, i64)
builder:PrependInt64Slot(6, i64, 0)
end
function TypeAliases.AddU64(builder, u64)
builder:PrependUint64Slot(7, u64, 0)
end
function TypeAliases.AddF32(builder, f32)
builder:PrependFloat32Slot(8, f32, 0.0)
end
function TypeAliases.AddF64(builder, f64)
builder:PrependFloat64Slot(9, f64, 0.0)
end
function TypeAliases.AddV8(builder, v8)
builder:PrependUOffsetTRelativeSlot(10, v8, 0)
end
function TypeAliases.StartV8Vector(builder, numElems)
return builder:StartVector(1, numElems, 1)
end
function TypeAliases.AddVf64(builder, vf64)
builder:PrependUOffsetTRelativeSlot(11, vf64, 0)
end
function TypeAliases.StartVf64Vector(builder, numElems)
return builder:StartVector(8, numElems, 8)
end
function TypeAliases.End(builder)
return builder:EndObject()
end
return TypeAliases

View File

@@ -1,54 +1,70 @@
-- automatically generated by the FlatBuffers compiler, do not modify
--[[ MyGame.Example.Vec3
-- namespace: Example
Automatically generated by the FlatBuffers compiler, do not modify.
Or modify. I'm a message, not a cop.
flatc version: 2.0.0
Declared by : //monster_test.fbs
Rooting type : MyGame.Example.Monster (//monster_test.fbs)
--]]
local flatbuffers = require('flatbuffers')
local Vec3 = {} -- the module
local Vec3_mt = {} -- the class metatable
local Vec3 = {}
local mt = {}
function Vec3.New()
local o = {}
setmetatable(o, {__index = Vec3_mt})
return o
end
function Vec3_mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function Vec3_mt:X()
return self.view:Get(flatbuffers.N.Float32, self.view.pos + 0)
end
function Vec3_mt:Y()
return self.view:Get(flatbuffers.N.Float32, self.view.pos + 4)
end
function Vec3_mt:Z()
return self.view:Get(flatbuffers.N.Float32, self.view.pos + 8)
end
function Vec3_mt:Test1()
return self.view:Get(flatbuffers.N.Float64, self.view.pos + 16)
end
function Vec3_mt:Test2()
return self.view:Get(flatbuffers.N.Uint8, self.view.pos + 24)
end
function Vec3_mt:Test3(obj)
obj:Init(self.view.bytes, self.view.pos + 26)
return obj
end
function Vec3.CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b)
builder:Prep(8, 32)
builder:Pad(2)
builder:Prep(2, 4)
builder:Pad(1)
builder:PrependInt8(test3_b)
builder:PrependInt16(test3_a)
builder:Pad(1)
builder:PrependUint8(test2)
builder:PrependFloat64(test1)
builder:Pad(4)
builder:PrependFloat32(z)
builder:PrependFloat32(y)
builder:PrependFloat32(x)
return builder:Offset()
local o = {}
setmetatable(o, {__index = mt})
return o
end
return Vec3 -- return the module
function mt:Init(buf, pos)
self.view = flatbuffers.view.New(buf, pos)
end
function mt:X()
return self.view:Get(flatbuffers.N.Float32, self.view.pos + 0)
end
function mt:Y()
return self.view:Get(flatbuffers.N.Float32, self.view.pos + 4)
end
function mt:Z()
return self.view:Get(flatbuffers.N.Float32, self.view.pos + 8)
end
function mt:Test1()
return self.view:Get(flatbuffers.N.Float64, self.view.pos + 16)
end
function mt:Test2()
return self.view:Get(flatbuffers.N.Uint8, self.view.pos + 24)
end
function mt:Test3(obj)
obj:Init(self.view.bytes, self.view.pos + 26)
return obj
end
function Vec3.CreateVec3(builder, x, y, z, test1, test2, test3_a, test3_b)
builder:Prep(8, 32)
builder:Pad(2)
builder:Prep(2, 4)
builder:Pad(1)
builder:PrependInt8(test3_b)
builder:PrependInt16(test3_a)
builder:Pad(1)
builder:PrependUint8(test2)
builder:PrependFloat64(test1)
builder:Pad(4)
builder:PrependFloat32(z)
builder:PrependFloat32(y)
builder:PrependFloat32(x)
return builder:Offset()
end
return Vec3