Skip to content

feature: Code enhancement #267

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 4 commits into from
Jun 27, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void arena_markAsDestroyed_preventUseAfterFree_class() {

try {
unsafelyEscapedOutsideArenaScope.echoIntMethod(1);
fail("Expected exception to be thrown! Object was suposed to be dead.");
fail("Expected exception to be thrown! Object was supposed to be dead.");
} catch (IllegalStateException ex) {
return;
}
Expand All @@ -82,7 +82,7 @@ public void arena_markAsDestroyed_preventUseAfterFree_struct() {

try {
unsafelyEscapedOutsideArenaScope.echoIntMethod(1);
fail("Expected exception to be thrown! Object was suposed to be dead.");
fail("Expected exception to be thrown! Object was supposed to be dead.");
} catch (IllegalStateException ex) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/JExtractSwiftLib/CodePrinter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public struct CodePrinter {
self.mode = mode
}

internal mutating func append(_ text: String) {
mutating func append(_ text: String) {
contents.append(text)
if self.verbose {
Swift.print(text, terminator: "")
}
}

internal mutating func append<S>(contentsOf text: S)
mutating func append<S>(contentsOf text: S)
where S: Sequence, S.Element == Character {
contents.append(contentsOf: text)
if self.verbose {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import SwiftDiagnostics
import SwiftSyntax

extension WithModifiersSyntax {
internal var accessControlModifiers: DeclModifierListSyntax {
var accessControlModifiers: DeclModifierListSyntax {
modifiers.filter { modifier in
modifier.isAccessControl
}
}
}

extension ImplicitlyUnwrappedOptionalTypeSyntax {
internal var asOptionalTypeSyntax: any TypeSyntaxProtocol {
var asOptionalTypeSyntax: any TypeSyntaxProtocol {
OptionalTypeSyntax(
leadingTrivia: leadingTrivia,
unexpectedBeforeWrappedType,
Expand Down
2 changes: 1 addition & 1 deletion Sources/JExtractSwiftLib/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ extension Logger.Level: ExpressibleByArgument {
}

extension Logger.Level {
internal var naturalIntegralValue: Int {
var naturalIntegralValue: Int {
switch self {
case .trace:
return 0
Expand Down
4 changes: 2 additions & 2 deletions Sources/JavaKit/JavaKitVM/LockedState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
//===----------------------------------------------------------------------===//

#if canImport(os)
internal import os
import os
#if FOUNDATION_FRAMEWORK && canImport(C.os.lock)
internal import C.os.lock
import C.os.lock
#endif
#elseif canImport(Bionic)
import Bionic
Expand Down
2 changes: 1 addition & 1 deletion Sources/JavaKit/JavaValue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import JavaTypes
/// The protocol provides operations to bridge values in both directions:
/// - `getJNIValue(in:)`: produces the JNI value (of type `JNIType`) for the
/// `self` Swift value in the given JNI environment.
/// - `init(fromJNI:in:)`: intializes a Swift value from the JNI value (of
/// - `init(fromJNI:in:)`: initializes a Swift value from the JNI value (of
/// type `JNIType`) in the given JNI environment.
///
/// The protocol also provides hooks to tie into JNI, including operations to
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftKitSwift/SwiftKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public func _swiftjava_swift_isUniquelyReferenced(object: UnsafeMutableRawPointe


@_alwaysEmitIntoClient @_transparent
internal func _swiftjava_withHeapObject<R>(
func _swiftjava_withHeapObject<R>(
of object: AnyObject,
_ body: (UnsafeMutableRawPointer) -> R
) -> R {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public abstract class SwiftValueWitnessTable {
MemoryLayout.PathElement.groupElement("vwt"));

/**
* Given the address of Swift type metadata for a type, return the addres
* Given the address of Swift type metadata for a type, return the address
* of the "full" type metadata that can be accessed via fullTypeMetadataLayout.
*/
public static MemorySegment fullTypeMetadata(MemorySegment typeMetadata) {
Expand Down
4 changes: 2 additions & 2 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Note that we are passing the Jar file in the `classpath` argument when initializ

### Downcasting

All Java classes available in Swift provide `is` and `as` methods to check whether an object dynamically matches another type. The `is` operation is the equivalent of Java's `instanceof` and Swift's `is` operator, and will checkin whether a given object is of the specified type, e.g.,
All Java classes available in Swift provide `is` and `as` methods to check whether an object dynamically matches another type. The `is` operation is the equivalent of Java's `instanceof` and Swift's `is` operator, and will checking whether a given object is of the specified type, e.g.,

```swift
if myObject.is(URL.self) {
Expand Down Expand Up @@ -620,7 +620,7 @@ The project is still very early days, however the general outline of using this
- These `.swiftinterface` files are imported by jextract-swift which generates `*.java` files
- The generated Java files contain generated code for efficient native invocations.

You can then use Swift libraries in Java just by calling the apropriate methods and initializers.
You can then use Swift libraries in Java just by calling the appropriate methods and initializers.

## `jextract-swift`: Generating Java bridging files

Expand Down