mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-04 19:51:11 +00:00
[Swift] Adds GRPC to Swift (#5758)
* Adds the basic structure for required to add grpc support Added the message implementation Updated the code to confirm to the protocol flatbuffersobject Adds an example for Swift flatbuffers GRPC Started implementing the swift GRPC code Gen Generator generates protocols now Fixing ci issues Migrated the logic to use grpc_generator::File instead of string Refactored swift project Implemented GRPC in swift Finished implementing GRPC in swift Fixes issues Adds contiguousBytes initializer to swift Adds documentation + fixes buffer nameing in tables + structs Adds documentation + fixes buffer nameing in tables + structs Updated tests * Updated version
This commit is contained in:
@@ -51,6 +51,35 @@ public final class ByteBuffer {
|
||||
_memory.initializeMemory(as: UInt8.self, repeating: 0, count: size)
|
||||
_capacity = size
|
||||
}
|
||||
|
||||
#if swift(>=5.0)
|
||||
/// Constructor that creates a Flatbuffer object from a ContiguousBytes
|
||||
/// - Parameters:
|
||||
/// - contiguousBytes: Binary stripe to use as the buffer
|
||||
/// - count: amount of readable bytes
|
||||
public init<Bytes: ContiguousBytes>(
|
||||
contiguousBytes: Bytes,
|
||||
count: Int
|
||||
) {
|
||||
_memory = UnsafeMutableRawPointer.allocate(byteCount: count, alignment: alignment)
|
||||
_capacity = count
|
||||
_writerSize = _capacity
|
||||
contiguousBytes.withUnsafeBytes { buf in
|
||||
_memory.copyMemory(from: buf.baseAddress!, byteCount: buf.count)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Creates a copy of the buffer that's being built by calling sizedBuffer
|
||||
/// - Parameters:
|
||||
/// - memory: Current memory of the buffer
|
||||
/// - count: count of bytes
|
||||
internal init(memory: UnsafeMutableRawPointer, count: Int) {
|
||||
_memory = UnsafeMutableRawPointer.allocate(byteCount: count, alignment: alignment)
|
||||
_memory.copyMemory(from: memory, byteCount: count)
|
||||
_capacity = count
|
||||
_writerSize = _capacity
|
||||
}
|
||||
|
||||
/// Creates a copy of the existing flatbuffer, by copying it to a different memory.
|
||||
/// - Parameters:
|
||||
|
||||
Reference in New Issue
Block a user