mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 22:28:53 +00:00
bulk code format fix (#8707)
This commit is contained in:
@@ -31,8 +31,8 @@ public struct FixedTypedVector: FlexBufferVector {
|
||||
offset: Int,
|
||||
byteWidth: UInt8,
|
||||
type: FlexBufferType,
|
||||
count: Int)
|
||||
{
|
||||
count: Int
|
||||
) {
|
||||
self.byteBuffer = byteBuffer
|
||||
self.offset = offset
|
||||
self.byteWidth = byteWidth
|
||||
|
||||
@@ -39,13 +39,14 @@ public protocol FlexBufferContiguousBytes {
|
||||
var count: Int { get }
|
||||
|
||||
func withUnsafeRawBufferPointer<Result>(
|
||||
_ body: (UnsafeRawBufferPointer) throws -> Result) rethrows -> Result
|
||||
_ body: (UnsafeRawBufferPointer) throws -> Result
|
||||
) rethrows -> Result
|
||||
}
|
||||
|
||||
extension FlexBufferContiguousBytes {
|
||||
public func withUnsafeRawBufferPointer<Result>(
|
||||
_ body: (UnsafeRawBufferPointer) throws -> Result) rethrows -> Result
|
||||
{
|
||||
_ body: (UnsafeRawBufferPointer) throws -> Result
|
||||
) rethrows -> Result {
|
||||
try byteBuffer.withUnsafePointerToSlice(
|
||||
index: offset,
|
||||
count: count,
|
||||
|
||||
@@ -58,8 +58,8 @@ public struct Reference {
|
||||
byteBuffer: ByteBuffer,
|
||||
offset: Int,
|
||||
parentWidth: UInt8,
|
||||
packedType: UInt8)
|
||||
{
|
||||
packedType: UInt8
|
||||
) {
|
||||
guard let type = FlexBufferType(rawValue: UInt64(packedType >> 2)) else {
|
||||
return nil
|
||||
}
|
||||
@@ -76,8 +76,8 @@ public struct Reference {
|
||||
offset: Int,
|
||||
parentWidth: UInt8,
|
||||
byteWidth: UInt8,
|
||||
type: FlexBufferType)
|
||||
{
|
||||
type: FlexBufferType
|
||||
) {
|
||||
self.byteBuffer = byteBuffer
|
||||
self.offset = offset
|
||||
self.parentWidth = parentWidth
|
||||
@@ -97,7 +97,8 @@ public struct Reference {
|
||||
public var uint: UInt64? {
|
||||
return switch type {
|
||||
case .uint: byteBuffer.readUInt64(offset: offset, byteWidth: byteWidth)
|
||||
case .indirectUInt: byteBuffer.readUInt64(
|
||||
case .indirectUInt:
|
||||
byteBuffer.readUInt64(
|
||||
offset: indirect(),
|
||||
byteWidth: byteWidth)
|
||||
default: nil
|
||||
@@ -108,7 +109,8 @@ public struct Reference {
|
||||
public var int: Int64? {
|
||||
return switch type {
|
||||
case .int: byteBuffer.readInt64(offset: offset, byteWidth: byteWidth)
|
||||
case .indirectInt: byteBuffer.readInt64(
|
||||
case .indirectInt:
|
||||
byteBuffer.readInt64(
|
||||
offset: indirect(),
|
||||
byteWidth: byteWidth)
|
||||
default: nil
|
||||
@@ -119,7 +121,8 @@ public struct Reference {
|
||||
public var double: Double? {
|
||||
return switch type {
|
||||
case .float: byteBuffer.readDouble(offset: offset, byteWidth: byteWidth)
|
||||
case .indirectFloat: byteBuffer.readDouble(
|
||||
case .indirectFloat:
|
||||
byteBuffer.readDouble(
|
||||
offset: indirect(),
|
||||
byteWidth: byteWidth)
|
||||
default: nil
|
||||
@@ -238,7 +241,8 @@ public struct Reference {
|
||||
@inline(__always)
|
||||
public func withUnsafeRawPointer<Result>(
|
||||
_ completion: (UnsafeRawPointer) throws
|
||||
-> Result)
|
||||
-> Result
|
||||
)
|
||||
rethrows -> Result?
|
||||
{
|
||||
return try byteBuffer.readWithUnsafeRawPointer(
|
||||
|
||||
@@ -30,8 +30,8 @@ public struct TypedVector: FlexBufferVector {
|
||||
byteBuffer: ByteBuffer,
|
||||
offset: Int,
|
||||
byteWidth: UInt8,
|
||||
type: FlexBufferType)
|
||||
{
|
||||
type: FlexBufferType
|
||||
) {
|
||||
self.byteBuffer = byteBuffer
|
||||
self.offset = offset
|
||||
self.byteWidth = byteWidth
|
||||
@@ -54,8 +54,8 @@ public struct TypedVector: FlexBufferVector {
|
||||
static func mapKeys(
|
||||
byteBuffer: ByteBuffer,
|
||||
offset: Int,
|
||||
byteWidth: UInt8) -> TypedVector
|
||||
{
|
||||
byteWidth: UInt8
|
||||
) -> TypedVector {
|
||||
let prefixedFields = 3
|
||||
let keysOffset = offset &- (numericCast(byteWidth) &* prefixedFields)
|
||||
|
||||
@@ -88,12 +88,11 @@ extension TypedVector {
|
||||
byteWidth)
|
||||
|
||||
return byteBuffer.readWithUnsafeRawPointer(
|
||||
position: indirectoffset)
|
||||
{ bufPointer in
|
||||
position: indirectoffset
|
||||
) { bufPointer in
|
||||
target.withCString { strPointer in
|
||||
Int(strcmp(bufPointer, strPointer))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user