mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 12:43:24 +00:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user