Adds min and max, comments, and all of swift's keywords + fix docs (#5737)

This commit is contained in:
mustiikhalil
2020-01-27 21:05:41 +03:00
committed by Wouter van Oortmerssen
parent f2a1272303
commit c580fa284c
6 changed files with 190 additions and 49 deletions

View File

@@ -231,13 +231,14 @@ public final class ByteBuffer {
public func duplicate(removing removeBytes: Int = 0) -> ByteBuffer {
return ByteBuffer(memory: _memory, count: _capacity, removing: _writerSize - removeBytes)
}
#if DEBUG
func debugMemory(str: String) {
let bufprt = UnsafeBufferPointer(start: _memory.assumingMemoryBound(to: UInt8.self),
count: _capacity)
let a = Array(bufprt)
print(str, a, " \nwith buffer size: \(a.count) and writer size: \(_writerSize)")
}
#endif
}
extension ByteBuffer: CustomDebugStringConvertible {
public var debugDescription: String {
"""
buffer located at: \(_memory), with capacity of \(_capacity)
{ writerSize: \(_writerSize), readerSize: \(reader), writerIndex: \(writerIndex) }
"""
}
}

View File

@@ -77,11 +77,8 @@ public final class FlatBufferBuilder {
public func clearOffsets() {
_vtable = []
}
}
// MARK: - Create Tables
extension FlatBufferBuilder {
// MARK: - Create Tables
/// Checks if the required fields were serialized into the buffer
/// - Parameters:
@@ -476,11 +473,16 @@ extension FlatBufferBuilder {
_bb.push(value: element, len: MemoryLayout<T>.size)
return _bb.size
}
#if DEBUG
/// Used to debug the buffer and the implementation
public func debug(str: String = "normal memory: ") {
_bb.debugMemory(str: str)
}
#endif
}
extension FlatBufferBuilder: CustomDebugStringConvertible {
public var debugDescription: String {
"""
buffer debug:
\(_bb)
builder debug:
{ finished: \(finished), serializeDefaults: \(serializeDefaults), isNested: \(isNested) }
"""
}
}