mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-19 00:08:56 +00:00
[Swift] Moves VTs from enums to structs to prevent empty enum generation
Moves VTs from enums to structs to prevent empty enum generation, which would usually cause a compilation error.
This commit is contained in:
@@ -38,10 +38,10 @@ public struct Property: NativeStruct, FlatbuffersVectorInitializable, Verifiable
|
||||
}
|
||||
|
||||
extension Property: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case property = "property"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if property != false {
|
||||
@@ -83,16 +83,14 @@ public struct TestMutatingBool: FlatBufferTable, FlatbuffersVectorInitializable,
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case b = 4
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let b: VOffset = 4
|
||||
}
|
||||
|
||||
public var b: Property? { let o = _accessor.offset(VTOFFSET.b.v); return o == 0 ? nil : _accessor.readBuffer(of: Property.self, at: o) }
|
||||
public var mutableB: Property_Mutable? { let o = _accessor.offset(VTOFFSET.b.v); return o == 0 ? nil : Property_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||
public var b: Property? { let o = _accessor.offset(VT.b); return o == 0 ? nil : _accessor.readBuffer(of: Property.self, at: o) }
|
||||
public var mutableB: Property_Mutable? { let o = _accessor.offset(VT.b); return o == 0 ? nil : Property_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||
public static func startTestMutatingBool(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(b: Property?, _ fbb: inout FlatBufferBuilder) { guard let b = b else { return }; fbb.create(struct: b, position: VTOFFSET.b.p) }
|
||||
public static func add(b: Property?, _ fbb: inout FlatBufferBuilder) { guard let b = b else { return }; fbb.create(struct: b, position: VT.b) }
|
||||
public static func endTestMutatingBool(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createTestMutatingBool(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -119,16 +117,16 @@ public struct TestMutatingBool: FlatBufferTable, FlatbuffersVectorInitializable,
|
||||
|
||||
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.b.p, fieldName: "b", required: false, type: Property.self)
|
||||
try _v.visit(field: VT.b, fieldName: "b", required: false, type: Property.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension TestMutatingBool: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case b = "b"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(b, forKey: .b)
|
||||
|
||||
@@ -84,13 +84,13 @@ public struct MyGame_Example_NestedStruct: NativeStruct, FlatbuffersVectorInitia
|
||||
|
||||
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
||||
extension MyGame_Example_NestedStruct: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case a = "a"
|
||||
case b = "b"
|
||||
case c = "c"
|
||||
case d = "d"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
var aContainer = container.nestedUnkeyedContainer(forKey: .a)
|
||||
@@ -206,7 +206,6 @@ public struct MyGame_Example_ArrayStruct: NativeStruct, FlatbuffersVectorInitial
|
||||
|
||||
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
||||
extension MyGame_Example_ArrayStruct: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case a = "a"
|
||||
case b = "b"
|
||||
@@ -215,6 +214,7 @@ extension MyGame_Example_ArrayStruct: Encodable {
|
||||
case e = "e"
|
||||
case f = "f"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if a != 0.0 {
|
||||
@@ -287,16 +287,14 @@ public struct MyGame_Example_ArrayTable: FlatBufferTable, FlatbuffersVectorIniti
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case a = 4
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let a: VOffset = 4
|
||||
}
|
||||
|
||||
public var a: MyGame_Example_ArrayStruct? { let o = _accessor.offset(VTOFFSET.a.v); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Example_ArrayStruct.self, at: o) }
|
||||
public var mutableA: MyGame_Example_ArrayStruct_Mutable? { let o = _accessor.offset(VTOFFSET.a.v); return o == 0 ? nil : MyGame_Example_ArrayStruct_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||
public var a: MyGame_Example_ArrayStruct? { let o = _accessor.offset(VT.a); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Example_ArrayStruct.self, at: o) }
|
||||
public var mutableA: MyGame_Example_ArrayStruct_Mutable? { let o = _accessor.offset(VT.a); return o == 0 ? nil : MyGame_Example_ArrayStruct_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||
public static func startArrayTable(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(a: MyGame_Example_ArrayStruct?, _ fbb: inout FlatBufferBuilder) { guard let a = a else { return }; fbb.create(struct: a, position: VTOFFSET.a.p) }
|
||||
public static func add(a: MyGame_Example_ArrayStruct?, _ fbb: inout FlatBufferBuilder) { guard let a = a else { return }; fbb.create(struct: a, position: VT.a) }
|
||||
public static func endArrayTable(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createArrayTable(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -323,17 +321,17 @@ public struct MyGame_Example_ArrayTable: FlatBufferTable, FlatbuffersVectorIniti
|
||||
|
||||
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.a.p, fieldName: "a", required: false, type: MyGame_Example_ArrayStruct.self)
|
||||
try _v.visit(field: VT.a, fieldName: "a", required: false, type: MyGame_Example_ArrayStruct.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
||||
extension MyGame_Example_ArrayTable: 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)
|
||||
|
||||
67
tests/swift/Tests/Flatbuffers/empty_vtable_generated.swift
Normal file
67
tests/swift/Tests/Flatbuffers/empty_vtable_generated.swift
Normal file
@@ -0,0 +1,67 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// swiftlint:disable all
|
||||
// swiftformat:disable all
|
||||
|
||||
#if canImport(Common)
|
||||
import Common
|
||||
#endif
|
||||
|
||||
import FlatBuffers
|
||||
|
||||
public struct DataModel_A: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable, ObjectAPIPacker {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
private var _accessor: Table
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private struct VT {
|
||||
}
|
||||
|
||||
public static func startA(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func endA(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createA(
|
||||
_ fbb: inout FlatBufferBuilder
|
||||
) -> Offset {
|
||||
let __start = DataModel_A.startA(&fbb)
|
||||
return DataModel_A.endA(&fbb, start: __start)
|
||||
}
|
||||
|
||||
public func unpack() -> DataModel_AT {
|
||||
return DataModel_AT(self)
|
||||
}
|
||||
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout DataModel_AT?) -> Offset {
|
||||
guard var obj = obj else { return Offset() }
|
||||
return pack(&builder, obj: &obj)
|
||||
}
|
||||
|
||||
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout DataModel_AT) -> Offset {
|
||||
let __root = DataModel_A.startA(&builder)
|
||||
return DataModel_A.endA(&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 DataModel_A: Encodable {
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
}
|
||||
}
|
||||
|
||||
public class DataModel_AT: NativeObject {
|
||||
|
||||
|
||||
public init(_ _t: borrowing DataModel_A) {
|
||||
}
|
||||
|
||||
public init() {
|
||||
}
|
||||
|
||||
public func serialize() -> ByteBuffer { return serialize(type: DataModel_A.self) }
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -40,35 +40,33 @@ public struct MoreDefaults: FlatBufferTable, FlatbuffersVectorInitializable, Ver
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case ints = 4
|
||||
case floats = 6
|
||||
case emptyString = 8
|
||||
case someString = 10
|
||||
case abcs = 12
|
||||
case bools = 14
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let ints: VOffset = 4
|
||||
static let floats: VOffset = 6
|
||||
static let emptyString: VOffset = 8
|
||||
static let someString: VOffset = 10
|
||||
static let abcs: VOffset = 12
|
||||
static let bools: VOffset = 14
|
||||
}
|
||||
|
||||
public var ints: FlatbufferVector<Int32> { return _accessor.vector(at: VTOFFSET.ints.v, byteSize: 4) }
|
||||
public func withUnsafePointerToInts<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.ints.v, body: body) }
|
||||
public var floats: FlatbufferVector<Float32> { return _accessor.vector(at: VTOFFSET.floats.v, byteSize: 4) }
|
||||
public func withUnsafePointerToFloats<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.floats.v, body: body) }
|
||||
public var emptyString: String? { let o = _accessor.offset(VTOFFSET.emptyString.v); return o == 0 ? "" : _accessor.string(at: o) }
|
||||
public var emptyStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.emptyString.v) }
|
||||
public var someString: String? { let o = _accessor.offset(VTOFFSET.someString.v); return o == 0 ? "some" : _accessor.string(at: o) }
|
||||
public var someStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.someString.v) }
|
||||
public var abcs: FlatbufferVector<ABC> { return _accessor.vector(at: VTOFFSET.abcs.v, byteSize: 4) }
|
||||
public var bools: FlatbufferVector<Bool> { return _accessor.vector(at: VTOFFSET.bools.v, byteSize: 1) }
|
||||
public func withUnsafePointerToBools<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.bools.v, body: body) }
|
||||
public var ints: FlatbufferVector<Int32> { return _accessor.vector(at: VT.ints, byteSize: 4) }
|
||||
public func withUnsafePointerToInts<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.ints, body: body) }
|
||||
public var floats: FlatbufferVector<Float32> { return _accessor.vector(at: VT.floats, byteSize: 4) }
|
||||
public func withUnsafePointerToFloats<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.floats, body: body) }
|
||||
public var emptyString: String? { let o = _accessor.offset(VT.emptyString); return o == 0 ? "" : _accessor.string(at: o) }
|
||||
public var emptyStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.emptyString) }
|
||||
public var someString: String? { let o = _accessor.offset(VT.someString); return o == 0 ? "some" : _accessor.string(at: o) }
|
||||
public var someStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.someString) }
|
||||
public var abcs: FlatbufferVector<ABC> { return _accessor.vector(at: VT.abcs, byteSize: 4) }
|
||||
public var bools: FlatbufferVector<Bool> { return _accessor.vector(at: VT.bools, byteSize: 1) }
|
||||
public func withUnsafePointerToBools<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.bools, body: body) }
|
||||
public static func startMoreDefaults(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 6) }
|
||||
public static func addVectorOf(ints: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: ints, at: VTOFFSET.ints.p) }
|
||||
public static func addVectorOf(floats: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: floats, at: VTOFFSET.floats.p) }
|
||||
public static func add(emptyString: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: emptyString, at: VTOFFSET.emptyString.p) }
|
||||
public static func add(someString: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: someString, at: VTOFFSET.someString.p) }
|
||||
public static func addVectorOf(abcs: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: abcs, at: VTOFFSET.abcs.p) }
|
||||
public static func addVectorOf(bools: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: bools, at: VTOFFSET.bools.p) }
|
||||
public static func addVectorOf(ints: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: ints, at: VT.ints) }
|
||||
public static func addVectorOf(floats: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: floats, at: VT.floats) }
|
||||
public static func add(emptyString: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: emptyString, at: VT.emptyString) }
|
||||
public static func add(someString: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: someString, at: VT.someString) }
|
||||
public static func addVectorOf(abcs: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: abcs, at: VT.abcs) }
|
||||
public static func addVectorOf(bools: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: bools, at: VT.bools) }
|
||||
public static func endMoreDefaults(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createMoreDefaults(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -128,18 +126,17 @@ public struct MoreDefaults: FlatBufferTable, FlatbuffersVectorInitializable, Ver
|
||||
|
||||
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.ints.p, fieldName: "ints", required: false, type: ForwardOffset<Vector<Int32, Int32>>.self)
|
||||
try _v.visit(field: VTOFFSET.floats.p, fieldName: "floats", required: false, type: ForwardOffset<Vector<Float32, Float32>>.self)
|
||||
try _v.visit(field: VTOFFSET.emptyString.p, fieldName: "emptyString", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VTOFFSET.someString.p, fieldName: "someString", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VTOFFSET.abcs.p, fieldName: "abcs", required: false, type: ForwardOffset<Vector<ABC, ABC>>.self)
|
||||
try _v.visit(field: VTOFFSET.bools.p, fieldName: "bools", required: false, type: ForwardOffset<Vector<Bool, Bool>>.self)
|
||||
try _v.visit(field: VT.ints, fieldName: "ints", required: false, type: ForwardOffset<Vector<Int32, Int32>>.self)
|
||||
try _v.visit(field: VT.floats, fieldName: "floats", required: false, type: ForwardOffset<Vector<Float32, Float32>>.self)
|
||||
try _v.visit(field: VT.emptyString, fieldName: "emptyString", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VT.someString, fieldName: "someString", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VT.abcs, fieldName: "abcs", required: false, type: ForwardOffset<Vector<ABC, ABC>>.self)
|
||||
try _v.visit(field: VT.bools, fieldName: "bools", required: false, type: ForwardOffset<Vector<Bool, Bool>>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension MoreDefaults: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case ints = "ints"
|
||||
case floats = "floats"
|
||||
@@ -148,6 +145,7 @@ extension MoreDefaults: Encodable {
|
||||
case abcs = "abcs"
|
||||
case bools = "bools"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(ints, forKey: .ints)
|
||||
|
||||
@@ -17,33 +17,31 @@ public struct Swift_Tests_NanInfTable: FlatBufferTable, FlatbuffersVectorInitial
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case defaultNan = 4
|
||||
case defaultInf = 6
|
||||
case defaultNinf = 8
|
||||
case valueNan = 10
|
||||
case valueInf = 12
|
||||
case valueNinf = 14
|
||||
case value = 16
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let defaultNan: VOffset = 4
|
||||
static let defaultInf: VOffset = 6
|
||||
static let defaultNinf: VOffset = 8
|
||||
static let valueNan: VOffset = 10
|
||||
static let valueInf: VOffset = 12
|
||||
static let valueNinf: VOffset = 14
|
||||
static let value: VOffset = 16
|
||||
}
|
||||
|
||||
public var defaultNan: Double { let o = _accessor.offset(VTOFFSET.defaultNan.v); return o == 0 ? .nan : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultInf: Double { let o = _accessor.offset(VTOFFSET.defaultInf.v); return o == 0 ? .infinity : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultNinf: Double { let o = _accessor.offset(VTOFFSET.defaultNinf.v); return o == 0 ? -.infinity : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var valueNan: Double { let o = _accessor.offset(VTOFFSET.valueNan.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var valueInf: Double { let o = _accessor.offset(VTOFFSET.valueInf.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var valueNinf: Double { let o = _accessor.offset(VTOFFSET.valueNinf.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var value: Double { let o = _accessor.offset(VTOFFSET.value.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultNan: Double { let o = _accessor.offset(VT.defaultNan); return o == 0 ? .nan : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultInf: Double { let o = _accessor.offset(VT.defaultInf); return o == 0 ? .infinity : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultNinf: Double { let o = _accessor.offset(VT.defaultNinf); return o == 0 ? -.infinity : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var valueNan: Double { let o = _accessor.offset(VT.valueNan); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var valueInf: Double { let o = _accessor.offset(VT.valueInf); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var valueNinf: Double { let o = _accessor.offset(VT.valueNinf); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var value: Double { let o = _accessor.offset(VT.value); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public static func startNanInfTable(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 7) }
|
||||
public static func add(defaultNan: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultNan, def: .nan, at: VTOFFSET.defaultNan.p) }
|
||||
public static func add(defaultInf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultInf, def: .infinity, at: VTOFFSET.defaultInf.p) }
|
||||
public static func add(defaultNinf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultNinf, def: -.infinity, at: VTOFFSET.defaultNinf.p) }
|
||||
public static func add(valueNan: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueNan, def: 0.0, at: VTOFFSET.valueNan.p) }
|
||||
public static func add(valueInf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueInf, def: 0.0, at: VTOFFSET.valueInf.p) }
|
||||
public static func add(valueNinf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueNinf, def: 0.0, at: VTOFFSET.valueNinf.p) }
|
||||
public static func add(value: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: value, def: 0.0, at: VTOFFSET.value.p) }
|
||||
public static func add(defaultNan: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultNan, def: .nan, at: VT.defaultNan) }
|
||||
public static func add(defaultInf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultInf, def: .infinity, at: VT.defaultInf) }
|
||||
public static func add(defaultNinf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultNinf, def: -.infinity, at: VT.defaultNinf) }
|
||||
public static func add(valueNan: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueNan, def: 0.0, at: VT.valueNan) }
|
||||
public static func add(valueInf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueInf, def: 0.0, at: VT.valueInf) }
|
||||
public static func add(valueNinf: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: valueNinf, def: 0.0, at: VT.valueNinf) }
|
||||
public static func add(value: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: value, def: 0.0, at: VT.value) }
|
||||
public static func endNanInfTable(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createNanInfTable(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -68,19 +66,18 @@ public struct Swift_Tests_NanInfTable: FlatBufferTable, FlatbuffersVectorInitial
|
||||
|
||||
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.defaultNan.p, fieldName: "defaultNan", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.defaultInf.p, fieldName: "defaultInf", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.defaultNinf.p, fieldName: "defaultNinf", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.valueNan.p, fieldName: "valueNan", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.valueInf.p, fieldName: "valueInf", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.valueNinf.p, fieldName: "valueNinf", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.value.p, fieldName: "value", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.defaultNan, fieldName: "defaultNan", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.defaultInf, fieldName: "defaultInf", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.defaultNinf, fieldName: "defaultNinf", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.valueNan, fieldName: "valueNan", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.valueInf, fieldName: "valueInf", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.valueNinf, fieldName: "valueNinf", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.value, fieldName: "value", required: false, type: Double.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension Swift_Tests_NanInfTable: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case defaultNan = "default_nan"
|
||||
case defaultInf = "default_inf"
|
||||
@@ -90,6 +87,7 @@ extension Swift_Tests_NanInfTable: Encodable {
|
||||
case valueNinf = "value_ninf"
|
||||
case value = "value"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if !defaultNan.isNaN {
|
||||
|
||||
@@ -42,122 +42,120 @@ public struct optional_scalars_ScalarStuff: FlatBufferTable, FlatbuffersVectorIn
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case justI8 = 4
|
||||
case maybeI8 = 6
|
||||
case defaultI8 = 8
|
||||
case justU8 = 10
|
||||
case maybeU8 = 12
|
||||
case defaultU8 = 14
|
||||
case justI16 = 16
|
||||
case maybeI16 = 18
|
||||
case defaultI16 = 20
|
||||
case justU16 = 22
|
||||
case maybeU16 = 24
|
||||
case defaultU16 = 26
|
||||
case justI32 = 28
|
||||
case maybeI32 = 30
|
||||
case defaultI32 = 32
|
||||
case justU32 = 34
|
||||
case maybeU32 = 36
|
||||
case defaultU32 = 38
|
||||
case justI64 = 40
|
||||
case maybeI64 = 42
|
||||
case defaultI64 = 44
|
||||
case justU64 = 46
|
||||
case maybeU64 = 48
|
||||
case defaultU64 = 50
|
||||
case justF32 = 52
|
||||
case maybeF32 = 54
|
||||
case defaultF32 = 56
|
||||
case justF64 = 58
|
||||
case maybeF64 = 60
|
||||
case defaultF64 = 62
|
||||
case justBool = 64
|
||||
case maybeBool = 66
|
||||
case defaultBool = 68
|
||||
case justEnum = 70
|
||||
case maybeEnum = 72
|
||||
case defaultEnum = 74
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let justI8: VOffset = 4
|
||||
static let maybeI8: VOffset = 6
|
||||
static let defaultI8: VOffset = 8
|
||||
static let justU8: VOffset = 10
|
||||
static let maybeU8: VOffset = 12
|
||||
static let defaultU8: VOffset = 14
|
||||
static let justI16: VOffset = 16
|
||||
static let maybeI16: VOffset = 18
|
||||
static let defaultI16: VOffset = 20
|
||||
static let justU16: VOffset = 22
|
||||
static let maybeU16: VOffset = 24
|
||||
static let defaultU16: VOffset = 26
|
||||
static let justI32: VOffset = 28
|
||||
static let maybeI32: VOffset = 30
|
||||
static let defaultI32: VOffset = 32
|
||||
static let justU32: VOffset = 34
|
||||
static let maybeU32: VOffset = 36
|
||||
static let defaultU32: VOffset = 38
|
||||
static let justI64: VOffset = 40
|
||||
static let maybeI64: VOffset = 42
|
||||
static let defaultI64: VOffset = 44
|
||||
static let justU64: VOffset = 46
|
||||
static let maybeU64: VOffset = 48
|
||||
static let defaultU64: VOffset = 50
|
||||
static let justF32: VOffset = 52
|
||||
static let maybeF32: VOffset = 54
|
||||
static let defaultF32: VOffset = 56
|
||||
static let justF64: VOffset = 58
|
||||
static let maybeF64: VOffset = 60
|
||||
static let defaultF64: VOffset = 62
|
||||
static let justBool: VOffset = 64
|
||||
static let maybeBool: VOffset = 66
|
||||
static let defaultBool: VOffset = 68
|
||||
static let justEnum: VOffset = 70
|
||||
static let maybeEnum: VOffset = 72
|
||||
static let defaultEnum: VOffset = 74
|
||||
}
|
||||
|
||||
public var justI8: Int8 { let o = _accessor.offset(VTOFFSET.justI8.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int8.self, at: o) }
|
||||
public var maybeI8: Int8? { let o = _accessor.offset(VTOFFSET.maybeI8.v); return o == 0 ? nil : _accessor.readBuffer(of: Int8.self, at: o) }
|
||||
public var defaultI8: Int8 { let o = _accessor.offset(VTOFFSET.defaultI8.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int8.self, at: o) }
|
||||
public var justU8: UInt8 { let o = _accessor.offset(VTOFFSET.justU8.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt8.self, at: o) }
|
||||
public var maybeU8: UInt8? { let o = _accessor.offset(VTOFFSET.maybeU8.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt8.self, at: o) }
|
||||
public var defaultU8: UInt8 { let o = _accessor.offset(VTOFFSET.defaultU8.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt8.self, at: o) }
|
||||
public var justI16: Int16 { let o = _accessor.offset(VTOFFSET.justI16.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||
public var maybeI16: Int16? { let o = _accessor.offset(VTOFFSET.maybeI16.v); return o == 0 ? nil : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||
public var defaultI16: Int16 { let o = _accessor.offset(VTOFFSET.defaultI16.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||
public var justU16: UInt16 { let o = _accessor.offset(VTOFFSET.justU16.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt16.self, at: o) }
|
||||
public var maybeU16: UInt16? { let o = _accessor.offset(VTOFFSET.maybeU16.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt16.self, at: o) }
|
||||
public var defaultU16: UInt16 { let o = _accessor.offset(VTOFFSET.defaultU16.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt16.self, at: o) }
|
||||
public var justI32: Int32 { let o = _accessor.offset(VTOFFSET.justI32.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public var maybeI32: Int32? { let o = _accessor.offset(VTOFFSET.maybeI32.v); return o == 0 ? nil : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public var defaultI32: Int32 { let o = _accessor.offset(VTOFFSET.defaultI32.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public var justU32: UInt32 { let o = _accessor.offset(VTOFFSET.justU32.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt32.self, at: o) }
|
||||
public var maybeU32: UInt32? { let o = _accessor.offset(VTOFFSET.maybeU32.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt32.self, at: o) }
|
||||
public var defaultU32: UInt32 { let o = _accessor.offset(VTOFFSET.defaultU32.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt32.self, at: o) }
|
||||
public var justI64: Int64 { let o = _accessor.offset(VTOFFSET.justI64.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
public var maybeI64: Int64? { let o = _accessor.offset(VTOFFSET.maybeI64.v); return o == 0 ? nil : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
public var defaultI64: Int64 { let o = _accessor.offset(VTOFFSET.defaultI64.v); return o == 0 ? 42 : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
public var justU64: UInt64 { let o = _accessor.offset(VTOFFSET.justU64.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
|
||||
public var maybeU64: UInt64? { let o = _accessor.offset(VTOFFSET.maybeU64.v); return o == 0 ? nil : _accessor.readBuffer(of: UInt64.self, at: o) }
|
||||
public var defaultU64: UInt64 { let o = _accessor.offset(VTOFFSET.defaultU64.v); return o == 0 ? 42 : _accessor.readBuffer(of: UInt64.self, at: o) }
|
||||
public var justF32: Float32 { let o = _accessor.offset(VTOFFSET.justF32.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o) }
|
||||
public var maybeF32: Float32? { let o = _accessor.offset(VTOFFSET.maybeF32.v); return o == 0 ? nil : _accessor.readBuffer(of: Float32.self, at: o) }
|
||||
public var defaultF32: Float32 { let o = _accessor.offset(VTOFFSET.defaultF32.v); return o == 0 ? 42.0 : _accessor.readBuffer(of: Float32.self, at: o) }
|
||||
public var justF64: Double { let o = _accessor.offset(VTOFFSET.justF64.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var maybeF64: Double? { let o = _accessor.offset(VTOFFSET.maybeF64.v); return o == 0 ? nil : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultF64: Double { let o = _accessor.offset(VTOFFSET.defaultF64.v); return o == 0 ? 42.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var justBool: Bool { let o = _accessor.offset(VTOFFSET.justBool.v); return o == 0 ? false : _accessor.readBuffer(of: Bool.self, at: o) }
|
||||
public var maybeBool: Bool? { let o = _accessor.offset(VTOFFSET.maybeBool.v); return o == 0 ? nil : _accessor.readBuffer(of: Bool.self, at: o) }
|
||||
public var defaultBool: Bool { let o = _accessor.offset(VTOFFSET.defaultBool.v); return o == 0 ? true : _accessor.readBuffer(of: Bool.self, at: o) }
|
||||
public var justEnum: optional_scalars_OptionalByte { let o = _accessor.offset(VTOFFSET.justEnum.v); return o == 0 ? .none_ : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .none_ }
|
||||
public var maybeEnum: optional_scalars_OptionalByte? { let o = _accessor.offset(VTOFFSET.maybeEnum.v); return o == 0 ? nil : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? nil }
|
||||
public var defaultEnum: optional_scalars_OptionalByte { let o = _accessor.offset(VTOFFSET.defaultEnum.v); return o == 0 ? .one : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .one }
|
||||
public var justI8: Int8 { let o = _accessor.offset(VT.justI8); return o == 0 ? 0 : _accessor.readBuffer(of: Int8.self, at: o) }
|
||||
public var maybeI8: Int8? { let o = _accessor.offset(VT.maybeI8); return o == 0 ? nil : _accessor.readBuffer(of: Int8.self, at: o) }
|
||||
public var defaultI8: Int8 { let o = _accessor.offset(VT.defaultI8); return o == 0 ? 42 : _accessor.readBuffer(of: Int8.self, at: o) }
|
||||
public var justU8: UInt8 { let o = _accessor.offset(VT.justU8); return o == 0 ? 0 : _accessor.readBuffer(of: UInt8.self, at: o) }
|
||||
public var maybeU8: UInt8? { let o = _accessor.offset(VT.maybeU8); return o == 0 ? nil : _accessor.readBuffer(of: UInt8.self, at: o) }
|
||||
public var defaultU8: UInt8 { let o = _accessor.offset(VT.defaultU8); return o == 0 ? 42 : _accessor.readBuffer(of: UInt8.self, at: o) }
|
||||
public var justI16: Int16 { let o = _accessor.offset(VT.justI16); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||
public var maybeI16: Int16? { let o = _accessor.offset(VT.maybeI16); return o == 0 ? nil : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||
public var defaultI16: Int16 { let o = _accessor.offset(VT.defaultI16); return o == 0 ? 42 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||
public var justU16: UInt16 { let o = _accessor.offset(VT.justU16); return o == 0 ? 0 : _accessor.readBuffer(of: UInt16.self, at: o) }
|
||||
public var maybeU16: UInt16? { let o = _accessor.offset(VT.maybeU16); return o == 0 ? nil : _accessor.readBuffer(of: UInt16.self, at: o) }
|
||||
public var defaultU16: UInt16 { let o = _accessor.offset(VT.defaultU16); return o == 0 ? 42 : _accessor.readBuffer(of: UInt16.self, at: o) }
|
||||
public var justI32: Int32 { let o = _accessor.offset(VT.justI32); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public var maybeI32: Int32? { let o = _accessor.offset(VT.maybeI32); return o == 0 ? nil : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public var defaultI32: Int32 { let o = _accessor.offset(VT.defaultI32); return o == 0 ? 42 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public var justU32: UInt32 { let o = _accessor.offset(VT.justU32); return o == 0 ? 0 : _accessor.readBuffer(of: UInt32.self, at: o) }
|
||||
public var maybeU32: UInt32? { let o = _accessor.offset(VT.maybeU32); return o == 0 ? nil : _accessor.readBuffer(of: UInt32.self, at: o) }
|
||||
public var defaultU32: UInt32 { let o = _accessor.offset(VT.defaultU32); return o == 0 ? 42 : _accessor.readBuffer(of: UInt32.self, at: o) }
|
||||
public var justI64: Int64 { let o = _accessor.offset(VT.justI64); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
public var maybeI64: Int64? { let o = _accessor.offset(VT.maybeI64); return o == 0 ? nil : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
public var defaultI64: Int64 { let o = _accessor.offset(VT.defaultI64); return o == 0 ? 42 : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
public var justU64: UInt64 { let o = _accessor.offset(VT.justU64); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.self, at: o) }
|
||||
public var maybeU64: UInt64? { let o = _accessor.offset(VT.maybeU64); return o == 0 ? nil : _accessor.readBuffer(of: UInt64.self, at: o) }
|
||||
public var defaultU64: UInt64 { let o = _accessor.offset(VT.defaultU64); return o == 0 ? 42 : _accessor.readBuffer(of: UInt64.self, at: o) }
|
||||
public var justF32: Float32 { let o = _accessor.offset(VT.justF32); return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.self, at: o) }
|
||||
public var maybeF32: Float32? { let o = _accessor.offset(VT.maybeF32); return o == 0 ? nil : _accessor.readBuffer(of: Float32.self, at: o) }
|
||||
public var defaultF32: Float32 { let o = _accessor.offset(VT.defaultF32); return o == 0 ? 42.0 : _accessor.readBuffer(of: Float32.self, at: o) }
|
||||
public var justF64: Double { let o = _accessor.offset(VT.justF64); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var maybeF64: Double? { let o = _accessor.offset(VT.maybeF64); return o == 0 ? nil : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var defaultF64: Double { let o = _accessor.offset(VT.defaultF64); return o == 0 ? 42.0 : _accessor.readBuffer(of: Double.self, at: o) }
|
||||
public var justBool: Bool { let o = _accessor.offset(VT.justBool); return o == 0 ? false : _accessor.readBuffer(of: Bool.self, at: o) }
|
||||
public var maybeBool: Bool? { let o = _accessor.offset(VT.maybeBool); return o == 0 ? nil : _accessor.readBuffer(of: Bool.self, at: o) }
|
||||
public var defaultBool: Bool { let o = _accessor.offset(VT.defaultBool); return o == 0 ? true : _accessor.readBuffer(of: Bool.self, at: o) }
|
||||
public var justEnum: optional_scalars_OptionalByte { let o = _accessor.offset(VT.justEnum); return o == 0 ? .none_ : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .none_ }
|
||||
public var maybeEnum: optional_scalars_OptionalByte? { let o = _accessor.offset(VT.maybeEnum); return o == 0 ? nil : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? nil }
|
||||
public var defaultEnum: optional_scalars_OptionalByte { let o = _accessor.offset(VT.defaultEnum); return o == 0 ? .one : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .one }
|
||||
public static func startScalarStuff(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 36) }
|
||||
public static func add(justI8: Int8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI8, def: 0, at: VTOFFSET.justI8.p) }
|
||||
public static func add(maybeI8: Int8?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI8, at: VTOFFSET.maybeI8.p) }
|
||||
public static func add(defaultI8: Int8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI8, def: 42, at: VTOFFSET.defaultI8.p) }
|
||||
public static func add(justU8: UInt8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU8, def: 0, at: VTOFFSET.justU8.p) }
|
||||
public static func add(maybeU8: UInt8?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU8, at: VTOFFSET.maybeU8.p) }
|
||||
public static func add(defaultU8: UInt8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU8, def: 42, at: VTOFFSET.defaultU8.p) }
|
||||
public static func add(justI16: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI16, def: 0, at: VTOFFSET.justI16.p) }
|
||||
public static func add(maybeI16: Int16?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI16, at: VTOFFSET.maybeI16.p) }
|
||||
public static func add(defaultI16: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI16, def: 42, at: VTOFFSET.defaultI16.p) }
|
||||
public static func add(justU16: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU16, def: 0, at: VTOFFSET.justU16.p) }
|
||||
public static func add(maybeU16: UInt16?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU16, at: VTOFFSET.maybeU16.p) }
|
||||
public static func add(defaultU16: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU16, def: 42, at: VTOFFSET.defaultU16.p) }
|
||||
public static func add(justI32: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI32, def: 0, at: VTOFFSET.justI32.p) }
|
||||
public static func add(maybeI32: Int32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI32, at: VTOFFSET.maybeI32.p) }
|
||||
public static func add(defaultI32: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI32, def: 42, at: VTOFFSET.defaultI32.p) }
|
||||
public static func add(justU32: UInt32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU32, def: 0, at: VTOFFSET.justU32.p) }
|
||||
public static func add(maybeU32: UInt32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU32, at: VTOFFSET.maybeU32.p) }
|
||||
public static func add(defaultU32: UInt32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU32, def: 42, at: VTOFFSET.defaultU32.p) }
|
||||
public static func add(justI64: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI64, def: 0, at: VTOFFSET.justI64.p) }
|
||||
public static func add(maybeI64: Int64?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI64, at: VTOFFSET.maybeI64.p) }
|
||||
public static func add(defaultI64: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI64, def: 42, at: VTOFFSET.defaultI64.p) }
|
||||
public static func add(justU64: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU64, def: 0, at: VTOFFSET.justU64.p) }
|
||||
public static func add(maybeU64: UInt64?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU64, at: VTOFFSET.maybeU64.p) }
|
||||
public static func add(defaultU64: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU64, def: 42, at: VTOFFSET.defaultU64.p) }
|
||||
public static func add(justF32: Float32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justF32, def: 0.0, at: VTOFFSET.justF32.p) }
|
||||
public static func add(maybeF32: Float32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeF32, at: VTOFFSET.maybeF32.p) }
|
||||
public static func add(defaultF32: Float32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultF32, def: 42.0, at: VTOFFSET.defaultF32.p) }
|
||||
public static func add(justF64: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justF64, def: 0.0, at: VTOFFSET.justF64.p) }
|
||||
public static func add(maybeF64: Double?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeF64, at: VTOFFSET.maybeF64.p) }
|
||||
public static func add(defaultF64: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultF64, def: 42.0, at: VTOFFSET.defaultF64.p) }
|
||||
public static func add(justI8: Int8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI8, def: 0, at: VT.justI8) }
|
||||
public static func add(maybeI8: Int8?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI8, at: VT.maybeI8) }
|
||||
public static func add(defaultI8: Int8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI8, def: 42, at: VT.defaultI8) }
|
||||
public static func add(justU8: UInt8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU8, def: 0, at: VT.justU8) }
|
||||
public static func add(maybeU8: UInt8?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU8, at: VT.maybeU8) }
|
||||
public static func add(defaultU8: UInt8, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU8, def: 42, at: VT.defaultU8) }
|
||||
public static func add(justI16: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI16, def: 0, at: VT.justI16) }
|
||||
public static func add(maybeI16: Int16?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI16, at: VT.maybeI16) }
|
||||
public static func add(defaultI16: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI16, def: 42, at: VT.defaultI16) }
|
||||
public static func add(justU16: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU16, def: 0, at: VT.justU16) }
|
||||
public static func add(maybeU16: UInt16?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU16, at: VT.maybeU16) }
|
||||
public static func add(defaultU16: UInt16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU16, def: 42, at: VT.defaultU16) }
|
||||
public static func add(justI32: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI32, def: 0, at: VT.justI32) }
|
||||
public static func add(maybeI32: Int32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI32, at: VT.maybeI32) }
|
||||
public static func add(defaultI32: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI32, def: 42, at: VT.defaultI32) }
|
||||
public static func add(justU32: UInt32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU32, def: 0, at: VT.justU32) }
|
||||
public static func add(maybeU32: UInt32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU32, at: VT.maybeU32) }
|
||||
public static func add(defaultU32: UInt32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU32, def: 42, at: VT.defaultU32) }
|
||||
public static func add(justI64: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justI64, def: 0, at: VT.justI64) }
|
||||
public static func add(maybeI64: Int64?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeI64, at: VT.maybeI64) }
|
||||
public static func add(defaultI64: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultI64, def: 42, at: VT.defaultI64) }
|
||||
public static func add(justU64: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justU64, def: 0, at: VT.justU64) }
|
||||
public static func add(maybeU64: UInt64?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeU64, at: VT.maybeU64) }
|
||||
public static func add(defaultU64: UInt64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultU64, def: 42, at: VT.defaultU64) }
|
||||
public static func add(justF32: Float32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justF32, def: 0.0, at: VT.justF32) }
|
||||
public static func add(maybeF32: Float32?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeF32, at: VT.maybeF32) }
|
||||
public static func add(defaultF32: Float32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultF32, def: 42.0, at: VT.defaultF32) }
|
||||
public static func add(justF64: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justF64, def: 0.0, at: VT.justF64) }
|
||||
public static func add(maybeF64: Double?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeF64, at: VT.maybeF64) }
|
||||
public static func add(defaultF64: Double, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultF64, def: 42.0, at: VT.defaultF64) }
|
||||
public static func add(justBool: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justBool, def: false,
|
||||
at: VTOFFSET.justBool.p) }
|
||||
public static func add(maybeBool: Bool?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeBool, at: VTOFFSET.maybeBool.p) }
|
||||
at: VT.justBool) }
|
||||
public static func add(maybeBool: Bool?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeBool, at: VT.maybeBool) }
|
||||
public static func add(defaultBool: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultBool, def: true,
|
||||
at: VTOFFSET.defaultBool.p) }
|
||||
public static func add(justEnum: optional_scalars_OptionalByte, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justEnum.rawValue, def: 0, at: VTOFFSET.justEnum.p) }
|
||||
public static func add(maybeEnum: optional_scalars_OptionalByte?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeEnum?.rawValue, at: VTOFFSET.maybeEnum.p) }
|
||||
public static func add(defaultEnum: optional_scalars_OptionalByte, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultEnum.rawValue, def: 1, at: VTOFFSET.defaultEnum.p) }
|
||||
at: VT.defaultBool) }
|
||||
public static func add(justEnum: optional_scalars_OptionalByte, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justEnum.rawValue, def: 0, at: VT.justEnum) }
|
||||
public static func add(maybeEnum: optional_scalars_OptionalByte?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeEnum?.rawValue, at: VT.maybeEnum) }
|
||||
public static func add(defaultEnum: optional_scalars_OptionalByte, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultEnum.rawValue, def: 1, at: VT.defaultEnum) }
|
||||
public static func endScalarStuff(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createScalarStuff(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -240,48 +238,47 @@ public struct optional_scalars_ScalarStuff: FlatBufferTable, FlatbuffersVectorIn
|
||||
|
||||
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.justI8.p, fieldName: "justI8", required: false, type: Int8.self)
|
||||
try _v.visit(field: VTOFFSET.maybeI8.p, fieldName: "maybeI8", required: false, type: Int8.self)
|
||||
try _v.visit(field: VTOFFSET.defaultI8.p, fieldName: "defaultI8", required: false, type: Int8.self)
|
||||
try _v.visit(field: VTOFFSET.justU8.p, fieldName: "justU8", required: false, type: UInt8.self)
|
||||
try _v.visit(field: VTOFFSET.maybeU8.p, fieldName: "maybeU8", required: false, type: UInt8.self)
|
||||
try _v.visit(field: VTOFFSET.defaultU8.p, fieldName: "defaultU8", required: false, type: UInt8.self)
|
||||
try _v.visit(field: VTOFFSET.justI16.p, fieldName: "justI16", required: false, type: Int16.self)
|
||||
try _v.visit(field: VTOFFSET.maybeI16.p, fieldName: "maybeI16", required: false, type: Int16.self)
|
||||
try _v.visit(field: VTOFFSET.defaultI16.p, fieldName: "defaultI16", required: false, type: Int16.self)
|
||||
try _v.visit(field: VTOFFSET.justU16.p, fieldName: "justU16", required: false, type: UInt16.self)
|
||||
try _v.visit(field: VTOFFSET.maybeU16.p, fieldName: "maybeU16", required: false, type: UInt16.self)
|
||||
try _v.visit(field: VTOFFSET.defaultU16.p, fieldName: "defaultU16", required: false, type: UInt16.self)
|
||||
try _v.visit(field: VTOFFSET.justI32.p, fieldName: "justI32", required: false, type: Int32.self)
|
||||
try _v.visit(field: VTOFFSET.maybeI32.p, fieldName: "maybeI32", required: false, type: Int32.self)
|
||||
try _v.visit(field: VTOFFSET.defaultI32.p, fieldName: "defaultI32", required: false, type: Int32.self)
|
||||
try _v.visit(field: VTOFFSET.justU32.p, fieldName: "justU32", required: false, type: UInt32.self)
|
||||
try _v.visit(field: VTOFFSET.maybeU32.p, fieldName: "maybeU32", required: false, type: UInt32.self)
|
||||
try _v.visit(field: VTOFFSET.defaultU32.p, fieldName: "defaultU32", required: false, type: UInt32.self)
|
||||
try _v.visit(field: VTOFFSET.justI64.p, fieldName: "justI64", required: false, type: Int64.self)
|
||||
try _v.visit(field: VTOFFSET.maybeI64.p, fieldName: "maybeI64", required: false, type: Int64.self)
|
||||
try _v.visit(field: VTOFFSET.defaultI64.p, fieldName: "defaultI64", required: false, type: Int64.self)
|
||||
try _v.visit(field: VTOFFSET.justU64.p, fieldName: "justU64", required: false, type: UInt64.self)
|
||||
try _v.visit(field: VTOFFSET.maybeU64.p, fieldName: "maybeU64", required: false, type: UInt64.self)
|
||||
try _v.visit(field: VTOFFSET.defaultU64.p, fieldName: "defaultU64", required: false, type: UInt64.self)
|
||||
try _v.visit(field: VTOFFSET.justF32.p, fieldName: "justF32", required: false, type: Float32.self)
|
||||
try _v.visit(field: VTOFFSET.maybeF32.p, fieldName: "maybeF32", required: false, type: Float32.self)
|
||||
try _v.visit(field: VTOFFSET.defaultF32.p, fieldName: "defaultF32", required: false, type: Float32.self)
|
||||
try _v.visit(field: VTOFFSET.justF64.p, fieldName: "justF64", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.maybeF64.p, fieldName: "maybeF64", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.defaultF64.p, fieldName: "defaultF64", required: false, type: Double.self)
|
||||
try _v.visit(field: VTOFFSET.justBool.p, fieldName: "justBool", required: false, type: Bool.self)
|
||||
try _v.visit(field: VTOFFSET.maybeBool.p, fieldName: "maybeBool", required: false, type: Bool.self)
|
||||
try _v.visit(field: VTOFFSET.defaultBool.p, fieldName: "defaultBool", required: false, type: Bool.self)
|
||||
try _v.visit(field: VTOFFSET.justEnum.p, fieldName: "justEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||
try _v.visit(field: VTOFFSET.maybeEnum.p, fieldName: "maybeEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||
try _v.visit(field: VTOFFSET.defaultEnum.p, fieldName: "defaultEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||
try _v.visit(field: VT.justI8, fieldName: "justI8", required: false, type: Int8.self)
|
||||
try _v.visit(field: VT.maybeI8, fieldName: "maybeI8", required: false, type: Int8.self)
|
||||
try _v.visit(field: VT.defaultI8, fieldName: "defaultI8", required: false, type: Int8.self)
|
||||
try _v.visit(field: VT.justU8, fieldName: "justU8", required: false, type: UInt8.self)
|
||||
try _v.visit(field: VT.maybeU8, fieldName: "maybeU8", required: false, type: UInt8.self)
|
||||
try _v.visit(field: VT.defaultU8, fieldName: "defaultU8", required: false, type: UInt8.self)
|
||||
try _v.visit(field: VT.justI16, fieldName: "justI16", required: false, type: Int16.self)
|
||||
try _v.visit(field: VT.maybeI16, fieldName: "maybeI16", required: false, type: Int16.self)
|
||||
try _v.visit(field: VT.defaultI16, fieldName: "defaultI16", required: false, type: Int16.self)
|
||||
try _v.visit(field: VT.justU16, fieldName: "justU16", required: false, type: UInt16.self)
|
||||
try _v.visit(field: VT.maybeU16, fieldName: "maybeU16", required: false, type: UInt16.self)
|
||||
try _v.visit(field: VT.defaultU16, fieldName: "defaultU16", required: false, type: UInt16.self)
|
||||
try _v.visit(field: VT.justI32, fieldName: "justI32", required: false, type: Int32.self)
|
||||
try _v.visit(field: VT.maybeI32, fieldName: "maybeI32", required: false, type: Int32.self)
|
||||
try _v.visit(field: VT.defaultI32, fieldName: "defaultI32", required: false, type: Int32.self)
|
||||
try _v.visit(field: VT.justU32, fieldName: "justU32", required: false, type: UInt32.self)
|
||||
try _v.visit(field: VT.maybeU32, fieldName: "maybeU32", required: false, type: UInt32.self)
|
||||
try _v.visit(field: VT.defaultU32, fieldName: "defaultU32", required: false, type: UInt32.self)
|
||||
try _v.visit(field: VT.justI64, fieldName: "justI64", required: false, type: Int64.self)
|
||||
try _v.visit(field: VT.maybeI64, fieldName: "maybeI64", required: false, type: Int64.self)
|
||||
try _v.visit(field: VT.defaultI64, fieldName: "defaultI64", required: false, type: Int64.self)
|
||||
try _v.visit(field: VT.justU64, fieldName: "justU64", required: false, type: UInt64.self)
|
||||
try _v.visit(field: VT.maybeU64, fieldName: "maybeU64", required: false, type: UInt64.self)
|
||||
try _v.visit(field: VT.defaultU64, fieldName: "defaultU64", required: false, type: UInt64.self)
|
||||
try _v.visit(field: VT.justF32, fieldName: "justF32", required: false, type: Float32.self)
|
||||
try _v.visit(field: VT.maybeF32, fieldName: "maybeF32", required: false, type: Float32.self)
|
||||
try _v.visit(field: VT.defaultF32, fieldName: "defaultF32", required: false, type: Float32.self)
|
||||
try _v.visit(field: VT.justF64, fieldName: "justF64", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.maybeF64, fieldName: "maybeF64", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.defaultF64, fieldName: "defaultF64", required: false, type: Double.self)
|
||||
try _v.visit(field: VT.justBool, fieldName: "justBool", required: false, type: Bool.self)
|
||||
try _v.visit(field: VT.maybeBool, fieldName: "maybeBool", required: false, type: Bool.self)
|
||||
try _v.visit(field: VT.defaultBool, fieldName: "defaultBool", required: false, type: Bool.self)
|
||||
try _v.visit(field: VT.justEnum, fieldName: "justEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||
try _v.visit(field: VT.maybeEnum, fieldName: "maybeEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||
try _v.visit(field: VT.defaultEnum, fieldName: "defaultEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension optional_scalars_ScalarStuff: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case justI8 = "just_i8"
|
||||
case maybeI8 = "maybe_i8"
|
||||
@@ -320,6 +317,7 @@ extension optional_scalars_ScalarStuff: Encodable {
|
||||
case maybeEnum = "maybe_enum"
|
||||
case defaultEnum = "default_enum"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if justI8 != 0 {
|
||||
|
||||
@@ -152,10 +152,10 @@ public struct Rapunzel: NativeStruct, FlatbuffersVectorInitializable, Verifiable
|
||||
}
|
||||
|
||||
extension Rapunzel: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case hairLength = "hair_length"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if hairLength != 0 {
|
||||
@@ -218,10 +218,10 @@ public struct BookReader: NativeStruct, FlatbuffersVectorInitializable, Verifiab
|
||||
}
|
||||
|
||||
extension BookReader: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case booksRead = "books_read"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if booksRead != 0 {
|
||||
@@ -284,10 +284,10 @@ public struct FallingTub: NativeStruct, FlatbuffersVectorInitializable, Verifiab
|
||||
}
|
||||
|
||||
extension FallingTub: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case weight = "weight"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if weight != 0 {
|
||||
@@ -331,16 +331,14 @@ public struct Attacker: FlatBufferTable, FlatbuffersVectorInitializable, Verifia
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case swordAttackDamage = 4
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let swordAttackDamage: VOffset = 4
|
||||
}
|
||||
|
||||
public var swordAttackDamage: Int32 { let o = _accessor.offset(VTOFFSET.swordAttackDamage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
@discardableResult public func mutate(swordAttackDamage: Int32) -> Bool {let o = _accessor.offset(VTOFFSET.swordAttackDamage.v); return _accessor.mutate(swordAttackDamage, index: o) }
|
||||
public var swordAttackDamage: Int32 { let o = _accessor.offset(VT.swordAttackDamage); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
@discardableResult public func mutate(swordAttackDamage: Int32) -> Bool {let o = _accessor.offset(VT.swordAttackDamage); return _accessor.mutate(swordAttackDamage, index: o) }
|
||||
public static func startAttacker(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(swordAttackDamage: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: swordAttackDamage, def: 0, at: VTOFFSET.swordAttackDamage.p) }
|
||||
public static func add(swordAttackDamage: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: swordAttackDamage, def: 0, at: VT.swordAttackDamage) }
|
||||
public static func endAttacker(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createAttacker(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -367,16 +365,16 @@ public struct Attacker: FlatBufferTable, FlatbuffersVectorInitializable, Verifia
|
||||
|
||||
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.swordAttackDamage.p, fieldName: "swordAttackDamage", required: false, type: Int32.self)
|
||||
try _v.visit(field: VT.swordAttackDamage, fieldName: "swordAttackDamage", required: false, type: Int32.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension Attacker: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case swordAttackDamage = "sword_attack_damage"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if swordAttackDamage != 0 {
|
||||
@@ -411,16 +409,14 @@ public struct HandFan: FlatBufferTable, FlatbuffersVectorInitializable, Verifiab
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case length = 4
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let length: VOffset = 4
|
||||
}
|
||||
|
||||
public var length: Int32 { let o = _accessor.offset(VTOFFSET.length.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
@discardableResult public func mutate(length: Int32) -> Bool {let o = _accessor.offset(VTOFFSET.length.v); return _accessor.mutate(length, index: o) }
|
||||
public var length: Int32 { let o = _accessor.offset(VT.length); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
@discardableResult public func mutate(length: Int32) -> Bool {let o = _accessor.offset(VT.length); return _accessor.mutate(length, index: o) }
|
||||
public static func startHandFan(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(length: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: length, def: 0, at: VTOFFSET.length.p) }
|
||||
public static func add(length: Int32, _ fbb: inout FlatBufferBuilder) { fbb.add(element: length, def: 0, at: VT.length) }
|
||||
public static func endHandFan(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createHandFan(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -447,16 +443,16 @@ public struct HandFan: FlatBufferTable, FlatbuffersVectorInitializable, Verifiab
|
||||
|
||||
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.length.p, fieldName: "length", required: false, type: Int32.self)
|
||||
try _v.visit(field: VT.length, fieldName: "length", required: false, type: Int32.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension HandFan: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case length = "length"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if length != 0 {
|
||||
@@ -491,25 +487,23 @@ public struct Movie: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case mainCharacterType = 4
|
||||
case mainCharacter = 6
|
||||
case charactersType = 8
|
||||
case characters = 10
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let mainCharacterType: VOffset = 4
|
||||
static let mainCharacter: VOffset = 6
|
||||
static let charactersType: VOffset = 8
|
||||
static let characters: VOffset = 10
|
||||
}
|
||||
|
||||
public var mainCharacterType: Character { let o = _accessor.offset(VTOFFSET.mainCharacterType.v); return o == 0 ? .none_ : Character(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
||||
public func mainCharacter<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.mainCharacter.v); return o == 0 ? nil : _accessor.union(o) }
|
||||
public var charactersType: FlatbufferVector<Character> { return _accessor.vector(at: VTOFFSET.charactersType.v, byteSize: 1) }
|
||||
public var characters: UnionFlatbufferVector { return _accessor.unionVector(at: VTOFFSET.characters.v, byteSize: 4) }
|
||||
public func characters<T: FlatbuffersInitializable>(at index: Int32, type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.characters.v); return o == 0 ? nil : _accessor.directUnion(_accessor.vector(at: o) + index * 4) }
|
||||
public var mainCharacterType: Character { let o = _accessor.offset(VT.mainCharacterType); return o == 0 ? .none_ : Character(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
||||
public func mainCharacter<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VT.mainCharacter); return o == 0 ? nil : _accessor.union(o) }
|
||||
public var charactersType: FlatbufferVector<Character> { return _accessor.vector(at: VT.charactersType, byteSize: 1) }
|
||||
public var characters: UnionFlatbufferVector { return _accessor.unionVector(at: VT.characters, byteSize: 4) }
|
||||
public func characters<T: FlatbuffersInitializable>(at index: Int32, type: T.Type) -> T? { let o = _accessor.offset(VT.characters); return o == 0 ? nil : _accessor.directUnion(_accessor.vector(at: o) + index * 4) }
|
||||
public static func startMovie(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 4) }
|
||||
public static func add(mainCharacterType: Character, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mainCharacterType.rawValue, def: 0, at: VTOFFSET.mainCharacterType.p) }
|
||||
public static func add(mainCharacter: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: mainCharacter, at: VTOFFSET.mainCharacter.p) }
|
||||
public static func addVectorOf(charactersType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: charactersType, at: VTOFFSET.charactersType.p) }
|
||||
public static func addVectorOf(characters: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: characters, at: VTOFFSET.characters.p) }
|
||||
public static func add(mainCharacterType: Character, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mainCharacterType.rawValue, def: 0, at: VT.mainCharacterType) }
|
||||
public static func add(mainCharacter: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: mainCharacter, at: VT.mainCharacter) }
|
||||
public static func addVectorOf(charactersType: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: charactersType, at: VT.charactersType) }
|
||||
public static func addVectorOf(characters: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: characters, at: VT.characters) }
|
||||
public static func endMovie(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createMovie(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -556,7 +550,7 @@ public struct Movie: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable
|
||||
|
||||
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(unionKey: VTOFFSET.mainCharacterType.p, unionField: VTOFFSET.mainCharacter.p, unionKeyName: "mainCharacterType", fieldName: "mainCharacter", required: false, completion: { (verifier, key: Character, pos) in
|
||||
try _v.visit(unionKey: VT.mainCharacterType, unionField: VT.mainCharacter, unionKeyName: "mainCharacterType", fieldName: "mainCharacter", required: false, completion: { (verifier, key: Character, pos) in
|
||||
switch key {
|
||||
case .none_:
|
||||
break // NOTE - SWIFT doesnt support none
|
||||
@@ -574,7 +568,7 @@ public struct Movie: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable
|
||||
try ForwardOffset<String>.verify(&verifier, at: pos, of: String.self)
|
||||
}
|
||||
})
|
||||
try _v.visitUnionVector(unionKey: VTOFFSET.charactersType.p, unionField: VTOFFSET.characters.p, unionKeyName: "charactersType", fieldName: "characters", required: false, completion: { (verifier, key: Character, pos) in
|
||||
try _v.visitUnionVector(unionKey: VT.charactersType, unionField: VT.characters, unionKeyName: "charactersType", fieldName: "characters", required: false, completion: { (verifier, key: Character, pos) in
|
||||
switch key {
|
||||
case .none_:
|
||||
break // NOTE - SWIFT doesnt support none
|
||||
@@ -597,13 +591,13 @@ public struct Movie: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable
|
||||
}
|
||||
|
||||
extension Movie: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case mainCharacterType = "main_character_type"
|
||||
case mainCharacter = "main_character"
|
||||
case charactersType = "characters_type"
|
||||
case characters = "characters"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if mainCharacterType != .none_ {
|
||||
|
||||
@@ -17,24 +17,22 @@ public struct Swift_Tests_Vectors: FlatBufferTable, FlatbuffersVectorInitializab
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case none_ = 4
|
||||
case empty = 6
|
||||
case array = 8
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let none_: VOffset = 4
|
||||
static let empty: VOffset = 6
|
||||
static let array: VOffset = 8
|
||||
}
|
||||
|
||||
public var none_: FlatbufferVector<UInt64> { return _accessor.vector(at: VTOFFSET.none_.v, byteSize: 8) }
|
||||
public func withUnsafePointerToNone<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.none_.v, body: body) }
|
||||
public var empty: FlatbufferVector<UInt64> { return _accessor.vector(at: VTOFFSET.empty.v, byteSize: 8) }
|
||||
public func withUnsafePointerToEmpty<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.empty.v, body: body) }
|
||||
public var array: FlatbufferVector<UInt64> { return _accessor.vector(at: VTOFFSET.array.v, byteSize: 8) }
|
||||
public func withUnsafePointerToArray<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.array.v, body: body) }
|
||||
public var none_: FlatbufferVector<UInt64> { return _accessor.vector(at: VT.none_, byteSize: 8) }
|
||||
public func withUnsafePointerToNone<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.none_, body: body) }
|
||||
public var empty: FlatbufferVector<UInt64> { return _accessor.vector(at: VT.empty, byteSize: 8) }
|
||||
public func withUnsafePointerToEmpty<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.empty, body: body) }
|
||||
public var array: FlatbufferVector<UInt64> { return _accessor.vector(at: VT.array, byteSize: 8) }
|
||||
public func withUnsafePointerToArray<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.array, body: body) }
|
||||
public static func startVectors(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
|
||||
public static func addVectorOf(none_: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: none_, at: VTOFFSET.none_.p) }
|
||||
public static func addVectorOf(empty: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: empty, at: VTOFFSET.empty.p) }
|
||||
public static func addVectorOf(array: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: array, at: VTOFFSET.array.p) }
|
||||
public static func addVectorOf(none_: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: none_, at: VT.none_) }
|
||||
public static func addVectorOf(empty: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: empty, at: VT.empty) }
|
||||
public static func addVectorOf(array: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: array, at: VT.array) }
|
||||
public static func endVectors(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createVectors(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -51,20 +49,20 @@ public struct Swift_Tests_Vectors: FlatBufferTable, FlatbuffersVectorInitializab
|
||||
|
||||
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.none_.p, fieldName: "none_", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||
try _v.visit(field: VTOFFSET.empty.p, fieldName: "empty", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||
try _v.visit(field: VTOFFSET.array.p, fieldName: "array", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||
try _v.visit(field: VT.none_, fieldName: "none_", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||
try _v.visit(field: VT.empty, fieldName: "empty", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||
try _v.visit(field: VT.array, fieldName: "array", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension Swift_Tests_Vectors: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case none_ = "none"
|
||||
case empty = "empty"
|
||||
case array = "array"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(none_, forKey: .none_)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
5
tests/swift/fuzzer/CodeGenerationTests/empty_vtable.fbs
Normal file
5
tests/swift/fuzzer/CodeGenerationTests/empty_vtable.fbs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace DataModel;
|
||||
|
||||
table A {
|
||||
a:int (deprecated);
|
||||
}
|
||||
@@ -17,16 +17,14 @@ internal struct Message: FlatBufferTable, FlatbuffersVectorInitializable, Verifi
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
internal init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case internalMessage = 4
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let internalMessage: VOffset = 4
|
||||
}
|
||||
|
||||
internal var internalMessage: String? { let o = _accessor.offset(VTOFFSET.internalMessage.v); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
internal var internalMessageSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.internalMessage.v) }
|
||||
internal var internalMessage: String? { let o = _accessor.offset(VT.internalMessage); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
internal var internalMessageSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.internalMessage) }
|
||||
internal static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
internal static func add(internalMessage: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: internalMessage, at: VTOFFSET.internalMessage.p) }
|
||||
internal static func add(internalMessage: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: internalMessage, at: VT.internalMessage) }
|
||||
internal static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
internal static func createMessage(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -60,16 +58,16 @@ internal struct Message: FlatBufferTable, FlatbuffersVectorInitializable, Verifi
|
||||
|
||||
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.internalMessage.p, fieldName: "internalMessage", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VT.internalMessage, fieldName: "internalMessage", required: false, type: ForwardOffset<String>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension Message: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case internalMessage = "internal_message"
|
||||
}
|
||||
|
||||
internal func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(internalMessage, forKey: .internalMessage)
|
||||
|
||||
@@ -32,10 +32,10 @@ public struct BytesCount: NativeStruct, FlatbuffersVectorInitializable, Verifiab
|
||||
}
|
||||
|
||||
extension BytesCount: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case x = "x"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if x != 0 {
|
||||
@@ -77,16 +77,14 @@ public struct InternalMessage: FlatBufferTable, FlatbuffersVectorInitializable,
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
private enum VTOFFSET: VOffset {
|
||||
case str = 4
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let str: VOffset = 4
|
||||
}
|
||||
|
||||
public var str: String? { let o = _accessor.offset(VTOFFSET.str.v); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var strSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.str.v) }
|
||||
public var str: String? { let o = _accessor.offset(VT.str); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var strSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.str) }
|
||||
public static func startInternalMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(str: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: str, at: VTOFFSET.str.p) }
|
||||
public static func add(str: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: str, at: VT.str) }
|
||||
public static func endInternalMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createInternalMessage(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -120,16 +118,16 @@ public struct InternalMessage: FlatBufferTable, FlatbuffersVectorInitializable,
|
||||
|
||||
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.str.p, fieldName: "str", required: false, type: ForwardOffset<String>.self)
|
||||
try _v.visit(field: VT.str, fieldName: "str", required: false, type: ForwardOffset<String>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension InternalMessage: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case str = "str"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encodeIfPresent(str, forKey: .str)
|
||||
@@ -159,23 +157,21 @@ public struct Message: FlatBufferTable, FlatbuffersVectorInitializable, Verifiab
|
||||
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 position = 6
|
||||
case pointer = 8
|
||||
var v: Int32 { Int32(self.rawValue) }
|
||||
var p: VOffset { self.rawValue }
|
||||
private struct VT {
|
||||
static let id: VOffset = 4
|
||||
static let position: VOffset = 6
|
||||
static let pointer: VOffset = 8
|
||||
}
|
||||
|
||||
public var id: Int64 { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
@discardableResult public func mutate(id: Int64) -> Bool {let o = _accessor.offset(VTOFFSET.id.v); return _accessor.mutate(id, index: o) }
|
||||
public var position: BytesCount! { let o = _accessor.offset(VTOFFSET.position.v); return _accessor.readBuffer(of: BytesCount.self, at: o) }
|
||||
public var mutablePosition: BytesCount_Mutable! { let o = _accessor.offset(VTOFFSET.position.v); return BytesCount_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||
public var pointer: InternalMessage! { let o = _accessor.offset(VTOFFSET.pointer.v); return InternalMessage(_accessor.bb, o: _accessor.indirect(o + _accessor.position)) }
|
||||
public var id: Int64 { let o = _accessor.offset(VT.id); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
|
||||
@discardableResult public func mutate(id: Int64) -> Bool {let o = _accessor.offset(VT.id); return _accessor.mutate(id, index: o) }
|
||||
public var position: BytesCount! { let o = _accessor.offset(VT.position); return _accessor.readBuffer(of: BytesCount.self, at: o) }
|
||||
public var mutablePosition: BytesCount_Mutable! { let o = _accessor.offset(VT.position); return BytesCount_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||
public var pointer: InternalMessage! { let o = _accessor.offset(VT.pointer); return InternalMessage(_accessor.bb, o: _accessor.indirect(o + _accessor.position)) }
|
||||
public static func startMessage(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 3) }
|
||||
public static func add(id: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: id, def: 0, at: VTOFFSET.id.p) }
|
||||
public static func add(position: BytesCount?, _ fbb: inout FlatBufferBuilder) { guard let position = position else { return }; fbb.create(struct: position, position: VTOFFSET.position.p) }
|
||||
public static func add(pointer: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: pointer, at: VTOFFSET.pointer.p) }
|
||||
public static func add(id: Int64, _ fbb: inout FlatBufferBuilder) { fbb.add(element: id, def: 0, at: VT.id) }
|
||||
public static func add(position: BytesCount?, _ fbb: inout FlatBufferBuilder) { guard let position = position else { return }; fbb.create(struct: position, position: VT.position) }
|
||||
public static func add(pointer: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: pointer, at: VT.pointer) }
|
||||
public static func endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); fbb.require(table: end, fields: [6, 8]); return end }
|
||||
public static func createMessage(
|
||||
_ fbb: inout FlatBufferBuilder,
|
||||
@@ -209,20 +205,20 @@ public struct Message: FlatBufferTable, FlatbuffersVectorInitializable, Verifiab
|
||||
|
||||
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: Int64.self)
|
||||
try _v.visit(field: VTOFFSET.position.p, fieldName: "position", required: true, type: BytesCount.self)
|
||||
try _v.visit(field: VTOFFSET.pointer.p, fieldName: "pointer", required: true, type: ForwardOffset<InternalMessage>.self)
|
||||
try _v.visit(field: VT.id, fieldName: "id", required: false, type: Int64.self)
|
||||
try _v.visit(field: VT.position, fieldName: "position", required: true, type: BytesCount.self)
|
||||
try _v.visit(field: VT.pointer, fieldName: "pointer", required: true, type: ForwardOffset<InternalMessage>.self)
|
||||
_v.finish()
|
||||
}
|
||||
}
|
||||
|
||||
extension Message: Encodable {
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id = "id"
|
||||
case position = "position"
|
||||
case pointer = "pointer"
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
if id != 0 {
|
||||
|
||||
Reference in New Issue
Block a user