Mark Base64 API with ExperimentalEncodingApi
This commit is contained in:
committed by
Space Team
parent
954ec1f63c
commit
ba2833b90f
@@ -1,5 +1,5 @@
|
||||
@kotlin.SinceKotlin(version = "1.8")
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
@kotlin.io.encoding.ExperimentalEncodingApi
|
||||
public open class Base64 {
|
||||
public final fun decode(source: kotlin.ByteArray, startIndex: kotlin.Int = ..., endIndex: kotlin.Int = ...): kotlin.ByteArray
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@kotlin.SinceKotlin(version = "1.8")
|
||||
@kotlin.ExperimentalStdlibApi
|
||||
@kotlin.io.encoding.ExperimentalEncodingApi
|
||||
public open class Base64 {
|
||||
public final fun decode(source: kotlin.ByteArray, startIndex: kotlin.Int = ..., endIndex: kotlin.Int = ...): kotlin.ByteArray
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ compileTestKotlinCommon {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ compileTestKotlin {
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.path.ExperimentalPathApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-Xcommon-sources=${fileTree('../test').join(',')}",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
]
|
||||
|
||||
@@ -79,6 +79,7 @@ compileTestKotlin {
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.path.ExperimentalPathApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-Xcommon-sources=${fileTree('../test').join(',')}",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
]
|
||||
|
||||
@@ -143,6 +143,7 @@ tasks.withType<KotlinCompile<*>>().configureEach {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ compileTestKotlin2Js {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package kotlin.io.encoding
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, startIndex: Int, endIndex: Int): ByteArray {
|
||||
return charsToBytesImpl(source, startIndex, endIndex)
|
||||
@@ -14,7 +14,7 @@ internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, sta
|
||||
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeToString(source: ByteArray, startIndex: Int, endIndex: Int): String {
|
||||
val byteResult = encodeToByteArrayImpl(source, startIndex, endIndex)
|
||||
@@ -22,7 +22,7 @@ internal actual inline fun Base64.platformEncodeToString(source: ByteArray, star
|
||||
}
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeIntoByteArray(
|
||||
source: ByteArray,
|
||||
@@ -35,7 +35,7 @@ internal actual inline fun Base64.platformEncodeIntoByteArray(
|
||||
}
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeToByteArray(
|
||||
source: ByteArray,
|
||||
|
||||
@@ -176,6 +176,7 @@ compileTestKotlin {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
]
|
||||
// This is needed for JavaTypeTest; typeOf for non-reified type parameters doesn't work otherwise, for implementation reasons.
|
||||
|
||||
@@ -35,7 +35,7 @@ import kotlin.io.encoding.Base64.Default.symbolsPerGroup
|
||||
* Closing the returned input stream will close the underlying input stream.
|
||||
*/
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
public fun InputStream.decodingWith(base64: Base64): InputStream {
|
||||
return DecodeInputStream(this, base64)
|
||||
}
|
||||
@@ -54,13 +54,13 @@ public fun InputStream.decodingWith(base64: Base64): InputStream {
|
||||
* Closing the returned output stream will close the underlying output stream.
|
||||
*/
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
public fun OutputStream.encodingWith(base64: Base64): OutputStream {
|
||||
return EncodeOutputStream(this, base64)
|
||||
}
|
||||
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
private class DecodeInputStream(
|
||||
private val input: InputStream,
|
||||
private val base64: Base64
|
||||
@@ -228,7 +228,7 @@ private class DecodeInputStream(
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
private class EncodeOutputStream(
|
||||
private val output: OutputStream,
|
||||
private val base64: Base64
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package kotlin.io.encoding
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, startIndex: Int, endIndex: Int): ByteArray {
|
||||
return if (source is String) {
|
||||
@@ -20,7 +20,7 @@ internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, sta
|
||||
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeToString(source: ByteArray, startIndex: Int, endIndex: Int): String {
|
||||
// val subArray = if (startIndex == 0 && endIndex == source.size) {
|
||||
@@ -35,7 +35,7 @@ internal actual inline fun Base64.platformEncodeToString(source: ByteArray, star
|
||||
}
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeIntoByteArray(
|
||||
source: ByteArray,
|
||||
@@ -55,7 +55,7 @@ internal actual inline fun Base64.platformEncodeIntoByteArray(
|
||||
}
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeToByteArray(
|
||||
source: ByteArray,
|
||||
@@ -73,7 +73,7 @@ internal actual inline fun Base64.platformEncodeToByteArray(
|
||||
}
|
||||
|
||||
//@SinceKotlin("1.8")
|
||||
//@ExperimentalStdlibApi
|
||||
//@ExperimentalEncodingApi
|
||||
//private fun Base64.javaEncoder(): java.util.Base64.Encoder {
|
||||
// return if (isMimeScheme) {
|
||||
// java.util.Base64.getMimeEncoder(Base64.mimeLineLength, Base64.mimeLineSeparatorSymbols)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package kotlin.io.encoding
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, startIndex: Int, endIndex: Int): ByteArray {
|
||||
return charsToBytesImpl(source, startIndex, endIndex)
|
||||
@@ -14,7 +14,7 @@ internal actual inline fun Base64.platformCharsToBytes(source: CharSequence, sta
|
||||
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeToString(source: ByteArray, startIndex: Int, endIndex: Int): String {
|
||||
val byteResult = encodeToByteArrayImpl(source, startIndex, endIndex)
|
||||
@@ -22,7 +22,7 @@ internal actual inline fun Base64.platformEncodeToString(source: ByteArray, star
|
||||
}
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeIntoByteArray(
|
||||
source: ByteArray,
|
||||
@@ -35,7 +35,7 @@ internal actual inline fun Base64.platformEncodeIntoByteArray(
|
||||
}
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@kotlin.internal.InlineOnly
|
||||
internal actual inline fun Base64.platformEncodeToByteArray(
|
||||
source: ByteArray,
|
||||
|
||||
@@ -16,7 +16,7 @@ import kotlin.native.concurrent.SharedImmutable
|
||||
* There are also [Base64.UrlSafe] and [Base64.Mime] instances.
|
||||
*/
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
public open class Base64 private constructor(
|
||||
internal val isUrlSafe: Boolean,
|
||||
internal val isMimeScheme: Boolean
|
||||
@@ -574,7 +574,7 @@ private val base64EncodeMap = byteArrayOf(
|
||||
119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47, /* 48 - 63 */
|
||||
)
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@SharedImmutable
|
||||
private val base64DecodeMap = IntArray(256).apply {
|
||||
this.fill(-1)
|
||||
@@ -593,7 +593,7 @@ private val base64UrlEncodeMap = byteArrayOf(
|
||||
119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 45, 95, /* 48 - 63 */
|
||||
)
|
||||
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
@SharedImmutable
|
||||
private val base64UrlDecodeMap = IntArray(256).apply {
|
||||
this.fill(-1)
|
||||
@@ -605,14 +605,14 @@ private val base64UrlDecodeMap = IntArray(256).apply {
|
||||
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
internal fun isInMimeAlphabet(symbol: Int): Boolean {
|
||||
return symbol in base64DecodeMap.indices && base64DecodeMap[symbol] != -1
|
||||
}
|
||||
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
internal expect fun Base64.platformCharsToBytes(
|
||||
source: CharSequence,
|
||||
startIndex: Int,
|
||||
@@ -621,7 +621,7 @@ internal expect fun Base64.platformCharsToBytes(
|
||||
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
internal expect fun Base64.platformEncodeToString(
|
||||
source: ByteArray,
|
||||
startIndex: Int,
|
||||
@@ -629,7 +629,7 @@ internal expect fun Base64.platformEncodeToString(
|
||||
): String
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
internal expect fun Base64.platformEncodeIntoByteArray(
|
||||
source: ByteArray,
|
||||
destination: ByteArray,
|
||||
@@ -639,7 +639,7 @@ internal expect fun Base64.platformEncodeIntoByteArray(
|
||||
): Int
|
||||
|
||||
@SinceKotlin("1.8")
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalEncodingApi
|
||||
internal expect fun Base64.platformEncodeToByteArray(
|
||||
source: ByteArray,
|
||||
startIndex: Int,
|
||||
|
||||
@@ -123,6 +123,7 @@ tasks.withType<KotlinCompile<*>>().configureEach {
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
"-opt-in=kotlin.ExperimentalUnsignedTypes",
|
||||
"-opt-in=kotlin.ExperimentalStdlibApi",
|
||||
"-opt-in=kotlin.io.encoding.ExperimentalEncodingApi",
|
||||
"-XXLanguage:+RangeUntilOperator",
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user