From b177e50b15611f2dd6cb74d7f8aa85f44d23c37e Mon Sep 17 00:00:00 2001 From: Alex Gerveshi Date: Tue, 1 Sep 2026 08:05:57 -0700 Subject: [PATCH] Remove AsBuffer accessors and regenerate test code --- .yamato/Build.yml | 17 +++++ src/idl_gen_swift.cpp | 7 --- swift/Sources/FlatBuffers/Table.swift | 16 ----- .../Flatbuffers/monster_test_generated.swift | 62 ++++++++++--------- .../monster_test_generated.swift | 62 ++++++++++--------- tests/union_vector/union_vector_generated.h | 27 -------- 6 files changed, 85 insertions(+), 106 deletions(-) diff --git a/.yamato/Build.yml b/.yamato/Build.yml index 04a79a464f..fac97b4799 100644 --- a/.yamato/Build.yml +++ b/.yamato/Build.yml @@ -4,6 +4,7 @@ all: - .yamato/Build.yml#build_linux - .yamato/Build.yml#build_windows - .yamato/Build.yml#build_osx_universal + - .yamato/Build.yml#check_generated_code build_linux: name: Build - Linux @@ -54,3 +55,19 @@ build_osx_universal: reported_artifacts: paths: - Release/flatc + +check_generated_code: + name: Check - Generated Code + agent: + type: Unity::VM + image: platform-foundation/linux-ubuntu-18.04-mono-bokken:0.1.7-978398 + flavor: b1.xlarge + config: + env_vars: + - PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin + commands: + - cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF + - cmake --build . --config Release + - python3 scripts/check_generate_code.py + - python3 scripts/check-grpc-generated-code.py + timeout: 30 diff --git a/src/idl_gen_swift.cpp b/src/idl_gen_swift.cpp index 41b003c657..64091f99d0 100644 --- a/src/idl_gen_swift.cpp +++ b/src/idl_gen_swift.cpp @@ -912,9 +912,6 @@ class SwiftGenerator : public BaseGenerator { if (IsScalar(vectortype.base_type) && !IsEnum(vectortype) && !IsBool(field.value.type.base_type)) { - code_ += - "{{ACCESS_TYPE}} var {{FIELDVAR}}AsBuffer: UnsafeBufferPointer<{{VALUETYPE}}>? { return " - "{{ACCESS}}.getBufferPointer(at: {{TABLEOFFSET}}.{{OFFSET}}.v) }"; if (parser_.opts.mutable_buffer) code_ += GenMutateArray(); GenUnsafeBufferPointer(field); return; @@ -922,10 +919,6 @@ class SwiftGenerator : public BaseGenerator { if (vectortype.base_type == BASE_TYPE_STRUCT && field.value.type.struct_def->fixed) { - // do this before we swap to mutable, we don't want the mutable version - code_ += - "{{ACCESS_TYPE}} var {{FIELDVAR}}AsBuffer: UnsafeBufferPointer<{{VALUETYPE}}>? { return " - "{{ACCESS}}.getBufferPointer(at: {{TABLEOFFSET}}.{{OFFSET}}.v) }"; code_.SetValue("FIELDVAR", namer_.Method("mutable", field)); code_ += "{{ACCESS_TYPE}} var {{FIELDVAR}}: " diff --git a/swift/Sources/FlatBuffers/Table.swift b/swift/Sources/FlatBuffers/Table.swift index ed5379832e..4aa08d576f 100644 --- a/swift/Sources/FlatBuffers/Table.swift +++ b/swift/Sources/FlatBuffers/Table.swift @@ -112,22 +112,6 @@ public struct Table { return bb.readSlice(index: Int(vector(at: o)), count: Int(vector(count: o))) } - /// Returns an UnsafeBufferPointer of type T direct to the memory inside the buffer - public func getBufferPointer(at off: Int32) -> UnsafeBufferPointer? { - let o = offset(off) - guard o != 0 else { return nil } - let bufOffset = Int(vector(at: o)) - let count = Int(vector(count: o)) - return bb.withUnsafePointerToSlice( - index: bufOffset, - count: count &* MemoryLayout.stride) - { rawBuffer in - UnsafeBufferPointer( - start: rawBuffer.baseAddress?.assumingMemoryBound(to: T.self), - count: count) - } - } - public func vector(at off: Int32, byteSize: Int) -> FlatbufferVector { let off = offset(off) return FlatbufferVector( diff --git a/tests/swift/Tests/Flatbuffers/monster_test_generated.swift b/tests/swift/Tests/Flatbuffers/monster_test_generated.swift index 1702d81587..432a4f6ec6 100644 --- a/tests/swift/Tests/Flatbuffers/monster_test_generated.swift +++ b/tests/swift/Tests/Flatbuffers/monster_test_generated.swift @@ -9,29 +9,32 @@ import Common import FlatBuffers /// Composite components of Monster color. -public enum MyGame_Example_Color: UInt8, FlatbuffersVectorInitializable, Enum, Verifiable { +public struct MyGame_Example_Color: OptionSet, Enum, Verifiable { public typealias T = UInt8 + public let rawValue: T + + public init(rawValue: T) { + self.rawValue = rawValue + } + public static var byteSize: Int { return MemoryLayout.size } public var value: UInt8 { return self.rawValue } - case red = 1 + public static let red = MyGame_Example_Color(rawValue: 1) /// \brief color Green /// Green is bit_flag with value (1u << 1) - case green = 2 + public static let green = MyGame_Example_Color(rawValue: 2) /// \brief color Blue (1u << 3) - case blue = 8 + public static let blue = MyGame_Example_Color(rawValue: 8) - public static var max: MyGame_Example_Color { return .blue } - public static var min: MyGame_Example_Color { return .red } + public static let none: MyGame_Example_Color = [] + public static let all: MyGame_Example_Color = [.red, .green, .blue] + public static var min: MyGame_Example_Color { [] } } extension MyGame_Example_Color: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() - switch self { - case .red: try container.encode("Red") - case .green: try container.encode("Green") - case .blue: try container.encode("Blue") - } + try container.encode(rawValue) } } @@ -60,26 +63,29 @@ extension MyGame_Example_Race: Encodable { } } -public enum MyGame_Example_LongEnum: UInt64, FlatbuffersVectorInitializable, Enum, Verifiable { +public struct MyGame_Example_LongEnum: OptionSet, Enum, Verifiable { public typealias T = UInt64 + public let rawValue: T + + public init(rawValue: T) { + self.rawValue = rawValue + } + public static var byteSize: Int { return MemoryLayout.size } public var value: UInt64 { return self.rawValue } - case longone = 2 - case longtwo = 4 - case longbig = 1099511627776 + public static let longone = MyGame_Example_LongEnum(rawValue: 2) + public static let longtwo = MyGame_Example_LongEnum(rawValue: 4) + public static let longbig = MyGame_Example_LongEnum(rawValue: 1099511627776) - public static var max: MyGame_Example_LongEnum { return .longbig } - public static var min: MyGame_Example_LongEnum { return .longone } + public static let none: MyGame_Example_LongEnum = [] + public static let all: MyGame_Example_LongEnum = [.longone, .longtwo, .longbig] + public static var min: MyGame_Example_LongEnum { [] } } extension MyGame_Example_LongEnum: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() - switch self { - case .longone: try container.encode("LongOne") - case .longtwo: try container.encode("LongTwo") - case .longbig: try container.encode("LongBig") - } + try container.encode(rawValue) } } @@ -367,7 +373,7 @@ public struct MyGame_Example_Vec3: NativeStruct, FlatbuffersVectorInitializable, public var y: Float32 { _y } public var z: Float32 { _z } public var test1: Double { _test1 } - public var test2: MyGame_Example_Color { MyGame_Example_Color(rawValue: _test2)! } + public var test2: MyGame_Example_Color { MyGame_Example_Color(rawValue: _test2) } public var test3: MyGame_Example_Test { _test3 } public static func verify(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable { @@ -422,7 +428,7 @@ public struct MyGame_Example_Vec3_Mutable: FlatBufferStruct, FlatbuffersVectorIn @discardableResult public func mutate(z: Float32) -> Bool { return _accessor.mutate(z, index: 8) } public var test1: Double { return _accessor.readBuffer(of: Double.self, at: 16) } @discardableResult public func mutate(test1: Double) -> Bool { return _accessor.mutate(test1, index: 16) } - public var test2: MyGame_Example_Color { return MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: 24)) ?? .red } + public var test2: MyGame_Example_Color { return MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: 24)) } @discardableResult public func mutate(test2: MyGame_Example_Color) -> Bool { return _accessor.mutate(test2.rawValue, index: 24) } public var test3: MyGame_Example_Test_Mutable { return MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.position + 26) } @@ -781,7 +787,7 @@ internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferTable, Flatbuf var p: VOffset { self.rawValue } } - internal var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .green : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .green } + internal var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .green : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) } @discardableResult internal func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) } internal static func startTestSimpleTableWithEnum(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) } internal static func add(color: MyGame_Example_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) } @@ -1175,7 +1181,7 @@ public struct MyGame_Example_Monster: FlatBufferTable, FlatbuffersVectorInitiali public var inventory: FlatbufferVector { return _accessor.vector(at: VTOFFSET.inventory.v, 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 withUnsafePointerToInventory(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.inventory.v, body: body) } - public var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .blue } + public var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) } @discardableResult public func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) } public var testType: MyGame_Example_Any_ { let o = _accessor.offset(VTOFFSET.testType.v); return o == 0 ? .none_ : MyGame_Example_Any_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ } public func test(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.test.v); return o == 0 ? nil : _accessor.union(o) } @@ -1269,9 +1275,9 @@ public struct MyGame_Example_Monster: FlatBufferTable, FlatbuffersVectorInitiali public func scalarKeySortedTablesBy(key: UInt16) -> MyGame_Example_Stat? { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? nil : MyGame_Example_Stat.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) } public var nativeInline: MyGame_Example_Test? { let o = _accessor.offset(VTOFFSET.nativeInline.v); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Example_Test.self, at: o) } public var mutableNativeInline: MyGame_Example_Test_Mutable? { let o = _accessor.offset(VTOFFSET.nativeInline.v); return o == 0 ? nil : MyGame_Example_Test_Mutable(_accessor.bb, o: o + _accessor.position) } - public var longEnumNonEnumDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNonEnumDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) ?? .longone } + public var longEnumNonEnumDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNonEnumDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) } @discardableResult public func mutate(longEnumNonEnumDefault: MyGame_Example_LongEnum) -> Bool {let o = _accessor.offset(VTOFFSET.longEnumNonEnumDefault.v); return _accessor.mutate(longEnumNonEnumDefault.rawValue, index: o) } - public var longEnumNormalDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNormalDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) ?? .longone } + public var longEnumNormalDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNormalDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) } @discardableResult public func mutate(longEnumNormalDefault: MyGame_Example_LongEnum) -> Bool {let o = _accessor.offset(VTOFFSET.longEnumNormalDefault.v); return _accessor.mutate(longEnumNormalDefault.rawValue, index: o) } public var nanDefault: Float32 { let o = _accessor.offset(VTOFFSET.nanDefault.v); return o == 0 ? .nan : _accessor.readBuffer(of: Float32.self, at: o) } @discardableResult public func mutate(nanDefault: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.nanDefault.v); return _accessor.mutate(nanDefault, index: o) } diff --git a/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift b/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift index 1702d81587..432a4f6ec6 100644 --- a/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift +++ b/tests/swift/Wasm.tests/Tests/FlatBuffers.Test.Swift.WasmTests/monster_test_generated.swift @@ -9,29 +9,32 @@ import Common import FlatBuffers /// Composite components of Monster color. -public enum MyGame_Example_Color: UInt8, FlatbuffersVectorInitializable, Enum, Verifiable { +public struct MyGame_Example_Color: OptionSet, Enum, Verifiable { public typealias T = UInt8 + public let rawValue: T + + public init(rawValue: T) { + self.rawValue = rawValue + } + public static var byteSize: Int { return MemoryLayout.size } public var value: UInt8 { return self.rawValue } - case red = 1 + public static let red = MyGame_Example_Color(rawValue: 1) /// \brief color Green /// Green is bit_flag with value (1u << 1) - case green = 2 + public static let green = MyGame_Example_Color(rawValue: 2) /// \brief color Blue (1u << 3) - case blue = 8 + public static let blue = MyGame_Example_Color(rawValue: 8) - public static var max: MyGame_Example_Color { return .blue } - public static var min: MyGame_Example_Color { return .red } + public static let none: MyGame_Example_Color = [] + public static let all: MyGame_Example_Color = [.red, .green, .blue] + public static var min: MyGame_Example_Color { [] } } extension MyGame_Example_Color: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() - switch self { - case .red: try container.encode("Red") - case .green: try container.encode("Green") - case .blue: try container.encode("Blue") - } + try container.encode(rawValue) } } @@ -60,26 +63,29 @@ extension MyGame_Example_Race: Encodable { } } -public enum MyGame_Example_LongEnum: UInt64, FlatbuffersVectorInitializable, Enum, Verifiable { +public struct MyGame_Example_LongEnum: OptionSet, Enum, Verifiable { public typealias T = UInt64 + public let rawValue: T + + public init(rawValue: T) { + self.rawValue = rawValue + } + public static var byteSize: Int { return MemoryLayout.size } public var value: UInt64 { return self.rawValue } - case longone = 2 - case longtwo = 4 - case longbig = 1099511627776 + public static let longone = MyGame_Example_LongEnum(rawValue: 2) + public static let longtwo = MyGame_Example_LongEnum(rawValue: 4) + public static let longbig = MyGame_Example_LongEnum(rawValue: 1099511627776) - public static var max: MyGame_Example_LongEnum { return .longbig } - public static var min: MyGame_Example_LongEnum { return .longone } + public static let none: MyGame_Example_LongEnum = [] + public static let all: MyGame_Example_LongEnum = [.longone, .longtwo, .longbig] + public static var min: MyGame_Example_LongEnum { [] } } extension MyGame_Example_LongEnum: Encodable { public func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() - switch self { - case .longone: try container.encode("LongOne") - case .longtwo: try container.encode("LongTwo") - case .longbig: try container.encode("LongBig") - } + try container.encode(rawValue) } } @@ -367,7 +373,7 @@ public struct MyGame_Example_Vec3: NativeStruct, FlatbuffersVectorInitializable, public var y: Float32 { _y } public var z: Float32 { _z } public var test1: Double { _test1 } - public var test2: MyGame_Example_Color { MyGame_Example_Color(rawValue: _test2)! } + public var test2: MyGame_Example_Color { MyGame_Example_Color(rawValue: _test2) } public var test3: MyGame_Example_Test { _test3 } public static func verify(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable { @@ -422,7 +428,7 @@ public struct MyGame_Example_Vec3_Mutable: FlatBufferStruct, FlatbuffersVectorIn @discardableResult public func mutate(z: Float32) -> Bool { return _accessor.mutate(z, index: 8) } public var test1: Double { return _accessor.readBuffer(of: Double.self, at: 16) } @discardableResult public func mutate(test1: Double) -> Bool { return _accessor.mutate(test1, index: 16) } - public var test2: MyGame_Example_Color { return MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: 24)) ?? .red } + public var test2: MyGame_Example_Color { return MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: 24)) } @discardableResult public func mutate(test2: MyGame_Example_Color) -> Bool { return _accessor.mutate(test2.rawValue, index: 24) } public var test3: MyGame_Example_Test_Mutable { return MyGame_Example_Test_Mutable(_accessor.bb, o: _accessor.position + 26) } @@ -781,7 +787,7 @@ internal struct MyGame_Example_TestSimpleTableWithEnum: FlatBufferTable, Flatbuf var p: VOffset { self.rawValue } } - internal var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .green : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .green } + internal var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .green : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) } @discardableResult internal func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) } internal static func startTestSimpleTableWithEnum(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) } internal static func add(color: MyGame_Example_Color, _ fbb: inout FlatBufferBuilder) { fbb.add(element: color.rawValue, def: 2, at: VTOFFSET.color.p) } @@ -1175,7 +1181,7 @@ public struct MyGame_Example_Monster: FlatBufferTable, FlatbuffersVectorInitiali public var inventory: FlatbufferVector { return _accessor.vector(at: VTOFFSET.inventory.v, 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 withUnsafePointerToInventory(_ body: (UnsafeRawBufferPointer, Int) throws -> T) rethrows -> T? { return try _accessor.withUnsafePointerToSlice(at: VTOFFSET.inventory.v, body: body) } - public var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .blue } + public var color: MyGame_Example_Color { let o = _accessor.offset(VTOFFSET.color.v); return o == 0 ? .blue : MyGame_Example_Color(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) } @discardableResult public func mutate(color: MyGame_Example_Color) -> Bool {let o = _accessor.offset(VTOFFSET.color.v); return _accessor.mutate(color.rawValue, index: o) } public var testType: MyGame_Example_Any_ { let o = _accessor.offset(VTOFFSET.testType.v); return o == 0 ? .none_ : MyGame_Example_Any_(rawValue: _accessor.readBuffer(of: UInt8.self, at: o)) ?? .none_ } public func test(type: T.Type) -> T? { let o = _accessor.offset(VTOFFSET.test.v); return o == 0 ? nil : _accessor.union(o) } @@ -1269,9 +1275,9 @@ public struct MyGame_Example_Monster: FlatBufferTable, FlatbuffersVectorInitiali public func scalarKeySortedTablesBy(key: UInt16) -> MyGame_Example_Stat? { let o = _accessor.offset(VTOFFSET.scalarKeySortedTables.v); return o == 0 ? nil : MyGame_Example_Stat.lookupByKey(vector: _accessor.vector(at: o), key: key, fbb: _accessor.bb) } public var nativeInline: MyGame_Example_Test? { let o = _accessor.offset(VTOFFSET.nativeInline.v); return o == 0 ? nil : _accessor.readBuffer(of: MyGame_Example_Test.self, at: o) } public var mutableNativeInline: MyGame_Example_Test_Mutable? { let o = _accessor.offset(VTOFFSET.nativeInline.v); return o == 0 ? nil : MyGame_Example_Test_Mutable(_accessor.bb, o: o + _accessor.position) } - public var longEnumNonEnumDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNonEnumDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) ?? .longone } + public var longEnumNonEnumDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNonEnumDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) } @discardableResult public func mutate(longEnumNonEnumDefault: MyGame_Example_LongEnum) -> Bool {let o = _accessor.offset(VTOFFSET.longEnumNonEnumDefault.v); return _accessor.mutate(longEnumNonEnumDefault.rawValue, index: o) } - public var longEnumNormalDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNormalDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) ?? .longone } + public var longEnumNormalDefault: MyGame_Example_LongEnum { let o = _accessor.offset(VTOFFSET.longEnumNormalDefault.v); return o == 0 ? .longone : MyGame_Example_LongEnum(rawValue: _accessor.readBuffer(of: UInt64.self, at: o)) } @discardableResult public func mutate(longEnumNormalDefault: MyGame_Example_LongEnum) -> Bool {let o = _accessor.offset(VTOFFSET.longEnumNormalDefault.v); return _accessor.mutate(longEnumNormalDefault.rawValue, index: o) } public var nanDefault: Float32 { let o = _accessor.offset(VTOFFSET.nanDefault.v); return o == 0 ? .nan : _accessor.readBuffer(of: Float32.self, at: o) } @discardableResult public func mutate(nanDefault: Float32) -> Bool {let o = _accessor.offset(VTOFFSET.nanDefault.v); return _accessor.mutate(nanDefault, index: o) } diff --git a/tests/union_vector/union_vector_generated.h b/tests/union_vector/union_vector_generated.h index b2e1de568d..25a0d332be 100644 --- a/tests/union_vector/union_vector_generated.h +++ b/tests/union_vector/union_vector_generated.h @@ -360,9 +360,6 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) Rapunzel FLATBUFFERS_FINAL_CLASS { static const ::flatbuffers::TypeTable *MiniReflectTypeTable() { return RapunzelTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "Rapunzel"; - } Rapunzel() : hair_length_(0) { } @@ -400,9 +397,6 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) BookReader FLATBUFFERS_FINAL_CLASS { static const ::flatbuffers::TypeTable *MiniReflectTypeTable() { return BookReaderTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "BookReader"; - } BookReader() : books_read_(0) { } @@ -440,9 +434,6 @@ FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(4) FallingTub FLATBUFFERS_FINAL_CLASS { static const ::flatbuffers::TypeTable *MiniReflectTypeTable() { return FallingTubTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "FallingTub"; - } FallingTub() : weight_(0) { } @@ -474,9 +465,6 @@ inline H AbslHashValue(H h, const FallingTub &obj) { struct AttackerT : public ::flatbuffers::NativeTable { typedef Attacker TableType; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "AttackerT"; - } int32_t sword_attack_damage = 0; }; @@ -486,9 +474,6 @@ struct Attacker FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { static const ::flatbuffers::TypeTable *MiniReflectTypeTable() { return AttackerTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "Attacker"; - } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_SWORD_ATTACK_DAMAGE = 4 }; @@ -539,9 +524,6 @@ ::flatbuffers::Offset CreateAttacker(::flatbuffers::FlatBufferBuilder struct HandFanT : public ::flatbuffers::NativeTable { typedef HandFan TableType; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "HandFanT"; - } int32_t length = 0; }; @@ -551,9 +533,6 @@ struct HandFan FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { static const ::flatbuffers::TypeTable *MiniReflectTypeTable() { return HandFanTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "HandFan"; - } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_LENGTH = 4 }; @@ -604,9 +583,6 @@ ::flatbuffers::Offset CreateHandFan(::flatbuffers::FlatBufferBuilder &_ struct MovieT : public ::flatbuffers::NativeTable { typedef Movie TableType; - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "MovieT"; - } CharacterUnion main_character{}; std::vector characters{}; }; @@ -617,9 +593,6 @@ struct Movie FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { static const ::flatbuffers::TypeTable *MiniReflectTypeTable() { return MovieTypeTable(); } - static FLATBUFFERS_CONSTEXPR_CPP11 const char *GetFullyQualifiedName() { - return "Movie"; - } enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_MAIN_CHARACTER_TYPE = 4, VT_MAIN_CHARACTER = 6,