Gross stdlib cleanup (part 3). (#1929)

This commit is contained in:
Nikolay Igotti
2018-08-24 18:46:00 +03:00
committed by GitHub
parent a52dd55d42
commit cbc404324c
48 changed files with 280 additions and 497 deletions
@@ -147,7 +147,7 @@ private fun AnnotationDescriptor.properValue(key: String) =
private fun functionImplName(descriptor: DeclarationDescriptor, default: String, shortName: Boolean): String {
assert(descriptor is FunctionDescriptor)
val annotation = descriptor.annotations.findAnnotation(cnameAnnotation) ?: return default
val key = if (shortName) "shortName" else "fullName"
val key = if (shortName) "shortName" else "externName"
val value = annotation.properValue(key)
return value.takeIf { value != null && value.isNotEmpty() } ?: default
}
@@ -262,8 +262,8 @@ private class ExportedElement(val kind: ElementKind,
if (declaration !is FunctionDescriptor || !declaration.annotations.hasAnnotation(cnameAnnotation))
return false
val annotation = declaration.annotations.findAnnotation(cnameAnnotation)!!
val fullName = annotation.properValue("fullName")
return fullName != null && fullName.isNotEmpty()
val externName = annotation.properValue("externName")
return externName != null && externName.isNotEmpty()
}
val isClass = declaration is ClassDescriptor && declaration.kind != ClassKind.ENUM_ENTRY
val isEnumEntry = declaration is ClassDescriptor && declaration.kind == ClassKind.ENUM_ENTRY
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
// TODO: port this code to IR.
internal val IrDeclaration.isAnonymousObject get() = DescriptorUtils.isAnonymousObject(this.descriptor)
internal val IrFunction.isExternal get() = this.descriptor.isExternal
internal val IrDeclaration.isLocal get() = DescriptorUtils.isLocal(this.descriptor)
internal val IrDeclaration.module get() = this.descriptor.module
@@ -245,7 +245,7 @@ private fun Context.buildBridge(startOffset: Int, endOffset: Int,
val delegatingCall = IrCallImpl(
startOffset,
endOffset,
(targetSymbol.owner as IrFunction).returnType,
targetSymbol.owner.returnType,
targetSymbol,
targetSymbol.descriptor,
superQualifierSymbol = superQualifierSymbol /* Call non-virtually */
@@ -183,13 +183,12 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass
superTypes += functionIrClass.symbol.typeWith(functionClassTypeParameters)
var suspendFunctionIrClass: IrClass? = null
var suspendFunctionClassTypeParameters: List<IrType>? = null
val lastParameterType = unboundFunctionParameters.lastOrNull()?.type
if (lastParameterType != null && lastParameterType.classifierOrNull?.descriptor == continuationClassDescriptor) {
lastParameterType as IrSimpleType
// If the last parameter is Continuation<> inherit from SuspendFunction.
suspendFunctionIrClass = context.ir.symbols.suspendFunctions[numberOfParameters - 1].owner
suspendFunctionClassTypeParameters = functionParameterTypes.dropLast(1) +
var suspendFunctionClassTypeParameters = functionParameterTypes.dropLast(1) +
(lastParameterType.arguments.single().typeOrNull ?: context.irBuiltIns.anyNType)
superTypes += suspendFunctionIrClass.symbol.typeWith(suspendFunctionClassTypeParameters)
}
-2
View File
@@ -1452,8 +1452,6 @@ task array3(type: RunKonanTest) {
}
task typed_array0(type: RunKonanTest) {
// MIPS target is big-endian.
disabled = (project.testTarget == 'linux_mips32')
goldValue = "OK\n"
source = "runtime/collections/typed_array0.kt"
}
@@ -27,7 +27,7 @@ class AllCodePointsTest {
fun codePointToString(codePoint: Int): String {
val charArray = Char.toChars(codePoint)
return fromCharArray(charArray, 0, charArray.size)
return String(charArray, 0, charArray.size)
}
// TODO: Here is a performance problem: an execution of this test requires much more time than it in Kotlin/JVM.
@@ -15,12 +15,12 @@ open class Base {
open fun fooParam(arg0: String, arg1: Int) = println("Base.fooParam: $arg0 $arg1")
@CName(fullName = "", shortName = "strangeName") fun странноеИмя() = 111
@CName(externName = "", shortName = "strangeName") fun странноеИмя() = 111
}
// Top level functions.
@CName(fullName = "topLevelFunctionFromC", shortName = "topLevelFunctionFromCShort")
@CName(externName = "topLevelFunctionFromC", shortName = "topLevelFunctionFromCShort")
fun topLevelFunction(x1: Int, x2: Int) = x1 - x2
@CName("topLevelFunctionVoidFromC")
+1 -2
View File
@@ -17,6 +17,5 @@ import kotlin.test.*
a[2] = 'l'
a[3] = 'l'
a[4] = 'o'
// Note that it uses private Konan API.
println("Hello".hashCode() == fromCharArray(a, 0, 5).hashCode())
println("Hello".hashCode() == String(a, 0, 5).hashCode())
}
@@ -10,5 +10,5 @@ import kotlin.test.*
print(" ")
}
println()
println(fromCharArray(array, 0, array.size))
println(String(array, 0, array.size))
}
+39 -5
View File
@@ -146,7 +146,12 @@ KChar Kotlin_ByteArray_getCharAt(KConstRef thiz, KInt index) {
if (static_cast<uint32_t>(index + 1) >= array->count_) {
ThrowArrayIndexOutOfBoundsException();
}
return *reinterpret_cast<const KChar*>(ByteArrayAddressOfElementAt(array, index));
auto result = *reinterpret_cast<const KChar*>(ByteArrayAddressOfElementAt(array, index));
#if __BIG_ENDIAN__
return __builtin_bswap16(result);
#else
return result;
#endif
}
KShort Kotlin_ByteArray_getShortAt(KConstRef thiz, KInt index) {
@@ -154,7 +159,12 @@ KShort Kotlin_ByteArray_getShortAt(KConstRef thiz, KInt index) {
if (static_cast<uint32_t>(index + 1) >= array->count_) {
ThrowArrayIndexOutOfBoundsException();
}
return *reinterpret_cast<const KShort*>(ByteArrayAddressOfElementAt(array, index));
auto result = *reinterpret_cast<const KShort*>(ByteArrayAddressOfElementAt(array, index));
#if __BIG_ENDIAN__
return __builtin_bswap16(result);
#else
return result;
#endif
}
KInt Kotlin_ByteArray_getIntAt(KConstRef thiz, KInt index) {
@@ -162,7 +172,12 @@ KInt Kotlin_ByteArray_getIntAt(KConstRef thiz, KInt index) {
if (static_cast<uint32_t>(index + 3) >= array->count_) {
ThrowArrayIndexOutOfBoundsException();
}
return *reinterpret_cast<const KInt*>(ByteArrayAddressOfElementAt(array, index));
auto result = *reinterpret_cast<const KInt*>(ByteArrayAddressOfElementAt(array, index));
#if __BIG_ENDIAN__
return __builtin_bswap32(result);
#else
return result;
#endif
}
KLong Kotlin_ByteArray_getLongAt(KConstRef thiz, KInt index) {
@@ -170,7 +185,13 @@ KLong Kotlin_ByteArray_getLongAt(KConstRef thiz, KInt index) {
if (static_cast<uint32_t>(index + 7) >= array->count_) {
ThrowArrayIndexOutOfBoundsException();
}
return *reinterpret_cast<const KLong*>(ByteArrayAddressOfElementAt(array, index));
auto result = *reinterpret_cast<const KLong*>(ByteArrayAddressOfElementAt(array, index));
#if __BIG_ENDIAN__
return __builtin_bswap64(result);
#else
return result;
#endif
}
KFloat Kotlin_ByteArray_getFloatAt(KConstRef thiz, KInt index) {
@@ -178,7 +199,8 @@ KFloat Kotlin_ByteArray_getFloatAt(KConstRef thiz, KInt index) {
if (static_cast<uint32_t>(index + 3) >= array->count_) {
ThrowArrayIndexOutOfBoundsException();
}
return *reinterpret_cast<const KFloat*>(ByteArrayAddressOfElementAt(array, index));
auto result = *reinterpret_cast<const KFloat*>(ByteArrayAddressOfElementAt(array, index));
return result;
}
KDouble Kotlin_ByteArray_getDoubleAt(KConstRef thiz, KInt index) {
@@ -195,6 +217,9 @@ void Kotlin_ByteArray_setCharAt(KRef thiz, KInt index, KChar value) {
ThrowArrayIndexOutOfBoundsException();
}
mutabilityCheck(thiz);
#if __BIG_ENDIAN__
value = __builtin_bswap16(value);
#endif
*reinterpret_cast<KChar*>(ByteArrayAddressOfElementAt(array, index)) = value;
}
@@ -204,6 +229,9 @@ void Kotlin_ByteArray_setShortAt(KRef thiz, KInt index, KShort value) {
ThrowArrayIndexOutOfBoundsException();
}
mutabilityCheck(thiz);
#if __BIG_ENDIAN__
value = __builtin_bswap16(value);
#endif
*reinterpret_cast<KShort*>(ByteArrayAddressOfElementAt(array, index)) = value;
}
@@ -213,6 +241,9 @@ void Kotlin_ByteArray_setIntAt(KRef thiz, KInt index, KInt value) {
ThrowArrayIndexOutOfBoundsException();
}
mutabilityCheck(thiz);
#if __BIG_ENDIAN__
value = __builtin_bswap32(value);
#endif
*reinterpret_cast<KInt*>(ByteArrayAddressOfElementAt(array, index)) = value;
}
@@ -222,6 +253,9 @@ void Kotlin_ByteArray_setLongAt(KRef thiz, KInt index, KLong value) {
ThrowArrayIndexOutOfBoundsException();
}
mutabilityCheck(thiz);
#if __BIG_ENDIAN__
value = __builtin_bswap64(value);
#endif
*reinterpret_cast<KLong*>(ByteArrayAddressOfElementAt(array, index)) = value;
}
+1 -2
View File
@@ -23,7 +23,7 @@ import kotlin.native.internal.PointsTo
@ExportTypeInfo("theArrayTypeInfo")
public final class Array<T> {
// Constructors are handled with compiler magic.
@InlineConstructor
@Suppress("TYPE_PARAMETER_AS_REIFIED")
public constructor(size: Int, init: (Int) -> T): this(size) {
@@ -52,7 +52,6 @@ public final class Array<T> {
return IteratorImpl(this)
}
// Konan-specific.
@SymbolName("Kotlin_Array_getArrayLength")
external private fun getArrayLength(): Int
}
+2 -2
View File
@@ -20,7 +20,8 @@ package kotlin
* Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are
* represented as values of the primitive type `boolean`.
*/
public final class Boolean private constructor(private val value: kotlin.native.internal.BooleanValue) : Comparable<Boolean> {
public class Boolean private constructor(
private val value: kotlin.native.internal.BooleanValue) : Comparable<Boolean> {
@SinceKotlin("1.3")
companion object {}
@@ -52,7 +53,6 @@ public final class Boolean private constructor(private val value: kotlin.native.
@SymbolName("Kotlin_Boolean_compareTo_Boolean")
external public override fun compareTo(other: Boolean): Int
// Konan-specific.
public fun equals(other: Boolean): Boolean = kotlin.native.internal.areEqualByValue(this, other)
public override fun equals(other: Any?): Boolean =
+2 -4
View File
@@ -18,10 +18,9 @@ package kotlin
/**
* Represents a 16-bit Unicode character.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/
public final class Char private constructor(private val value: kotlin.native.internal.ShortValue) : Comparable<Char> {
public class Char private constructor(
private val value: kotlin.native.internal.ShortValue) : Comparable<Char> {
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
@@ -155,7 +154,6 @@ public final class Char private constructor(private val value: kotlin.native.int
public const val MAX_RADIX: Int = 36
}
// Konan-specific.
public fun equals(other: Char): Boolean = this == other
public override fun equals(other: Any?): Boolean =
+2 -2
View File
@@ -16,11 +16,11 @@
package kotlin
actual interface Comparator<T> {
actual public interface Comparator<T> {
actual fun compare(a: T, b: T): Int
}
actual inline fun <T> Comparator(crossinline comparison: (a: T, b: T) -> Int): Comparator<T> {
actual public inline fun <T> Comparator(crossinline comparison: (a: T, b: T) -> Int): Comparator<T> {
return object: Comparator<T> {
override fun compare(a: T, b: T) = comparison(a, b)
}
+3 -2
View File
@@ -22,6 +22,7 @@ package kotlin
* information on enum classes.
*/
public abstract class Enum<E: Enum<E>>(public val name: String, public val ordinal: Int): Comparable<E> {
public companion object {
}
@@ -49,10 +50,10 @@ public abstract class Enum<E: Enum<E>>(public val name: String, public val ordin
}
@Suppress("UNUSED_PARAMETER")
fun <T: Enum<T>> enumValueOf(name: String): T {
public fun <T: Enum<T>> enumValueOf(name: String): T {
throw Exception("Call to this function should've been lowered")
}
fun <T: Enum<T>> enumValues(): Array<T> {
public fun <T: Enum<T>> enumValues(): Array<T> {
throw Exception("Call to this function should've been lowered")
}
+23 -25
View File
@@ -16,96 +16,94 @@
package kotlin
// (0..22).joinToString("\n") { i -> "interface Function$i<${(1..i).joinToString("") { j -> "in P$j, " }}out R> : Function<R> {\n operator fun invoke(${(1..i).joinToString { j -> "p$j: P$j" }}): R\n}\n" }
interface Function0<out R> : Function<R> {
public interface Function0<out R> : Function<R> {
operator fun invoke(): R
}
interface Function1<in P1, out R> : Function<R> {
public interface Function1<in P1, out R> : Function<R> {
operator fun invoke(p1: P1): R
}
interface Function2<in P1, in P2, out R> : Function<R> {
public interface Function2<in P1, in P2, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2): R
}
interface Function3<in P1, in P2, in P3, out R> : Function<R> {
public interface Function3<in P1, in P2, in P3, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3): R
}
interface Function4<in P1, in P2, in P3, in P4, out R> : Function<R> {
public interface Function4<in P1, in P2, in P3, in P4, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R
}
interface Function5<in P1, in P2, in P3, in P4, in P5, out R> : Function<R> {
public interface Function5<in P1, in P2, in P3, in P4, in P5, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R
}
interface Function6<in P1, in P2, in P3, in P4, in P5, in P6, out R> : Function<R> {
public interface Function6<in P1, in P2, in P3, in P4, in P5, in P6, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R
}
interface Function7<in P1, in P2, in P3, in P4, in P5, in P6, in P7, out R> : Function<R> {
public interface Function7<in P1, in P2, in P3, in P4, in P5, in P6, in P7, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R
}
interface Function8<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, out R> : Function<R> {
public interface Function8<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R
}
interface Function9<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, out R> : Function<R> {
public interface Function9<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R
}
interface Function10<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, out R> : Function<R> {
public interface Function10<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R
}
interface Function11<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, out R> : Function<R> {
public interface Function11<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R
}
interface Function12<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, out R> : Function<R> {
public interface Function12<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R
}
interface Function13<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, out R> : Function<R> {
public interface Function13<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R
}
interface Function14<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, out R> : Function<R> {
public interface Function14<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R
}
interface Function15<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, out R> : Function<R> {
public interface Function15<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R
}
interface Function16<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, out R> : Function<R> {
public interface Function16<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R
}
interface Function17<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, out R> : Function<R> {
public interface Function17<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R
}
interface Function18<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, out R> : Function<R> {
public interface Function18<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R
}
interface Function19<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, out R> : Function<R> {
public interface Function19<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R
}
interface Function20<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, out R> : Function<R> {
public interface Function20<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R
}
interface Function21<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, out R> : Function<R> {
public interface Function21<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R
}
interface Function22<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, in P22, out R> : Function<R> {
public interface Function22<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, in P22, out R> : Function<R> {
operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R
}
+3 -3
View File
@@ -44,8 +44,8 @@ public actual fun <T> lazy(initializer: () -> T): Lazy<T> = FreezeAwareLazyImpl(
@FixmeConcurrency
public actual fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy<T> =
when (mode) {
LazyThreadSafetyMode.SYNCHRONIZED -> TODO() // was SynchronizedLazyImpl(initializer)
LazyThreadSafetyMode.PUBLICATION -> TODO() // was SafePublicationLazyImpl(initializer)
LazyThreadSafetyMode.SYNCHRONIZED -> throw UnsupportedOperationException()
LazyThreadSafetyMode.PUBLICATION -> throw UnsupportedOperationException()
LazyThreadSafetyMode.NONE -> UnsafeLazyImpl(initializer)
}
@@ -62,4 +62,4 @@ public actual fun <T> lazy(mode: LazyThreadSafetyMode, initializer: () -> T): La
*/
@FixmeConcurrency
@Suppress("UNUSED_PARAMETER")
public actual fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = TODO() // was SynchronizedLazyImpl(initializer, lock)
public actual fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> = throw UnsupportedOperationException()
+1 -6
View File
@@ -20,9 +20,9 @@ import kotlin.native.internal.NumberConverter
/**
* Represents a 8-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`.
*/
public final class Byte private constructor(private val value: kotlin.native.internal.ByteValue) : Number(), Comparable<Byte> {
companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
@@ -246,7 +246,6 @@ public final class Byte private constructor(private val value: kotlin.native.int
/**
* Represents a 16-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `short`.
*/
public final class Short private constructor(private val value: kotlin.native.internal.ShortValue) : Number(), Comparable<Short> {
companion object {
@@ -472,7 +471,6 @@ public final class Short private constructor(private val value: kotlin.native.in
/**
* Represents a 32-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `int`.
*/
public final class Int private constructor(private val value: kotlin.native.internal.IntValue) : Number(), Comparable<Int> {
companion object {
@@ -720,7 +718,6 @@ public final class Int private constructor(private val value: kotlin.native.inte
/**
* Represents a 64-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `long`.
*/
public final class Long private constructor(private val value: kotlin.native.internal.LongValue) : Number(), Comparable<Long> {
companion object {
@@ -968,7 +965,6 @@ public final class Long private constructor(private val value: kotlin.native.int
/**
* Represents a single-precision 32-bit IEEE 754 floating point number.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `float`.
*/
public final class Float private constructor(private val value: kotlin.native.internal.FloatValue) : Number(), Comparable<Float> {
companion object {
@@ -1188,7 +1184,6 @@ public final class Float private constructor(private val value: kotlin.native.in
/**
* Represents a double-precision 64-bit IEEE 754 floating point number.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `double`.
*/
public final class Double private constructor(private val value: kotlin.native.internal.DoubleValue) : Number(), Comparable<Double> {
companion object {
+2 -5
View File
@@ -58,11 +58,8 @@ public final class String : Comparable<String>, CharSequence {
external public override fun equals(other: Any?): Boolean
}
// TODO: in big Kotlin this operations are in kotlin.kotlin_builtins.
private fun nullString() = "null"
public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String =
(this?.toString() ?: nullString()).plus(other?.toString() ?: nullString())
(this?.toString() ?: "null").plus(other?.toString() ?: "null")
public fun Any?.toString() = this?.toString() ?: nullString()
public fun Any?.toString() = this?.toString() ?: "null"
@@ -16,96 +16,94 @@
package kotlin
// (0..22).joinToString("\n") { i -> "interface SuspendFunction$i<${(1..i).joinToString("") { j -> "in P$j, " }}out R> : SuspendFunction<R> {\n operator suspend fun invoke(${(1..i).joinToString { j -> "p$j: P$j" }}): R\n}\n" }
interface SuspendFunction0<out R> : SuspendFunction<R> {
public interface SuspendFunction0<out R> : SuspendFunction<R> {
operator suspend fun invoke(): R
}
interface SuspendFunction1<in P1, out R> : SuspendFunction<R> {
public interface SuspendFunction1<in P1, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1): R
}
interface SuspendFunction2<in P1, in P2, out R> : SuspendFunction<R> {
public interface SuspendFunction2<in P1, in P2, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2): R
}
interface SuspendFunction3<in P1, in P2, in P3, out R> : SuspendFunction<R> {
public interface SuspendFunction3<in P1, in P2, in P3, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3): R
}
interface SuspendFunction4<in P1, in P2, in P3, in P4, out R> : SuspendFunction<R> {
public interface SuspendFunction4<in P1, in P2, in P3, in P4, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R
}
interface SuspendFunction5<in P1, in P2, in P3, in P4, in P5, out R> : SuspendFunction<R> {
public interface SuspendFunction5<in P1, in P2, in P3, in P4, in P5, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R
}
interface SuspendFunction6<in P1, in P2, in P3, in P4, in P5, in P6, out R> : SuspendFunction<R> {
public interface SuspendFunction6<in P1, in P2, in P3, in P4, in P5, in P6, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R
}
interface SuspendFunction7<in P1, in P2, in P3, in P4, in P5, in P6, in P7, out R> : SuspendFunction<R> {
public interface SuspendFunction7<in P1, in P2, in P3, in P4, in P5, in P6, in P7, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R
}
interface SuspendFunction8<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, out R> : SuspendFunction<R> {
public interface SuspendFunction8<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R
}
interface SuspendFunction9<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, out R> : SuspendFunction<R> {
public interface SuspendFunction9<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R
}
interface SuspendFunction10<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, out R> : SuspendFunction<R> {
public interface SuspendFunction10<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R
}
interface SuspendFunction11<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, out R> : SuspendFunction<R> {
public interface SuspendFunction11<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R
}
interface SuspendFunction12<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, out R> : SuspendFunction<R> {
public interface SuspendFunction12<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R
}
interface SuspendFunction13<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, out R> : SuspendFunction<R> {
public interface SuspendFunction13<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R
}
interface SuspendFunction14<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, out R> : SuspendFunction<R> {
public interface SuspendFunction14<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R
}
interface SuspendFunction15<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, out R> : SuspendFunction<R> {
public interface SuspendFunction15<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R
}
interface SuspendFunction16<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, out R> : SuspendFunction<R> {
public interface SuspendFunction16<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R
}
interface SuspendFunction17<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, out R> : SuspendFunction<R> {
public interface SuspendFunction17<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R
}
interface SuspendFunction18<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, out R> : SuspendFunction<R> {
public interface SuspendFunction18<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R
}
interface SuspendFunction19<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, out R> : SuspendFunction<R> {
public interface SuspendFunction19<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R
}
interface SuspendFunction20<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, out R> : SuspendFunction<R> {
public interface SuspendFunction20<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R
}
interface SuspendFunction21<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, out R> : SuspendFunction<R> {
public interface SuspendFunction21<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R
}
interface SuspendFunction22<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, in P22, out R> : SuspendFunction<R> {
public interface SuspendFunction22<in P1, in P2, in P3, in P4, in P5, in P6, in P7, in P8, in P9, in P10, in P11, in P12, in P13, in P14, in P15, in P16, in P17, in P18, in P19, in P20, in P21, in P22, out R> : SuspendFunction<R> {
operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R
}
@@ -307,7 +307,9 @@ external private fun copyImpl(array: BooleanArray, fromIndex: Int,
* Copies a range of array elements at a specified [fromIndex] (inclusive) to [toIndex] (exclusive) range of indices
* to another [destination] array starting at [destinationIndex].
*/
fun <E> Array<out E>.copyRangeTo(destination: Array<in E>, fromIndex: Int, toIndex: Int, destinationIndex: Int = 0) {
@PublishedApi
internal fun <E> Array<out E>.copyRangeTo(
destination: Array<in E>, fromIndex: Int, toIndex: Int, destinationIndex: Int = 0) {
copyImpl(@Suppress("UNCHECKED_CAST") (this as Array<Any>), fromIndex,
@Suppress("UNCHECKED_CAST") (destination as Array<Any>),
destinationIndex, toIndex - fromIndex)
@@ -71,9 +71,9 @@ public annotation class SharedImmutable
/**
* Makes top level function available from C/C++ code with the given name.
* `fullName` controls the name of top level function, `shortName` controls the short name.
* If `fullName` is empty, no top level declaration is being created.
* `externName` controls the name of top level function, `shortName` controls the short name.
* If `externName` is empty, no top level declaration is being created.
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
public annotation class CName(val fullName: String = "", val shortName: String = "")
public annotation class CName(val externName: String = "", val shortName: String = "")
@@ -14,12 +14,11 @@
* limitations under the License.
*/
package kotlin
package kotlin.native
/**
* A vector of bits growing if necessary and allowing one to set/clear/read bits from it by a bit index.
*/
// TODO: make me internal!
public class BitSet(size: Int = ELEMENT_SIZE) {
companion object {
@@ -0,0 +1,62 @@
/*
* Copyright 2010-2018 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.native
/**
* Converts an UTF-8 array into a [String]. Replaces invalid input sequences with a default character.
*/
public fun ByteArray.stringFromUtf8(start: Int = 0, size: Int = this.size) : String =
stringFromUtf8Impl(start, size)
@SymbolName("Kotlin_ByteArray_stringFromUtf8")
private external fun ByteArray.stringFromUtf8Impl(start: Int, size: Int) : String
/**
* Converts an UTF-8 array into a [String]. Throws [IllegalCharacterConversionException] if the input is invalid.
*/
public fun ByteArray.stringFromUtf8OrThrow(start: Int = 0, size: Int = this.size) : String =
stringFromUtf8OrThrowImpl(start, size)
@SymbolName("Kotlin_ByteArray_stringFromUtf8OrThrow")
private external fun ByteArray.stringFromUtf8OrThrowImpl(start: Int, size: Int) : String
/**
* Converts a [String] into an UTF-8 array. Replaces invalid input sequences with a default character.
*/
public fun String.toUtf8(start: Int = 0, size: Int = this.length) : ByteArray =
toUtf8Impl(start, size)
@SymbolName("Kotlin_String_toUtf8")
private external fun String.toUtf8Impl(start: Int, size: Int) : ByteArray
/**
* Converts a [String] into an UTF-8 array. Throws [IllegalCharacterConversionException] if the input is invalid.
*/
public fun String.toUtf8OrThrow(start: Int = 0, size: Int = this.length) : ByteArray =
toUtf8OrThrowImpl(start, size)
@SymbolName("Kotlin_String_toUtf8OrThrow")
private external fun String.toUtf8OrThrowImpl(start: Int, size: Int) : ByteArray
@SymbolName("Kotlin_String_fromCharArray")
internal external fun fromCharArray(array: CharArray, start: Int, size: Int) : String
@SymbolName("Kotlin_StringBuilder_insertString")
internal external fun insertString(array: CharArray, start: Int, value: String): Int
@SymbolName("Kotlin_StringBuilder_insertInt")
internal external fun insertInt(array: CharArray, start: Int, value: Int): Int
@@ -17,63 +17,69 @@ package kotlin.native
import kotlin.native.SymbolName
fun ByteArray.ubyteAt(index: Int): UByte = UByte(get(index))
/**
* Those operations allows to extract primitive values out of the byte buffers.
* Data is treated as if it was in Least-Significant-Byte first (little-endian) byte order.
* If index is outside of array boundaries - ArrayIndexOutOfBoundsException is thrown.
*/
@ExperimentalUnsignedTypes
public fun ByteArray.ubyteAt(index: Int): UByte = UByte(get(index))
@SymbolName("Kotlin_ByteArray_getCharAt")
external fun ByteArray.charAt(index: Int): Char
public external fun ByteArray.charAt(index: Int): Char
@SymbolName("Kotlin_ByteArray_getShortAt")
external fun ByteArray.shortAt(index: Int): Short
public external fun ByteArray.shortAt(index: Int): Short
@SymbolName("Kotlin_ByteArray_getShortAt")
@ExperimentalUnsignedTypes
external fun ByteArray.ushortAt(index: Int): UShort
public external fun ByteArray.ushortAt(index: Int): UShort
@SymbolName("Kotlin_ByteArray_getIntAt")
external fun ByteArray.intAt(index: Int): Int
public external fun ByteArray.intAt(index: Int): Int
@SymbolName("Kotlin_ByteArray_getIntAt")
@ExperimentalUnsignedTypes
external fun ByteArray.uintAt(index: Int): UInt
public external fun ByteArray.uintAt(index: Int): UInt
@SymbolName("Kotlin_ByteArray_getLongAt")
external fun ByteArray.longAt(index: Int): Long
public external fun ByteArray.longAt(index: Int): Long
@SymbolName("Kotlin_ByteArray_getLongAt")
@ExperimentalUnsignedTypes
external fun ByteArray.ulongAt(index: Int): ULong
public external fun ByteArray.ulongAt(index: Int): ULong
@SymbolName("Kotlin_ByteArray_getFloatAt")
external fun ByteArray.floatAt(index: Int): Float
public external fun ByteArray.floatAt(index: Int): Float
@SymbolName("Kotlin_ByteArray_getDoubleAt")
external fun ByteArray.doubleAt(index: Int): Double
public external fun ByteArray.doubleAt(index: Int): Double
@SymbolName("Kotlin_ByteArray_setCharAt")
external fun ByteArray.setCharAt(index: Int, value: Char)
public external fun ByteArray.setCharAt(index: Int, value: Char)
@SymbolName("Kotlin_ByteArray_setShortAt")
external fun ByteArray.setShortAt(index: Int, value: Short)
public external fun ByteArray.setShortAt(index: Int, value: Short)
@SymbolName("Kotlin_ByteArray_setShortAt")
@ExperimentalUnsignedTypes
external fun ByteArray.setUShortAt(index: Int, value: UShort)
public external fun ByteArray.setUShortAt(index: Int, value: UShort)
@SymbolName("Kotlin_ByteArray_setIntAt")
external fun ByteArray.setIntAt(index: Int, value: Int)
public external fun ByteArray.setIntAt(index: Int, value: Int)
@SymbolName("Kotlin_ByteArray_setIntAt")
external fun ByteArray.setUIntAt(index: Int, value: UInt)
public external fun ByteArray.setUIntAt(index: Int, value: UInt)
@SymbolName("Kotlin_ByteArray_setLongAt")
external fun ByteArray.setLongAt(index: Int, value: Long)
public external fun ByteArray.setLongAt(index: Int, value: Long)
@SymbolName("Kotlin_ByteArray_setLongAt")
@ExperimentalUnsignedTypes
external fun ByteArray.setULongAt(index: Int, value: ULong)
public external fun ByteArray.setULongAt(index: Int, value: ULong)
@SymbolName("Kotlin_ByteArray_setFloatAt")
external fun ByteArray.setFloatAt(index: Int, value: Float)
public external fun ByteArray.setFloatAt(index: Int, value: Float)
@SymbolName("Kotlin_ByteArray_setDoubleAt")
external fun ByteArray.setDoubleAt(index: Int, value: Double)
public external fun ByteArray.setDoubleAt(index: Int, value: Double)
@@ -18,7 +18,7 @@ package kotlin.random
import kotlin.native.concurrent.AtomicLong
import kotlin.system.getTimeNanos
abstract class NativeRandom {
public abstract class NativeRandom {
/**
* A default pseudo-random linear congruential generator.
*/
@@ -21,13 +21,9 @@ import kotlin.internal.getProgressionLastElement
/**
* A progression of values of type `Char`.
*/
public open class CharProgression
internal constructor
(
start: Char,
endInclusive: Char,
step: Int
) : Iterable<Char> {
public open class CharProgression internal constructor(
start: Char, endInclusive: Char, step: Int) : Iterable<Char> {
init {
if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero")
}
@@ -75,13 +71,9 @@ internal constructor
/**
* A progression of values of type `Int`.
*/
public open class IntProgression
internal constructor
(
start: Int,
endInclusive: Int,
step: Int
) : Iterable<Int> {
public open class IntProgression internal constructor(
start: Int, endInclusive: Int, step: Int) : Iterable<Int> {
init {
if (step == 0) throw kotlin.IllegalArgumentException("Step must be non-zero")
}
@@ -122,20 +114,17 @@ internal constructor
* The progression starts with the [rangeStart] value and goes toward the [rangeEnd] value not excluding it, with the specified [step].
* In order to go backwards the [step] must be negative.
*/
public fun fromClosedRange(rangeStart: Int, rangeEnd: Int, step: Int): IntProgression = IntProgression(rangeStart, rangeEnd, step)
public fun fromClosedRange(rangeStart: Int, rangeEnd: Int, step: Int): IntProgression =
IntProgression(rangeStart, rangeEnd, step)
}
}
/**
* A progression of values of type `Long`.
*/
public open class LongProgression
internal constructor
(
start: Long,
endInclusive: Long,
step: Long
) : Iterable<Long> {
public open class LongProgression internal constructor(
start: Long, endInclusive: Long, step: Long) : Iterable<Long> {
init {
if (step == 0L) throw kotlin.IllegalArgumentException("Step must be non-zero")
}
@@ -24,9 +24,4 @@ import kotlin.native.internal.FixmeReflection
* for more information.
*/
@FixmeReflection
public interface KAnnotatedElement {
// /**
// * Annotations which are present on this element.
// */
// public val annotations: List<Annotation>
}
public interface KAnnotatedElement
@@ -35,59 +35,8 @@ public interface KCallable<out R> : KAnnotatedElement {
*/
public val name: String
// /**
// * Parameters required to make a call to this callable.
// * If this callable requires a `this` instance or an extension receiver parameter,
// * they come first in the list in that order.
// */
// public val parameters: List<KParameter>
/**
* The type of values returned by this callable.
*/
public val returnType: KType
// /**
// * The list of type parameters of this callable.
// */
// @SinceKotlin("1.1")
// public val typeParameters: List<KTypeParameter>
//
// /**
// * Calls this callable with the specified list of arguments and returns the result.
// * Throws an exception if the number of specified arguments is not equal to the size of [parameters],
// * or if their types do not match the types of the parameters.
// */
// public fun call(vararg args: Any?): R
//
// /**
// * Calls this callable with the specified mapping of parameters to arguments and returns the result.
// * If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional]),
// * or its type does not match the type of the provided value, an exception is thrown.
// */
// public fun callBy(args: Map<KParameter, Any?>): R
//
// /**
// * Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin.
// */
// @SinceKotlin("1.1")
// public val visibility: KVisibility?
//
// /**
// * `true` if this callable is `final`.
// */
// @SinceKotlin("1.1")
// public val isFinal: Boolean
//
// /**
// * `true` if this callable is `open`.
// */
// @SinceKotlin("1.1")
// public val isOpen: Boolean
//
// /**
// * `true` if this callable is `abstract`.
// */
// @SinceKotlin("1.1")
// public val isAbstract: Boolean
}
@@ -37,101 +37,12 @@ public interface KClass<T : Any> : KDeclarationContainer, KAnnotatedElement, KCl
*/
public val qualifiedName: String?
// /**
// * All functions and properties accessible in this class, including those declared in this class
// * and all of its superclasses. Does not include constructors.
// */
// override val members: Collection<KCallable<*>>
//
// /**
// * All constructors declared in this class.
// */
// public val constructors: Collection<KFunction<T>>
//
// /**
// * All classes declared inside this class. This includes both inner and static nested classes.
// */
// public val nestedClasses: Collection<KClass<*>>
//
// /**
// * The instance of the object declaration, or `null` if this class is not an object declaration.
// */
// public val objectInstance: T?
/**
* Returns `true` if [value] is an instance of this class on a given platform.
*/
@SinceKotlin("1.1")
public fun isInstance(value: Any?): Boolean
// /**
// * The list of type parameters of this class. This list does *not* include type parameters of outer classes.
// */
// @SinceKotlin("1.1")
// public val typeParameters: List<KTypeParameter>
//
// /**
// * The list of immediate supertypes of this class, in the order they are listed in the source code.
// */
// @SinceKotlin("1.1")
// public val supertypes: List<KType>
//
// /**
// * Visibility of this class, or `null` if its visibility cannot be represented in Kotlin.
// */
// @SinceKotlin("1.1")
// public val visibility: KVisibility?
//
// /**
// * `true` if this class is `final`.
// */
// @SinceKotlin("1.1")
// public val isFinal: Boolean
//
// /**
// * `true` if this class is `open`.
// */
// @SinceKotlin("1.1")
// public val isOpen: Boolean
//
// /**
// * `true` if this class is `abstract`.
// */
// @SinceKotlin("1.1")
// public val isAbstract: Boolean
//
// /**
// * `true` if this class is `sealed`.
// * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/classes.html#sealed-classes)
// * for more information.
// */
// @SinceKotlin("1.1")
// public val isSealed: Boolean
//
// /**
// * `true` if this class is a data class.
// * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/data-classes.html)
// * for more information.
// */
// @SinceKotlin("1.1")
// public val isData: Boolean
//
// /**
// * `true` if this class is an inner class.
// * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/nested-classes.html#inner-classes)
// * for more information.
// */
// @SinceKotlin("1.1")
// public val isInner: Boolean
//
// /**
// * `true` if this class is a companion object.
// * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects)
// * for more information.
// */
// @SinceKotlin("1.1")
// public val isCompanion: Boolean
/**
* Returns `true` if this [KClass] instance represents the same Kotlin class as the class represented by [other].
* On JVM this means that all of the following conditions are satisfied:
@@ -20,9 +20,4 @@ package kotlin.reflect
* Represents an entity which may contain declarations of any other entities,
* such as a class or a package.
*/
public interface KDeclarationContainer {
// /**
// * All functions and properties accessible in this container.
// */
// public val members: Collection<KCallable<*>>
}
public interface KDeclarationContainer
@@ -27,97 +27,35 @@ import kotlin.native.internal.FixmeReflection
* @param R the type of the property.
*/
@FixmeReflection
public interface KProperty<out R> : KCallable<R> {
// /**
// * `true` if this property is `lateinit`.
// * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#late-initialized-properties)
// * for more information.
// */
// @SinceKotlin("1.1")
// public val isLateinit: Boolean
//
// /**
// * `true` if this property is `const`.
// * See the [Kotlin language documentation](https://kotlinlang.org/docs/reference/properties.html#compile-time-constants)
// * for more information.
// */
// @SinceKotlin("1.1")
// public val isConst: Boolean
//
// /** The getter of this property, used to obtain the value of the property. */
// public val getter: Getter<R>
//
// /**
// * Represents a property accessor, which is a `get` or `set` method declared alongside the property.
// * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/properties.html#getters-and-setters)
// * for more information.
// *
// * @param R the type of the property, which it is an accessor of.
// */
// public interface Accessor<out R> {
// /** The property which this accessor is originated from. */
// public val property: KProperty<R>
// }
//
// /**
// * Getter of the property is a `get` method declared alongside the property.
// */
// public interface Getter<out R> : Accessor<R>, KFunction<R>
}
public interface KProperty<out R> : KCallable<R>
//
@FixmeReflection
public interface KProperty0<out R> : kotlin.reflect.KProperty<R>, () -> R {
// public abstract val getter: kotlin.reflect.KProperty1.Getter<T, R>
public abstract fun get(): R
public override abstract operator fun invoke(): R
// @kotlin.SinceKotlin public abstract fun getDelegate(receiver: T): kotlin.Any?
//
// public interface Getter<T, out R> : kotlin.reflect.KProperty.Getter<R>, (T) -> R {
// }
public override abstract operator fun invoke(): R
}
@FixmeReflection
public interface KProperty1<T, out R> : kotlin.reflect.KProperty<R>, (T) -> R {
// public abstract val getter: kotlin.reflect.KProperty1.Getter<T, R>
public abstract fun get(p1: T): R
public override abstract operator fun invoke(p1: T): R
// @kotlin.SinceKotlin public abstract fun getDelegate(receiver: T): kotlin.Any?
//
// public interface Getter<T, out R> : kotlin.reflect.KProperty.Getter<R>, (T) -> R {
// }
public override abstract operator fun invoke(p1: T): R
}
@FixmeReflection
public interface KProperty2<T1, T2, out R> : kotlin.reflect.KProperty<R>, (T1, T2) -> R {
// public abstract val getter: kotlin.reflect.KProperty1.Getter<T, R>
public abstract fun get(p1: T1, p2: T2): R
public override abstract operator fun invoke(p1: T1, p2: T2): R
// @kotlin.SinceKotlin public abstract fun getDelegate(receiver: T): kotlin.Any?
//
// public interface Getter<T, out R> : kotlin.reflect.KProperty.Getter<R>, (T) -> R {
// }
public override abstract operator fun invoke(p1: T1, p2: T2): R
}
/**
* Represents a property declared as a `var`.
*/
@FixmeReflection
public interface KMutableProperty<R> : KProperty<R> {
// /** The setter of this mutable property, used to change the value of the property. */
// public val setter: Setter<R>
//
// /**
// * Setter of the property is a `set` method declared alongside the property.
// */
// public interface Setter<R> : KProperty.Accessor<R>, KFunction<Unit>
}
public interface KMutableProperty<R> : KProperty<R>
@FixmeReflection
public interface KMutableProperty0<R> : KProperty0<R>, KMutableProperty<R> {
@@ -30,17 +30,6 @@ public interface KType {
@SinceKotlin("1.1")
public val classifier: KClassifier?
/**
* Type arguments passed for the parameters of the classifier in this type.
* For example, in the type `Array<out Number>` the only type argument is `out Number`.
*
* In case this type is based on an inner class, the returned list contains the type arguments provided for the innermost class first,
* then its outer class, and so on.
* For example, in the type `Outer<A, B>.Inner<C, D>` the returned list is `[C, D, A, B]`.
*/
// @SinceKotlin("1.1")
// public val arguments: List<KTypeProjection>
/**
* `true` if this type was marked nullable in the source code.
*
@@ -21,28 +21,28 @@ package kotlin.test
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
annotation class Test
public annotation class Test
/**
* Marks a function to be executed before a suite. Not supported in Kotlin/Common.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
annotation class BeforeClass
public annotation class BeforeClass
/**
* Marks a function to be executed after a suite. Not supported in Kotlin/Common.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
annotation class AfterClass
public annotation class AfterClass
/**
* Marks a function to be executed before a test.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
annotation class BeforeEach
public annotation class BeforeEach
/**
@@ -50,14 +50,14 @@ annotation class BeforeEach
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.FUNCTION)
annotation class AfterEach
public annotation class AfterEach
/**
* Marks a test or a suite as ignored/pending.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class Ignore
public annotation class Ignore
typealias AfterTest = AfterEach
typealias BeforeTest = BeforeEach
public typealias AfterTest = AfterEach
public typealias BeforeTest = BeforeEach
@@ -15,7 +15,7 @@
*/
/**
* A number of common helper methods for writing unit tests. Copied from Kotlin repo.
* A number of common helper methods for writing unit tests.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@@ -28,56 +28,56 @@ import kotlin.reflect.KClass
/**
* Current adapter providing assertion implementations
*/
val asserter: Asserter
private val asserter: Asserter
get() = _asserter ?: lookupAsserter()
/** Used to override current asserter internally */
internal var _asserter: Asserter? = null
/** Asserts that the given [block] returns `true`. */
fun assertTrue(message: String? = null, block: () -> Boolean): Unit = assertTrue(block(), message)
public fun assertTrue(message: String? = null, block: () -> Boolean): Unit = assertTrue(block(), message)
/** Asserts that the expression is `true` with an optional [message]. */
fun assertTrue(actual: Boolean, message: String? = null) {
public fun assertTrue(actual: Boolean, message: String? = null) {
return asserter.assertTrue(message ?: "Expected value to be true.", actual)
}
/** Asserts that the given [block] returns `false`. */
fun assertFalse(message: String? = null, block: () -> Boolean): Unit = assertFalse(block(), message)
public fun assertFalse(message: String? = null, block: () -> Boolean): Unit = assertFalse(block(), message)
/** Asserts that the expression is `false` with an optional [message]. */
fun assertFalse(actual: Boolean, message: String? = null) {
public fun assertFalse(actual: Boolean, message: String? = null) {
return asserter.assertTrue(message ?: "Expected value to be false.", !actual)
}
/** Asserts that the [expected] value is equal to the [actual] value, with an optional [message]. */
fun <@OnlyInputTypes T> assertEquals(expected: T, actual: T, message: String? = null) {
public fun <@OnlyInputTypes T> assertEquals(expected: T, actual: T, message: String? = null) {
asserter.assertEquals(message, expected, actual)
}
/** Asserts that the [actual] value is not equal to the illegal value, with an optional [message]. */
fun <@OnlyInputTypes T> assertNotEquals(illegal: T, actual: T, message: String? = null) {
public fun <@OnlyInputTypes T> assertNotEquals(illegal: T, actual: T, message: String? = null) {
asserter.assertNotEquals(message, illegal, actual)
}
/** Asserts that [expected] is the same instance as [actual], with an optional [message]. */
fun <@OnlyInputTypes T> assertSame(expected: T, actual: T, message: String? = null) {
public fun <@OnlyInputTypes T> assertSame(expected: T, actual: T, message: String? = null) {
asserter.assertSame(message, expected, actual)
}
/** Asserts that [actual] is not the same instance as [illegal], with an optional [message]. */
fun <@OnlyInputTypes T> assertNotSame(illegal: T, actual: T, message: String? = null) {
public fun <@OnlyInputTypes T> assertNotSame(illegal: T, actual: T, message: String? = null) {
asserter.assertNotSame(message, illegal, actual)
}
/** Asserts that the [actual] value is not `null`, with an optional [message]. */
fun <T : Any> assertNotNull(actual: T?, message: String? = null): T {
public fun <T : Any> assertNotNull(actual: T?, message: String? = null): T {
asserter.assertNotNull(message, actual)
return actual!!
}
/** Asserts that the [actual] value is not `null`, with an optional [message] and a function [block] to process the not-null value. */
fun <T : Any, R> assertNotNull(actual: T?, message: String? = null, block: (T) -> R) {
public fun <T: Any, R> assertNotNull(actual: T?, message: String? = null, block: (T) -> R) {
asserter.assertNotNull(message, actual)
if (actual != null) {
block(actual)
@@ -85,31 +85,31 @@ fun <T : Any, R> assertNotNull(actual: T?, message: String? = null, block: (T) -
}
/** Asserts that the [actual] value is `null`, with an optional [message]. */
fun assertNull(actual: Any?, message: String? = null) {
public fun assertNull(actual: Any?, message: String? = null) {
asserter.assertNull(message, actual)
}
/** Marks a test as having failed if this point in the execution path is reached, with an optional [message]. */
fun fail(message: String? = null): Nothing {
public fun fail(message: String? = null): Nothing {
asserter.fail(message)
}
/** Asserts that given function [block] returns the given [expected] value. */
fun <@OnlyInputTypes T> expect(expected: T, block: () -> T) {
public fun <@OnlyInputTypes T> expect(expected: T, block: () -> T) {
assertEquals(expected, block())
}
/** Asserts that given function [block] returns the given [expected] value and use the given [message] if it fails. */
fun <@OnlyInputTypes T> expect(expected: T, message: String?, block: () -> T) {
public fun <@OnlyInputTypes T> expect(expected: T, message: String?, block: () -> T) {
assertEquals(expected, block(), message)
}
/** Asserts that given function [block] fails by throwing an exception. */
fun assertFails(block: () -> Unit): Throwable = assertFails(null, block)
public fun assertFails(block: () -> Unit): Throwable = assertFails(null, block)
/** Asserts that given function [block] fails by throwing an exception. */
@SinceKotlin("1.1")
fun assertFails(message: String?, block: () -> Unit): Throwable {
public fun assertFails(message: String?, block: () -> Unit): Throwable {
try {
block()
} catch (e: Throwable) {
@@ -123,11 +123,11 @@ fun assertFails(message: String?, block: () -> Unit): Throwable {
* Since inline method doesn't allow to trace where it was invoked, it is required to pass a [message] to distinguish this method call from others.
*/
@InlineOnly
inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noinline block: () -> Unit) : T =
public inline fun <reified T : Throwable> assertFailsWith(message: String? = null, noinline block: () -> Unit) : T =
assertFailsWith(T::class, message, block)
/** Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown. */
fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T =
public fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T =
assertFailsWith(exceptionClass, null, block)
@@ -137,12 +137,12 @@ fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit
* to implement in your unit test output
*/
@Suppress("UNUSED_PARAMETER")
inline fun todo(block: () -> Unit) {
public inline fun todo(block: () -> Unit) {
println("TODO")
}
/** Asserts that a [block] fails with a specific exception of type [exceptionClass] being thrown. */
fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T {
public fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T {
try {
block()
} catch (e: Throwable) {
@@ -164,7 +164,7 @@ fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?,
/**
* Abstracts the logic for performing assertions.
*/
interface Asserter {
public interface Asserter {
/**
* Fails the current test with the specified message.
*
@@ -251,7 +251,7 @@ interface Asserter {
/**
* Checks applicability and provides Asserter instance
*/
interface AsserterContributor {
public interface AsserterContributor {
/**
* Provides [Asserter] instance or `null` depends on the current context.
*
@@ -19,7 +19,7 @@ package kotlin.test
/**
* Default [Asserter] implementation for Kotlin/Native.
*/
object DefaultAsserter : Asserter {
public object DefaultAsserter : Asserter {
override fun fail(message: String?): Nothing {
if (message == null)
throw AssertionError()
@@ -16,7 +16,7 @@
package kotlin.text
actual interface Appendable {
public actual interface Appendable {
actual fun append(c: Char): Appendable
actual fun append(csq: CharSequence?): Appendable
actual fun append(csq: CharSequence?, start: Int, end: Int): Appendable
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.text
// The values duplicate constants defined in KString.cpp.
/**
* Represents the character general category in the Unicode specification.
*/
@@ -1,18 +1,17 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Copyright 2010-2018 JetBrains s.r.o.
*
* http://www.apache.org/licenses/LICENSE-2.0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.text
@@ -21,8 +20,6 @@ package kotlin.text
* Encapsulates a syntax error that occurred during the compilation of a
* [Pattern]. Might include a detailed description, the original regular
* expression, and the index at which the error occurred.
*
*/
class PatternSyntaxException(val description: String = "", val pattern: String = "", index: Int = -1)
internal class PatternSyntaxException(val description: String = "", val pattern: String = "", index: Int = -1)
: IllegalArgumentException("Error in \"$pattern\" ($index). $description")
+2 -2
View File
@@ -31,7 +31,7 @@ private fun fromInt(value: Int): Set<RegexOption> =
/**
* Provides enumeration values to use to set regular expression options.
*/
actual enum class RegexOption(override val value: Int, override val mask: Int = value) : FlagEnum {
actual public enum class RegexOption(override val value: Int, override val mask: Int = value) : FlagEnum {
// common
/** Enables case-insensitive matching. Case comparison is Unicode-aware. */
@@ -79,7 +79,7 @@ actual data class MatchGroup(actual val value: String, val range: IntRange)
*
* For pattern syntax reference see [Pattern]
*/
actual class Regex internal constructor(internal val nativePattern: Pattern) {
actual public class Regex internal constructor(internal val nativePattern: Pattern) {
enum class Mode {
FIND, MATCH
@@ -16,14 +16,6 @@
package kotlin.text
// ByteArray -> String (UTF-8 -> UTF-16)
@Deprecated("Use ByteArray.stringFromUtf8()", ReplaceWith("array.stringFromUtf8(start, end)"))
fun fromUtf8Array(array: ByteArray, start: Int, size: Int) = array.stringFromUtf8Impl(start, size)
@Deprecated("Use String.toUtf8()", ReplaceWith("string.toUtf8(start, end)"))
fun toUtf8Array(string: String, start: Int, size: Int) : ByteArray = string.toUtf8(start, size)
/**
* Clears the content of this string builder making it empty.
*
@@ -32,53 +24,6 @@ fun toUtf8Array(string: String, start: Int, size: Int) : ByteArray = string.toUt
@SinceKotlin("1.3")
public actual fun StringBuilder.clear(): StringBuilder = apply { setLength(0) }
/**
* Converts an UTF-8 array into a [String]. Replaces invalid input sequences with a default character.
*/
fun ByteArray.stringFromUtf8(start: Int = 0, size: Int = this.size) : String =
stringFromUtf8Impl(start, size)
@SymbolName("Kotlin_ByteArray_stringFromUtf8")
private external fun ByteArray.stringFromUtf8Impl(start: Int, size: Int) : String
/**
* Converts an UTF-8 array into a [String]. Throws [IllegalCharacterConversionException] if the input is invalid.
*/
fun ByteArray.stringFromUtf8OrThrow(start: Int = 0, size: Int = this.size) : String =
stringFromUtf8OrThrowImpl(start, size)
@SymbolName("Kotlin_ByteArray_stringFromUtf8OrThrow")
private external fun ByteArray.stringFromUtf8OrThrowImpl(start: Int, size: Int) : String
// String -> ByteArray (UTF-16 -> UTF-8)
/**
* Converts a [String] into an UTF-8 array. Replaces invalid input sequences with a default character.
*/
fun String.toUtf8(start: Int = 0, size: Int = this.length) : ByteArray =
toUtf8Impl(start, size)
@SymbolName("Kotlin_String_toUtf8")
private external fun String.toUtf8Impl(start: Int, size: Int) : ByteArray
/**
* Converts a [String] into an UTF-8 array. Throws [IllegalCharacterConversionException] if the input is invalid.
*/
fun String.toUtf8OrThrow(start: Int = 0, size: Int = this.length) : ByteArray =
toUtf8OrThrowImpl(start, size)
@SymbolName("Kotlin_String_toUtf8OrThrow")
private external fun String.toUtf8OrThrowImpl(start: Int, size: Int) : ByteArray
// TODO: make it somewhat private?
@SymbolName("Kotlin_String_fromCharArray")
external fun fromCharArray(array: CharArray, start: Int, size: Int) : String
@SymbolName("Kotlin_StringBuilder_insertString")
private external fun insertString(array: CharArray, start: Int, value: String): Int
@SymbolName("Kotlin_StringBuilder_insertInt")
private external fun insertInt(array: CharArray, start: Int, value: Int): Int
/**
* Sets the character at the specified [index] to the specified [value].
*/
@@ -86,8 +31,8 @@ private external fun insertInt(array: CharArray, start: Int, value: Int): Int
public inline operator fun StringBuilder.set(index: Int, value: Char): Unit = this.setCharAt(index, value)
actual class StringBuilder private constructor (
private var array: CharArray
) : CharSequence, Appendable {
private var array: CharArray) : CharSequence, Appendable {
actual constructor() : this(10)
actual constructor(capacity: Int) : this(CharArray(capacity))
@@ -16,7 +16,6 @@
package kotlin.text
fun StringBuilder.appendln(it: String) = append(it).appendln()
fun StringBuilder.appendln(it: Boolean) = append(it).appendln()
fun StringBuilder.appendln(it: Byte) = append(it).appendln()
@@ -48,7 +48,6 @@ public actual fun CharSequence.repeat(n: Int): String {
/**
* Converts the characters in the specified array to a string.
*/
// external fun fromCharArray(array: CharArray, start: Int, size: Int) : String
public actual fun String(chars: CharArray): String = fromCharArray(chars, 0, chars.size)
/**
@@ -460,7 +460,7 @@ internal class Lexer(val patternString: String, flags: Int) {
// Word/whitespace/digit.
'w', 's', 'd', 'W', 'S', 'D' -> {
lookAheadSpecialToken = AbstractCharClass.getPredefinedClass(
fromCharArray(pattern, prevNonWhitespaceIndex, 1),
String(pattern, prevNonWhitespaceIndex, 1),
false
)
lookAhead = 0
@@ -802,7 +802,7 @@ internal class Pattern(val pattern: String, flags: Int = 0) {
val isSupplCodePoint = Char.isSupplementaryCodePoint(ch)
return when {
isSupplCodePoint -> SequenceSet(fromCharArray(Char.toChars(ch), 0, 2), hasFlag(CASE_INSENSITIVE))
isSupplCodePoint -> SequenceSet(String(Char.toChars(ch), 0, 2), hasFlag(CASE_INSENSITIVE))
ch.toChar().isLowSurrogate() -> LowSurrogateCharSet(ch.toChar())
ch.toChar().isHighSurrogate() -> HighSurrogateCharSet(ch.toChar())
else -> CharSet(ch.toChar(), hasFlag(CASE_INSENSITIVE))
@@ -33,6 +33,8 @@
package kotlin.text.regex
import kotlin.text.*
/**
* Represents canonical decomposition of Hangul syllable. Is used when
* CANON_EQ flag of Pattern class is specified.
@@ -52,7 +54,7 @@ internal class HangulDecomposedCharSet(
* String representing syllable
*/
private val decomposedCharUTF16: String by lazy {
fromCharArray(decomposedChar, 0, decomposedChar.size)
String(decomposedChar, 0, decomposedChar.size)
}
override val name: String
@@ -102,7 +102,7 @@ package kotlin.text.regex
* Represents node accepting single supplementary codepoint.
*/
internal class SupplementaryCharSet(val codePoint: Int, ignoreCase: Boolean)
: SequenceSet(fromCharArray(Char.toChars(codePoint), 0, 2), ignoreCase) {
: SequenceSet(String(Char.toChars(codePoint), 0, 2), ignoreCase) {
override val name: String
get() = patternString
@@ -18,13 +18,6 @@ package kotlin.util
import kotlin.comparisons.*
// TODO: Implement sort for primitives with a custom comparator.
// Array<T> =============================================================================
// We use merge because the quick sort may cause segfaults if
// the comparator or the comparable implementation is incorrect (e.g. if it never returns 0).
// Sort of comparables.
private fun <T: Comparable<T>> mergeSort(array: Array<T>, start: Int, endInclusive: Int) {
@Suppress("UNCHECKED_CAST")
val buffer = arrayOfNulls<Any?>(array.size) as Array<T>