@@ -87,6 +87,26 @@ extension JavaType {
8787
8888}
8989
90+ /// Determines how type conversion should deal with Swift's unsigned numeric types.
91+ ///
92+ /// When `ignoreSign` is used, unsigned Swift types are imported directly as their corresponding bit-width types,
93+ /// which may yield surprising values when an unsigned Swift value is interpreted as a signed Java type:
94+ /// - `UInt8` is imported as `byte`
95+ /// - `UInt16` is imported as `char` (this is always correct, since `char` is unsigned in Java)
96+ /// - `UInt32` is imported as `int`
97+ /// - `UInt64` is imported as `long`
98+ ///
99+ /// When `wrapAsUnsignedNumbers` is used, unsigned Swift types are imported as safe "wrapper" types on the Java side.
100+ /// These make the Unsigned nature of the types explicit in Java, however they come at a cost of allocating the wrapper
101+ /// object, and indirection when accessing the underlying numeric value. These are often useful as a signal to watch out
102+ /// when dealing with a specific API, however in high performance use-cases, one may want to choose using the primitive
103+ /// values directly, and interact with them using {@code UnsignedIntegers} SwiftKit helper classes on the Java side.
104+ ///
105+ /// The type mappings in this mode are as follows:
106+ /// - `UInt8` is imported as `org.swift.swiftkit.core.primitives.UnsignedByte`
107+ /// - `UInt16` is imported as `char` (this is always correct, since `char` is unsigned in Java)
108+ /// - `UInt32` is imported as `org.swift.swiftkit.core.primitives.UnsignedInteger`
109+ /// - `UInt64` is imported as `org.swift.swiftkit.core.primitives.UnsignedLong`
90110public enum UnsignedNumericsMode {
91111 case ignoreSign
92112 case wrapAsUnsignedNumbers
0 commit comments