xref: /aosp_15_r20/external/flatbuffers/tests/MyGame/Example/StructOfStructs.lua (revision 890232f25432b36107d06881e0a25aaa6b473652)
1--[[ MyGame.Example.StructOfStructs
2
3  Automatically generated by the FlatBuffers compiler, do not modify.
4  Or modify. I'm a message, not a cop.
5
6  flatc version: 2.0.7
7
8  Declared by  : //monster_test.fbs
9  Rooting type : MyGame.Example.Monster (//monster_test.fbs)
10
11--]]
12
13local flatbuffers = require('flatbuffers')
14
15local StructOfStructs = {}
16local mt = {}
17
18function StructOfStructs.New()
19  local o = {}
20  setmetatable(o, {__index = mt})
21  return o
22end
23
24function mt:Init(buf, pos)
25  self.view = flatbuffers.view.New(buf, pos)
26end
27
28function mt:A(obj)
29  obj:Init(self.view.bytes, self.view.pos + 0)
30  return obj
31end
32
33function mt:B(obj)
34  obj:Init(self.view.bytes, self.view.pos + 8)
35  return obj
36end
37
38function mt:C(obj)
39  obj:Init(self.view.bytes, self.view.pos + 12)
40  return obj
41end
42
43function StructOfStructs.CreateStructOfStructs(builder, a_id, a_distance, b_a, b_b, c_id, c_distance)
44  builder:Prep(4, 20)
45  builder:Prep(4, 8)
46  builder:PrependUint32(c_distance)
47  builder:PrependUint32(c_id)
48  builder:Prep(2, 4)
49  builder:Pad(1)
50  builder:PrependInt8(b_b)
51  builder:PrependInt16(b_a)
52  builder:Prep(4, 8)
53  builder:PrependUint32(a_distance)
54  builder:PrependUint32(a_id)
55  return builder:Offset()
56end
57
58return StructOfStructs