Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SPICE-0009 External Readers #26

Merged
merged 9 commits into from
Jan 17, 2025
Merged

Conversation

HT154
Copy link
Contributor

@HT154 HT154 commented Sep 25, 2024

SPICE-0009

  • Add EvaluatorOptions.externalModuleReaders and EvaluatorOptions.externalResourceReaders.
  • Add ExternalReaderClient to host the child process side of the external reader workflow.

Comment on lines +335 to +339
case let bytes as [UInt8]:
guard type(of: value) == [UInt8].self else {
fallthrough
}
try self.encode(bytes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Swift, empty arrays succeed for dynamic casting operations to other array types (Array<T>() is Array<U> == true). In order to correctly fall through for empty non-UInt8 array an additional type comparison using type(of:) is required. For the fallthrough to work correctly this case must directly precede the default case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!

@HT154
Copy link
Contributor Author

HT154 commented Jan 14, 2025

This should be all set now! Probably best to merge after apple/pkl#882 lands, gets backported, and Pkl 0.27.2 is published and added to pkl-swift CI.

Copy link
Contributor

@bioball bioball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mostly looks good! See comments.

Also: can you update the license headers here?

For new files, set year to 2025. For files that have been modified, set year to 2024-2025.

Sources/PklSwift/MessageTransport.swift Outdated Show resolved Hide resolved
docs/modules/ROOT/pages/external-readers.adoc Show resolved Hide resolved
Comment on lines +335 to +339
case let bytes as [UInt8]:
guard type(of: value) == [UInt8].self else {
fallthrough
}
try self.encode(bytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL!

Sources/PklSwift/ExternalReaderClient.swift Outdated Show resolved Hide resolved
Sources/PklSwift/ExternalReaderClient.swift Outdated Show resolved Hide resolved
@HT154 HT154 requested a review from bioball January 16, 2025 03:31
Copy link
Contributor

@bioball bioball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Contributor

@stackoverflow stackoverflow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bioball bioball merged commit 64c66ae into apple:main Jan 17, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants