mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 19:58:17 +00:00
[Swift] Inline arrays (#8755)
Implements InlineArrays which allow us to use Flatbuffers arrays within Structs natively, and also implements FlatbufferVectors as a secondary API when using mutable Structs Fixes mutations within fixed sizes arrays Adds tests and remove inout and mutating from generated objects in favor of borrowing --------- Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
This commit is contained in:
@@ -88,10 +88,9 @@ public struct MoreDefaults: FlatBufferTable, FlatbuffersVectorInitializable, Ver
|
||||
MoreDefaults.addVectorOf(bools: bools, &fbb)
|
||||
return MoreDefaults.endMoreDefaults(&fbb, start: __start)
|
||||
}
|
||||
|
||||
|
||||
public mutating func unpack() -> MoreDefaultsT {
|
||||
return MoreDefaultsT(&self)
|
||||
public func unpack() -> MoreDefaultsT {
|
||||
return MoreDefaultsT(self)
|
||||
}
|
||||
public static func pack(_ builder: inout FlatBufferBuilder, obj: inout MoreDefaultsT?) -> Offset {
|
||||
guard var obj = obj else { return Offset() }
|
||||
@@ -169,7 +168,7 @@ public class MoreDefaultsT: NativeObject {
|
||||
public var abcs: [ABC]
|
||||
public var bools: [Bool]
|
||||
|
||||
public init(_ _t: inout MoreDefaults) {
|
||||
public init(_ _t: borrowing MoreDefaults) {
|
||||
ints = []
|
||||
ints.append(contentsOf: _t.ints)
|
||||
floats = []
|
||||
|
||||
Reference in New Issue
Block a user