mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 01:07:29 +00:00
Updates swift generated monster sample file (#6616)
Updates swift generated monster sample file Adds frozen attribute
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@frozen
|
||||
public struct ByteBuffer {
|
||||
|
||||
/// Storage is a container that would hold the memory pointer to solve the issue of
|
||||
@@ -29,12 +30,14 @@ public struct ByteBuffer {
|
||||
/// Capacity of UInt8 the buffer can hold
|
||||
var capacity: Int
|
||||
|
||||
@usableFromInline
|
||||
init(count: Int, alignment: Int) {
|
||||
memory = UnsafeMutableRawPointer.allocate(byteCount: count, alignment: alignment)
|
||||
capacity = count
|
||||
unowned = false
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
init(memory: UnsafeMutableRawPointer, capacity: Int, unowned: Bool) {
|
||||
self.memory = memory
|
||||
self.capacity = capacity
|
||||
@@ -47,6 +50,7 @@ public struct ByteBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
func copy(from ptr: UnsafeRawPointer, count: Int) {
|
||||
assert(
|
||||
!unowned,
|
||||
@@ -54,6 +58,7 @@ public struct ByteBuffer {
|
||||
memory.copyMemory(from: ptr, byteCount: count)
|
||||
}
|
||||
|
||||
@usableFromInline
|
||||
func initialize(for size: Int) {
|
||||
assert(
|
||||
!unowned,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@frozen
|
||||
public struct FlatBufferBuilder {
|
||||
|
||||
/// Storage for the Vtables used in the buffer are stored in here, so they would be written later in EndTable
|
||||
@@ -532,6 +533,7 @@ extension FlatBufferBuilder: CustomDebugStringConvertible {
|
||||
var addedElements: Int { capacity - (numOfFields &* size) }
|
||||
|
||||
/// Creates the memory to store the buffer in
|
||||
@usableFromInline
|
||||
init() {
|
||||
memory = UnsafeMutableRawBufferPointer.allocate(byteCount: 0, alignment: 0)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@frozen
|
||||
public struct Struct {
|
||||
public private(set) var bb: ByteBuffer
|
||||
public private(set) var postion: Int32
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@frozen
|
||||
public struct Table {
|
||||
public private(set) var bb: ByteBuffer
|
||||
public private(set) var postion: Int32
|
||||
@@ -113,9 +114,6 @@ public struct Table {
|
||||
o += postion
|
||||
return o + bb.read(def: Int32.self, position: Int(o)) + 4
|
||||
}
|
||||
}
|
||||
|
||||
extension Table {
|
||||
|
||||
static public func indirect(_ o: Int32, _ fbb: ByteBuffer) -> Int32 { o + fbb.read(
|
||||
def: Int32.self,
|
||||
|
||||
Reference in New Issue
Block a user