mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +00:00
* Migrate to swift 6.0 & swift-gRPC 2.0 The following migrates to swift 6.0, and also migrate to swift-grpc 2.0 that uses swift-nio under the hood to provide nicer API and async await Adds sendable to enum & update @_implementationOnly imports to use internal imports * Address PR comments regarding misspelling & proper method naming.
151 lines
4.9 KiB
Swift
151 lines
4.9 KiB
Swift
// 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 Property: NativeStruct, FlatbuffersVectorInitializable, Verifiable, FlatbuffersInitializable, NativeObject {
|
|
|
|
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
|
|
|
private var _property: Bool
|
|
|
|
public init(_ bb: ByteBuffer, o: Int32) {
|
|
self = bb.read(def: Self.self, position: Int(o))
|
|
}
|
|
|
|
public init(property: Bool) {
|
|
_property = property
|
|
}
|
|
|
|
public init() {
|
|
_property = false
|
|
}
|
|
|
|
public init(_ _t: borrowing Property_Mutable) {
|
|
_property = _t.property
|
|
}
|
|
|
|
public var property: Bool { _property }
|
|
|
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
|
try verifier.inBuffer(position: position, of: Property.self)
|
|
}
|
|
}
|
|
|
|
extension Property: Encodable {
|
|
enum CodingKeys: String, CodingKey {
|
|
case property = "property"
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
if property != false {
|
|
try container.encodeIfPresent(property, forKey: .property)
|
|
}
|
|
}
|
|
}
|
|
|
|
public struct Property_Mutable: FlatBufferStruct, FlatbuffersVectorInitializable {
|
|
|
|
static func validateVersion() { FlatBuffersVersion_25_12_19() }
|
|
public var __buffer: ByteBuffer! { return _accessor.bb }
|
|
private var _accessor: Struct
|
|
|
|
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Struct(bb: bb, position: o) }
|
|
|
|
public var property: Bool { return _accessor.readBuffer(of: Bool.self, at: 0) }
|
|
@discardableResult public func mutate(property: Bool) -> Bool { return _accessor.mutate(property, index: 0) }
|
|
|
|
public func unpack() -> Property {
|
|
return Property(self)
|
|
}
|
|
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout Property?) -> Offset {
|
|
guard var obj = obj else { return Offset() }
|
|
return pack(&builder, obj: &obj)
|
|
}
|
|
|
|
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout Property) -> Offset {
|
|
return builder.create(struct: obj)
|
|
}
|
|
}
|
|
|
|
public struct TestMutatingBool: FlatBufferVerifiableTable, FlatbuffersVectorInitializable, 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 {
|
|
static let b: VOffset = 4
|
|
}
|
|
|
|
public var b: Property? { let o = _accessor.offset(VT.b); return o == 0 ? nil : _accessor.readBuffer(of: Property.self, at: o) }
|
|
public var mutableB: Property_Mutable? { let o = _accessor.offset(VT.b); return o == 0 ? nil : Property_Mutable(_accessor.bb, o: o + _accessor.position) }
|
|
public static func startTestMutatingBool(_ fbb: inout FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
|
public static func add(b: Property?, _ fbb: inout FlatBufferBuilder) { guard let b = b else { return }; fbb.create(struct: b, position: VT.b) }
|
|
public static func endTestMutatingBool(_ fbb: inout FlatBufferBuilder, start: UOffset) -> Offset { let end = Offset(offset: fbb.endTable(at: start)); return end }
|
|
public static func createTestMutatingBool(
|
|
_ fbb: inout FlatBufferBuilder,
|
|
b: Property? = nil
|
|
) -> Offset {
|
|
let __start = TestMutatingBool.startTestMutatingBool(&fbb)
|
|
TestMutatingBool.add(b: b, &fbb)
|
|
return TestMutatingBool.endTestMutatingBool(&fbb, start: __start)
|
|
}
|
|
|
|
public func unpack() -> TestMutatingBoolT {
|
|
return TestMutatingBoolT(self)
|
|
}
|
|
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout TestMutatingBoolT?) -> Offset {
|
|
guard var obj = obj else { return Offset() }
|
|
return pack(&builder, obj: &obj)
|
|
}
|
|
|
|
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout TestMutatingBoolT) -> Offset {
|
|
let __root = TestMutatingBool.startTestMutatingBool(&builder)
|
|
TestMutatingBool.add(b: obj.b, &builder)
|
|
return TestMutatingBool.endTestMutatingBool(&builder, start: __root)
|
|
}
|
|
|
|
public static func verify<T>(_ verifier: inout Verifier, at position: Int, of type: T.Type) throws where T: Verifiable {
|
|
var _v = try verifier.visitTable(at: position)
|
|
try _v.visit(field: VT.b, fieldName: "b", required: false, type: Property.self)
|
|
_v.finish()
|
|
}
|
|
}
|
|
|
|
extension TestMutatingBool: Encodable {
|
|
enum CodingKeys: String, CodingKey {
|
|
case b = "b"
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: CodingKeys.self)
|
|
try container.encodeIfPresent(b, forKey: .b)
|
|
}
|
|
}
|
|
|
|
public class TestMutatingBoolT: NativeObject {
|
|
|
|
public var b: Property?
|
|
|
|
public init(_ _t: borrowing TestMutatingBool) {
|
|
b = _t.b
|
|
}
|
|
|
|
public init() {
|
|
b = Property()
|
|
}
|
|
|
|
public func serialize() -> ByteBuffer { return serialize(type: TestMutatingBool.self) }
|
|
|
|
}
|