Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ jobs:
enable_windows_checks: false

embedded:
name: Embedded Test (Linux nightly-6.3)
name: Embedded Test (Linux nightly-${{ matrix.swift_version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift_version: ["6.3", "6.4.x"]
container:
image: swiftlang/swift:nightly-6.3-jammy
image: swiftlang/swift:nightly-${{ matrix.swift_version }}-jammy
steps:
- name: Swift version
run: swift --version
Expand Down
6 changes: 5 additions & 1 deletion EmbeddedExample/EmbeddedParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ struct EmbeddedTest {

precondition(a == 1)
precondition(b == 0x203)
print(c)
precondition(c == 0x405)
print("Should print '1 / 515 / 1029' on separate lines")
print(a) // 1
print(b) // 515
print(c) // 1029
}
}
2 changes: 1 addition & 1 deletion Sources/BinaryParsing/Parser Types/ParserSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public protocol ParserSpanProvider {
}

extension ParserSpanProvider {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// Executes the given closure with a `ParserSpan` over the contents of this
/// type, consuming the given parser range instead of the full span.
@_alwaysEmitIntoClient
Expand Down
27 changes: 15 additions & 12 deletions Sources/BinaryParsing/Parser Types/ParsingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public struct ParsingError: Error {
_location >= 0 ? _location : nil
}

#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// The user-provided error associated with this parsing error.
public var userError: (any Error)?

Expand Down Expand Up @@ -78,13 +78,15 @@ public struct ParsingError: Error {
}
}

#if !$Embedded
#if !$Embedded || compiler(>=6.4)
extension ParsingError {
public init(userError: any Error) {
self = .init(status: .userError, userError: userError)
}
}
#endif

#if !$Embedded
extension ParsingError: CustomStringConvertible {
public var description: String {
if let location {
Expand All @@ -109,19 +111,20 @@ extension ParsingError.Status: CustomStringConvertible {
}
#endif

#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// An error thrown by the library user.
///
/// In a build for non-embedded Swift, `ThrownParsingError` aliases `any Error`,
/// so you can throw an error of any kind from closures passed to methods that
/// are designated as `throws(ThrownParsingError)`. When the method throws an
/// error, it will always be either your error or an instance of
/// `ParsingError`.
/// In a build for non-embedded Swift, or any build using a 6.4 or newer compiler,
/// `ThrownParsingError` aliases `any Error`, so you can throw an error of
/// any kind from closures passed to methods that are designated as
/// `throws(ThrownParsingError)`. When the method throws an error,
/// it will always be either your error or an instance of `ParsingError`.
///
/// In a build for embedded Swift, `ThrownParsingError` instead aliases the
/// specific `ParsingError` type. Because embedded Swift supports only
/// fully-typed throws, and not the existential `any Error`, this allows you to
/// still use error-throwing APIs in an embedded context.
/// In a build for embedded Swift using a pre-6.4 compiler, `ThrownParsingError`
/// instead aliases the specific `ParsingError` type. Because this version of
/// embedded Swift supports only fully-typed throws, and not the existential
/// `any Error`, this allows you to still use error-throwing APIs in an embedded
/// context.
public typealias ThrownParsingError = any Error
#else
// Documentation is built using the non-embedded build.
Expand Down
2 changes: 1 addition & 1 deletion Sources/BinaryParsing/Parsers/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extension Array where Element == UInt8 {
}

extension Array {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// Creates a new array by parsing the specified number of elements from the given
/// parser span, using the provided closure for parsing.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/BinaryParsing/Parsers/InlineArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension InlineArray where Element == UInt8 {

@available(macOS 26, iOS 26, watchOS 26, tvOS 26, visionOS 26, *)
extension InlineArray where Element: ~Copyable {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// Creates a new array by parsing the specified number of elements from the given
/// parser span, using the provided closure for parsing.
///
Expand Down
8 changes: 4 additions & 4 deletions Sources/BinaryParsing/Parsers/Range.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// MARK: Start & Count

extension Range where Bound: FixedWidthInteger {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// Creates a new half-open range by parsing the start and count of the range,
/// using the given parser closure for each value.
///
Expand Down Expand Up @@ -68,7 +68,7 @@ extension Range where Bound: FixedWidthInteger {
}

extension ClosedRange where Bound: FixedWidthInteger {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
@available(
*, deprecated,
message:
Expand Down Expand Up @@ -112,7 +112,7 @@ extension ClosedRange where Bound: FixedWidthInteger {
// MARK: Start & End

extension Range {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// Creates a new half-open range by parsing the start and end of the range,
/// using the given parser closure for each value.
///
Expand Down Expand Up @@ -168,7 +168,7 @@ extension Range {
}

extension ClosedRange {
#if !$Embedded
#if !$Embedded || compiler(>=6.4)
/// Creates a new closed range by parsing the start and end of the range,
/// using the given parser closure for each value.
///
Expand Down
Loading