Austin Schuh | 272c613 | 2020-11-14 16:37:52 -0800 | [diff] [blame^] | 1 | import Foundation |
| 2 | |
| 3 | /// FlatbufferObject structures all the Flatbuffers objects |
| 4 | public protocol FlatBufferObject { |
| 5 | var __buffer: ByteBuffer! { get } |
| 6 | init(_ bb: ByteBuffer, o: Int32) |
| 7 | } |
| 8 | |
| 9 | public protocol ObjectAPI { |
| 10 | associatedtype T |
| 11 | static func pack(_ builder: inout FlatBufferBuilder, obj: inout T) -> Offset<UOffset> |
| 12 | mutating func unpack() -> T |
| 13 | } |
| 14 | |
| 15 | /// Readable is structures all the Flatbuffers structs |
| 16 | /// |
| 17 | /// Readable is a procotol that each Flatbuffer struct should confirm to since |
| 18 | /// FlatBufferBuilder would require a Type to both create(struct:) and createVector(structs:) functions |
| 19 | public protocol Readable: FlatBufferObject { |
| 20 | static var size: Int { get } |
| 21 | static var alignment: Int { get } |
| 22 | } |
| 23 | |
| 24 | public protocol Enum { |
| 25 | associatedtype T: Scalar |
| 26 | static var byteSize: Int { get } |
| 27 | var value: T { get } |
| 28 | } |