[stdlib] Explicit visibility and return types: Wasm

This commit is contained in:
Ilya Gorbunov
2023-11-12 02:09:15 +01:00
committed by Space Team
parent 381a8fd55f
commit cfa8a1dc0f
15 changed files with 54 additions and 54 deletions
@@ -35,7 +35,7 @@ public actual inline fun <T : AutoCloseable?, R> T.use(block: (T) -> R): R {
@SinceKotlin("1.8")
@ExperimentalStdlibApi
@PublishedApi
internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when {
internal fun AutoCloseable?.closeFinally(cause: Throwable?): Unit = when {
this == null -> {}
cause == null -> close()
else ->
@@ -33,4 +33,4 @@ package kotlin.native
AnnotationTarget.TYPEALIAS,
)
@Retention(AnnotationRetention.BINARY)
actual annotation class FreezingIsDeprecated
public actual annotation class FreezingIsDeprecated
@@ -14,14 +14,14 @@ public actual interface Appendable {
*
* @param value the character to append.
*/
actual fun append(value: Char): Appendable
public actual fun append(value: Char): Appendable
/**
* Appends the specified character sequence [value] to this Appendable and returns this instance.
*
* @param value the character sequence to append. If [value] is `null`, then the four characters `"null"` are appended to this Appendable.
*/
actual fun append(value: CharSequence?): Appendable
public actual fun append(value: CharSequence?): Appendable
/**
* Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance.
@@ -33,5 +33,5 @@ public actual interface Appendable {
*
* @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
*/
actual fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable
public actual fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable
}
@@ -56,7 +56,7 @@ public actual enum class RegexOption(internal val value: Int, internal val mask:
* @param value The value of captured group.
* @param range The range of indices in the input string where group was captured.
*/
public actual data class MatchGroup(actual val value: String, val range: IntRange)
public actual data class MatchGroup(public actual val value: String, val range: IntRange)
/**
@@ -90,42 +90,42 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
}
/** Creates a regular expression from the specified [pattern] string and the default options. */
actual constructor(pattern: String): this(Pattern(pattern))
public actual constructor(pattern: String): this(Pattern(pattern))
/** Creates a regular expression from the specified [pattern] string and the specified single [option]. */
actual constructor(pattern: String, option: RegexOption): this(Pattern(pattern, option.value))
public actual constructor(pattern: String, option: RegexOption): this(Pattern(pattern, option.value))
/** Creates a regular expression from the specified [pattern] string and the specified set of [options]. */
actual constructor(pattern: String, options: Set<RegexOption>): this(Pattern(pattern, options.toInt()))
public actual constructor(pattern: String, options: Set<RegexOption>): this(Pattern(pattern, options.toInt()))
/** The pattern string of this regular expression. */
actual val pattern: String
public actual val pattern: String
get() = nativePattern.pattern
private val startNode = nativePattern.startNode
/** The set of options that were used to create this regular expression. */
actual val options: Set<RegexOption> = fromInt(nativePattern.flags)
public actual val options: Set<RegexOption> = fromInt(nativePattern.flags)
actual companion object {
public actual companion object {
/**
* Returns a regular expression that matches the specified [literal] string literally.
* No characters of that string will have special meaning when searching for an occurrence of the regular expression.
*/
actual fun fromLiteral(literal: String): Regex = Regex(literal, RegexOption.LITERAL)
public actual fun fromLiteral(literal: String): Regex = Regex(literal, RegexOption.LITERAL)
/**
* Returns a regular expression pattern string that matches the specified [literal] string literally.
* No characters of that string will have special meaning when searching for an occurrence of the regular expression.
*/
actual fun escape(literal: String): String = Pattern.quote(literal)
public actual fun escape(literal: String): String = Pattern.quote(literal)
/**
* Returns a literal replacement expression for the specified [literal] string.
* No characters of that string will have special meaning when it is used as a replacement string in [Regex.replace] function.
*/
actual fun escapeReplacement(literal: String): String {
public actual fun escapeReplacement(literal: String): String {
if (!literal.contains('\\') && !literal.contains('$'))
return literal
@@ -155,10 +155,10 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
}
/** Indicates whether the regular expression matches the entire [input]. */
actual infix fun matches(input: CharSequence): Boolean = doMatch(input, Mode.MATCH) != null
public actual infix fun matches(input: CharSequence): Boolean = doMatch(input, Mode.MATCH) != null
/** Indicates whether the regular expression can find at least one match in the specified [input]. */
actual fun containsMatchIn(input: CharSequence): Boolean = find(input) != null
public actual fun containsMatchIn(input: CharSequence): Boolean = find(input) != null
@SinceKotlin("1.7")
@WasExperimental(ExperimentalStdlibApi::class)
@@ -175,7 +175,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* @sample samples.text.Regexps.find
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult? {
public actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult? {
if (startIndex < 0 || startIndex > input.length) {
throw IndexOutOfBoundsException("Start index is out of bounds: $startIndex, input length: ${input.length}")
}
@@ -199,7 +199,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* @sample samples.text.Regexps.findAll
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> {
public actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence<MatchResult> {
if (startIndex < 0 || startIndex > input.length) {
throw IndexOutOfBoundsException("Start index is out of bounds: $startIndex, input length: ${input.length}")
}
@@ -211,7 +211,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
*
* @return An instance of [MatchResult] if the entire input matches or `null` otherwise.
*/
actual fun matchEntire(input: CharSequence): MatchResult?= doMatch(input, Mode.MATCH)
public actual fun matchEntire(input: CharSequence): MatchResult?= doMatch(input, Mode.MATCH)
@SinceKotlin("1.7")
@WasExperimental(ExperimentalStdlibApi::class)
@@ -249,7 +249,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* @return the result of replacing each occurrence of this regular expression in [input] with the result of evaluating the [replacement] expression
* @throws RuntimeException if [replacement] expression is malformed, or capturing group with specified `name` or `index` does not exist
*/
actual fun replace(input: CharSequence, replacement: String): String
public actual fun replace(input: CharSequence, replacement: String): String
= replace(input) { match -> substituteGroupRefs(match, replacement) }
/**
@@ -257,7 +257,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* the given function [transform] that takes [MatchResult] and returns a string to be used as a
* replacement for that match.
*/
actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String {
public actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String {
var match: MatchResult? = find(input) ?: return input.toString()
var lastStart = 0
@@ -297,7 +297,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* @return the result of replacing the first occurrence of this regular expression in [input] with the result of evaluating the [replacement] expression
* @throws RuntimeException if [replacement] expression is malformed, or capturing group with specified `name` or `index` does not exist
*/
actual fun replaceFirst(input: CharSequence, replacement: String): String {
public actual fun replaceFirst(input: CharSequence, replacement: String): String {
val match = find(input) ?: return input.toString()
val length = input.length
val result = StringBuilder(length)
@@ -316,7 +316,7 @@ public actual class Regex internal constructor(internal val nativePattern: Patte
* Zero by default means no limit is set.
*/
@Suppress("ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS")
actual fun split(input: CharSequence, limit: Int = 0): List<String> {
public actual fun split(input: CharSequence, limit: Int = 0): List<String> {
requireNonNegativeLimit(limit)
var match: MatchResult? = find(input)