Skip to content
Open
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
6 changes: 3 additions & 3 deletions .circleci/config.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs {
["test-pkl-\(distribution.normalizedVersion)"] {
docker {
new {
image = "swift:5.10-rhel-ubi9"
image = "swift:6.1-rhel-ubi9"
}
}
resource_class = "xlarge"
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs {
["test-format"] {
docker {
new {
image = "swift:5.10-rhel-ubi9"
image = "swift:6.1-rhel-ubi9"
}
}
steps {
Expand Down Expand Up @@ -197,7 +197,7 @@ jobs {
["pkl-gen-swift-linux-\(arch)"] {
docker {
new {
image = "swift:5.10-rhel-ubi9"
image = "swift:6.1-rhel-ubi9"
}
}
resource_class = if (arch == "amd64") "xlarge" else "arm.xlarge"
Expand Down
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
path: .out/test-results/
resource_class: xlarge
docker:
- image: swift:5.10-rhel-ubi9
- image: swift:6.1-rhel-ubi9
test-pkl-0-29-0:
steps:
- checkout
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
path: .out/test-results/
resource_class: xlarge
docker:
- image: swift:5.10-rhel-ubi9
- image: swift:6.1-rhel-ubi9
test-license-headers:
steps:
- checkout
Expand All @@ -66,7 +66,7 @@ jobs:
- run:
command: make swiftformat-lint
docker:
- image: swift:5.10-rhel-ubi9
- image: swift:6.1-rhel-ubi9
pkl-gen-swift-macos:
steps:
- checkout
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
- out/
resource_class: arm.xlarge
docker:
- image: swift:5.10-rhel-ubi9
- image: swift:6.1-rhel-ubi9
pkl-gen-swift-linux-amd64:
steps:
- checkout
Expand All @@ -114,7 +114,7 @@ jobs:
- out/
resource_class: xlarge
docker:
- image: swift:5.10-rhel-ubi9
- image: swift:6.1-rhel-ubi9
pkl-package:
steps:
- checkout
Expand Down
4 changes: 3 additions & 1 deletion DEVELOPMENT.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ make format
swiftformat .

hawkeye format
----
----

To regenerate all the test fixtures after changes to the codegen run `make generate-fixtures`.
24 changes: 16 additions & 8 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.10
// swift-tools-version: 6.0
//===----------------------------------------------------------------------===//
// Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
//
Expand Down Expand Up @@ -49,28 +49,33 @@ let package = Package(
targets: [
.target(
name: "PklSwift",
dependencies: ["MessagePack", "PklSwiftInternals", "SemanticVersion"]
dependencies: ["MessagePack", "PklSwiftInternals", "SemanticVersion"],
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
.target(
name: "PklSwiftInternals"
name: "PklSwiftInternals",
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
.target(
name: "MessagePack",
dependencies: [
.product(name: "SystemPackage", package: "swift-system"),
]
],
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
.executableTarget(
name: "pkl-gen-swift",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
"PklSwift",
],
resources: [.embedInCode("Resources/VERSION.txt")]
resources: [.embedInCode("Resources/VERSION.txt")],
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
.executableTarget(
name: "test-external-reader",
dependencies: ["PklSwift"]
dependencies: ["PklSwift"],
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
.testTarget(
name: "PklSwiftTests",
Expand All @@ -87,14 +92,17 @@ let package = Package(
"Fixtures/Collections.pkl",
"Fixtures/Poly.pkl",
"Fixtures/ApiTypes.pkl",
]
],
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
.testTarget(
name: "MessagePackTests",
dependencies: [
"MessagePack",
]
],
swiftSettings: [.enableUpcomingFeature("StrictConcurrency")]
),
],
swiftLanguageModes: [.v5, .v6],
cxxLanguageStandard: .cxx20
)
2 changes: 1 addition & 1 deletion Sources/MessagePack/Decoder/MessagePackDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public final class MessagePackDecoder {
}

/// A generic representation of MessagePack values.
public enum MessagePackValue {
public enum MessagePackValue: @unchecked Sendable {
case `nil`
case bool(Bool)
case int(any BinaryInteger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
}
}

func decode(_: Date.Type) throws -> Date {
private func decode(_: Date.Type) throws -> Date {
switch value {
case .timestamp(let value):
return value
Expand All @@ -101,7 +101,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
}
}

func decode(_: Data.Type) throws -> Data {
private func decode(_: Data.Type) throws -> Data {
switch value {
case .bin(let value):
return Data(value)
Expand All @@ -110,7 +110,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
}
}

func decode(_: [UInt8].Type) throws -> [UInt8] {
private func decode(_: [UInt8].Type) throws -> [UInt8] {
// accept either msgpack binary or array
switch value {
case .bin(let value):
Expand All @@ -130,7 +130,7 @@ extension _MessagePackDecoder.SingleValueContainer: SingleValueDecodingContainer
}
}

func decode(_: URL.Type) throws -> URL {
private func decode(_: URL.Type) throws -> URL {
switch value {
case .string(let value):
if let url = URL(string: value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
self.storage.append(contentsOf: value.bytes)
}

func encode(_ value: Date) throws {
private func encode(_ value: Date) throws {
try checkCanEncode(value: value)
defer { self.canEncodeNewValue = false }

Expand All @@ -246,7 +246,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
}
}

func encode(_ value: Data) throws {
private func encode(_ value: Data) throws {
let length = value.count
if let uint8 = UInt8(exactly: length) {
self.storage.append(0xC4)
Expand All @@ -269,7 +269,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
}
}

func encode(_ value: [UInt8]) throws {
private func encode(_ value: [UInt8]) throws {
let length = value.count
if let uint8 = UInt8(exactly: length) {
self.storage.append(0xC4)
Expand All @@ -292,7 +292,7 @@ extension _MessagePackEncoder.SingleValueContainer: SingleValueEncodingContainer
}
}

func encode(_ value: URL) throws {
private func encode(_ value: URL) throws {
try self.encode(value.absoluteString)
}

Expand Down
10 changes: 5 additions & 5 deletions Sources/MessagePack/IO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.
//===----------------------------------------------------------------------===//

public protocol Writer {
public protocol Writer: Sendable {
/// Write the given bytes into an output somewhere.
func write(_ buffer: UnsafeRawBufferPointer) throws

Expand All @@ -32,7 +32,7 @@ extension Writer {
}
}

public protocol Reader {
public protocol Reader: Sendable {
/// Reads bytes from somewhere, writing them into the given bytearray.
func read(into: UnsafeMutableRawBufferPointer) throws -> Int

Expand All @@ -41,7 +41,7 @@ public protocol Reader {
}

/// Writes bytes into an internal buffer.
public class BufferWriter: Writer {
public class BufferWriter: Writer, @unchecked Sendable {
var bytes: [UInt8] = []

public func write(_ buffer: UnsafeRawBufferPointer) throws {
Expand All @@ -54,7 +54,7 @@ public class BufferWriter: Writer {
}

/// Reads bytes from the provided buffer.
public class BufferReader: Reader {
public class BufferReader: Reader, @unchecked Sendable {
let bytes: [UInt8]
var index: Int

Expand All @@ -81,7 +81,7 @@ public class BufferReader: Reader {
}

/// Like [Reader], but also supports a way to peek bytes.
class PeekableReader: Reader {
class PeekableReader: Reader, @unchecked Sendable {
var peekedByte: UInt8?

let reader: Reader
Expand Down
4 changes: 2 additions & 2 deletions Sources/PklSwift/API/DataSize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
import MessagePack

/// DataSize is the Swift representation of Pkl's `pkl.DataSize`.
public struct DataSize: Hashable {
public struct DataSize: Hashable, Sendable {
/// The value of this ``DataSize`` in the unit set in ``unit``.
let value: Float64

Expand Down Expand Up @@ -150,7 +150,7 @@ extension DataSize {
}

/// The unit of a ``DataSize``.
public enum DataSizeUnit: String, CaseIterable, Decodable {
public enum DataSizeUnit: String, CaseIterable, Decodable, Sendable {
/// byte
case b

Expand Down
4 changes: 2 additions & 2 deletions Sources/PklSwift/API/Duration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Foundation

/// Duration is the Swift representation of Pkl's `pkl.Duration`.
public struct Duration: Hashable {
public struct Duration: Hashable, Sendable {
/// The value of this ``Duration`` in the unit set in ``unit``.
public let value: Float64

Expand Down Expand Up @@ -137,7 +137,7 @@ extension Duration {
}

/// A unit (magnitude) of duration.
public enum DurationUnit: String, CaseIterable, Decodable {
public enum DurationUnit: String, CaseIterable, Decodable, Sendable {
/// Nanosecond
case ns

Expand Down
2 changes: 1 addition & 1 deletion Sources/PklSwift/Decoder/PklDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import Foundation
import MessagePack

public enum PklValueType: UInt8, Decodable {
public enum PklValueType: UInt8, Decodable, Sendable {
case object = 0x1
case map = 0x2
case mapping = 0x3
Expand Down
10 changes: 5 additions & 5 deletions Sources/PklSwift/Evaluator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Foundation
/// - Parameters:
/// - options: The options used to configure the evaluator.
/// - action: The action to perform.
public func withEvaluator<T>(options: EvaluatorOptions, _ action: (Evaluator) async throws -> T) async throws -> T {
public func withEvaluator<T: Sendable>(options: EvaluatorOptions, _ action: (Evaluator) async throws -> T) async throws -> T {
try await withEvaluatorManager { manager in
let evaluator: Evaluator = try await manager.newEvaluator(options: options)
return try await action(evaluator)
Expand All @@ -32,7 +32,7 @@ public func withEvaluator<T>(options: EvaluatorOptions, _ action: (Evaluator) as
/// Like ``withEvaluator(options:_:)``, but with preconfigured evaluator options.
///
/// - Parameter action: The action to perform
public func withEvaluator<T>(_ action: (Evaluator) async throws -> T) async throws -> T {
public func withEvaluator<T: Sendable>(_ action: (Evaluator) async throws -> T) async throws -> T {
try await withEvaluator(options: .preconfigured, action)
}

Expand All @@ -42,7 +42,7 @@ public func withEvaluator<T>(_ action: (Evaluator) async throws -> T) async thro
/// - projectBaseURI: The base path containing the PklProject file.
/// - action: The action to perform.
/// - Returns: The result of the action.
public func withProjectEvaluator<T>(projectBaseURI: URL, _ action: (Evaluator) async throws -> T) async throws -> T {
public func withProjectEvaluator<T: Sendable>(projectBaseURI: URL, _ action: (Evaluator) async throws -> T) async throws -> T {
try await withProjectEvaluator(projectBaseURI: projectBaseURI, options: .preconfigured, action)
}

Expand All @@ -57,7 +57,7 @@ public func withProjectEvaluator<T>(projectBaseURI: URL, _ action: (Evaluator) a
/// - options: The base options used to configure the evaluator.
/// - action: The action to perform.
/// - Returns: The result of the action.
public func withProjectEvaluator<T>(
public func withProjectEvaluator<T: Sendable>(
projectBaseURI: URL,
options: EvaluatorOptions,
_ action: (Evaluator) async throws -> T
Expand All @@ -69,7 +69,7 @@ public func withProjectEvaluator<T>(
}

/// The core API for evaluating Pkl modules.
public struct Evaluator {
public struct Evaluator: Sendable {
private var manager: EvaluatorManager
private let evaluatorID: Int64
private let resourceReaders: [ResourceReader]
Expand Down
Loading