forked from google/flatbuffers
/
monster_test_generated.swift
2559 lines (2322 loc) · 135 KB
/
monster_test_generated.swift
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// automatically generated by the FlatBuffers compiler, do not modify
// swiftlint:disable all
// swiftformat:disable all
import FlatBuffers
/// Composite components of Monster color.
public enum MyGame_Example_Color: UInt8, Enum, Verifiable {
public typealias T = UInt8
public static var byteSize: Int { return MemoryLayout<UInt8>.size }
public var value: UInt8 { return self.rawValue }
case red = 1
/// \brief color Green
/// Green is bit_flag with value (1u << 1)
case green = 2
/// \brief color Blue (1u << 3)
case blue = 8
public static var max: MyGame_Example_Color { return .blue }
public static var min: MyGame_Example_Color { return .red }
}
extension MyGame_Example_Color: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .red: try container.encode("Red")
case .green: try container.encode("Green")
case .blue: try container.encode("Blue")
}
}
}
public enum MyGame_Example_Race: Int8, Enum, Verifiable {
public typealias T = Int8
public static var byteSize: Int { return MemoryLayout<Int8>.size }
public var value: Int8 { return self.rawValue }
case none_ = -1
case human = 0
case dwarf = 1
case elf = 2
public static var max: MyGame_Example_Race { return .elf }
public static var min: MyGame_Example_Race { return .none_ }
}
extension MyGame_Example_Race: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .none_: try container.encode("None")
case .human: try container.encode("Human")
case .dwarf: try container.encode("Dwarf")
case .elf: try container.encode("Elf")
}
}
}
public enum MyGame_Example_LongEnum: UInt64, Enum, Verifiable {
public typealias T = UInt64
public static var byteSize: Int { return MemoryLayout<UInt64>.size }
public var value: UInt64 { return self.rawValue }
case longone = 2
case longtwo = 4
case longbig = 1099511627776
public static var max: MyGame_Example_LongEnum { return .longbig }
public static var min: MyGame_Example_LongEnum { return .longone }
}
extension MyGame_Example_LongEnum: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .longone: try container.encode("LongOne")
case .longtwo: try container.encode("LongTwo")
case .longbig: try container.encode("LongBig")
}
}
}
public enum MyGame_Example_Any_: UInt8, UnionEnum {
public typealias T = UInt8
public init?(value: T) {
self.init(rawValue: value)
}
public static var byteSize: Int { return MemoryLayout<UInt8>.size }
public var value: UInt8 { return self.rawValue }
case none_ = 0
case monster = 1
case testsimpletablewithenum = 2
case mygameExample2Monster = 3
public static var max: MyGame_Example_Any_ { return .mygameExample2Monster }
public static var min: MyGame_Example_Any_ { return .none_ }
}
extension MyGame_Example_Any_: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .none_: try container.encode("NONE")
case .monster: try container.encode("Monster")
case .testsimpletablewithenum: try container.encode("TestSimpleTableWithEnum")
case .mygameExample2Monster: try container.encode("MyGame_Example2_Monster")
}
}
}
public struct MyGame_Example_Any_Union {
public var type: MyGame_Example_Any_
public var value: NativeObject?
public init(_ v: NativeObject?, type: MyGame_Example_Any_) {
self.type = type
self.value = v
}
public func pack(builder: inout FlatBufferBuilder) -> Offset {
switch type {
case .monster:
var __obj = value as? MyGame_Example_MonsterT
return MyGame_Example_Monster.pack(&builder, obj: &__obj)
case .testsimpletablewithenum:
var __obj = value as? MyGame_Example_TestSimpleTableWithEnumT
return MyGame_Example_TestSimpleTableWithEnum.pack(&builder, obj: &__obj)
case .mygameExample2Monster:
var __obj = value as? MyGame_Example2_MonsterT
return MyGame_Example2_Monster.pack(&builder, obj: &__obj)
default: return Offset()
}
}
}
public enum MyGame_Example_AnyUniqueAliases: UInt8, UnionEnum {
public typealias T = UInt8
public init?(value: T) {
self.init(rawValue: value)
}
public static var byteSize: Int { return MemoryLayout<UInt8>.size }
public var value: UInt8 { return self.rawValue }
case none_ = 0
case m = 1
case ts = 2
case m2 = 3
public static var max: MyGame_Example_AnyUniqueAliases { return .m2 }
public static var min: MyGame_Example_AnyUniqueAliases { return .none_ }
}
extension MyGame_Example_AnyUniqueAliases: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .none_: try container.encode("NONE")
case .m: try container.encode("M")
case .ts: try container.encode("TS")
case .m2: try container.encode("M2")
}
}
}
public struct MyGame_Example_AnyUniqueAliasesUnion {
public var type: MyGame_Example_AnyUniqueAliases
public var value: NativeObject?
public init(_ v: NativeObject?, type: MyGame_Example_AnyUniqueAliases) {
self.type = type
self.value = v
}
public func pack(builder: inout FlatBufferBuilder) -> Offset {
switch type {
case .m:
var __obj = value as? MyGame_Example_MonsterT
return MyGame_Example_Monster.pack(&builder, obj: &__obj)
case .ts:
var __obj = value as? MyGame_Example_TestSimpleTableWithEnumT
return MyGame_Example_TestSimpleTableWithEnum.pack(&builder, obj: &__obj)
case .m2:
var __obj = value as? MyGame_Example2_MonsterT
return MyGame_Example2_Monster.pack(&builder, obj: &__obj)
default: return Offset()
}
}
}
public enum MyGame_Example_AnyAmbiguousAliases: UInt8, UnionEnum {
public typealias T = UInt8
public init?(value: T) {
self.init(rawValue: value)
}
public static var byteSize: Int { return MemoryLayout<UInt8>.size }
public var value: UInt8 { return self.rawValue }
case none_ = 0
case m1 = 1
case m2 = 2
case m3 = 3
public static var max: MyGame_Example_AnyAmbiguousAliases { return .m3 }
public static var min: MyGame_Example_AnyAmbiguousAliases { return .none_ }
}
extension MyGame_Example_AnyAmbiguousAliases: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case .none_: try container.encode("NONE")
case .m1: try container.encode("M1")
case .m2: try container.encode("M2")
case .m3: try container.encode("M3")
}
}
}
public struct MyGame_Example_AnyAmbiguousAliasesUnion {
public var type: MyGame_Example_AnyAmbiguousAliases
public var value: NativeObject?
public init(_ v: NativeObject?, type: MyGame_Example_AnyAmbiguousAliases) {
self.type = type
self.value = v
}
public func pack(builder: inout FlatBufferBuilder) -> Offset {
switch type {
case .m1:
var __obj = value as? MyGame_Example_MonsterT
return MyGame_Example_Monster.pack(&builder, obj: &__obj)
case .m2:
var __obj = value as? MyGame_Example_MonsterT
return MyGame_Example_Monster.pack(&builder, obj: &__obj)
case .m3:
var __obj = value as? MyGame_Example_MonsterT
return MyGame_Example_Monster.pack(&builder, obj: &__obj)
default: return Offset()
}
}
}
public struct MyGame_Example_Test: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: Int16
private var _b: Int8
private let padding0__: UInt8 = 0
public init(_ bb: ByteBuffer, o: Int32) {
let _accessor = Struct(bb: bb, position: o)
_a = _accessor.readBuffer(of: Int16.self, at: 0)
_b = _accessor.readBuffer(of: Int8.self, at: 2)
}
public init(a: Int16, b: Int8) {
_a = a
_b = b
}
public init() {
_a = 0
_b = 0
}
public init(_ _t: inout MyGame_Example_Test_Mutable) {
_a = _t.a
_b = _t.b
}
public var a: Int16 { _a }
public var b: Int8 { _b }
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
try verifier.inBuffer(position: position, of: MyGame_Example_Test.self)
}
}
extension MyGame_Example_Test: Encodable {
enum CodingKeys: String, CodingKey {
case a = "a"
case b = "b"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
if a != 0 {
try container.encodeIfPresent(a, forKey: .a)
}
if b != 0 {
try container.encodeIfPresent(b, forKey: .b)
}
}
}
public struct MyGame_Example_Test_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
public var a: Int16 { return _accessor.readBuffer(of: Int16.self, at: 0) }
@discardableResult public func mutate(a: Int16) -> Bool { return _accessor.mutate(a, index: 0) }
public var b: Int8 { return _accessor.readBuffer(of: Int8.self, at: 2) }
@discardableResult public func mutate(b: Int8) -> Bool { return _accessor.mutate(b, index: 2) }
public mutating func unpack() -> MyGame_Example_Test {
return MyGame_Example_Test(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_Test?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_Test) -> Offset {
return builder.create(struct: obj)
}
}
public struct MyGame_Example_Vec3: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _x: Float32
private var _y: Float32
private var _z: Float32
private let padding0__: UInt32 = 0
private var _test1: Double
private var _test2: UInt8
private let padding1__: UInt8 = 0
private var _test3: MyGame_Example_Test
private let padding2__: UInt16 = 0
public init(_ bb: ByteBuffer, o: Int32) {
let _accessor = Struct(bb: bb, position: o)
_x = _accessor.readBuffer(of: Float32.self, at: 0)
_y = _accessor.readBuffer(of: Float32.self, at: 4)
_z = _accessor.readBuffer(of: Float32.self, at: 8)
_test1 = _accessor.readBuffer(of: Double.self, at: 16)
_test2 = _accessor.readBuffer(of: UInt8.self, at: 24)
_test3 = MyGame_Example_Test(_accessor.bb, o: _accessor.postion + 26)
}
public init(x: Float32, y: Float32, z: Float32, test1: Double, test2: MyGame_Example_Color, test3: MyGame_Example_Test) {
_x = x
_y = y
_z = z
_test1 = test1
_test2 = test2.value
_test3 = test3
}
public init() {
_x = 0.0
_y = 0.0
_z = 0.0
_test1 = 0.0
_test2 = 0
_test3 = MyGame_Example_Test()
}
public init(_ _t: inout MyGame_Example_Vec3_Mutable) {
_x = _t.x
_y = _t.y
_z = _t.z
_test1 = _t.test1
_test2 = _t.test2.value
var _vtest3 = _t.test3
_test3 = _vtest3.unpack()
}
public var x: Float32 { _x }
public var y: Float32 { _y }
public var z: Float32 { _z }
public var test1: Double { _test1 }
public var test2: MyGame_Example_Color { MyGame_Example_Color(rawValue: _test2)! }
public var test3: MyGame_Example_Test { _test3 }
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
try verifier.inBuffer(position: position, of: MyGame_Example_Vec3.self)
}
}
extension MyGame_Example_Vec3: Encodable {
enum CodingKeys: String, CodingKey {
case x = "x"
case y = "y"
case z = "z"
case test1 = "test1"
case test2 = "test2"
case test3 = "test3"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
if x != 0.0 {
try container.encodeIfPresent(x, forKey: .x)
}
if y != 0.0 {
try container.encodeIfPresent(y, forKey: .y)
}
if z != 0.0 {
try container.encodeIfPresent(z, forKey: .z)
}
if test1 != 0.0 {
try container.encodeIfPresent(test1, forKey: .test1)
}
if test2 != .red {
try container.encodeIfPresent(test2, forKey: .test2)
}
try container.encodeIfPresent(test3, forKey: .test3)
}
}
public struct MyGame_Example_Vec3_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
public var x: Float32 { return _accessor.readBuffer(of: Float32.self, at: 0) }
@discardableResult public func mutate(x: Float32) -> Bool { return _accessor.mutate(x, index: 0) }
public var y: Float32 { return _accessor.readBuffer(of: Float32.self, at: 4) }
@discardableResult public func mutate(y: Float32) -> Bool { return _accessor.mutate(y, index: 4) }
public var z: Float32 { return _accessor.readBuffer(of: Float32.self, at: 8) }
@discardableResult public func mutate(z: Float32) -> Bool { return _accessor.mutate(z, index: 8) }
public var test1: Double { return _accessor.readBuffer(of: Double.self, at: 16) }
@discardableResult public func mutate(test1: Double) -> Bool { return _accessor.mutate(test1, index: 16) }
public var test2: MyGame_Example_Color { return MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: 24)) ?? .red }
@discardableResult public func mutate(test2: MyGame_Example_Color) -> Bool { return _accessor.mutate(test2.rawValue, index: 24) }
public var test3: MyGame_Example_Test_Mutable { return MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.postion + 26) }
public mutating func unpack() -> MyGame_Example_Vec3 {
return MyGame_Example_Vec3(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_Vec3?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_Vec3) -> Offset {
return builder.create(struct: obj)
}
}
public struct MyGame_Example_Ability: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _id: UInt32
private var _distance: UInt32
public init(_ bb: ByteBuffer, o: Int32) {
let _accessor = Struct(bb: bb, position: o)
_id = _accessor.readBuffer(of: UInt32.self, at: 0)
_distance = _accessor.readBuffer(of: UInt32.self, at: 4)
}
public init(id: UInt32, distance: UInt32) {
_id = id
_distance = distance
}
public init() {
_id = 0
_distance = 0
}
public init(_ _t: inout MyGame_Example_Ability_Mutable) {
_id = _t.id
_distance = _t.distance
}
public var id: UInt32 { _id }
public var distance: UInt32 { _distance }
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
try verifier.inBuffer(position: position, of: MyGame_Example_Ability.self)
}
}
extension MyGame_Example_Ability: Encodable {
enum CodingKeys: String, CodingKey {
case id = "id"
case distance = "distance"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
if id != 0 {
try container.encodeIfPresent(id, forKey: .id)
}
if distance != 0 {
try container.encodeIfPresent(distance, forKey: .distance)
}
}
}
public struct MyGame_Example_Ability_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
public var id: UInt32 { return _accessor.readBuffer(of: UInt32.self, at: 0) }
@discardableResult public func mutate(id: UInt32) -> Bool { return _accessor.mutate(id, index: 0) }
public var distance: UInt32 { return _accessor.readBuffer(of: UInt32.self, at: 4) }
@discardableResult public func mutate(distance: UInt32) -> Bool { return _accessor.mutate(distance, index: 4) }
public mutating func unpack() -> MyGame_Example_Ability {
return MyGame_Example_Ability(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_Ability?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_Ability) -> Offset {
return builder.create(struct: obj)
}
}
public struct MyGame_Example_StructOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_Ability
private var _b: MyGame_Example_Test
private var _c: MyGame_Example_Ability
public init(_ bb: ByteBuffer, o: Int32) {
let _accessor = Struct(bb: bb, position: o)
_a = MyGame_Example_Ability(_accessor.bb, o: _accessor.postion + 0)
_b = MyGame_Example_Test(_accessor.bb, o: _accessor.postion + 8)
_c = MyGame_Example_Ability(_accessor.bb, o: _accessor.postion + 12)
}
public init(a: MyGame_Example_Ability, b: MyGame_Example_Test, c: MyGame_Example_Ability) {
_a = a
_b = b
_c = c
}
public init() {
_a = MyGame_Example_Ability()
_b = MyGame_Example_Test()
_c = MyGame_Example_Ability()
}
public init(_ _t: inout MyGame_Example_StructOfStructs_Mutable) {
var _va = _t.a
_a = _va.unpack()
var _vb = _t.b
_b = _vb.unpack()
var _vc = _t.c
_c = _vc.unpack()
}
public var a: MyGame_Example_Ability { _a }
public var b: MyGame_Example_Test { _b }
public var c: MyGame_Example_Ability { _c }
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
try verifier.inBuffer(position: position, of: MyGame_Example_StructOfStructs.self)
}
}
extension MyGame_Example_StructOfStructs: Encodable {
enum CodingKeys: String, CodingKey {
case a = "a"
case b = "b"
case c = "c"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(a, forKey: .a)
try container.encodeIfPresent(b, forKey: .b)
try container.encodeIfPresent(c, forKey: .c)
}
}
public struct MyGame_Example_StructOfStructs_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
public var a: MyGame_Example_Ability_Mutable { return MyGame_Example_Ability_Mutable(_accessor.bb, o: _accessor.postion + 0) }
public var b: MyGame_Example_Test_Mutable { return MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.postion + 8) }
public var c: MyGame_Example_Ability_Mutable { return MyGame_Example_Ability_Mutable(_accessor.bb, o: _accessor.postion + 12) }
public mutating func unpack() -> MyGame_Example_StructOfStructs {
return MyGame_Example_StructOfStructs(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructs?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructs) -> Offset {
return builder.create(struct: obj)
}
}
public struct MyGame_Example_StructOfStructsOfStructs: NativeStruct, Verifiable, FlatbuffersInitializable, NativeObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
private var _a: MyGame_Example_StructOfStructs
public init(_ bb: ByteBuffer, o: Int32) {
let _accessor = Struct(bb: bb, position: o)
_a = MyGame_Example_StructOfStructs(_accessor.bb, o: _accessor.postion + 0)
}
public init(a: MyGame_Example_StructOfStructs) {
_a = a
}
public init() {
_a = MyGame_Example_StructOfStructs()
}
public init(_ _t: inout MyGame_Example_StructOfStructsOfStructs_Mutable) {
var _va = _t.a
_a = _va.unpack()
}
public var a: MyGame_Example_StructOfStructs { _a }
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
try verifier.inBuffer(position: position, of: MyGame_Example_StructOfStructsOfStructs.self)
}
}
extension MyGame_Example_StructOfStructsOfStructs: Encodable {
enum CodingKeys: String, CodingKey {
case a = "a"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(a, forKey: .a)
}
}
public struct MyGame_Example_StructOfStructsOfStructs_Mutable: FlatBufferObject {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Struct
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
public var a: MyGame_Example_StructOfStructs_Mutable { return MyGame_Example_StructOfStructs_Mutable(_accessor.bb, o: _accessor.postion + 0) }
public mutating func unpack() -> MyGame_Example_StructOfStructsOfStructs {
return MyGame_Example_StructOfStructsOfStructs(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructsOfStructs?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StructOfStructsOfStructs) -> Offset {
return builder.create(struct: obj)
}
}
public struct MyGame_InParentNamespace: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
public static var id: String { "MONS" }
public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_InParentNamespace.id, addPrefix: prefix) }
public static func getRootAsInParentNamespace(bb: ByteBuffer) -> MyGame_InParentNamespace { return MyGame_InParentNamespace(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
public static func startInParentNamespace(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
public static func endInParentNamespace(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
public mutating func unpack() -> MyGame_InParentNamespaceT {
return MyGame_InParentNamespaceT(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_InParentNamespaceT?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_InParentNamespaceT) -> Offset {
let __root = MyGame_InParentNamespace.startInParentNamespace(&builder)
return MyGame_InParentNamespace.endInParentNamespace(&builder, start: __root)
}
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
_v.finish()
}
}
extension MyGame_InParentNamespace: Encodable {
public func encode(to encoder: Encoder) throws {
}
}
public class MyGame_InParentNamespaceT: NativeObject {
public init(_ _t: inout MyGame_InParentNamespace) {
}
public init() {
}
public func serialize() -> ByteBuffer { return serialize(type: MyGame_InParentNamespace.self) }
}
public struct MyGame_Example2_Monster: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
public static var id: String { "MONS" }
public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example2_Monster.id, addPrefix: prefix) }
public static func getRootAsMonster(bb: ByteBuffer) -> MyGame_Example2_Monster { return MyGame_Example2_Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 0) }
public static func endMonster(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
public mutating func unpack() -> MyGame_Example2_MonsterT {
return MyGame_Example2_MonsterT(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example2_MonsterT?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example2_MonsterT) -> Offset {
let __root = MyGame_Example2_Monster.startMonster(&builder)
return MyGame_Example2_Monster.endMonster(&builder, start: __root)
}
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
_v.finish()
}
}
extension MyGame_Example2_Monster: Encodable {
public func encode(to encoder: Encoder) throws {
}
}
public class MyGame_Example2_MonsterT: NativeObject {
public init(_ _t: inout MyGame_Example2_Monster) {
}
public init() {
}
public func serialize() -> ByteBuffer { return serialize(type: MyGame_Example2_Monster.self) }
}
internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
internal var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
internal static var id: String { "MONS" }
internal static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_TestSimpleTableWithEnum.id, addPrefix: prefix) }
internal static func getRootAsTestSimpleTableWithEnum(bb: ByteBuffer) -> MyGame_Example_TestSimpleTableWithEnum { return MyGame_Example_TestSimpleTableWithEnum(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
internal init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
private enum VTOFFSET: VOffset {
case color = 4
var v: Int32 { Int32(self.rawValue) }
var p: VOffset { self.rawValue }
}
internal var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .green : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .green }
@discardableResult internal func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) }
internal static func startTestSimpleTableWithEnum(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
internal static func add(color: MyGame_Example_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) }
internal static func endTestSimpleTableWithEnum(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
internal static func createTestSimpleTableWithEnum(
_ fbb: inout FlatBufferBuilder,
color: MyGame_Example_Color = .green
) -> Offset {
let __start = MyGame_Example_TestSimpleTableWithEnum.startTestSimpleTableWithEnum(&fbb)
MyGame_Example_TestSimpleTableWithEnum.add(color: color, &fbb)
return MyGame_Example_TestSimpleTableWithEnum.endTestSimpleTableWithEnum(&fbb, start: __start)
}
internal mutating func unpack() -> MyGame_Example_TestSimpleTableWithEnumT {
return MyGame_Example_TestSimpleTableWithEnumT(&self)
}
internal static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_TestSimpleTableWithEnumT?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
internal static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_TestSimpleTableWithEnumT) -> Offset {
let __root = MyGame_Example_TestSimpleTableWithEnum.startTestSimpleTableWithEnum(&builder)
MyGame_Example_TestSimpleTableWithEnum.add(color: obj.color, &builder)
return MyGame_Example_TestSimpleTableWithEnum.endTestSimpleTableWithEnum(&builder, start: __root)
}
internal static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Example_Color.self)
_v.finish()
}
}
extension MyGame_Example_TestSimpleTableWithEnum: Encodable {
enum CodingKeys: String, CodingKey {
case color = "color"
}
internal func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
if color != .green {
try container.encodeIfPresent(color, forKey: .color)
}
}
}
internal class MyGame_Example_TestSimpleTableWithEnumT: NativeObject {
internal var color: MyGame_Example_Color
internal init(_ _t: inout MyGame_Example_TestSimpleTableWithEnum) {
color = _t.color
}
internal init() {
color = .green
}
internal func serialize() -> ByteBuffer { return serialize(type: MyGame_Example_TestSimpleTableWithEnum.self) }
}
public struct MyGame_Example_Stat: FlatBufferObject, Verifiable, ObjectAPIPacker {
static func validateVersion() { FlatBuffersVersion_2_0_8() }
public var __buffer: ByteBuffer! { return _accessor.bb }
private var _accessor: Table
public static var id: String { "MONS" }
public static func finish(_ fbb: inout FlatBufferBuilder, end: Offset, prefix: Bool = false) { fbb.finish(offset: end, fileId: MyGame_Example_Stat.id, addPrefix: prefix) }
public static func getRootAsStat(bb: ByteBuffer) -> MyGame_Example_Stat { return MyGame_Example_Stat(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
private init(_ t: Table) { _accessor = t }
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
private enum VTOFFSET: VOffset {
case id = 4
case val = 6
case count = 8
var v: Int32 { Int32(self.rawValue) }
var p: VOffset { self.rawValue }
}
public var id: String? { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? nil : _accessor.string(at: o) }
public var idSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.id.v) }
public var val: Int64 { let o = _accessor.offset(VTOFFSET.val.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
@discardableResult public func mutate(val: Int64) -> Bool {let o = _accessor.offset(VTOFFSET.val.v); return _accessor.mutate(val, index: o) }
public var count: UInt16 { let o = _accessor.offset(VTOFFSET.count.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt16.self, at: o) }
@discardableResult public func mutate(count: UInt16) -> Bool {let o = _accessor.offset(VTOFFSET.count.v); return _accessor.mutate(count, index: o) }
public static func startStat(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
public static func add(id: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: id, at: VTOFFSET.id.p) }
public static func add(val: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: val, def: 0, at: VTOFFSET.val.p) }
public static func add(count: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: count, def: 0, at: VTOFFSET.count.p) }
public static func endStat(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
public static func createStat(
_ fbb: inout FlatBufferBuilder,
idOffset id: Offset = Offset(),
val: Int64 = 0,
count: UInt16 = 0
) -> Offset {
let __start = MyGame_Example_Stat.startStat(&fbb)
MyGame_Example_Stat.add(id: id, &fbb)
MyGame_Example_Stat.add(val: val, &fbb)
MyGame_Example_Stat.add(count: count, &fbb)
return MyGame_Example_Stat.endStat(&fbb, start: __start)
}
public static func sortVectorOfStat(offsets:[Offset], _ fbb: inout FlatBufferBuilder) -> Offset {
var off = offsets
off.sort { Table.compare(Table.offset(Int32($1.o), vOffset: 8, fbb: fbb.buffer), Table.offset(Int32($0.o), vOffset: 8, fbb: fbb.buffer), fbb: fbb.buffer) < 0 }
return fbb.createVector(ofOffsets: off)
}
fileprivate static func lookupByKey(vector: Int32, key: UInt16, fbb: ByteBuffer) -> MyGame_Example_Stat? {
var span = fbb.read(def: Int32.self, position: Int(vector - 4))
var start: Int32 = 0
while span != 0 {
var middle = span / 2
let tableOffset = Table.indirect(vector + 4 * (start + middle), fbb)
let comp = fbb.read(def: UInt16.self, position: Int(Table.offset(Int32(fbb.capacity) - tableOffset, vOffset: 8, fbb: fbb)))
if comp > 0 {
span = middle
} else if comp < 0 {
middle += 1
start += middle
span -= middle
} else {
return MyGame_Example_Stat(fbb, o: tableOffset)
}
}
return nil
}
public mutating func unpack() -> MyGame_Example_StatT {
return MyGame_Example_StatT(&self)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StatT?) -> Offset {
guard var obj = obj else { return Offset() }
return pack(&builder, obj: &obj)
}
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MyGame_Example_StatT) -> Offset {
let __id: Offset
if let s = obj.id {
__id = builder.create(string: s)
} else {
__id = Offset()
}
let __root = MyGame_Example_Stat.startStat(&builder)
MyGame_Example_Stat.add(id: __id, &builder)
MyGame_Example_Stat.add(val: obj.val, &builder)
MyGame_Example_Stat.add(count: obj.count, &builder)
return MyGame_Example_Stat.endStat(&builder, start: __root)
}
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
var _v = try verifier.visitTable(at: position)
try _v.visit(field: VTOFFSET.id.p, fieldName: "id", required: false, type: ForwardOffset<String>.self)
try _v.visit(field: VTOFFSET.val.p, fieldName: "val", required: false, type: Int64.self)
try _v.visit(field: VTOFFSET.count.p, fieldName: "count", required: false, type: UInt16.self)
_v.finish()
}
}
extension MyGame_Example_Stat: Encodable {
enum CodingKeys: String, CodingKey {
case id = "id"
case val = "val"
case count = "count"
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encodeIfPresent(id, forKey: .id)
if val != 0 {
try container.encodeIfPresent(val, forKey: .val)
}
if count != 0 {
try container.encodeIfPresent(count, forKey: .count)
}
}
}
public class MyGame_Example_StatT: NativeObject {
public var id: String?
public var val: Int64
public var count: UInt16
public init(_ _t: inout MyGame_Example_Stat) {
id = _t.id
val = _t.val