mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +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:
@@ -17,16 +17,14 @@ public struct models_HelloReply: FlatBufferTable, FlatbuffersVectorInitializable
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case message = 4
|
static let message: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var message: String? { let o = _accessor.offset(VTOFFSET.message.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var message: String? { let o = _accessor.offset(VT.message); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.message.v) }
|
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.message) }
|
||||||
public static func startHelloReply(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
public static func startHelloReply(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||||
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VTOFFSET.message.p) }
|
public static func add(message: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: message, at: VT.message) }
|
||||||
public static func endHelloReply(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endHelloReply(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHelloReply(
|
public static func createHelloReply(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -39,16 +37,16 @@ public struct models_HelloReply: FlatBufferTable, FlatbuffersVectorInitializable
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: 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)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.message.p, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.message, fieldName: "message", required: false, type: ForwardOffset<String>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension models_HelloReply: Encodable {
|
extension models_HelloReply: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case message = "message"
|
case message = "message"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(message, forKey: .message)
|
try container.encodeIfPresent(message, forKey: .message)
|
||||||
@@ -64,16 +62,14 @@ public struct models_HelloRequest: FlatBufferTable, FlatbuffersVectorInitializab
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case name = 4
|
static let name: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
public static func startHelloRequest(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endHelloRequest(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHelloRequest(
|
public static func createHelloRequest(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -86,16 +82,16 @@ public struct models_HelloRequest: FlatBufferTable, FlatbuffersVectorInitializab
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: 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)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension models_HelloRequest: Encodable {
|
extension models_HelloRequest: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name = "name"
|
case name = "name"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(name, forKey: .name)
|
try container.encodeIfPresent(name, forKey: .name)
|
||||||
|
|||||||
@@ -113,12 +113,12 @@ public struct MyGame_Sample_Vec3: NativeStruct, FlatbuffersVectorInitializable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension MyGame_Sample_Vec3: Encodable {
|
extension MyGame_Sample_Vec3: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case x = "x"
|
case x = "x"
|
||||||
case y = "y"
|
case y = "y"
|
||||||
case z = "z"
|
case z = "z"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if x != 0.0 {
|
if x != 0.0 {
|
||||||
@@ -170,51 +170,49 @@ public struct MyGame_Sample_Monster: FlatBufferTable, FlatbuffersVectorInitializ
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case pos = 4
|
static let pos: VOffset = 4
|
||||||
case mana = 6
|
static let mana: VOffset = 6
|
||||||
case hp = 8
|
static let hp: VOffset = 8
|
||||||
case name = 10
|
static let name: VOffset = 10
|
||||||
case inventory = 14
|
static let inventory: VOffset = 14
|
||||||
case color = 16
|
static let color: VOffset = 16
|
||||||
case weapons = 18
|
static let weapons: VOffset = 18
|
||||||
case equippedType = 20
|
static let equippedType: VOffset = 20
|
||||||
case equipped = 22
|
static let equipped: VOffset = 22
|
||||||
case path = 24
|
static let path: VOffset = 24
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var pos: MyGame_Sample_Vec3? { let o = _accessor.offset(VTOFFSET.pos.v); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Sample_Vec3.self, at: o) }
|
public var pos: MyGame_Sample_Vec3? { let o = _accessor.offset(VT.pos); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Sample_Vec3.self, at: o) }
|
||||||
public var mutablePos: MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VTOFFSET.pos.v); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: o + _accessor.position) }
|
public var mutablePos: MyGame_Sample_Vec3_Mutable? { let o = _accessor.offset(VT.pos); return o == 0 ? nil : MyGame_Sample_Vec3_Mutable(_accessor.bb, o: o + _accessor.position) }
|
||||||
public var mana: Int16 { let o = _accessor.offset(VTOFFSET.mana.v); return o == 0 ? 150 : _accessor.readBuffer(of: Int16.self, at: o) }
|
public var mana: Int16 { let o = _accessor.offset(VT.mana); return o == 0 ? 150 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||||
@discardableResult public func mutate(mana: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.mana.v); return _accessor.mutate(mana, index: o) }
|
@discardableResult public func mutate(mana: Int16) -> Bool {let o = _accessor.offset(VT.mana); return _accessor.mutate(mana, index: o) }
|
||||||
public var hp: Int16 { let o = _accessor.offset(VTOFFSET.hp.v); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
|
public var hp: Int16 { let o = _accessor.offset(VT.hp); return o == 0 ? 100 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||||
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.hp.v); return _accessor.mutate(hp, index: o) }
|
@discardableResult public func mutate(hp: Int16) -> Bool {let o = _accessor.offset(VT.hp); return _accessor.mutate(hp, index: o) }
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public var inventory: FlatbufferVector<UInt8> { return _accessor.vector(at: VTOFFSET.inventory.v, byteSize: 1) }
|
public var inventory: FlatbufferVector<UInt8> { return _accessor.vector(at: VT.inventory, byteSize: 1) }
|
||||||
public func mutate(inventory: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VTOFFSET.inventory.v); return _accessor.directMutate(inventory, index: _accessor.vector(at: o) + index * 1) }
|
public func mutate(inventory: UInt8, at index: Int32) -> Bool { let o = _accessor.offset(VT.inventory); return _accessor.directMutate(inventory, index: _accessor.vector(at: o) + index * 1) }
|
||||||
public func withUnsafePointerToInventory<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.inventory.v, body: body) }
|
public func withUnsafePointerToInventory<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.inventory, body: body) }
|
||||||
public var color: MyGame_Sample_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Sample_Color(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .blue }
|
public var color: MyGame_Sample_Color { let o = _accessor.offset(VT.color); return o == 0 ? .blue : MyGame_Sample_Color(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .blue }
|
||||||
@discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) }
|
@discardableResult public func mutate(color: MyGame_Sample_Color) -> Bool {let o = _accessor.offset(VT.color); return _accessor.mutate(color.rawValue, index: o) }
|
||||||
public var weapons: FlatbufferVector<MyGame_Sample_Weapon> { return _accessor.vector(at: VTOFFSET.weapons.v, byteSize: 4) }
|
public var weapons: FlatbufferVector<MyGame_Sample_Weapon> { return _accessor.vector(at: VT.weapons, byteSize: 4) }
|
||||||
public var equippedType: MyGame_Sample_Equipment { let o = _accessor.offset(VTOFFSET.equippedType.v); return o == 0 ? .none_ : MyGame_Sample_Equipment(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
public var equippedType: MyGame_Sample_Equipment { let o = _accessor.offset(VT.equippedType); return o == 0 ? .none_ : MyGame_Sample_Equipment(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ }
|
||||||
public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.equipped.v); return o == 0 ? nil : _accessor.union(o) }
|
public func equipped<T: FlatbuffersInitializable>(type: T.Type) -> T? { let o = _accessor.offset(VT.equipped); return o == 0 ? nil : _accessor.union(o) }
|
||||||
public var path: FlatbufferVector<MyGame_Sample_Vec3> { return _accessor.vector(at: VTOFFSET.path.v, byteSize: 12) }
|
public var path: FlatbufferVector<MyGame_Sample_Vec3> { return _accessor.vector(at: VT.path, byteSize: 12) }
|
||||||
public var mutablePath: FlatbufferVector<MyGame_Sample_Vec3_Mutable> { return _accessor.vector(at: VTOFFSET.path.v, byteSize: 12) }
|
public var mutablePath: FlatbufferVector<MyGame_Sample_Vec3_Mutable> { return _accessor.vector(at: VT.path, byteSize: 12) }
|
||||||
public func withUnsafePointerToPath<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.path.v, body: body) }
|
public func withUnsafePointerToPath<T>(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VT.path, body: body) }
|
||||||
public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
|
public static func startMonster(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 11) }
|
||||||
public static func add(pos: MyGame_Sample_Vec3?, _ fbb: inout FlatBufferBuilder) { guard let pos = pos else { return }; fbb.create(struct: pos, position: VTOFFSET.pos.p) }
|
public static func add(pos: MyGame_Sample_Vec3?, _ fbb: inout FlatBufferBuilder) { guard let pos = pos else { return }; fbb.create(struct: pos, position: VT.pos) }
|
||||||
public static func add(mana: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mana, def: 150, at: VTOFFSET.mana.p) }
|
public static func add(mana: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: mana, def: 150, at: VT.mana) }
|
||||||
public static func add(hp: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: hp, def: 100, at: VTOFFSET.hp.p) }
|
public static func add(hp: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: hp, def: 100, at: VT.hp) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func addVectorOf(inventory: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: inventory, at: VTOFFSET.inventory.p) }
|
public static func addVectorOf(inventory: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: inventory, at: VT.inventory) }
|
||||||
public static func add(color: MyGame_Sample_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) }
|
public static func add(color: MyGame_Sample_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VT.color) }
|
||||||
public static func addVectorOf(weapons: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: weapons, at: VTOFFSET.weapons.p) }
|
public static func addVectorOf(weapons: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: weapons, at: VT.weapons) }
|
||||||
public static func add(equippedType: MyGame_Sample_Equipment, _ fbb: inout FlatBufferBuilder) { fbb.add(element: equippedType.rawValue, def: 0, at: VTOFFSET.equippedType.p) }
|
public static func add(equippedType: MyGame_Sample_Equipment, _ fbb: inout FlatBufferBuilder) { fbb.add(element: equippedType.rawValue, def: 0, at: VT.equippedType) }
|
||||||
public static func add(equipped: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: equipped, at: VTOFFSET.equipped.p) }
|
public static func add(equipped: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: equipped, at: VT.equipped) }
|
||||||
public static func addVectorOf(path: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: path, at: VTOFFSET.path.p) }
|
public static func addVectorOf(path: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: path, at: VT.path) }
|
||||||
public static func startVectorOfPath(_ size: Int, in builder: inout FlatBufferBuilder) {
|
public static func startVectorOfPath(_ size: Int, in builder: inout FlatBufferBuilder) {
|
||||||
builder.startVector(size * MemoryLayout<MyGame_Sample_Vec3>.size, elementSize: MemoryLayout<MyGame_Sample_Vec3>.alignment)
|
builder.startVector(size * MemoryLayout<MyGame_Sample_Vec3>.size, elementSize: MemoryLayout<MyGame_Sample_Vec3>.alignment)
|
||||||
}
|
}
|
||||||
@@ -293,14 +291,14 @@ public struct MyGame_Sample_Monster: FlatBufferTable, FlatbuffersVectorInitializ
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: 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)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.pos.p, fieldName: "pos", required: false, type: MyGame_Sample_Vec3.self)
|
try _v.visit(field: VT.pos, fieldName: "pos", required: false, type: MyGame_Sample_Vec3.self)
|
||||||
try _v.visit(field: VTOFFSET.mana.p, fieldName: "mana", required: false, type: Int16.self)
|
try _v.visit(field: VT.mana, fieldName: "mana", required: false, type: Int16.self)
|
||||||
try _v.visit(field: VTOFFSET.hp.p, fieldName: "hp", required: false, type: Int16.self)
|
try _v.visit(field: VT.hp, fieldName: "hp", required: false, type: Int16.self)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
try _v.visit(field: VTOFFSET.inventory.p, fieldName: "inventory", required: false, type: ForwardOffset<Vector<UInt8, UInt8>>.self)
|
try _v.visit(field: VT.inventory, fieldName: "inventory", required: false, type: ForwardOffset<Vector<UInt8, UInt8>>.self)
|
||||||
try _v.visit(field: VTOFFSET.color.p, fieldName: "color", required: false, type: MyGame_Sample_Color.self)
|
try _v.visit(field: VT.color, fieldName: "color", required: false, type: MyGame_Sample_Color.self)
|
||||||
try _v.visit(field: VTOFFSET.weapons.p, fieldName: "weapons", required: false, type: ForwardOffset<Vector<ForwardOffset<MyGame_Sample_Weapon>, MyGame_Sample_Weapon>>.self)
|
try _v.visit(field: VT.weapons, fieldName: "weapons", required: false, type: ForwardOffset<Vector<ForwardOffset<MyGame_Sample_Weapon>, MyGame_Sample_Weapon>>.self)
|
||||||
try _v.visit(unionKey: VTOFFSET.equippedType.p, unionField: VTOFFSET.equipped.p, unionKeyName: "equippedType", fieldName: "equipped", required: false, completion: { (verifier, key: MyGame_Sample_Equipment, pos) in
|
try _v.visit(unionKey: VT.equippedType, unionField: VT.equipped, unionKeyName: "equippedType", fieldName: "equipped", required: false, completion: { (verifier, key: MyGame_Sample_Equipment, pos) in
|
||||||
switch key {
|
switch key {
|
||||||
case .none_:
|
case .none_:
|
||||||
break // NOTE - SWIFT doesnt support none
|
break // NOTE - SWIFT doesnt support none
|
||||||
@@ -308,13 +306,12 @@ public struct MyGame_Sample_Monster: FlatBufferTable, FlatbuffersVectorInitializ
|
|||||||
try ForwardOffset<MyGame_Sample_Weapon>.verify(&verifier, at: pos, of: MyGame_Sample_Weapon.self)
|
try ForwardOffset<MyGame_Sample_Weapon>.verify(&verifier, at: pos, of: MyGame_Sample_Weapon.self)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
try _v.visit(field: VTOFFSET.path.p, fieldName: "path", required: false, type: ForwardOffset<Vector<MyGame_Sample_Vec3, MyGame_Sample_Vec3>>.self)
|
try _v.visit(field: VT.path, fieldName: "path", required: false, type: ForwardOffset<Vector<MyGame_Sample_Vec3, MyGame_Sample_Vec3>>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MyGame_Sample_Monster: Encodable {
|
extension MyGame_Sample_Monster: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case pos = "pos"
|
case pos = "pos"
|
||||||
case mana = "mana"
|
case mana = "mana"
|
||||||
@@ -327,6 +324,7 @@ extension MyGame_Sample_Monster: Encodable {
|
|||||||
case equipped = "equipped"
|
case equipped = "equipped"
|
||||||
case path = "path"
|
case path = "path"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(pos, forKey: .pos)
|
try container.encodeIfPresent(pos, forKey: .pos)
|
||||||
@@ -411,20 +409,18 @@ public struct MyGame_Sample_Weapon: FlatBufferTable, FlatbuffersVectorInitializa
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case name = 4
|
static let name: VOffset = 4
|
||||||
case damage = 6
|
static let damage: VOffset = 6
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var name: String? { let o = _accessor.offset(VTOFFSET.name.v); return o == 0 ? nil : _accessor.string(at: o) }
|
public var name: String? { let o = _accessor.offset(VT.name); return o == 0 ? nil : _accessor.string(at: o) }
|
||||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VTOFFSET.name.v) }
|
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.name) }
|
||||||
public var damage: Int16 { let o = _accessor.offset(VTOFFSET.damage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
|
public var damage: Int16 { let o = _accessor.offset(VT.damage); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.self, at: o) }
|
||||||
@discardableResult public func mutate(damage: Int16) -> Bool {let o = _accessor.offset(VTOFFSET.damage.v); return _accessor.mutate(damage, index: o) }
|
@discardableResult public func mutate(damage: Int16) -> Bool {let o = _accessor.offset(VT.damage); return _accessor.mutate(damage, index: o) }
|
||||||
public static func startWeapon(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
public static func startWeapon(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
||||||
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VTOFFSET.name.p) }
|
public static func add(name: Offset, _ fbb: inout FlatBufferBuilder) { fbb.add(offset: name, at: VT.name) }
|
||||||
public static func add(damage: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damage, def: 0, at: VTOFFSET.damage.p) }
|
public static func add(damage: Int16, _ fbb: inout FlatBufferBuilder) { fbb.add(element: damage, def: 0, at: VT.damage) }
|
||||||
public static func endWeapon(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
public static func endWeapon(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createWeapon(
|
public static func createWeapon(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ fbb: inout FlatBufferBuilder,
|
||||||
@@ -461,18 +457,18 @@ public struct MyGame_Sample_Weapon: FlatBufferTable, FlatbuffersVectorInitializa
|
|||||||
|
|
||||||
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: 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)
|
var _v = try verifier.visitTable(at: position)
|
||||||
try _v.visit(field: VTOFFSET.name.p, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
try _v.visit(field: VT.name, fieldName: "name", required: false, type: ForwardOffset<String>.self)
|
||||||
try _v.visit(field: VTOFFSET.damage.p, fieldName: "damage", required: false, type: Int16.self)
|
try _v.visit(field: VT.damage, fieldName: "damage", required: false, type: Int16.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MyGame_Sample_Weapon: Encodable {
|
extension MyGame_Sample_Weapon: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case name = "name"
|
case name = "name"
|
||||||
case damage = "damage"
|
case damage = "damage"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(name, forKey: .name)
|
try container.encodeIfPresent(name, forKey: .name)
|
||||||
|
|||||||
@@ -517,6 +517,13 @@ flatc(
|
|||||||
cwd=swift_code_gen,
|
cwd=swift_code_gen,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
flatc(
|
||||||
|
SWIFT_OPTS_CODE_GEN + BASE_OPTS,
|
||||||
|
schema="empty_vtable.fbs",
|
||||||
|
cwd=swift_code_gen,
|
||||||
|
prefix="../../Tests/Flatbuffers/",
|
||||||
|
)
|
||||||
|
|
||||||
# Swift Wasm Tests
|
# Swift Wasm Tests
|
||||||
swift_Wasm_prefix = "swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests"
|
swift_Wasm_prefix = "swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests"
|
||||||
flatc(
|
flatc(
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
bool generate() {
|
bool generate() {
|
||||||
code_.Clear();
|
code_.Clear();
|
||||||
code_.SetValue("ACCESS", "_accessor");
|
code_.SetValue("ACCESS", "_accessor");
|
||||||
code_.SetValue("TABLEOFFSET", "VTOFFSET");
|
code_.SetValue("TABLEOFFSET", "VT");
|
||||||
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
code_ += "// " + std::string(FlatBuffersGeneratedWarning());
|
||||||
code_ += "// swiftlint:disable all";
|
code_ += "// swiftlint:disable all";
|
||||||
code_ += "// swiftformat:disable all\n";
|
code_ += "// swiftformat:disable all\n";
|
||||||
@@ -518,7 +518,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
void GenTableAccessors(const StructDef& struct_def) {
|
void GenTableAccessors(const StructDef& struct_def) {
|
||||||
// Generate field id constants.
|
// Generate field id constants.
|
||||||
if (struct_def.fields.vec.size() > 0) {
|
if (struct_def.fields.vec.size() > 0) {
|
||||||
code_ += "private enum {{TABLEOFFSET}}: VOffset {";
|
code_ += "private struct {{TABLEOFFSET}} {";
|
||||||
Indent();
|
Indent();
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
it != struct_def.fields.vec.end(); ++it) {
|
it != struct_def.fields.vec.end(); ++it) {
|
||||||
@@ -528,10 +528,8 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
code_.SetValue("OFFSET_NAME", namer_.Variable(field));
|
code_.SetValue("OFFSET_NAME", namer_.Variable(field));
|
||||||
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
|
code_.SetValue("OFFSET_VALUE", NumToString(field.value.offset));
|
||||||
code_ += "case {{OFFSET_NAME}} = {{OFFSET_VALUE}}";
|
code_ += "static let {{OFFSET_NAME}}: VOffset = {{OFFSET_VALUE}}";
|
||||||
}
|
}
|
||||||
code_ += "var v: Int32 { Int32(self.rawValue) }";
|
|
||||||
code_ += "var p: VOffset { self.rawValue }";
|
|
||||||
Outdent();
|
Outdent();
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
@@ -620,7 +618,8 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
if (should_generate_create) {
|
if (should_generate_create) {
|
||||||
code_ += "{{ACCESS_TYPE}} static func create{{SHORT_STRUCTNAME}}(";
|
code_ += "{{ACCESS_TYPE}} static func create{{SHORT_STRUCTNAME}}(";
|
||||||
Indent();
|
Indent();
|
||||||
code_ += "_ fbb: inout FlatBufferBuilder,";
|
code_ += "_ fbb: inout FlatBufferBuilder\\";
|
||||||
|
if (create_func_header.empty() == false) code_ += ",";
|
||||||
for (auto it = create_func_header.begin(); it < create_func_header.end();
|
for (auto it = create_func_header.begin(); it < create_func_header.end();
|
||||||
++it) {
|
++it) {
|
||||||
code_ += *it + "\\";
|
code_ += *it + "\\";
|
||||||
@@ -699,7 +698,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ += field.IsOptional() ? (optional_enum + "\\")
|
code_ += field.IsOptional() ? (optional_enum + "\\")
|
||||||
: (is_enum + ", def: {{CONSTANT}}\\");
|
: (is_enum + ", def: {{CONSTANT}}\\");
|
||||||
|
|
||||||
code_ += ", at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
code_ += ", at: {{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
|
|
||||||
const auto default_value =
|
const auto default_value =
|
||||||
IsEnum(field.value.type)
|
IsEnum(field.value.type)
|
||||||
@@ -719,7 +718,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"{{VALUETYPE}}" + builder_string + "fbb.add(element: {{FIELDVAR}},\\";
|
"{{VALUETYPE}}" + builder_string + "fbb.add(element: {{FIELDVAR}},\\";
|
||||||
code_ += field.IsOptional() ? "\\" : " def: {{CONSTANT}},";
|
code_ += field.IsOptional() ? "\\" : " def: {{CONSTANT}},";
|
||||||
code_ += " at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
code_ += " at: {{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
create_func_header.push_back(
|
create_func_header.push_back(
|
||||||
field_var + ": " + nullable_type + " = " +
|
field_var + ": " + nullable_type + " = " +
|
||||||
(field.IsOptional() ? "nil" : default_value));
|
(field.IsOptional() ? "nil" : default_value));
|
||||||
@@ -730,7 +729,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
const auto create_struct =
|
const auto create_struct =
|
||||||
"guard let {{FIELDVAR}} = {{FIELDVAR}} else { return };"
|
"guard let {{FIELDVAR}} = {{FIELDVAR}} else { return };"
|
||||||
" fbb.create(struct: {{FIELDVAR}}, position: "
|
" fbb.create(struct: {{FIELDVAR}}, position: "
|
||||||
"{{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
"{{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
code_ += type + "?" + builder_string + create_struct;
|
code_ += type + "?" + builder_string + create_struct;
|
||||||
/// Optional hard coded since structs are always optional
|
/// Optional hard coded since structs are always optional
|
||||||
create_func_header.push_back(field_var + ": " + type +
|
create_func_header.push_back(field_var + ": " + type +
|
||||||
@@ -747,8 +746,9 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
(field.IsRequired() ? "" : " = Offset()"));
|
(field.IsRequired() ? "" : " = Offset()"));
|
||||||
const auto reader_type =
|
const auto reader_type =
|
||||||
IsStruct(field.value.type) && field.value.type.struct_def->fixed
|
IsStruct(field.value.type) && field.value.type.struct_def->fixed
|
||||||
? "structOffset: {{TABLEOFFSET}}.{{OFFSET}}.p) }"
|
? "structOffset: {{TABLEOFFSET}}.{{OFFSET}}) }"
|
||||||
: "offset: {{FIELDVAR}}, at: {{TABLEOFFSET}}.{{OFFSET}}.p) }";
|
: "offset: {{FIELDVAR}}, at: {{TABLEOFFSET}}.{{OFFSET}}) "
|
||||||
|
"}";
|
||||||
code_ += "Offset" + builder_string + "fbb.add(" + reader_type;
|
code_ += "Offset" + builder_string + "fbb.add(" + reader_type;
|
||||||
|
|
||||||
const auto vectortype = field.value.type.VectorType();
|
const auto vectortype = field.value.type.VectorType();
|
||||||
@@ -860,7 +860,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}SegmentArray: [UInt8]" +
|
code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}SegmentArray: [UInt8]" +
|
||||||
is_required +
|
is_required +
|
||||||
" { return "
|
" { return "
|
||||||
"{{ACCESS}}.getVector(at: {{TABLEOFFSET}}.{{OFFSET}}.v) }";
|
"{{ACCESS}}.getVector(at: {{TABLEOFFSET}}.{{OFFSET}}) }";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BASE_TYPE_ARRAY:
|
case BASE_TYPE_ARRAY:
|
||||||
@@ -894,7 +894,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
||||||
"FlatbufferVector<{{VALUETYPE}}> "
|
"FlatbufferVector<{{VALUETYPE}}> "
|
||||||
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"byteSize: {{SIZE}}) }";
|
"byteSize: {{SIZE}}) }";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,7 +911,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
"{{ACCESS_TYPE}} var {{FIELDVAR}}: "
|
||||||
"FlatbufferVector<{{VALUETYPE}}_Mutable> "
|
"FlatbufferVector<{{VALUETYPE}}_Mutable> "
|
||||||
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{ return {{ACCESS}}.vector(at: {{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"byteSize: {{SIZE}}) }";
|
"byteSize: {{SIZE}}) }";
|
||||||
GenUnsafeBufferPointer(field);
|
GenUnsafeBufferPointer(field);
|
||||||
return;
|
return;
|
||||||
@@ -920,7 +920,8 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
if (vectortype.base_type == BASE_TYPE_UNION) {
|
if (vectortype.base_type == BASE_TYPE_UNION) {
|
||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} var {{FIELDVAR}}: UnionFlatbufferVector "
|
"{{ACCESS_TYPE}} var {{FIELDVAR}}: UnionFlatbufferVector "
|
||||||
"{ return {{ACCESS}}.unionVector(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{ return {{ACCESS}}.unionVector(at: "
|
||||||
|
"{{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"byteSize: {{SIZE}}) }";
|
"byteSize: {{SIZE}}) }";
|
||||||
code_ +=
|
code_ +=
|
||||||
"{{ACCESS_TYPE}} func {{FIELDVAR}}<T: FlatbuffersInitializable>(at "
|
"{{ACCESS_TYPE}} func {{FIELDVAR}}<T: FlatbuffersInitializable>(at "
|
||||||
@@ -954,24 +955,21 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
"{{ACCESS_TYPE}} func {{functionName}}<T>(_ body: "
|
"{{ACCESS_TYPE}} func {{functionName}}<T>(_ body: "
|
||||||
"(UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return "
|
"(UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return "
|
||||||
"try "
|
"try "
|
||||||
"{{ACCESS}}.withUnsafePointerToSlice(at: {{TABLEOFFSET}}.{{OFFSET}}.v, "
|
"{{ACCESS}}.withUnsafePointerToSlice(at: "
|
||||||
|
"{{TABLEOFFSET}}.{{OFFSET}}, "
|
||||||
"body: body) }";
|
"body: body) }";
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateCodingKeys(const StructDef& struct_def) {
|
std::vector<std::string> GenerateCodingKeys(const StructDef& struct_def) {
|
||||||
code_ += "enum CodingKeys: String, CodingKey {";
|
std::vector<std::string> coding_keys;
|
||||||
Indent();
|
|
||||||
for (auto it = struct_def.fields.vec.begin();
|
for (auto it = struct_def.fields.vec.begin();
|
||||||
it != struct_def.fields.vec.end(); ++it) {
|
it != struct_def.fields.vec.end(); ++it) {
|
||||||
const auto& field = **it;
|
const auto& field = **it;
|
||||||
if (field.deprecated) continue;
|
if (field.deprecated) continue;
|
||||||
|
coding_keys.push_back("case " + namer_.Variable(field) + " = \"" +
|
||||||
code_.SetValue("RAWVALUENAME", field.name);
|
field.name + "\"");
|
||||||
code_.SetValue("FIELDVAR", namer_.Variable(field));
|
|
||||||
code_ += "case {{FIELDVAR}} = \"{{RAWVALUENAME}}\"";
|
|
||||||
}
|
}
|
||||||
Outdent();
|
return coding_keys;
|
||||||
code_ += "}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenerateEncoderUnionBody(const FieldDef& field) {
|
void GenerateEncoderUnionBody(const FieldDef& field) {
|
||||||
@@ -1093,14 +1091,31 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
GenOSVersionChecks();
|
GenOSVersionChecks();
|
||||||
code_ += "extension {{STRUCTNAME}}: Encodable {";
|
code_ += "extension {{STRUCTNAME}}: Encodable {";
|
||||||
Indent();
|
Indent();
|
||||||
code_ += "";
|
auto coding_keys = GenerateCodingKeys(struct_def);
|
||||||
if (struct_def.fields.vec.empty() == false) GenerateCodingKeys(struct_def);
|
|
||||||
|
if (coding_keys.empty() == false) {
|
||||||
|
code_ += "enum CodingKeys: String, CodingKey {";
|
||||||
|
Indent();
|
||||||
|
for (auto it = coding_keys.begin(); it != coding_keys.end(); ++it) {
|
||||||
|
const auto& field = *it;
|
||||||
|
code_ += field;
|
||||||
|
}
|
||||||
|
Outdent();
|
||||||
|
code_ += "}";
|
||||||
|
|
||||||
|
code_ += "";
|
||||||
|
}
|
||||||
|
|
||||||
code_ += "{{ACCESS_TYPE}} func encode(to encoder: Encoder) throws {";
|
code_ += "{{ACCESS_TYPE}} func encode(to encoder: Encoder) throws {";
|
||||||
Indent();
|
|
||||||
if (struct_def.fields.vec.empty() == false) GenerateEncoderBody(struct_def);
|
if (coding_keys.empty() == false) {
|
||||||
Outdent();
|
Indent();
|
||||||
|
GenerateEncoderBody(struct_def);
|
||||||
|
Outdent();
|
||||||
|
}
|
||||||
|
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
|
|
||||||
Outdent();
|
Outdent();
|
||||||
code_ += "}";
|
code_ += "}";
|
||||||
code_ += "";
|
code_ += "";
|
||||||
@@ -1130,7 +1145,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
code_ +=
|
code_ +=
|
||||||
"try _v.visit(field: {{TABLEOFFSET}}.{{OFFSET}}.p, fieldName: "
|
"try _v.visit(field: {{TABLEOFFSET}}.{{OFFSET}}, fieldName: "
|
||||||
"\"{{FIELDVAR}}\", required: {{ISREQUIRED}}, type: "
|
"\"{{FIELDVAR}}\", required: {{ISREQUIRED}}, type: "
|
||||||
"{{VALUETYPE}}.self)";
|
"{{VALUETYPE}}.self)";
|
||||||
}
|
}
|
||||||
@@ -1150,8 +1165,9 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
code_.SetValue("VALUETYPE", namer_.NamespacedType(union_def));
|
code_.SetValue("VALUETYPE", namer_.NamespacedType(union_def));
|
||||||
code_.SetValue("FUNCTION_NAME", is_vector ? "visitUnionVector" : "visit");
|
code_.SetValue("FUNCTION_NAME", is_vector ? "visitUnionVector" : "visit");
|
||||||
code_ +=
|
code_ +=
|
||||||
"try _v.{{FUNCTION_NAME}}(unionKey: {{TABLEOFFSET}}.{{OFFSET}}Type.p, "
|
"try _v.{{FUNCTION_NAME}}(unionKey: "
|
||||||
"unionField: {{TABLEOFFSET}}.{{OFFSET}}.p, unionKeyName: "
|
"{{TABLEOFFSET}}.{{OFFSET}}Type, "
|
||||||
|
"unionField: {{TABLEOFFSET}}.{{OFFSET}}, unionKeyName: "
|
||||||
"\"{{FIELDVAR}}Type\", fieldName: \"{{FIELDVAR}}\", required: "
|
"\"{{FIELDVAR}}Type\", fieldName: \"{{FIELDVAR}}\", required: "
|
||||||
"{{ISREQUIRED}}, completion: { (verifier, key: {{VALUETYPE}}, pos) in";
|
"{{ISREQUIRED}}, completion: { (verifier, key: {{VALUETYPE}}, pos) in";
|
||||||
Indent();
|
Indent();
|
||||||
@@ -1893,7 +1909,7 @@ class SwiftGenerator : public BaseGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string GenOffset() {
|
std::string GenOffset() {
|
||||||
return "let o = {{ACCESS}}.offset({{TABLEOFFSET}}.{{OFFSET}}.v); ";
|
return "let o = {{ACCESS}}.offset({{TABLEOFFSET}}.{{OFFSET}}); ";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GenReaderMainBody(const std::string& optional = "") {
|
std::string GenReaderMainBody(const std::string& optional = "") {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public struct Table {
|
|||||||
/// the vtable
|
/// the vtable
|
||||||
/// - Parameter o: current offset
|
/// - Parameter o: current offset
|
||||||
/// - Returns: offset of field within buffer
|
/// - Returns: offset of field within buffer
|
||||||
public func offset(_ o: Int32) -> Int32 {
|
public func offset(_ o: VOffset) -> Int32 {
|
||||||
let vtable = position &- bb.read(def: Int32.self, position: Int(position))
|
let vtable = position &- bb.read(def: Int32.self, position: Int(position))
|
||||||
return o
|
return o
|
||||||
< bb
|
< bb
|
||||||
@@ -57,7 +57,7 @@ public struct Table {
|
|||||||
? Int32(
|
? Int32(
|
||||||
bb.read(
|
bb.read(
|
||||||
def: Int16.self,
|
def: Int16.self,
|
||||||
position: Int(vtable &+ o))) : 0
|
position: Int(vtable &+ Int32(o)))) : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the indirect offset of the current stored object
|
/// Gets the indirect offset of the current stored object
|
||||||
@@ -106,13 +106,13 @@ public struct Table {
|
|||||||
/// This should only be used by `Scalars`
|
/// This should only be used by `Scalars`
|
||||||
/// - Parameter off: Readable offset
|
/// - Parameter off: Readable offset
|
||||||
/// - Returns: Returns a vector of type [T]
|
/// - Returns: Returns a vector of type [T]
|
||||||
public func getVector<T>(at off: Int32) -> [T]? {
|
public func getVector<T>(at off: VOffset) -> [T]? {
|
||||||
let o = offset(off)
|
let o = offset(off)
|
||||||
guard o != 0 else { return nil }
|
guard o != 0 else { return nil }
|
||||||
return bb.readSlice(index: Int(vector(at: o)), count: Int(vector(count: o)))
|
return bb.readSlice(index: Int(vector(at: o)), count: Int(vector(count: o)))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func vector<T>(at off: Int32, byteSize: Int) -> FlatbufferVector<T> {
|
public func vector<T>(at off: VOffset, byteSize: Int) -> FlatbufferVector<T> {
|
||||||
let off = offset(off)
|
let off = offset(off)
|
||||||
return FlatbufferVector(
|
return FlatbufferVector(
|
||||||
bb: bb,
|
bb: bb,
|
||||||
@@ -122,7 +122,7 @@ public struct Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func unionVector(
|
public func unionVector(
|
||||||
at off: Int32,
|
at off: VOffset,
|
||||||
byteSize: Int) -> UnionFlatbufferVector
|
byteSize: Int) -> UnionFlatbufferVector
|
||||||
{
|
{
|
||||||
let off = offset(off)
|
let off = offset(off)
|
||||||
@@ -146,7 +146,7 @@ public struct Table {
|
|||||||
/// - Returns: Returns a pointer to the underlying data
|
/// - Returns: Returns a pointer to the underlying data
|
||||||
@inline(__always)
|
@inline(__always)
|
||||||
public func withUnsafePointerToSlice<T>(
|
public func withUnsafePointerToSlice<T>(
|
||||||
at off: Int32,
|
at off: VOffset,
|
||||||
body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T?
|
body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T?
|
||||||
{
|
{
|
||||||
let o = offset(off)
|
let o = offset(off)
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ public struct Property: NativeStruct, FlatbuffersVectorInitializable, Verifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Property: Encodable {
|
extension Property: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case property = "property"
|
case property = "property"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if property != false {
|
if property != false {
|
||||||
@@ -83,16 +83,14 @@ public struct TestMutatingBool: FlatBufferTable, FlatbuffersVectorInitializable,
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case b = 4
|
static let b: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var b: Property? { let o = _accessor.offset(VTOFFSET.b.v); return o == 0 ? nil : _accessor.readBuffer(of: Property.self, at: o) }
|
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(VTOFFSET.b.v); return o == 0 ? nil : Property_Mutable(_accessor.bb, o: o + _accessor.position) }
|
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 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 endTestMutatingBool(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createTestMutatingBool(
|
public static func createTestMutatingBool(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension TestMutatingBool: Encodable {
|
extension TestMutatingBool: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case b = "b"
|
case b = "b"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(b, forKey: .b)
|
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, *)
|
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
||||||
extension MyGame_Example_NestedStruct: Encodable {
|
extension MyGame_Example_NestedStruct: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case a = "a"
|
case a = "a"
|
||||||
case b = "b"
|
case b = "b"
|
||||||
case c = "c"
|
case c = "c"
|
||||||
case d = "d"
|
case d = "d"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
var aContainer = container.nestedUnkeyedContainer(forKey: .a)
|
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, *)
|
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
||||||
extension MyGame_Example_ArrayStruct: Encodable {
|
extension MyGame_Example_ArrayStruct: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case a = "a"
|
case a = "a"
|
||||||
case b = "b"
|
case b = "b"
|
||||||
@@ -215,6 +214,7 @@ extension MyGame_Example_ArrayStruct: Encodable {
|
|||||||
case e = "e"
|
case e = "e"
|
||||||
case f = "f"
|
case f = "f"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if a != 0.0 {
|
if a != 0.0 {
|
||||||
@@ -287,16 +287,14 @@ public struct MyGame_Example_ArrayTable: FlatBufferTable, FlatbuffersVectorIniti
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case a = 4
|
static let a: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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(VTOFFSET.a.v); return o == 0 ? nil : MyGame_Example_ArrayStruct_Mutable(_accessor.bb, o: o + _accessor.position) }
|
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 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 endArrayTable(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createArrayTable(
|
public static func createArrayTable(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
@available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, *)
|
||||||
extension MyGame_Example_ArrayTable: Encodable {
|
extension MyGame_Example_ArrayTable: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case a = "a"
|
case a = "a"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(a, forKey: .a)
|
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 }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case ints = 4
|
static let ints: VOffset = 4
|
||||||
case floats = 6
|
static let floats: VOffset = 6
|
||||||
case emptyString = 8
|
static let emptyString: VOffset = 8
|
||||||
case someString = 10
|
static let someString: VOffset = 10
|
||||||
case abcs = 12
|
static let abcs: VOffset = 12
|
||||||
case bools = 14
|
static let bools: VOffset = 14
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var ints: FlatbufferVector<Int32> { return _accessor.vector(at: VTOFFSET.ints.v, byteSize: 4) }
|
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: VTOFFSET.ints.v, body: body) }
|
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: VTOFFSET.floats.v, byteSize: 4) }
|
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: VTOFFSET.floats.v, body: body) }
|
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(VTOFFSET.emptyString.v); return o == 0 ? "" : _accessor.string(at: o) }
|
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: VTOFFSET.emptyString.v) }
|
public var emptyStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.emptyString) }
|
||||||
public var someString: String? { let o = _accessor.offset(VTOFFSET.someString.v); return o == 0 ? "some" : _accessor.string(at: o) }
|
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: VTOFFSET.someString.v) }
|
public var someStringSegmentArray: [UInt8]? { return _accessor.getVector(at: VT.someString) }
|
||||||
public var abcs: FlatbufferVector<ABC> { return _accessor.vector(at: VTOFFSET.abcs.v, byteSize: 4) }
|
public var abcs: FlatbufferVector<ABC> { return _accessor.vector(at: VT.abcs, byteSize: 4) }
|
||||||
public var bools: FlatbufferVector<Bool> { return _accessor.vector(at: VTOFFSET.bools.v, byteSize: 1) }
|
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: VTOFFSET.bools.v, body: body) }
|
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 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(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: VTOFFSET.floats.p) }
|
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: VTOFFSET.emptyString.p) }
|
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: VTOFFSET.someString.p) }
|
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: VTOFFSET.abcs.p) }
|
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: VTOFFSET.bools.p) }
|
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 endMoreDefaults(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createMoreDefaults(
|
public static func createMoreDefaults(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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: VT.ints, 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: VT.floats, 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: VT.emptyString, 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: VT.someString, 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: VT.abcs, 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.bools, fieldName: "bools", required: false, type: ForwardOffset<Vector<Bool, Bool>>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension MoreDefaults: Encodable {
|
extension MoreDefaults: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case ints = "ints"
|
case ints = "ints"
|
||||||
case floats = "floats"
|
case floats = "floats"
|
||||||
@@ -148,6 +145,7 @@ extension MoreDefaults: Encodable {
|
|||||||
case abcs = "abcs"
|
case abcs = "abcs"
|
||||||
case bools = "bools"
|
case bools = "bools"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(ints, forKey: .ints)
|
try container.encodeIfPresent(ints, forKey: .ints)
|
||||||
|
|||||||
@@ -17,33 +17,31 @@ public struct Swift_Tests_NanInfTable: FlatBufferTable, FlatbuffersVectorInitial
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case defaultNan = 4
|
static let defaultNan: VOffset = 4
|
||||||
case defaultInf = 6
|
static let defaultInf: VOffset = 6
|
||||||
case defaultNinf = 8
|
static let defaultNinf: VOffset = 8
|
||||||
case valueNan = 10
|
static let valueNan: VOffset = 10
|
||||||
case valueInf = 12
|
static let valueInf: VOffset = 12
|
||||||
case valueNinf = 14
|
static let valueNinf: VOffset = 14
|
||||||
case value = 16
|
static let value: VOffset = 16
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var defaultNan: Double { let o = _accessor.offset(VTOFFSET.defaultNan.v); return o == 0 ? .nan : _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(VTOFFSET.defaultInf.v); return o == 0 ? .infinity : _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(VTOFFSET.defaultNinf.v); 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(VTOFFSET.valueNan.v); return o == 0 ? 0.0 : _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(VTOFFSET.valueInf.v); 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(VTOFFSET.valueNinf.v); 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(VTOFFSET.value.v); 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 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(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: VTOFFSET.defaultInf.p) }
|
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: VTOFFSET.defaultNinf.p) }
|
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: VTOFFSET.valueNan.p) }
|
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: VTOFFSET.valueInf.p) }
|
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: VTOFFSET.valueNinf.p) }
|
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: VTOFFSET.value.p) }
|
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 endNanInfTable(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createNanInfTable(
|
public static func createNanInfTable(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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: VT.defaultNan, 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: VT.defaultInf, 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: VT.defaultNinf, 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: VT.valueNan, 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: VT.valueInf, 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: VT.valueNinf, 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.value, fieldName: "value", required: false, type: Double.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Swift_Tests_NanInfTable: Encodable {
|
extension Swift_Tests_NanInfTable: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case defaultNan = "default_nan"
|
case defaultNan = "default_nan"
|
||||||
case defaultInf = "default_inf"
|
case defaultInf = "default_inf"
|
||||||
@@ -90,6 +87,7 @@ extension Swift_Tests_NanInfTable: Encodable {
|
|||||||
case valueNinf = "value_ninf"
|
case valueNinf = "value_ninf"
|
||||||
case value = "value"
|
case value = "value"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if !defaultNan.isNaN {
|
if !defaultNan.isNaN {
|
||||||
|
|||||||
@@ -42,122 +42,120 @@ public struct optional_scalars_ScalarStuff: FlatBufferTable, FlatbuffersVectorIn
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case justI8 = 4
|
static let justI8: VOffset = 4
|
||||||
case maybeI8 = 6
|
static let maybeI8: VOffset = 6
|
||||||
case defaultI8 = 8
|
static let defaultI8: VOffset = 8
|
||||||
case justU8 = 10
|
static let justU8: VOffset = 10
|
||||||
case maybeU8 = 12
|
static let maybeU8: VOffset = 12
|
||||||
case defaultU8 = 14
|
static let defaultU8: VOffset = 14
|
||||||
case justI16 = 16
|
static let justI16: VOffset = 16
|
||||||
case maybeI16 = 18
|
static let maybeI16: VOffset = 18
|
||||||
case defaultI16 = 20
|
static let defaultI16: VOffset = 20
|
||||||
case justU16 = 22
|
static let justU16: VOffset = 22
|
||||||
case maybeU16 = 24
|
static let maybeU16: VOffset = 24
|
||||||
case defaultU16 = 26
|
static let defaultU16: VOffset = 26
|
||||||
case justI32 = 28
|
static let justI32: VOffset = 28
|
||||||
case maybeI32 = 30
|
static let maybeI32: VOffset = 30
|
||||||
case defaultI32 = 32
|
static let defaultI32: VOffset = 32
|
||||||
case justU32 = 34
|
static let justU32: VOffset = 34
|
||||||
case maybeU32 = 36
|
static let maybeU32: VOffset = 36
|
||||||
case defaultU32 = 38
|
static let defaultU32: VOffset = 38
|
||||||
case justI64 = 40
|
static let justI64: VOffset = 40
|
||||||
case maybeI64 = 42
|
static let maybeI64: VOffset = 42
|
||||||
case defaultI64 = 44
|
static let defaultI64: VOffset = 44
|
||||||
case justU64 = 46
|
static let justU64: VOffset = 46
|
||||||
case maybeU64 = 48
|
static let maybeU64: VOffset = 48
|
||||||
case defaultU64 = 50
|
static let defaultU64: VOffset = 50
|
||||||
case justF32 = 52
|
static let justF32: VOffset = 52
|
||||||
case maybeF32 = 54
|
static let maybeF32: VOffset = 54
|
||||||
case defaultF32 = 56
|
static let defaultF32: VOffset = 56
|
||||||
case justF64 = 58
|
static let justF64: VOffset = 58
|
||||||
case maybeF64 = 60
|
static let maybeF64: VOffset = 60
|
||||||
case defaultF64 = 62
|
static let defaultF64: VOffset = 62
|
||||||
case justBool = 64
|
static let justBool: VOffset = 64
|
||||||
case maybeBool = 66
|
static let maybeBool: VOffset = 66
|
||||||
case defaultBool = 68
|
static let defaultBool: VOffset = 68
|
||||||
case justEnum = 70
|
static let justEnum: VOffset = 70
|
||||||
case maybeEnum = 72
|
static let maybeEnum: VOffset = 72
|
||||||
case defaultEnum = 74
|
static let defaultEnum: VOffset = 74
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var justI8: Int8 { let o = _accessor.offset(VTOFFSET.justI8.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int8.self, at: o) }
|
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(VTOFFSET.maybeI8.v); return o == 0 ? nil : _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(VTOFFSET.defaultI8.v); return o == 0 ? 42 : _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(VTOFFSET.justU8.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt8.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(VTOFFSET.maybeU8.v); return o == 0 ? nil : _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(VTOFFSET.defaultU8.v); return o == 0 ? 42 : _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(VTOFFSET.justI16.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int16.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(VTOFFSET.maybeI16.v); return o == 0 ? nil : _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(VTOFFSET.defaultI16.v); return o == 0 ? 42 : _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(VTOFFSET.justU16.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt16.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(VTOFFSET.maybeU16.v); return o == 0 ? nil : _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(VTOFFSET.defaultU16.v); return o == 0 ? 42 : _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(VTOFFSET.justI32.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.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(VTOFFSET.maybeI32.v); return o == 0 ? nil : _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(VTOFFSET.defaultI32.v); return o == 0 ? 42 : _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(VTOFFSET.justU32.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt32.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(VTOFFSET.maybeU32.v); return o == 0 ? nil : _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(VTOFFSET.defaultU32.v); return o == 0 ? 42 : _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(VTOFFSET.justI64.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.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(VTOFFSET.maybeI64.v); return o == 0 ? nil : _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(VTOFFSET.defaultI64.v); return o == 0 ? 42 : _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(VTOFFSET.justU64.v); return o == 0 ? 0 : _accessor.readBuffer(of: UInt64.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(VTOFFSET.maybeU64.v); return o == 0 ? nil : _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(VTOFFSET.defaultU64.v); return o == 0 ? 42 : _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(VTOFFSET.justF32.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Float32.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(VTOFFSET.maybeF32.v); return o == 0 ? nil : _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(VTOFFSET.defaultF32.v); return o == 0 ? 42.0 : _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(VTOFFSET.justF64.v); return o == 0 ? 0.0 : _accessor.readBuffer(of: Double.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(VTOFFSET.maybeF64.v); return o == 0 ? nil : _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(VTOFFSET.defaultF64.v); return o == 0 ? 42.0 : _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(VTOFFSET.justBool.v); return o == 0 ? false : _accessor.readBuffer(of: Bool.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(VTOFFSET.maybeBool.v); return o == 0 ? nil : _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(VTOFFSET.defaultBool.v); return o == 0 ? true : _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(VTOFFSET.justEnum.v); return o == 0 ? .none_ : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .none_ }
|
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(VTOFFSET.maybeEnum.v); return o == 0 ? nil : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? nil }
|
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(VTOFFSET.defaultEnum.v); return o == 0 ? .one : optional_scalars_OptionalByte(rawValue: _accessor.readBuffer(of: Int8.self, at: o)) ?? .one }
|
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 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(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: VTOFFSET.maybeI8.p) }
|
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: VTOFFSET.defaultI8.p) }
|
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: VTOFFSET.justU8.p) }
|
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: VTOFFSET.maybeU8.p) }
|
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: VTOFFSET.defaultU8.p) }
|
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: VTOFFSET.justI16.p) }
|
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: VTOFFSET.maybeI16.p) }
|
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: VTOFFSET.defaultI16.p) }
|
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: VTOFFSET.justU16.p) }
|
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: VTOFFSET.maybeU16.p) }
|
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: VTOFFSET.defaultU16.p) }
|
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: VTOFFSET.justI32.p) }
|
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: VTOFFSET.maybeI32.p) }
|
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: VTOFFSET.defaultI32.p) }
|
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: VTOFFSET.justU32.p) }
|
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: VTOFFSET.maybeU32.p) }
|
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: VTOFFSET.defaultU32.p) }
|
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: VTOFFSET.justI64.p) }
|
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: VTOFFSET.maybeI64.p) }
|
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: VTOFFSET.defaultI64.p) }
|
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: VTOFFSET.justU64.p) }
|
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: VTOFFSET.maybeU64.p) }
|
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: VTOFFSET.defaultU64.p) }
|
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: VTOFFSET.justF32.p) }
|
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: VTOFFSET.maybeF32.p) }
|
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: VTOFFSET.defaultF32.p) }
|
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: VTOFFSET.justF64.p) }
|
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: VTOFFSET.maybeF64.p) }
|
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: VTOFFSET.defaultF64.p) }
|
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,
|
public static func add(justBool: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: justBool, def: false,
|
||||||
at: VTOFFSET.justBool.p) }
|
at: VT.justBool) }
|
||||||
public static func add(maybeBool: Bool?, _ fbb: inout FlatBufferBuilder) { fbb.add(element: maybeBool, at: VTOFFSET.maybeBool.p) }
|
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,
|
public static func add(defaultBool: Bool, _ fbb: inout FlatBufferBuilder) { fbb.add(element: defaultBool, def: true,
|
||||||
at: VTOFFSET.defaultBool.p) }
|
at: VT.defaultBool) }
|
||||||
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(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: VTOFFSET.maybeEnum.p) }
|
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: VTOFFSET.defaultEnum.p) }
|
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 endScalarStuff(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createScalarStuff(
|
public static func createScalarStuff(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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: VT.justI8, 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: VT.maybeI8, 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: VT.defaultI8, 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: VT.justU8, 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: VT.maybeU8, 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: VT.defaultU8, 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: VT.justI16, 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: VT.maybeI16, 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: VT.defaultI16, 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: VT.justU16, 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: VT.maybeU16, 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: VT.defaultU16, 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: VT.justI32, 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: VT.maybeI32, 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: VT.defaultI32, 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: VT.justU32, 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: VT.maybeU32, 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: VT.defaultU32, 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: VT.justI64, 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: VT.maybeI64, 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: VT.defaultI64, 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: VT.justU64, 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: VT.maybeU64, 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: VT.defaultU64, 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: VT.justF32, 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: VT.maybeF32, 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: VT.defaultF32, 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: VT.justF64, 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: VT.maybeF64, 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: VT.defaultF64, 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: VT.justBool, 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: VT.maybeBool, 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: VT.defaultBool, 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: VT.justEnum, 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: VT.maybeEnum, 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.defaultEnum, fieldName: "defaultEnum", required: false, type: optional_scalars_OptionalByte.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension optional_scalars_ScalarStuff: Encodable {
|
extension optional_scalars_ScalarStuff: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case justI8 = "just_i8"
|
case justI8 = "just_i8"
|
||||||
case maybeI8 = "maybe_i8"
|
case maybeI8 = "maybe_i8"
|
||||||
@@ -320,6 +317,7 @@ extension optional_scalars_ScalarStuff: Encodable {
|
|||||||
case maybeEnum = "maybe_enum"
|
case maybeEnum = "maybe_enum"
|
||||||
case defaultEnum = "default_enum"
|
case defaultEnum = "default_enum"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if justI8 != 0 {
|
if justI8 != 0 {
|
||||||
|
|||||||
@@ -152,10 +152,10 @@ public struct Rapunzel: NativeStruct, FlatbuffersVectorInitializable, Verifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Rapunzel: Encodable {
|
extension Rapunzel: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case hairLength = "hair_length"
|
case hairLength = "hair_length"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if hairLength != 0 {
|
if hairLength != 0 {
|
||||||
@@ -218,10 +218,10 @@ public struct BookReader: NativeStruct, FlatbuffersVectorInitializable, Verifiab
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension BookReader: Encodable {
|
extension BookReader: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case booksRead = "books_read"
|
case booksRead = "books_read"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if booksRead != 0 {
|
if booksRead != 0 {
|
||||||
@@ -284,10 +284,10 @@ public struct FallingTub: NativeStruct, FlatbuffersVectorInitializable, Verifiab
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension FallingTub: Encodable {
|
extension FallingTub: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case weight = "weight"
|
case weight = "weight"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if weight != 0 {
|
if weight != 0 {
|
||||||
@@ -331,16 +331,14 @@ public struct Attacker: FlatBufferTable, FlatbuffersVectorInitializable, Verifia
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case swordAttackDamage = 4
|
static let swordAttackDamage: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var swordAttackDamage: Int32 { let o = _accessor.offset(VTOFFSET.swordAttackDamage.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: 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(VTOFFSET.swordAttackDamage.v); return _accessor.mutate(swordAttackDamage, index: 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 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 endAttacker(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createAttacker(
|
public static func createAttacker(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Attacker: Encodable {
|
extension Attacker: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case swordAttackDamage = "sword_attack_damage"
|
case swordAttackDamage = "sword_attack_damage"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if swordAttackDamage != 0 {
|
if swordAttackDamage != 0 {
|
||||||
@@ -411,16 +409,14 @@ public struct HandFan: FlatBufferTable, FlatbuffersVectorInitializable, Verifiab
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case length = 4
|
static let length: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var length: Int32 { let o = _accessor.offset(VTOFFSET.length.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: 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(VTOFFSET.length.v); return _accessor.mutate(length, index: 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 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 endHandFan(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createHandFan(
|
public static func createHandFan(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension HandFan: Encodable {
|
extension HandFan: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case length = "length"
|
case length = "length"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if length != 0 {
|
if length != 0 {
|
||||||
@@ -491,25 +487,23 @@ public struct Movie: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case mainCharacterType = 4
|
static let mainCharacterType: VOffset = 4
|
||||||
case mainCharacter = 6
|
static let mainCharacter: VOffset = 6
|
||||||
case charactersType = 8
|
static let charactersType: VOffset = 8
|
||||||
case characters = 10
|
static let characters: VOffset = 10
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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(VTOFFSET.mainCharacter.v); return o == 0 ? nil : _accessor.union(o) }
|
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: VTOFFSET.charactersType.v, byteSize: 1) }
|
public var charactersType: FlatbufferVector<Character> { return _accessor.vector(at: VT.charactersType, byteSize: 1) }
|
||||||
public var characters: UnionFlatbufferVector { return _accessor.unionVector(at: VTOFFSET.characters.v, byteSize: 4) }
|
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(VTOFFSET.characters.v); return o == 0 ? nil : _accessor.directUnion(_accessor.vector(at: o) + index * 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 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(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: VTOFFSET.mainCharacter.p) }
|
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: VTOFFSET.charactersType.p) }
|
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: VTOFFSET.characters.p) }
|
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 endMovie(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createMovie(
|
public static func createMovie(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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 {
|
switch key {
|
||||||
case .none_:
|
case .none_:
|
||||||
break // NOTE - SWIFT doesnt support 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 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 {
|
switch key {
|
||||||
case .none_:
|
case .none_:
|
||||||
break // NOTE - SWIFT doesnt support none
|
break // NOTE - SWIFT doesnt support none
|
||||||
@@ -597,13 +591,13 @@ public struct Movie: FlatBufferTable, FlatbuffersVectorInitializable, Verifiable
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Movie: Encodable {
|
extension Movie: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case mainCharacterType = "main_character_type"
|
case mainCharacterType = "main_character_type"
|
||||||
case mainCharacter = "main_character"
|
case mainCharacter = "main_character"
|
||||||
case charactersType = "characters_type"
|
case charactersType = "characters_type"
|
||||||
case characters = "characters"
|
case characters = "characters"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if mainCharacterType != .none_ {
|
if mainCharacterType != .none_ {
|
||||||
|
|||||||
@@ -17,24 +17,22 @@ public struct Swift_Tests_Vectors: FlatBufferTable, FlatbuffersVectorInitializab
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case none_ = 4
|
static let none_: VOffset = 4
|
||||||
case empty = 6
|
static let empty: VOffset = 6
|
||||||
case array = 8
|
static let array: VOffset = 8
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var none_: FlatbufferVector<UInt64> { return _accessor.vector(at: VTOFFSET.none_.v, byteSize: 8) }
|
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: VTOFFSET.none_.v, body: body) }
|
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: VTOFFSET.empty.v, byteSize: 8) }
|
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: VTOFFSET.empty.v, body: body) }
|
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: VTOFFSET.array.v, byteSize: 8) }
|
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: VTOFFSET.array.v, body: body) }
|
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 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(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: VTOFFSET.empty.p) }
|
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: VTOFFSET.array.p) }
|
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 endVectors(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createVectors(
|
public static func createVectors(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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: VT.none_, 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: VT.empty, 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.array, fieldName: "array", required: false, type: ForwardOffset<Vector<UInt64, UInt64>>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Swift_Tests_Vectors: Encodable {
|
extension Swift_Tests_Vectors: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case none_ = "none"
|
case none_ = "none"
|
||||||
case empty = "empty"
|
case empty = "empty"
|
||||||
case array = "array"
|
case array = "array"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(none_, forKey: .none_)
|
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 }
|
private init(_ t: Table) { _accessor = t }
|
||||||
internal init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
internal init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case internalMessage = 4
|
static let internalMessage: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal var internalMessage: String? { let o = _accessor.offset(VTOFFSET.internalMessage.v); return o == 0 ? nil : _accessor.string(at: o) }
|
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: VTOFFSET.internalMessage.v) }
|
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 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 endMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
internal static func createMessage(
|
internal static func createMessage(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Message: Encodable {
|
extension Message: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case internalMessage = "internal_message"
|
case internalMessage = "internal_message"
|
||||||
}
|
}
|
||||||
|
|
||||||
internal func encode(to encoder: Encoder) throws {
|
internal func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(internalMessage, forKey: .internalMessage)
|
try container.encodeIfPresent(internalMessage, forKey: .internalMessage)
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ public struct BytesCount: NativeStruct, FlatbuffersVectorInitializable, Verifiab
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension BytesCount: Encodable {
|
extension BytesCount: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case x = "x"
|
case x = "x"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if x != 0 {
|
if x != 0 {
|
||||||
@@ -77,16 +77,14 @@ public struct InternalMessage: FlatBufferTable, FlatbuffersVectorInitializable,
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case str = 4
|
static let str: VOffset = 4
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var str: String? { let o = _accessor.offset(VTOFFSET.str.v); return o == 0 ? nil : _accessor.string(at: o) }
|
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: VTOFFSET.str.v) }
|
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 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 endInternalMessage(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
||||||
public static func createInternalMessage(
|
public static func createInternalMessage(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension InternalMessage: Encodable {
|
extension InternalMessage: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case str = "str"
|
case str = "str"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
try container.encodeIfPresent(str, forKey: .str)
|
try container.encodeIfPresent(str, forKey: .str)
|
||||||
@@ -159,23 +157,21 @@ public struct Message: FlatBufferTable, FlatbuffersVectorInitializable, Verifiab
|
|||||||
private init(_ t: Table) { _accessor = t }
|
private init(_ t: Table) { _accessor = t }
|
||||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||||
|
|
||||||
private enum VTOFFSET: VOffset {
|
private struct VT {
|
||||||
case id = 4
|
static let id: VOffset = 4
|
||||||
case position = 6
|
static let position: VOffset = 6
|
||||||
case pointer = 8
|
static let pointer: VOffset = 8
|
||||||
var v: Int32 { Int32(self.rawValue) }
|
|
||||||
var p: VOffset { self.rawValue }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public var id: Int64 { let o = _accessor.offset(VTOFFSET.id.v); return o == 0 ? 0 : _accessor.readBuffer(of: Int64.self, at: o) }
|
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(VTOFFSET.id.v); return _accessor.mutate(id, index: 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(VTOFFSET.position.v); return _accessor.readBuffer(of: BytesCount.self, at: 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(VTOFFSET.position.v); return BytesCount_Mutable(_accessor.bb, o: o + _accessor.position) }
|
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(VTOFFSET.pointer.v); return InternalMessage(_accessor.bb, o: _accessor.indirect(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 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(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: VTOFFSET.position.p) }
|
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: VTOFFSET.pointer.p) }
|
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 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(
|
public static func createMessage(
|
||||||
_ fbb: inout FlatBufferBuilder,
|
_ 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 {
|
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)
|
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: VT.id, 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: VT.position, 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.pointer, fieldName: "pointer", required: true, type: ForwardOffset<InternalMessage>.self)
|
||||||
_v.finish()
|
_v.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Message: Encodable {
|
extension Message: Encodable {
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case id = "id"
|
case id = "id"
|
||||||
case position = "position"
|
case position = "position"
|
||||||
case pointer = "pointer"
|
case pointer = "pointer"
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||||
if id != 0 {
|
if id != 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user