mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-26 11:12:40 +00:00
Implements verifier and code gen for swift (#6373)
Updates test cases on linux Adhere to new protocol naming Adds fuzzing Adds documentation Adds support for string unions Updated fuzzer generated code
This commit is contained in:
@@ -16,16 +16,30 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Struct is a representation of a mutable `Flatbuffers` struct
|
||||
/// since native structs are value types and cant be mutated
|
||||
@frozen
|
||||
public struct Struct {
|
||||
|
||||
/// Hosting Bytebuffer
|
||||
public private(set) var bb: ByteBuffer
|
||||
/// Current position of the struct
|
||||
public private(set) var postion: Int32
|
||||
|
||||
/// Initializer for a mutable flatbuffers struct
|
||||
/// - Parameters:
|
||||
/// - bb: Current hosting Bytebuffer
|
||||
/// - position: Current position for the struct in the ByteBuffer
|
||||
public init(bb: ByteBuffer, position: Int32 = 0) {
|
||||
self.bb = bb
|
||||
postion = position
|
||||
}
|
||||
|
||||
/// Reads data from the buffer directly at offset O
|
||||
/// - Parameters:
|
||||
/// - type: Type of data to be read
|
||||
/// - o: Current offset of the data
|
||||
/// - Returns: Data of Type T that conforms to type Scalar
|
||||
public func readBuffer<T: Scalar>(of type: T.Type, at o: Int32) -> T {
|
||||
let r = bb.read(def: T.self, position: Int(o + postion))
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user