Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 12 additions & 0 deletions Plugins/JExtractSwiftPlugin/JExtractSwiftPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ struct JExtractSwiftBuildToolPlugin: SwiftJavaPluginProtocol, BuildToolPlugin {
arguments += ["--java-package", javaPackage]
}

if let unsignedNumbersMode = configuration.unsignedNumbersMode {
arguments += ["--unsigned-numbers", unsignedNumbersMode.rawValue]
}

if let minimumInputAccessLevelMode = configuration.minimumInputAccessLevelMode {
arguments += ["--minimum-input-access-level", minimumInputAccessLevelMode.rawValue]
}

if let memoryManagementMode = configuration.memoryManagementMode {
arguments += ["--memory-management-mode", memoryManagementMode.rawValue]
}

let swiftFiles = sourceModule.sourceFiles.map { $0.url }.filter {
$0.pathExtension == "swift"
}
Expand Down
4 changes: 2 additions & 2 deletions Plugins/PluginsShared/PluginUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ extension PluginContext {
.appending(path: "generated")
.appending(path: "java")
}

var outputSwiftDirectory: URL {
self.pluginWorkDirectoryURL
.appending(path: "Sources")
}

func cachedClasspathFile(swiftModule: String) -> URL {
self.pluginWorkDirectoryURL
.appending(path: "\(swiftModule)", directoryHint: .notDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ on the Java side.
| `Float` | `float` |
| `Double` | `double` |

#### Unsigned numbers mode: wrap-guava
#### Unsigned numbers mode: wrapGuava

You can configure `jextract` (in FFM mode) to instead import unsigned values as their unsigned type-safe representations
as offered by the Guava library: `UnsignedLong` or `UnsignedInt`. To enable this mode pass the `--unsigned-numbers wrap-guava`
as offered by the Guava library: `UnsignedLong` or `UnsignedInt`. To enable this mode pass the `--unsigned-numbers wrapGuava`
command line option, or set the corresponding configuration value in `swift-java.config` (TODO).

This approach is type-safe, however it incurs a performance penalty for allocating a wrapper class for every
Expand All @@ -163,7 +163,7 @@ you are expected to add a Guava dependency to your Java project.
| `Float` | `float` |
| `Double` | `double` |

> Note: The `wrap-guava` mode is currently only available in FFM mode of jextract.
> Note: The `wrapGuava` mode is currently only available in FFM mode of jextract.

### Enums

Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftJavaTool/Commands/JExtractCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ extension SwiftJava {
@Flag(help: "Some build systems require an output to be present when it was 'expected', even if empty. This is used by the JExtractSwiftPlugin build plugin, but otherwise should not be necessary.")
var writeEmptyFiles: Bool = false

@Option(help: "The mode of generation to use for the output files. Used with jextract mode. By default, unsigned Swift types are imported as their bit-width compatible signed Java counterparts, and annotated using the '@Unsigned' annotation. You may choose the 'wrap-guava' mode in order to import types as class wrapper types (`UnsignedInteger` et al) defined by the Google Guava library's `com.google.common.primitives' package. that ensure complete type-safety with regards to unsigned values, however they incur an allocation and performance overhead.")
@Option(help: "The mode of generation to use for the output files. Used with jextract mode. By default, unsigned Swift types are imported as their bit-width compatible signed Java counterparts, and annotated using the '@Unsigned' annotation. You may choose the 'wrapGuava' mode in order to import types as class wrapper types (`UnsignedInteger` et al) defined by the Google Guava library's `com.google.common.primitives' package. that ensure complete type-safety with regards to unsigned values, however they incur an allocation and performance overhead.")
var unsignedNumbers: JExtractUnsignedIntegerMode = .default

@Option(help: "The lowest access level of Swift declarations that should be extracted, defaults to 'public'.")
var minimumInputAccessLevel: JExtractMinimumAccessLevelMode = .default

@Option(help: "The memory management mode to use for the generated code. By default, the user must explicitly provide `SwiftArena` to all calls that require it. By choosing `allow-automatic`, user can omit this parameter and a global GC-based arena will be used. `force-automatic` removes all explicit memory management.")
@Option(help: "The memory management mode to use for the generated code. By default, the user must explicitly provide `SwiftArena` to all calls that require it. By choosing `allowGlobalAutomatic`, user can omit this parameter and a global GC-based arena will be used.")
var memoryManagementMode: JExtractMemoryManagementMode = .default

@Option(
Expand Down
Loading