[Wasm] Support enumValues and enumValueOf functions
^KT-57276 Fixed Merge-request: KT-MR-9169 Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
bcf7c38288
commit
a99ea1d3ce
@@ -8,6 +8,8 @@
|
||||
package kotlin
|
||||
|
||||
import kotlin.internal.PureReifiable
|
||||
import kotlin.wasm.internal.enumValueOfIntrinsic
|
||||
import kotlin.wasm.internal.enumValuesIntrinsic
|
||||
|
||||
public inline fun <T> emptyArray(): Array<T> = arrayOf()
|
||||
|
||||
@@ -80,12 +82,12 @@ public inline fun booleanArrayOf(vararg elements: Boolean): BooleanArray = eleme
|
||||
* Returns an array containing enum T entries.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NON_MEMBER_FUNCTION_NO_BODY")
|
||||
public inline fun <reified T : Enum<T>> enumValues(): Array<T>
|
||||
public inline fun <reified T : Enum<T>> enumValues(): Array<T> =
|
||||
enumValuesIntrinsic()
|
||||
|
||||
/**
|
||||
* Returns an enum entry with specified name.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NON_MEMBER_FUNCTION_NO_BODY", "UNUSED_PARAMETER")
|
||||
public inline fun <reified T : Enum<T>> enumValueOf(name: String): T
|
||||
public inline fun <reified T : Enum<T>> enumValueOf(name: String): T =
|
||||
enumValueOfIntrinsic(name)
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin.wasm.internal
|
||||
|
||||
@PublishedApi
|
||||
@ExcludedFromCodegen
|
||||
internal fun <T : Enum<T>> enumValuesIntrinsic(): Array<T> =
|
||||
implementedAsIntrinsic
|
||||
|
||||
@PublishedApi
|
||||
@ExcludedFromCodegen
|
||||
internal fun <T : Enum<T>> enumValueOfIntrinsic(@Suppress("UNUSED_PARAMETER") name: String): T =
|
||||
implementedAsIntrinsic
|
||||
Reference in New Issue
Block a user