mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 07:28:04 +00:00
[Swift] Adds GRPC to Swift (#5758)
* Adds the basic structure for required to add grpc support Added the message implementation Updated the code to confirm to the protocol flatbuffersobject Adds an example for Swift flatbuffers GRPC Started implementing the swift GRPC code Gen Generator generates protocols now Fixing ci issues Migrated the logic to use grpc_generator::File instead of string Refactored swift project Implemented GRPC in swift Finished implementing GRPC in swift Fixes issues Adds contiguousBytes initializer to swift Adds documentation + fixes buffer nameing in tables + structs Adds documentation + fixes buffer nameing in tables + structs Updated tests * Updated version
This commit is contained in:
49
tests/FlatBuffers.GRPC.Swift/Package.swift
Normal file
49
tests/FlatBuffers.GRPC.Swift/Package.swift
Normal file
@@ -0,0 +1,49 @@
|
||||
// swift-tools-version:5.1
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "FlatBuffers.GRPC.Swift",
|
||||
platforms: [
|
||||
.iOS(.v11),
|
||||
.macOS(.v10_14),
|
||||
],
|
||||
dependencies: [
|
||||
// Main SwiftNIO package
|
||||
.package(path: "../../swift"),
|
||||
.package(url: "https://github.com/grpc/grpc-swift.git", .branch("nio"))
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
|
||||
.target(
|
||||
name: "Model",
|
||||
dependencies: [
|
||||
"GRPC",
|
||||
"FlatBuffers"
|
||||
],
|
||||
path: "Sources/Model"
|
||||
),
|
||||
|
||||
// Client for the HelloWorld example
|
||||
.target(
|
||||
name: "Client",
|
||||
dependencies: [
|
||||
"GRPC",
|
||||
"Model",
|
||||
],
|
||||
path: "Sources/client"
|
||||
),
|
||||
|
||||
// Server for the HelloWorld example
|
||||
.target(
|
||||
name: "Server",
|
||||
dependencies: [
|
||||
"GRPC",
|
||||
"Model",
|
||||
],
|
||||
path: "Sources/server"
|
||||
),
|
||||
]
|
||||
)
|
||||
3
tests/FlatBuffers.GRPC.Swift/README.md
Normal file
3
tests/FlatBuffers.GRPC.Swift/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# FlatBuffers.GRPC.Swift
|
||||
|
||||
The following is Swift example on how GRPC would be with Swift Flatbuffers
|
||||
17
tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.fbs
Normal file
17
tests/FlatBuffers.GRPC.Swift/Sources/Model/greeter.fbs
Normal file
@@ -0,0 +1,17 @@
|
||||
table HelloReply {
|
||||
message:string;
|
||||
}
|
||||
|
||||
table HelloRequest {
|
||||
name:string;
|
||||
}
|
||||
|
||||
table ManyHellosRequest {
|
||||
name:string;
|
||||
num_greetings:int;
|
||||
}
|
||||
|
||||
rpc_service Greeter {
|
||||
SayHello(HelloRequest):HelloReply;
|
||||
SayManyHellos(ManyHellosRequest):HelloReply (streaming: "server");
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
// Generated GRPC code for FlatBuffers swift!
|
||||
/// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift
|
||||
/// in case of an issue please open github issue, though it would be maintained
|
||||
import Foundation
|
||||
import GRPC
|
||||
import NIO
|
||||
import NIOHTTP1
|
||||
import FlatBuffers
|
||||
|
||||
public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {}
|
||||
public extension GRPCFlatBufPayload {
|
||||
init(serializedByteBuffer: inout NIO.ByteBuffer) throws {
|
||||
self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes))
|
||||
}
|
||||
func serialize(into buffer: inout NIO.ByteBuffer) throws {
|
||||
let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size))
|
||||
buffer.writeBytes(buf)
|
||||
}
|
||||
}
|
||||
extension Message: GRPCFlatBufPayload {}
|
||||
|
||||
/// Usage: instantiate GreeterServiceClient, then call methods of this protocol to make API calls.
|
||||
public protocol GreeterService {
|
||||
func SayHello(_ request: Message<HelloRequest>, callOptions: CallOptions?) -> UnaryCall<Message<HelloRequest>,Message<HelloReply>>
|
||||
func SayManyHellos(_ request: Message<ManyHellosRequest>, callOptions: CallOptions?, handler: @escaping (Message<HelloReply>) -> Void) -> ServerStreamingCall<Message<ManyHellosRequest>, Message<HelloReply>>
|
||||
}
|
||||
|
||||
public final class GreeterServiceClient: GRPCClient, GreeterService {
|
||||
public let connection: ClientConnection
|
||||
public var defaultCallOptions: CallOptions
|
||||
|
||||
public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
|
||||
self.connection = connection
|
||||
self.defaultCallOptions = defaultCallOptions
|
||||
}
|
||||
|
||||
public func SayHello(_ request: Message<HelloRequest>, callOptions: CallOptions? = nil) -> UnaryCall<Message<HelloRequest>,Message<HelloReply>> {
|
||||
return self.makeUnaryCall(path: "/Greeter/SayHello", request: request, callOptions: callOptions ?? self.defaultCallOptions)
|
||||
}
|
||||
|
||||
public func SayManyHellos(_ request: Message<ManyHellosRequest>, callOptions: CallOptions? = nil, handler: @escaping (Message<HelloReply>) -> Void) -> ServerStreamingCall<Message<ManyHellosRequest>, Message<HelloReply>> {
|
||||
return self.makeServerStreamingCall(path: "/Greeter/SayManyHellos", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler)
|
||||
}
|
||||
}
|
||||
|
||||
public protocol GreeterProvider: CallHandlerProvider {
|
||||
func SayHello(_ request: Message<HelloRequest>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<HelloReply>>
|
||||
func SayManyHellos(request: Message<ManyHellosRequest>, context: StreamingResponseCallContext<Message<HelloReply>>) -> EventLoopFuture<GRPCStatus>
|
||||
}
|
||||
|
||||
public extension GreeterProvider {
|
||||
var serviceName: String { return "Greeter" }
|
||||
func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
|
||||
switch methodName {
|
||||
case "SayHello":
|
||||
return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
|
||||
return { request in
|
||||
self.SayHello(request, context: context)
|
||||
}
|
||||
}
|
||||
case "SayManyHellos":
|
||||
return ServerStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
|
||||
return { request in
|
||||
self.SayManyHellos(request: request, context: context)
|
||||
}
|
||||
}
|
||||
default: return nil;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import FlatBuffers
|
||||
|
||||
public struct HelloReply: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func getRootAsHelloReply(bb: ByteBuffer) -> HelloReply { return HelloReply(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
public var message: String? { let o = _accessor.offset(4); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var messageSegmentArray: [UInt8]? { return _accessor.getVector(at: 4) }
|
||||
public static func startHelloReply(_ fbb: FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(message: Offset<String>, _ fbb: FlatBufferBuilder) { fbb.add(offset: message, at: 0) }
|
||||
public static func endHelloReply(_ fbb: FlatBufferBuilder, start: UOffset) -> Offset<UOffset> { let end = Offset<UOffset>(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createHelloReply(_ fbb: FlatBufferBuilder,
|
||||
offsetOfMessage message: Offset<String> = Offset()) -> Offset<UOffset> {
|
||||
let __start = HelloReply.startHelloReply(fbb)
|
||||
HelloReply.add(message: message, fbb)
|
||||
return HelloReply.endHelloReply(fbb, start: __start)
|
||||
}
|
||||
}
|
||||
|
||||
public struct HelloRequest: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func getRootAsHelloRequest(bb: ByteBuffer) -> HelloRequest { return HelloRequest(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
public var name: String? { let o = _accessor.offset(4); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: 4) }
|
||||
public static func startHelloRequest(_ fbb: FlatBufferBuilder) -> UOffset { fbb.startTable(with: 1) }
|
||||
public static func add(name: Offset<String>, _ fbb: FlatBufferBuilder) { fbb.add(offset: name, at: 0) }
|
||||
public static func endHelloRequest(_ fbb: FlatBufferBuilder, start: UOffset) -> Offset<UOffset> { let end = Offset<UOffset>(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createHelloRequest(_ fbb: FlatBufferBuilder,
|
||||
offsetOfName name: Offset<String> = Offset()) -> Offset<UOffset> {
|
||||
let __start = HelloRequest.startHelloRequest(fbb)
|
||||
HelloRequest.add(name: name, fbb)
|
||||
return HelloRequest.endHelloRequest(fbb, start: __start)
|
||||
}
|
||||
}
|
||||
|
||||
public struct ManyHellosRequest: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func getRootAsManyHellosRequest(bb: ByteBuffer) -> ManyHellosRequest { return ManyHellosRequest(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
private init(_ t: Table) { _accessor = t }
|
||||
public init(_ bb: ByteBuffer, o: Int32) { _accessor = Table(bb: bb, position: o) }
|
||||
|
||||
public var name: String? { let o = _accessor.offset(4); return o == 0 ? nil : _accessor.string(at: o) }
|
||||
public var nameSegmentArray: [UInt8]? { return _accessor.getVector(at: 4) }
|
||||
public var numGreetings: Int32 { let o = _accessor.offset(6); return o == 0 ? 0 : _accessor.readBuffer(of: Int32.self, at: o) }
|
||||
public static func startManyHellosRequest(_ fbb: FlatBufferBuilder) -> UOffset { fbb.startTable(with: 2) }
|
||||
public static func add(name: Offset<String>, _ fbb: FlatBufferBuilder) { fbb.add(offset: name, at: 0) }
|
||||
public static func add(numGreetings: Int32, _ fbb: FlatBufferBuilder) { fbb.add(element: numGreetings, def: 0, at: 1) }
|
||||
public static func endManyHellosRequest(_ fbb: FlatBufferBuilder, start: UOffset) -> Offset<UOffset> { let end = Offset<UOffset>(offset: fbb.endTable(at: start)); return end }
|
||||
public static func createManyHellosRequest(_ fbb: FlatBufferBuilder,
|
||||
offsetOfName name: Offset<String> = Offset(),
|
||||
numGreetings: Int32 = 0) -> Offset<UOffset> {
|
||||
let __start = ManyHellosRequest.startManyHellosRequest(fbb)
|
||||
ManyHellosRequest.add(name: name, fbb)
|
||||
ManyHellosRequest.add(numGreetings: numGreetings, fbb)
|
||||
return ManyHellosRequest.endManyHellosRequest(fbb, start: __start)
|
||||
}
|
||||
}
|
||||
|
||||
101
tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift
Normal file
101
tests/FlatBuffers.GRPC.Swift/Sources/client/main.swift
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2020, gRPC Authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import GRPC
|
||||
import Model
|
||||
import NIO
|
||||
import Logging
|
||||
import FlatBuffers
|
||||
|
||||
// Quieten the logs.
|
||||
LoggingSystem.bootstrap {
|
||||
var handler = StreamLogHandler.standardOutput(label: $0)
|
||||
handler.logLevel = .critical
|
||||
return handler
|
||||
}
|
||||
|
||||
func greet(name: String, client greeter: GreeterServiceClient) {
|
||||
// Form the request with the name, if one was provided.
|
||||
var builder = FlatBufferBuilder()
|
||||
let name = builder.create(string: name)
|
||||
let root = HelloRequest.createHelloRequest(builder, offsetOfName: name)
|
||||
builder.finish(offset: root)
|
||||
|
||||
// Make the RPC call to the server.
|
||||
let sayHello = greeter.SayHello(Message<HelloRequest>(builder: &builder))
|
||||
// wait() on the response to stop the program from exiting before the response is received.
|
||||
do {
|
||||
let response = try sayHello.response.wait()
|
||||
print("Greeter received: \(response.object.message)")
|
||||
} catch {
|
||||
print("Greeter failed: \(error)")
|
||||
}
|
||||
|
||||
let surname = builder.create(string: "Name")
|
||||
let manyRoot = ManyHellosRequest.createManyHellosRequest(builder, offsetOfName: surname, numGreetings: 2)
|
||||
builder.finish(offset: manyRoot)
|
||||
|
||||
let call = greeter.SayManyHellos(Message(builder: &builder)) { message in
|
||||
print(message.object.message)
|
||||
}
|
||||
|
||||
let status = try! call.status.recover { _ in .processingError }.wait()
|
||||
if status.code != .ok {
|
||||
print("RPC failed: \(status)")
|
||||
}
|
||||
}
|
||||
|
||||
func main(args: [String]) {
|
||||
// arg0 (dropped) is the program name. We expect arg1 to be the port, and arg2 (optional) to be
|
||||
// the name sent in the request.
|
||||
let arg1 = args.dropFirst(1).first
|
||||
let arg2 = args.dropFirst(2).first
|
||||
|
||||
switch (arg1.flatMap(Int.init), arg2) {
|
||||
case (.none, _):
|
||||
print("Usage: PORT [NAME]")
|
||||
exit(1)
|
||||
|
||||
case let (.some(port), name):
|
||||
// Setup an `EventLoopGroup` for the connection to run on.
|
||||
//
|
||||
// See: https://github.com/apple/swift-nio#eventloops-and-eventloopgroups
|
||||
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
|
||||
// Make sure the group is shutdown when we're done with it.
|
||||
defer {
|
||||
try! group.syncShutdownGracefully()
|
||||
}
|
||||
|
||||
// Provide some basic configuration for the connection, in this case we connect to an endpoint on
|
||||
// localhost at the given port.
|
||||
let configuration = ClientConnection.Configuration(
|
||||
target: .hostAndPort("localhost", port),
|
||||
eventLoopGroup: group
|
||||
)
|
||||
|
||||
// Create a connection using the configuration.
|
||||
let connection = ClientConnection(configuration: configuration)
|
||||
|
||||
// Provide the connection to the generated client.
|
||||
let greeter = GreeterServiceClient(connection: connection)
|
||||
|
||||
// Do the greeting.
|
||||
greet(name: "Hello FlatBuffers!", client: greeter)
|
||||
}
|
||||
}
|
||||
|
||||
main(args: CommandLine.arguments)
|
||||
93
tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift
Normal file
93
tests/FlatBuffers.GRPC.Swift/Sources/server/main.swift
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2020, gRPC Authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import GRPC
|
||||
import NIO
|
||||
import FlatBuffers
|
||||
import Logging
|
||||
import Model
|
||||
|
||||
class Greeter: GreeterProvider {
|
||||
|
||||
var hellos: [Message<HelloReply>] = []
|
||||
|
||||
init() {
|
||||
let names = ["Stranger1", "Stranger2", "Stranger4", "Stranger3", "Stranger5", "Stranger6"]
|
||||
for name in names {
|
||||
var builder = FlatBufferBuilder()
|
||||
let off = builder.create(string: name)
|
||||
let root = HelloReply.createHelloReply(builder, offsetOfMessage: off)
|
||||
builder.finish(offset: root)
|
||||
hellos.append(Message(builder: &builder))
|
||||
}
|
||||
}
|
||||
|
||||
func SayHello(
|
||||
_ request: Message<HelloRequest>,
|
||||
context: StatusOnlyCallContext
|
||||
) -> EventLoopFuture<Message<HelloReply>> {
|
||||
let recipient = request.object.name ?? "Stranger"
|
||||
|
||||
var builder = FlatBufferBuilder()
|
||||
let off = builder.create(string: recipient)
|
||||
let root = HelloReply.createHelloReply(builder, offsetOfMessage: off)
|
||||
builder.finish(offset: root)
|
||||
return context.eventLoop.makeSucceededFuture(Message<HelloReply>(builder: &builder))
|
||||
}
|
||||
|
||||
func SayManyHellos(
|
||||
request: Message<ManyHellosRequest>,
|
||||
context: StreamingResponseCallContext<Message<HelloReply>>
|
||||
) -> EventLoopFuture<GRPCStatus> {
|
||||
for _ in 0..<Int(request.object.numGreetings) {
|
||||
let index = Int.random(in: 0..<hellos.count)
|
||||
_ = context.sendResponse(hellos[index])
|
||||
}
|
||||
return context.eventLoop.makeSucceededFuture(.ok)
|
||||
}
|
||||
}
|
||||
|
||||
// Quieten the logs.
|
||||
LoggingSystem.bootstrap {
|
||||
var handler = StreamLogHandler.standardOutput(label: $0)
|
||||
handler.logLevel = .critical
|
||||
return handler
|
||||
}
|
||||
|
||||
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
|
||||
defer {
|
||||
try! group.syncShutdownGracefully()
|
||||
}
|
||||
|
||||
// Create some configuration for the server:
|
||||
let configuration = Server.Configuration(
|
||||
target: .hostAndPort("localhost", 0),
|
||||
eventLoopGroup: group,
|
||||
serviceProviders: [Greeter()]
|
||||
)
|
||||
|
||||
// Start the server and print its address once it has started.
|
||||
let server = Server.start(configuration: configuration)
|
||||
server.map {
|
||||
$0.channel.localAddress
|
||||
}.whenSuccess { address in
|
||||
print("server started on port \(address!.port!)")
|
||||
}
|
||||
|
||||
// Wait on the server's `onClose` future to stop the program from exiting.
|
||||
_ = try server.flatMap {
|
||||
$0.onClose
|
||||
}.wait()
|
||||
@@ -76,6 +76,8 @@ func createVecWrite(x: Float32, y: Float32, z: Float32) -> UnsafeMutableRawPoint
|
||||
}
|
||||
|
||||
struct Vec: Readable {
|
||||
var __buffer: ByteBuffer! { __p.bb }
|
||||
|
||||
static var size = 12
|
||||
static var alignment = 4
|
||||
private var __p: Struct
|
||||
@@ -144,6 +146,8 @@ func createVec2(x: Float32 = 0, y: Float32 = 0, z: Float32 = 0, color: Color2) -
|
||||
}
|
||||
|
||||
struct Vec2: Readable {
|
||||
var __buffer: ByteBuffer! { __p.bb }
|
||||
|
||||
static var size = 13
|
||||
static var alignment = 4
|
||||
private var __p: Struct
|
||||
|
||||
@@ -115,6 +115,8 @@ enum RGB: Int32, Enum {
|
||||
}
|
||||
|
||||
struct Monster: FlatBufferObject {
|
||||
var __buffer: ByteBuffer! { _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
static func getRootAsMonster(bb: ByteBuffer) -> Monster { return Monster(Table(bb: bb, position: Int32(bb.read(def: UOffset.self, position: bb.reader)) + Int32(bb.reader))) }
|
||||
|
||||
@@ -189,8 +191,9 @@ struct Monster {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct Weapon: FlatBufferObject {
|
||||
|
||||
var __buffer: ByteBuffer! { __t.bb }
|
||||
|
||||
static let offsets: (name: VOffset, dmg: VOffset) = (0, 1)
|
||||
private var __t: Table
|
||||
|
||||
@@ -81,6 +81,7 @@ public enum AnyAmbiguousAliases: UInt8, Enum {
|
||||
public struct Test: Readable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Struct
|
||||
public static var size = 4
|
||||
@@ -96,6 +97,7 @@ public struct Test: Readable {
|
||||
public struct Vec3: Readable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Struct
|
||||
public static var size = 32
|
||||
@@ -117,6 +119,7 @@ public struct Vec3: Readable {
|
||||
public struct Ability: Readable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Struct
|
||||
public static var size = 8
|
||||
@@ -166,6 +169,7 @@ public static func createAbility(id: UInt32, distance: UInt32) -> UnsafeMutableR
|
||||
public struct InParentNamespace: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
@@ -187,6 +191,7 @@ public enum Example2 {
|
||||
public struct Monster: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
@@ -214,6 +219,7 @@ extension MyGame.Example {
|
||||
public struct TestSimpleTableWithEnum: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
@@ -238,6 +244,7 @@ public struct TestSimpleTableWithEnum: FlatBufferObject {
|
||||
public struct Stat: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
@@ -272,6 +279,7 @@ public struct Stat: FlatBufferObject {
|
||||
public struct Referrable: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
@@ -321,6 +329,7 @@ public struct Referrable: FlatBufferObject {
|
||||
public struct Monster: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
@@ -618,6 +627,7 @@ public struct Monster: FlatBufferObject {
|
||||
public struct TypeAliases: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MONS", addPrefix: prefix) }
|
||||
|
||||
@@ -22,6 +22,7 @@ public enum Character: UInt8, Enum {
|
||||
public struct Rapunzel: Readable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Struct
|
||||
public static var size = 4
|
||||
@@ -35,6 +36,7 @@ public struct Rapunzel: Readable {
|
||||
public struct BookReader: Readable {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Struct
|
||||
public static var size = 4
|
||||
@@ -62,6 +64,7 @@ public func createBookReader(booksRead: Int32) -> UnsafeMutableRawPointer {
|
||||
public struct Attacker: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MOVI", addPrefix: prefix) }
|
||||
@@ -86,6 +89,7 @@ public struct Attacker: FlatBufferObject {
|
||||
public struct Movie: FlatBufferObject {
|
||||
|
||||
static func validateVersion() { FlatBuffersVersion_1_11_1() }
|
||||
public var __buffer: ByteBuffer! { return _accessor.bb }
|
||||
|
||||
private var _accessor: Table
|
||||
public static func finish(_ fbb: FlatBufferBuilder, end: Offset<UOffset>, prefix: Bool = false) { fbb.finish(offset: end, fileId: "MOVI", addPrefix: prefix) }
|
||||
|
||||
Reference in New Issue
Block a user