From 8871cf660c12b88ad1889cb518c8d170df71192e Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Mon, 23 Apr 2018 22:51:06 +0300 Subject: [PATCH] [stdlib-js] Split core.kt in stdlib-js into few files to simplify using part of it in JS IR BE related tests --- .../stdlib/js/src/kotlin/collections/utils.kt | 12 ++++++ libraries/stdlib/js/src/kotlin/core.kt | 40 +++---------------- .../stdlib/js/src/kotlin/coreDeprecated.kt | 18 +++++++++ libraries/stdlib/js/src/kotlin/js.core.kt | 16 ++++++++ libraries/stdlib/js/src/kotlin/jsTypeOf.kt | 13 ++++++ 5 files changed, 64 insertions(+), 35 deletions(-) create mode 100644 libraries/stdlib/js/src/kotlin/collections/utils.kt create mode 100644 libraries/stdlib/js/src/kotlin/coreDeprecated.kt create mode 100644 libraries/stdlib/js/src/kotlin/js.core.kt create mode 100644 libraries/stdlib/js/src/kotlin/jsTypeOf.kt diff --git a/libraries/stdlib/js/src/kotlin/collections/utils.kt b/libraries/stdlib/js/src/kotlin/collections/utils.kt new file mode 100644 index 00000000000..a6a938ef8cc --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/collections/utils.kt @@ -0,0 +1,12 @@ +/* + * 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/LICENSE.txt file. + */ + +package kotlin.collections + +@kotlin.internal.InlineOnly +@Suppress("UNUSED_PARAMETER") +internal inline fun deleteProperty(obj: Any, property: Any) { + js("delete obj[property]") +} diff --git a/libraries/stdlib/js/src/kotlin/core.kt b/libraries/stdlib/js/src/kotlin/core.kt index 843470d1b6c..edf189a7ec7 100644 --- a/libraries/stdlib/js/src/kotlin/core.kt +++ b/libraries/stdlib/js/src/kotlin/core.kt @@ -1,7 +1,9 @@ -package kotlin.js +/* + * 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/LICENSE.txt file. + */ -@Deprecated(message = "Use `definedExternally` instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("definedExternally")) -public external val noImpl: Nothing +package kotlin.js /** * The property that can be used as a placeholder for statements and values that are defined in JavaScript. @@ -31,25 +33,6 @@ public external val noImpl: Nothing */ public external val definedExternally: Nothing -/** - * Exposes the JavaScript [eval function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) to Kotlin. - */ -public external fun eval(expr: String): dynamic - -/** - * Exposes the JavaScript [undefined property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) to Kotlin. - */ -public external val undefined: Nothing? - -@Deprecated("Use toInt() instead.", ReplaceWith("s.toInt()"), level = DeprecationLevel.ERROR) -public external fun parseInt(s: String): Int - -@Deprecated("Use toInt(radix) instead.", ReplaceWith("s.toInt(radix)"), level = DeprecationLevel.ERROR) -public external fun parseInt(s: String, radix: Int = definedExternally): Int - -@Deprecated("Use toDouble() instead.", ReplaceWith("s.toDouble()"), level = DeprecationLevel.ERROR) -public external fun parseFloat(s: String, radix: Int = definedExternally): Double - /** * Puts the given piece of a JavaScript code right into the calling function. * The compiler replaces call to `js(...)` code with the string constant provided as a parameter. @@ -68,16 +51,3 @@ public external fun parseFloat(s: String, radix: Int = definedExternally): Doubl * including parameters. You can't refer to functions, properties and classes by their short names. */ public external fun js(code: String): dynamic - -/** - * Function corresponding to JavaScript's `typeof` operator - */ -@kotlin.internal.InlineOnly -@Suppress("UNUSED_PARAMETER") -public inline fun jsTypeOf(a: Any?): String = js("typeof a") - -@kotlin.internal.InlineOnly -@Suppress("UNUSED_PARAMETER") -internal inline fun deleteProperty(obj: Any, property: Any) { - js("delete obj[property]") -} \ No newline at end of file diff --git a/libraries/stdlib/js/src/kotlin/coreDeprecated.kt b/libraries/stdlib/js/src/kotlin/coreDeprecated.kt new file mode 100644 index 00000000000..89cec8958bc --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/coreDeprecated.kt @@ -0,0 +1,18 @@ +/* + * 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/LICENSE.txt file. + */ + +package kotlin.js + +@Deprecated(message = "Use `definedExternally` instead", level = DeprecationLevel.ERROR, replaceWith = ReplaceWith("definedExternally")) +public external val noImpl: Nothing + +@Deprecated("Use toInt() instead.", ReplaceWith("s.toInt()"), level = DeprecationLevel.ERROR) +public external fun parseInt(s: String): Int + +@Deprecated("Use toInt(radix) instead.", ReplaceWith("s.toInt(radix)"), level = DeprecationLevel.ERROR) +public external fun parseInt(s: String, radix: Int = definedExternally): Int + +@Deprecated("Use toDouble() instead.", ReplaceWith("s.toDouble()"), level = DeprecationLevel.ERROR) +public external fun parseFloat(s: String, radix: Int = definedExternally): Double diff --git a/libraries/stdlib/js/src/kotlin/js.core.kt b/libraries/stdlib/js/src/kotlin/js.core.kt new file mode 100644 index 00000000000..2deb8db0356 --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/js.core.kt @@ -0,0 +1,16 @@ +/* + * 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/LICENSE.txt file. + */ + +package kotlin.js + +/** + * Exposes the JavaScript [undefined property](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined) to Kotlin. + */ +public external val undefined: Nothing? + +/** + * Exposes the JavaScript [eval function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval) to Kotlin. + */ +public external fun eval(expr: String): dynamic diff --git a/libraries/stdlib/js/src/kotlin/jsTypeOf.kt b/libraries/stdlib/js/src/kotlin/jsTypeOf.kt new file mode 100644 index 00000000000..4328e5165e2 --- /dev/null +++ b/libraries/stdlib/js/src/kotlin/jsTypeOf.kt @@ -0,0 +1,13 @@ +/* + * 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/LICENSE.txt file. + */ + +package kotlin.js + +/** + * Function corresponding to JavaScript's `typeof` operator + */ +@kotlin.internal.InlineOnly +@Suppress("UNUSED_PARAMETER") +public inline fun jsTypeOf(a: Any?): String = js("typeof a")