Skip to content

[JExtract/FFM] Translate 'some DataProtocol' parameters to 'Data' #303

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

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 10, 2025

  • Introduce SwiftType.opaque(SwiftType) and .existential(SwiftType) to represent some and any types respectively.
  • Introduce SwiftKnownTypes.representativeType(of:) to the hardcoded DataProtocol -> Data translation mapping.

* Introduce `SwiftType.opaque(SwiftType)` and `.existential(SwiftType)`
  to represent `some` and `any` types respectively.
* Introduce `SwiftKnownTypes.representativeType(of:)` to the hardcoded
  `DataProtocol` -> `Data` translation mapping.
try (var arena = AllocatingSwiftArena.ofConfined()) {
var bytes = arena.allocateFrom("hello");
var dat = Data.init(bytes, bytes.byteSize(), arena);
MySwiftLibrary.globalReceiveSomeDataProtocol(dat);
Copy link
Member Author

Choose a reason for hiding this comment

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

@ktoso I'd be happy to make this and Data thing test cases, but where exactly I should write? Any PR testing runs Samples:SwiftKitSampleApp:test?

Copy link
Collaborator

Choose a reason for hiding this comment

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

So every example has a ci-validate.sh and you can add a ./gradle test in there in Samples/SwiftKitSampleApp/ci-validate.sh and add a test in Samples/SwiftKitSampleApp/src/test/java/com/example/swift :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh boy I just realized we have tests there but we've not been running them huh. so yeah please add a gradle test there :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

let concreteTy = knownTypes.representativeType(of: knownProtocol)
{
return try lowerParameter(concreteTy, convention: convention, parameterName: parameterName)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Very nice!

Also, run Samples:SwiftKitSampleApp:test in CI
@rintaro rintaro merged commit 31fd9e3 into swiftlang:main Jul 10, 2025
55 of 56 checks passed
@rintaro rintaro deleted the jextract-ffm-representative branch July 11, 2025 00:07
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.

2 participants