Skip to content

Commit e998244

Browse files
committed
correct configuration and some compile issues
1 parent 3f5d93b commit e998244

File tree

9 files changed

+45
-242
lines changed

9 files changed

+45
-242
lines changed

Samples/SwiftKitSampleApp/src/test/java/com/example/swift/UnsignedNumbersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public class UnsignedNumbersTest {
2323
void take_uint32() {
2424
try (var arena = AllocatingSwiftArena.ofConfined()) {
2525
var c = MySwiftClass.init(1, 2, arena);
26-
c.takeUnsignedInt(UnsignedInteger.valueOf(128));
26+
c.takeUnsignedInt(128);
2727
}
2828
}
2929

3030
@Test
3131
void take_uint64() {
3232
try (var arena = AllocatingSwiftArena.ofConfined()) {
3333
var c = MySwiftClass.init(1, 2, arena);
34-
c.takeUnsignedLong(UnsignedLong.MAX_VALUE);
34+
c.takeUnsignedLong(Long.MAX_VALUE);
3535
}
3636
}
3737
}

Sources/JExtractSwiftLib/FFM/FFMSwift2JavaGenerator+JavaTranslation.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ extension FFMSwift2JavaGenerator {
321321
methodName: String
322322
) throws -> TranslatedParameter {
323323

324-
// If we need to handle unsigned integers "safely" do so here
325-
if config.unsignedNumbersMode.needsConversion {
324+
// If we need to handle unsigned integers do so here
325+
if config.effectiveUnsignedNumbersMode.needsConversion {
326326
if let unsignedWrapperType = JavaType.unsignedWrapper(for: swiftType) /* and we're in safe wrapper mode */ {
327327
return TranslatedParameter(
328328
javaParameters: [
@@ -540,7 +540,7 @@ extension FFMSwift2JavaGenerator {
540540
/// Determine if the given type needs any extra annotations that should be included
541541
/// in Java sources when the corresponding Java type is rendered.
542542
func getTypeAnnotations(swiftType: SwiftType) -> [JavaAnnotation] {
543-
if swiftType.isUnsignedInteger, config.unsignedNumbersMode == .annotate {
543+
if swiftType.isUnsignedInteger, config.effectiveUnsignedNumbersMode == .annotate {
544544
return [JavaAnnotation.unsigned]
545545
}
546546

@@ -583,15 +583,15 @@ extension FFMSwift2JavaGenerator {
583583
) throws -> TranslatedResult {
584584
let swiftType = swiftResult.type
585585

586-
// If we need to handle unsigned integers "safely" do so here
587-
if config.unsignedNumbersMode.needsConversion {
586+
// If we need to handle unsigned integers do so here
587+
if config.effectiveUnsignedNumbersMode.needsConversion {
588588
if let unsignedWrapperType = JavaType.unsignedWrapper(for: swiftType) /* and we're in safe wrapper mode */ {
589589
return TranslatedResult(
590590
javaResultType: unsignedWrapperType,
591591
outParameters: [],
592592
conversion: unsignedResultConversion(
593593
swiftType, to: unsignedWrapperType,
594-
mode: self.config.unsignedNumbersMode)
594+
mode: self.config.effectiveUnsignedNumbersMode)
595595
)
596596
}
597597
}

Sources/JavaKitConfigurationShared/Configuration.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public struct Configuration: Codable {
4242

4343
public var writeEmptyFiles: Bool? // FIXME: default it to false, but that plays not nice with Codable
4444

45-
public var unsignedNumbersMode: JExtractUnsignedIntegerMode = .default
45+
public var unsignedNumbersMode: JExtractUnsignedIntegerMode?
46+
public var effectiveUnsignedNumbersMode: JExtractUnsignedIntegerMode {
47+
unsignedNumbersMode ?? .default
48+
}
4649

4750
// ==== java 2 swift ---------------------------------------------------------
4851

Sources/JavaKitConfigurationShared/JExtractModes.swift renamed to Sources/JavaKitConfigurationShared/GenerationMode.swift

File renamed without changes.

Sources/_Subprocess/Configuration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct Configuration: Sendable {
4040
public var environment: Environment
4141
/// The working directory to use when running the executable.
4242
public var workingDirectory: FilePath
43-
/// The platform specifc options to use when
43+
/// The platform specific options to use when
4444
/// running the subprocess.
4545
public var platformOptions: PlatformOptions
4646

SwiftKitCore/src/main/java/org/swift/swiftkit/core/annotations/NonNull.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
package org.swift.swiftkit.core.annotations;
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
214

15+
package org.swift.swiftkit.core.annotations;
316

417
import java.lang.annotation.Documented;
518
import java.lang.annotation.Retention;

SwiftKitCore/src/main/java/org/swift/swiftkit/core/annotations/Nullable.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
package org.swift.swiftkit.core.annotations;
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift.org project authors
6+
// Licensed under Apache License v2.0
7+
//
8+
// See LICENSE.txt for license information
9+
// See CONTRIBUTORS.txt for the list of Swift.org project authors
10+
//
11+
// SPDX-License-Identifier: Apache-2.0
12+
//
13+
//===----------------------------------------------------------------------===//
214

15+
package org.swift.swiftkit.core.annotations;
316

417
import static java.lang.annotation.ElementType.TYPE_USE;
518
import static java.lang.annotation.RetentionPolicy.RUNTIME;

SwiftKitCore/src/main/java/org/swift/swiftkit/core/primitives/SignedBytes.java

Lines changed: 0 additions & 228 deletions
This file was deleted.

Tests/JExtractSwiftTests/UnsignedNumberTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class UnsignedNumberTests {
3737
);
3838
""",
3939
"""
40-
public static void unsignedChar(@Unsigned char arg) {
40+
public static void unsignedChar(char arg) {
4141
swiftjava_SwiftModule_unsignedChar__.call(arg);
4242
}
4343
""",
@@ -109,9 +109,11 @@ final class UnsignedNumberTests {
109109

110110
@Test("Import: return UInt32 (default)")
111111
func returnUnsignedIntDefault() throws {
112+
var config = Configuration()
113+
112114
try assertOutput(
113115
input: "public func returnUnsignedInt() -> UInt32",
114-
config: Configuration(),
116+
config: config,
115117
.ffm, .java,
116118
detectChunkByInitialLines: 2,
117119
expectedChunks: [

0 commit comments

Comments
 (0)