[Swift] Renaming protocols (#6469)

* Renaming protocols

* Updates Generated code

* format code
This commit is contained in:
mustiikhalil
2021-02-16 14:55:47 +03:00
committed by GitHub
parent a72a208272
commit a20f606c29
5 changed files with 42 additions and 41 deletions

View File

@@ -26,7 +26,7 @@ public protocol FlatBufferObject {
init(_ bb: ByteBuffer, o: Int32)
}
public protocol ObjectAPI {
public protocol ObjectAPIPacker {
associatedtype T
static func pack(_ builder: inout FlatBufferBuilder, obj: inout T) -> Offset<UOffset>
mutating func unpack() -> T

View File

@@ -16,14 +16,14 @@
import Foundation
public protocol UnionObject {}
public protocol NativeObject {}
extension UnionObject {
extension NativeObject {
/// Serialize is a helper function that serailizes the data from the Object API to a bytebuffer directly th
/// - Parameter type: Type of the Flatbuffer object
/// - Returns: returns the encoded sized ByteBuffer
public func serialize<T: ObjectAPI>(type: T.Type) -> ByteBuffer where T.T == Self {
public func serialize<T: ObjectAPIPacker>(type: T.Type) -> ByteBuffer where T.T == Self {
var builder = FlatBufferBuilder(initialSize: 1024)
return serialize(builder: &builder, type: type.self)
}
@@ -36,7 +36,7 @@ extension UnionObject {
/// - Returns: returns the encoded sized ByteBuffer
/// - Note: The `serialize(builder:type)` can be considered as a function that allows you to create smaller builder instead of the default `1024`.
/// It can be considered less expensive in terms of memory allocation
public func serialize<T: ObjectAPI>(builder: inout FlatBufferBuilder, type: T.Type) -> ByteBuffer where T.T == Self {
public func serialize<T: ObjectAPIPacker>(builder: inout FlatBufferBuilder, type: T.Type) -> ByteBuffer where T.T == Self {
var s = self
let root = type.pack(&builder, obj: &s)
builder.finish(offset: root)