mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 02:13:57 +00:00
[Swift] Implements FlatbuffersVector which confirms to RandomAccessCollection (#8752)
* Implements FlatbuffersVector in swift Implements FlatbuffersVector which confirms to RandomAccessCollection, this would give us semi-native sugary syntax to all the arrays in swift port. This work will also be the foundation of using arrays in swift * Fix failing tests for Swift
This commit is contained in:
@@ -27,7 +27,8 @@ extension NativeObject {
|
||||
/// - Parameter type: Type of the Flatbuffer object
|
||||
/// - Returns: returns the encoded sized ByteBuffer
|
||||
public func serialize<T: ObjectAPIPacker>(type: T.Type) -> ByteBuffer
|
||||
where T.T == Self {
|
||||
where T.T == Self
|
||||
{
|
||||
var builder = FlatBufferBuilder(initialSize: 1024)
|
||||
return serialize(builder: &builder, type: type.self)
|
||||
}
|
||||
@@ -42,8 +43,8 @@ extension NativeObject {
|
||||
/// It can be considered less expensive in terms of memory allocation
|
||||
public func serialize<T: ObjectAPIPacker>(
|
||||
builder: inout FlatBufferBuilder,
|
||||
type: T.Type
|
||||
) -> ByteBuffer where T.T == Self {
|
||||
type: T.Type) -> ByteBuffer where T.T == Self
|
||||
{
|
||||
var s = self
|
||||
let root = type.pack(&builder, obj: &s)
|
||||
builder.finish(offset: root)
|
||||
|
||||
Reference in New Issue
Block a user