diff options
author | mustiikhalil <mustii@mmk.one> | 2021-02-16 14:55:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-16 14:55:47 +0300 |
commit | a20f606c29871c114aca60d066847ce7ab5d3f44 (patch) | |
tree | 7d1b44679159cf8f991ccc73e6a4874c8f837d98 /swift | |
parent | a72a20827226a38a1c46dd3737779ec686330486 (diff) | |
download | flatbuffers-a20f606c29871c114aca60d066847ce7ab5d3f44.tar.gz flatbuffers-a20f606c29871c114aca60d066847ce7ab5d3f44.tar.bz2 flatbuffers-a20f606c29871c114aca60d066847ce7ab5d3f44.zip |
[Swift] Renaming protocols (#6469)
* Renaming protocols
* Updates Generated code
* format code
Diffstat (limited to 'swift')
-rw-r--r-- | swift/Sources/FlatBuffers/FlatBufferObject.swift | 2 | ||||
-rw-r--r-- | swift/Sources/FlatBuffers/NativeObject.swift (renamed from swift/Sources/FlatBuffers/UnionObject.swift) | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/swift/Sources/FlatBuffers/FlatBufferObject.swift b/swift/Sources/FlatBuffers/FlatBufferObject.swift index 14ab3ccd..c3f1713c 100644 --- a/swift/Sources/FlatBuffers/FlatBufferObject.swift +++ b/swift/Sources/FlatBuffers/FlatBufferObject.swift @@ -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 diff --git a/swift/Sources/FlatBuffers/UnionObject.swift b/swift/Sources/FlatBuffers/NativeObject.swift index 4d99ea9b..2f360f0c 100644 --- a/swift/Sources/FlatBuffers/UnionObject.swift +++ b/swift/Sources/FlatBuffers/NativeObject.swift @@ -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) |