KJS: mark as inline only some functions form js stdlib
This commit is contained in:
@@ -19,8 +19,10 @@ package kotlin.text
|
||||
// actually \s is enough to match all whitespace, but \xA0 added because of different regexp behavior of Rhino used in Selenium tests
|
||||
public fun Char.isWhitespace(): Boolean = toString().matches("[\\s\\xA0]")
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun Char.toLowerCase(): Char = asDynamic().toLowerCase()
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun Char.toUpperCase(): Char = asDynamic().toUpperCase()
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,4 +35,5 @@ public annotation class Volatile
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
public annotation class Synchronized
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <R> synchronized(lock: Any, crossinline block: () -> R): R = block()
|
||||
|
||||
@@ -20,8 +20,10 @@ public external fun js(code: String): dynamic
|
||||
/**
|
||||
* Function corresponding to JavaScript's `typeof` operator
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun jsTypeOf(a: Any?): String = js("typeof a")
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
internal inline fun deleteProperty(obj: Any, property: Any) {
|
||||
js("delete obj[property]")
|
||||
}
|
||||
@@ -16,11 +16,13 @@
|
||||
|
||||
package kotlin.js
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun Any?.asDynamic(): dynamic = this
|
||||
|
||||
/**
|
||||
* Reinterprets this value as a value of the specified type [T] without any actual type checking.
|
||||
*/
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> Any?.unsafeCast(): @kotlin.internal.NoInfer T = this.asDynamic()
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,7 @@ public inline fun <T> Any?.unsafeCast(): @kotlin.internal.NoInfer T = this.asDyn
|
||||
*/
|
||||
@kotlin.internal.DynamicExtension
|
||||
@JsName("unsafeCastDynamic")
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun <T> dynamic.unsafeCast(): @kotlin.internal.NoInfer T = this
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,10 @@ package kotlin.text
|
||||
|
||||
import kotlin.text.js.RegExp
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toUpperCase(): String = asDynamic().toUpperCase()
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.toLowerCase(): String = asDynamic().toLowerCase()
|
||||
|
||||
internal inline fun String.nativeIndexOf(str: String, fromIndex: Int): Int = asDynamic().indexOf(str, fromIndex)
|
||||
@@ -14,17 +16,22 @@ internal inline fun String.nativeStartsWith(s: String, position: Int): Boolean =
|
||||
|
||||
internal inline fun String.nativeEndsWith(s: String): Boolean = asDynamic().endsWith(s)
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.substring(startIndex: Int): String = asDynamic().substring(startIndex)
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.substring(startIndex: Int, endIndex: Int): String = asDynamic().substring(startIndex, endIndex)
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.concat(str: String): String = asDynamic().concat(str)
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline fun String.match(regex: String): Array<String> = asDynamic().match(regex)
|
||||
|
||||
//native public fun String.trim(): String
|
||||
//TODO: String.replace to implement effective trimLeading and trimTrailing
|
||||
|
||||
@kotlin.internal.InlineOnly
|
||||
public inline val CharSequence.size: Int get() = asDynamic().length
|
||||
|
||||
internal inline fun String.nativeReplace(pattern: RegExp, replacement: String): String = asDynamic().replace(pattern, replacement)
|
||||
|
||||
Reference in New Issue
Block a user