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 3 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
4 changes: 2 additions & 2 deletions Sources/_Subprocess/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
10 changes: 5 additions & 5 deletions Sources/_Subprocess/Platforms/Subprocess+Darwin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import _CShims

// Darwin specific implementation
extension Subprocess.Configuration {
internal typealias StringOrRawBytes = Subprocess.StringOrRawBytes
typealias StringOrRawBytes = Subprocess.StringOrRawBytes

internal func spawn(
func spawn(
withInput input: Subprocess.ExecutionInput,
output: Subprocess.ExecutionOutput,
error: Subprocess.ExecutionOutput
Expand Down Expand Up @@ -224,7 +224,7 @@ extension Subprocess {
public var launchRequirementData: Data? = nil
/// An ordered list of steps in order to tear down the child
/// process in case the parent task is cancelled before
/// the child proces terminates.
/// the child process terminates.
/// Always ends in sending a `.kill` signal at the end.
public var teardownSequence: [TeardownStep] = []
/// A closure to configure platform-specific
Expand Down Expand Up @@ -288,7 +288,7 @@ extension Subprocess.PlatformOptions: Hashable {
}

extension Subprocess.PlatformOptions : CustomStringConvertible, CustomDebugStringConvertible {
internal func description(withIndent indent: Int) -> String {
func description(withIndent indent: Int) -> String {
let indent = String(repeating: " ", count: indent * 4)
return """
PlatformOptions(
Expand All @@ -315,7 +315,7 @@ PlatformOptions(

// MARK: - Process Monitoring
@Sendable
internal func monitorProcessTermination(
func monitorProcessTermination(
forProcessWithIdentifier pid: Subprocess.ProcessIdentifier
) async throws -> Subprocess.TerminationStatus {
return try await withCheckedThrowingContinuation { continuation in
Expand Down
12 changes: 6 additions & 6 deletions Sources/_Subprocess/Platforms/Subprocess+Linux.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import _CShims

// Linux specific implementations
extension Subprocess.Configuration {
internal typealias StringOrRawBytes = Subprocess.StringOrRawBytes
typealias StringOrRawBytes = Subprocess.StringOrRawBytes

internal func spawn(
func spawn(
withInput input: Subprocess.ExecutionInput,
output: Subprocess.ExecutionOutput,
error: Subprocess.ExecutionOutput
Expand Down Expand Up @@ -123,7 +123,7 @@ extension Subprocess {
public var createSession: Bool = false
/// An ordered list of steps in order to tear down the child
/// process in case the parent task is cancelled before
/// the child proces terminates.
/// the child process terminates.
/// Always ends in sending a `.kill` signal at the end.
public var teardownSequence: [TeardownStep] = []
/// A closure to configure platform-specific
Expand Down Expand Up @@ -180,7 +180,7 @@ extension Subprocess.PlatformOptions: Hashable {
}

extension Subprocess.PlatformOptions : CustomStringConvertible, CustomDebugStringConvertible {
internal func description(withIndent indent: Int) -> String {
func description(withIndent indent: Int) -> String {
let indent = String(repeating: " ", count: indent * 4)
return """
PlatformOptions(
Expand Down Expand Up @@ -210,7 +210,7 @@ extension String {

// MARK: - Process Monitoring
@Sendable
internal func monitorProcessTermination(
func monitorProcessTermination(
forProcessWithIdentifier pid: Subprocess.ProcessIdentifier
) async throws -> Subprocess.TerminationStatus {
return try await withCheckedThrowingContinuation { continuation in
Expand Down Expand Up @@ -262,7 +262,7 @@ private let setup: () = {
default:
fatalError("Unexpected exit status: \(siginfo.si_code)")
}
if let status = status {
if let status {
let pid = siginfo._sifields._sigchld.si_pid
if let existing = continuations.removeValue(forKey: pid),
case .continuation(let c) = existing {
Expand Down
34 changes: 17 additions & 17 deletions Sources/_Subprocess/Platforms/Subprocess+Unix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extension Subprocess {
}
}

internal func tryTerminate() -> Error? {
func tryTerminate() -> Error? {
do {
try self.send(.kill, toProcessGroup: true)
} catch {
Expand All @@ -124,9 +124,9 @@ extension Subprocess {

// MARK: - Environment Resolution
extension Subprocess.Environment {
internal static let pathEnvironmentVariableName = "PATH"
static let pathEnvironmentVariableName = "PATH"

internal func pathValue() -> String? {
func pathValue() -> String? {
switch self.config {
case .inherit(let overrides):
// If PATH value exists in overrides, use it
Expand All @@ -145,7 +145,7 @@ extension Subprocess.Environment {

// This method follows the standard "create" rule: `env` needs to be
// manually deallocated
internal func createEnv() -> [UnsafeMutablePointer<CChar>?] {
func createEnv() -> [UnsafeMutablePointer<CChar>?] {
func createFullCString(
fromKey keyContainer: Subprocess.StringOrRawBytes,
value valueContainer: Subprocess.StringOrRawBytes
Expand Down Expand Up @@ -212,7 +212,7 @@ extension Subprocess.Environment {
extension Subprocess.Arguments {
// This method follows the standard "create" rule: `args` needs to be
// manually deallocated
internal func createArgs(withExecutablePath executablePath: String) -> [UnsafeMutablePointer<CChar>?] {
func createArgs(withExecutablePath executablePath: String) -> [UnsafeMutablePointer<CChar>?] {
var argv: [UnsafeMutablePointer<CChar>?] = self.storage.map { $0.createRawBytes() }
// argv[0] = executable path
if let override = self.executablePathOverride {
Expand Down Expand Up @@ -246,7 +246,7 @@ extension Subprocess.ProcessIdentifier : CustomStringConvertible, CustomDebugStr

// MARK: - Executable Searching
extension Subprocess.Executable {
internal static var defaultSearchPaths: Set<String> {
static var defaultSearchPaths: Set<String> {
return Set([
"/usr/bin",
"/bin",
Expand All @@ -256,7 +256,7 @@ extension Subprocess.Executable {
])
}

internal func resolveExecutablePath(withPathValue pathValue: String?) -> String? {
func resolveExecutablePath(withPathValue pathValue: String?) -> String? {
switch self.storage {
case .executable(let executableName):
// If the executableName in is already a full path, return it directly
Expand Down Expand Up @@ -289,7 +289,7 @@ extension Subprocess.Executable {

// MARK: - Configuration
extension Subprocess.Configuration {
internal func preSpawn() throws -> (
func preSpawn() throws -> (
executablePath: String,
env: [UnsafeMutablePointer<CChar>?],
argv: [UnsafeMutablePointer<CChar>?],
Expand Down Expand Up @@ -343,7 +343,7 @@ extension Subprocess.Configuration {
)
}

internal static func pathAccessible(_ path: String, mode: Int32) -> Bool {
static func pathAccessible(_ path: String, mode: Int32) -> Bool {
return path.withCString {
return access($0, mode) == 0
}
Expand All @@ -352,18 +352,18 @@ extension Subprocess.Configuration {

// MARK: - FileDescriptor extensions
extension FileDescriptor {
internal static func openDevNull(
static func openDevNull(
withAcessMode mode: FileDescriptor.AccessMode
) throws -> FileDescriptor {
let devnull: FileDescriptor = try .open("/dev/null", mode)
return devnull
}

internal var platformDescriptor: Subprocess.PlatformFileDescriptor {
var platformDescriptor: Subprocess.PlatformFileDescriptor {
return self
}

internal func readChunk(upToLength maxLength: Int) async throws -> Data? {
func readChunk(upToLength maxLength: Int) async throws -> Data? {
return try await withCheckedThrowingContinuation { continuation in
DispatchIO.read(
fromFileDescriptor: self.rawValue,
Expand All @@ -383,7 +383,7 @@ extension FileDescriptor {
}
}

internal func readUntilEOF(upToLength maxLength: Int) async throws -> Data {
func readUntilEOF(upToLength maxLength: Int) async throws -> Data {
return try await withCheckedThrowingContinuation { continuation in
let dispatchIO = DispatchIO(
type: .stream,
Expand All @@ -404,7 +404,7 @@ extension FileDescriptor {
continuation.resume(throwing: POSIXError(.init(rawValue: error) ?? .ENODEV))
return
}
if let data = data {
if let data {
buffer += Data(data)
}
if done {
Expand All @@ -415,7 +415,7 @@ extension FileDescriptor {
}
}

internal func write<S: Sequence>(_ data: S) async throws where S.Element == UInt8 {
func write<S: Sequence>(_ data: S) async throws where S.Element == UInt8 {
try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<Void, Error>) -> Void in
let dispatchData: DispatchData = Array(data).withUnsafeBytes {
return DispatchData(bytes: $0)
Expand All @@ -439,13 +439,13 @@ extension FileDescriptor {
}

extension Subprocess {
internal typealias PlatformFileDescriptor = FileDescriptor
typealias PlatformFileDescriptor = FileDescriptor
}

// MARK: - Read Buffer Size
extension Subprocess {
@inline(__always)
internal static var readBufferSize: Int {
static var readBufferSize: Int {
#if canImport(Darwin)
return 16384
#else
Expand Down
Loading