mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-05 05:07:05 +00:00
[Swift] Implements FlatbuffersVector which confirms to RandomAccessCollection (#8752)
* Implements FlatbuffersVector in swift Implements FlatbuffersVector which confirms to RandomAccessCollection, this would give us semi-native sugary syntax to all the arrays in swift port. This work will also be the foundation of using arrays in swift * Fix failing tests for Swift
This commit is contained in:
@@ -53,8 +53,8 @@ public struct Verifier {
|
||||
public init(
|
||||
buffer: inout ByteBuffer,
|
||||
options: VerifierOptions = .init(),
|
||||
checkAlignment: Bool = true
|
||||
) throws {
|
||||
checkAlignment: Bool = true) throws
|
||||
{
|
||||
guard buffer.capacity < FlatBufferMaxSize else {
|
||||
throw FlatbuffersErrors.exceedsMaxSizeAllowed
|
||||
}
|
||||
@@ -187,19 +187,19 @@ public struct Verifier {
|
||||
if offset > 0 {
|
||||
reportedOverflow =
|
||||
_int32Position
|
||||
.subtractingReportingOverflow(offset.magnitude)
|
||||
.subtractingReportingOverflow(offset.magnitude)
|
||||
} else {
|
||||
reportedOverflow =
|
||||
_int32Position
|
||||
.addingReportingOverflow(offset.magnitude)
|
||||
.addingReportingOverflow(offset.magnitude)
|
||||
}
|
||||
|
||||
/// since `subtractingReportingOverflow` & `addingReportingOverflow` returns true,
|
||||
/// if there is overflow we return failure
|
||||
if reportedOverflow.overflow
|
||||
|| reportedOverflow.partialValue
|
||||
> _buffer
|
||||
.capacity
|
||||
> _buffer
|
||||
.capacity
|
||||
{
|
||||
throw FlatbuffersErrors.signedOffsetOutOfBounds(
|
||||
offset: Int(offset),
|
||||
|
||||
Reference in New Issue
Block a user