[swift] Moves code to use VTablesStorage (#5888)

* Moves the code to use _vtablestorage

Rebuilt the test to confirm to the new API

Adds documentation + generates code for grpc

Reverts indentation

v0.4.0

Updated swift/readme.md

Updates VtableStorage to ensure space instead of reallocating each time

Fixes str count not being correct

* Fixes issue with boolean constant not being set + removes unused function
This commit is contained in:
mustiikhalil
2020-05-07 22:28:42 +03:00
committed by GitHub
parent c2da8d5d85
commit 870ecbc09a
15 changed files with 585 additions and 361 deletions

View File

@@ -121,7 +121,7 @@ public struct ByteBuffer {
ensureSpace(size: padding)
_writerSize += (MemoryLayout<UInt8>.size * Int(padding))
}
///Adds an array of type Scalar to the buffer memory
/// - Parameter elements: An array of Scalars
@usableFromInline mutating func push<T: Scalar>(elements: [T]) {
@@ -249,6 +249,11 @@ public struct ByteBuffer {
/// Resizes the buffer size
/// - Parameter size: new size for the buffer
@usableFromInline mutating internal func resize(_ size: Int) {
assert((_writerSize - size) > 0)
var zero: UInt8 = 0
for i in 0..<(_writerSize - size) {
memcpy(_storage.memory.advanced(by: writerIndex + i), &zero, MemoryLayout<UInt8>.size)
}
_writerSize = size
}