Skip to content

Commit 4b753f0

Browse files
committed
PR feedback
1 parent e94b6c2 commit 4b753f0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Sources/JExtractSwiftLib/JNI/JNISwift2JavaGenerator+JavaBindingsPrinting.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ extension JNISwift2JavaGenerator {
171171

172172
printer.print(
173173
"""
174-
// Pointer to the "self".
174+
/** Pointer to the "self". */
175175
private final long selfPointer;
176176
177177
/** Used to track additional state of the underlying object, e.g. if it was explicitly destroyed. */

Sources/SwiftJavaDocumentation/Documentation.docc/SupportedFeatures.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ SwiftJava's `swift-java jextract` tool automates generating Java bindings from S
6262
| Dictionaries: `[String: Int]`, `[K:V]` |||
6363
| Generic parameters in functions: `func f<T: A & B>(x: T)` |||
6464
| Generic return values in functions: `func f<T: A & B>() -> T` |||
65-
| `Foundation.Data`, `any Foundation.DataProtocol` |||
6665
| Tuples: `(Int, String)`, `(A, B, C)` |||
6766
| Protocols: `protocol` |||
67+
| Protocols: `protocol` with associated types |||
68+
| Existential parameters `f(x: any SomeProtocol) ` |||
6869
| Existential parameters `f(x: any (A & B)) ` |||
6970
| Existential return types `f() -> any Collection ` |||
71+
| Foundation Data and DataProtocol: `f(x: any DataProtocol) -> Data` |||
7072
| Opaque parameters: `func take(worker: some Builder) -> some Builder` |||
7173
| Opaque return types: `func get() -> some Builder` |||
7274
| Optional parameters: `func f(i: Int?, class: MyClass?)` |||
@@ -272,9 +274,11 @@ try (var arena = SwiftArena.ofConfined()) {
272274

273275
### Protocols
274276

275-
> Note: Protocols are currently only supported in JNI mode.
277+
> Note: Protocols are currently only supported in JNI mode.
278+
>
279+
> With the exception of `any DataProtocol` which is handled as `Foundation.Data` in the FFM mode.
276280
277-
Protocols are imported as Java `interface`s. For now, we require that all
281+
Swift `protocol` types are imported as Java `interface`s. For now, we require that all
278282
concrete types of an interface wrap a Swift instance. In the future, we will add support
279283
for providing Java-based implementations of interfaces, that you can pass to Java functions.
280284

@@ -305,6 +309,10 @@ will be exported as
305309
```java
306310
<S extends A & B, T1 extends C, T2 extends D> void f(S x, T1 y, T2 z)
307311
```
312+
On the Java side, only SwiftInstance implementing types may be passed;
313+
so this isn't a way for compatibility with just any arbitrary Java interfaces,
314+
but specifically, for allowing passing concrete binding types generated by jextract from Swift types
315+
which conform a to a given Swift protocol.
308316

309-
#### Return types
317+
#### Returning protocol types
310318
Protocols are not yet supported as return types.

0 commit comments

Comments
 (0)