[K/N] Move declarations from Text.kt to Strings.kt and StringBuilder.kt

This commit is contained in:
Abduqodiri Qurbonzoda
2021-03-27 04:22:13 +03:00
parent 71afd112c6
commit 7fdf7c6175
3 changed files with 35 additions and 40 deletions
@@ -1,40 +0,0 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
package kotlin.native
internal fun checkBoundsIndexes(startIndex: Int, endIndex: Int, size: Int) {
if (startIndex < 0 || endIndex > size) {
throw IndexOutOfBoundsException("startIndex: $startIndex, endIndex: $endIndex, size: $size")
}
if (startIndex > endIndex) {
throw IllegalArgumentException("startIndex: $startIndex > endIndex: $endIndex")
}
}
internal fun insertString(array: CharArray, start: Int, value: String): Int =
insertString(array, start, value, 0, value.length)
@SymbolName("Kotlin_ByteArray_unsafeStringFromUtf8")
internal external fun ByteArray.unsafeStringFromUtf8(start: Int, size: Int) : String
@SymbolName("Kotlin_ByteArray_unsafeStringFromUtf8OrThrow")
internal external fun ByteArray.unsafeStringFromUtf8OrThrow(start: Int, size: Int) : String
@SymbolName("Kotlin_String_unsafeStringToUtf8")
internal external fun String.unsafeStringToUtf8(start: Int, size: Int) : ByteArray
@SymbolName("Kotlin_String_unsafeStringToUtf8OrThrow")
internal external fun String.unsafeStringToUtf8OrThrow(start: Int, size: Int) : ByteArray
@SymbolName("Kotlin_String_unsafeStringFromCharArray")
internal external fun unsafeStringFromCharArray(array: CharArray, start: Int, size: Int) : String
@SymbolName("Kotlin_StringBuilder_insertString")
internal external fun insertString(array: CharArray, distIndex: Int, value: String, sourceIndex: Int, count: Int): Int
@SymbolName("Kotlin_StringBuilder_insertInt")
internal external fun insertInt(array: CharArray, start: Int, value: Int): Int
@@ -799,6 +799,17 @@ public actual inline fun StringBuilder.insertRange(index: Int, value: CharArray,
public actual inline fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder =
this.insertRange(index, value, startIndex, endIndex)
internal fun insertString(array: CharArray, start: Int, value: String): Int =
insertString(array, start, value, 0, value.length)
@SymbolName("Kotlin_StringBuilder_insertString")
internal external fun insertString(array: CharArray, distIndex: Int, value: String, sourceIndex: Int, count: Int): Int
@SymbolName("Kotlin_StringBuilder_insertInt")
internal external fun insertInt(array: CharArray, start: Int, value: Int): Int
// Method parameters renamings
@Suppress("EXTENSION_SHADOWED_BY_MEMBER")
@Deprecated("Use append(value: Boolean) instead", ReplaceWith("append(value = it)"), DeprecationLevel.WARNING)
@@ -328,6 +328,18 @@ public actual fun CharArray.concatToString(startIndex: Int, endIndex: Int): Stri
return unsafeStringFromCharArray(this, startIndex, endIndex - startIndex)
}
internal fun checkBoundsIndexes(startIndex: Int, endIndex: Int, size: Int) {
if (startIndex < 0 || endIndex > size) {
throw IndexOutOfBoundsException("startIndex: $startIndex, endIndex: $endIndex, size: $size")
}
if (startIndex > endIndex) {
throw IllegalArgumentException("startIndex: $startIndex > endIndex: $endIndex")
}
}
@SymbolName("Kotlin_String_unsafeStringFromCharArray")
internal external fun unsafeStringFromCharArray(array: CharArray, start: Int, size: Int) : String
/**
* Returns a [CharArray] containing characters of this string or its substring.
*
@@ -399,6 +411,18 @@ public actual fun String.encodeToByteArray(startIndex: Int, endIndex: Int, throw
unsafeStringToUtf8(startIndex, endIndex - startIndex)
}
@SymbolName("Kotlin_ByteArray_unsafeStringFromUtf8")
internal external fun ByteArray.unsafeStringFromUtf8(start: Int, size: Int) : String
@SymbolName("Kotlin_ByteArray_unsafeStringFromUtf8OrThrow")
internal external fun ByteArray.unsafeStringFromUtf8OrThrow(start: Int, size: Int) : String
@SymbolName("Kotlin_String_unsafeStringToUtf8")
internal external fun String.unsafeStringToUtf8(start: Int, size: Int) : ByteArray
@SymbolName("Kotlin_String_unsafeStringToUtf8OrThrow")
internal external fun String.unsafeStringToUtf8OrThrow(start: Int, size: Int) : ByteArray
internal fun compareToIgnoreCase(thiz: String, other: String): Int {
val length = minOf(thiz.length, other.length)