[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:
mustiikhalil
2020-02-24 20:27:41 +03:00
committed by GitHub
parent cd88e6b2aa
commit 34305c4ce4
26 changed files with 973 additions and 8 deletions

View File

@@ -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: