JS: replace noImpl with definedExternally in hand-written stdlib
This commit is contained in:
@@ -2,11 +2,11 @@ package kotlin.browser
|
|||||||
|
|
||||||
import org.w3c.dom.*
|
import org.w3c.dom.*
|
||||||
|
|
||||||
public external val window: Window = noImpl
|
public external val window: Window
|
||||||
|
|
||||||
public external val document: Document = noImpl
|
public external val document: Document
|
||||||
|
|
||||||
public external val localStorage: Storage = noImpl
|
public external val localStorage: Storage
|
||||||
|
|
||||||
public external val sessionStorage: Storage = noImpl
|
public external val sessionStorage: Storage
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ internal fun <T> copyToArrayImpl(collection: Collection<*>, array: Array<T>): Ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@library("arrayToString")
|
@library("arrayToString")
|
||||||
internal fun arrayToString(array: Array<*>): String = noImpl
|
internal fun arrayToString(array: Array<*>): String = definedExternally
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an immutable list containing only the specified object [element].
|
* Returns an immutable list containing only the specified object [element].
|
||||||
|
|||||||
@@ -1,22 +1,20 @@
|
|||||||
package kotlin.js
|
package kotlin.js
|
||||||
|
|
||||||
public external val noImpl: Nothing
|
public external val noImpl: Nothing
|
||||||
get() = definedExternally
|
|
||||||
|
|
||||||
public external val definedExternally: Nothing
|
public external val definedExternally: Nothing
|
||||||
get() = definedExternally
|
|
||||||
|
|
||||||
public external fun eval(expr: String): dynamic = noImpl
|
public external fun eval(expr: String): dynamic
|
||||||
|
|
||||||
public external val undefined: Nothing? = noImpl
|
public external val undefined: Nothing?
|
||||||
|
|
||||||
@Deprecated("Use toInt(radix) instead.", ReplaceWith("s.toInt(radix)"), level = DeprecationLevel.ERROR)
|
@Deprecated("Use toInt(radix) instead.", ReplaceWith("s.toInt(radix)"), level = DeprecationLevel.ERROR)
|
||||||
public external fun parseInt(s: String, radix: Int = noImpl): Int
|
public external fun parseInt(s: String, radix: Int = definedExternally): Int
|
||||||
|
|
||||||
@Deprecated("Use toDouble() instead.", ReplaceWith("s.toDouble()"), level = DeprecationLevel.ERROR)
|
@Deprecated("Use toDouble() instead.", ReplaceWith("s.toDouble()"), level = DeprecationLevel.ERROR)
|
||||||
public external fun parseFloat(s: String, radix: Int = noImpl): Double
|
public external fun parseFloat(s: String, radix: Int = definedExternally): Double
|
||||||
|
|
||||||
public external fun js(code: String): dynamic = noImpl
|
public external fun js(code: String): dynamic
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function corresponding to JavaScript's `typeof` operator
|
* Function corresponding to JavaScript's `typeof` operator
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package kotlin.js
|
package kotlin.js
|
||||||
|
|
||||||
public external class Date() {
|
public external class Date() {
|
||||||
public fun getTime(): Int = noImpl
|
public fun getTime(): Int
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ external public interface Console {
|
|||||||
public fun warn(vararg o: Any?): Unit
|
public fun warn(vararg o: Any?): Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
public external val console: Console = noImpl
|
public external val console: Console
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ package java.util
|
|||||||
|
|
||||||
@Deprecated("Use kotlin.js.Date instead", ReplaceWith("kotlin.js.Date"))
|
@Deprecated("Use kotlin.js.Date instead", ReplaceWith("kotlin.js.Date"))
|
||||||
public external class Date() {
|
public external class Date() {
|
||||||
public fun getTime(): Int = noImpl
|
public fun getTime(): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use kotlin.collections.RandomAccess instead", ReplaceWith("kotlin.collections.RandomAccess"))
|
@Deprecated("Use kotlin.collections.RandomAccess instead", ReplaceWith("kotlin.collections.RandomAccess"))
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package kotlin.js
|
package kotlin.js
|
||||||
|
|
||||||
public external class Json() {
|
public external class Json() {
|
||||||
operator fun get(propertyName: String): Any? = noImpl
|
operator fun get(propertyName: String): Any?
|
||||||
operator fun set(propertyName: String, value: Any?): Unit = noImpl
|
operator fun set(propertyName: String, value: Any?): Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun json(vararg pairs: Pair<String, Any?>): Json {
|
public fun json(vararg pairs: Pair<String, Any?>): Json {
|
||||||
|
|||||||
@@ -22,31 +22,31 @@ package kotlin
|
|||||||
public inline fun <T> emptyArray(): Array<T> = js("[]")
|
public inline fun <T> emptyArray(): Array<T> = js("[]")
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun <T> arrayOf(vararg elements: T): Array<T> = noImpl
|
public fun <T> arrayOf(vararg elements: T): Array<T> = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun doubleArrayOf(vararg elements: Double): DoubleArray = noImpl
|
public fun doubleArrayOf(vararg elements: Double): DoubleArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun floatArrayOf(vararg elements: Float): FloatArray = noImpl
|
public fun floatArrayOf(vararg elements: Float): FloatArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun longArrayOf(vararg elements: Long): LongArray = noImpl
|
public fun longArrayOf(vararg elements: Long): LongArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun intArrayOf(vararg elements: Int): IntArray = noImpl
|
public fun intArrayOf(vararg elements: Int): IntArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun charArrayOf(vararg elements: Char): CharArray = noImpl
|
public fun charArrayOf(vararg elements: Char): CharArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun shortArrayOf(vararg elements: Short): ShortArray = noImpl
|
public fun shortArrayOf(vararg elements: Short): ShortArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun byteArrayOf(vararg elements: Byte): ByteArray = noImpl
|
public fun byteArrayOf(vararg elements: Byte): ByteArray = definedExternally
|
||||||
|
|
||||||
@library
|
@library
|
||||||
public fun booleanArrayOf(vararg elements: Boolean): BooleanArray = noImpl
|
public fun booleanArrayOf(vararg elements: Boolean): BooleanArray = definedExternally
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
|
* Creates a new instance of the [Lazy] that uses the specified initialization function [initializer].
|
||||||
|
|||||||
@@ -2,29 +2,29 @@ package kotlin.js
|
|||||||
|
|
||||||
//TODO: declare using number
|
//TODO: declare using number
|
||||||
public external object Math {
|
public external object Math {
|
||||||
public val PI: Double = noImpl
|
public val PI: Double
|
||||||
public fun random(): Double = noImpl
|
public fun random(): Double
|
||||||
public fun abs(value: Double): Double = noImpl
|
public fun abs(value: Double): Double
|
||||||
public fun acos(value: Double): Double = noImpl
|
public fun acos(value: Double): Double
|
||||||
public fun asin(value: Double): Double = noImpl
|
public fun asin(value: Double): Double
|
||||||
public fun atan(value: Double): Double = noImpl
|
public fun atan(value: Double): Double
|
||||||
public fun atan2(x: Double, y: Double): Double = noImpl
|
public fun atan2(x: Double, y: Double): Double
|
||||||
public fun cos(value: Double): Double = noImpl
|
public fun cos(value: Double): Double
|
||||||
public fun sin(value: Double): Double = noImpl
|
public fun sin(value: Double): Double
|
||||||
public fun exp(value: Double): Double = noImpl
|
public fun exp(value: Double): Double
|
||||||
public fun max(vararg values: Int): Int = noImpl
|
public fun max(vararg values: Int): Int
|
||||||
public fun max(vararg values: Float): Float = noImpl
|
public fun max(vararg values: Float): Float
|
||||||
public fun max(vararg values: Double): Double = noImpl
|
public fun max(vararg values: Double): Double
|
||||||
public fun min(vararg values: Int): Int = noImpl
|
public fun min(vararg values: Int): Int
|
||||||
public fun min(vararg values: Float): Float = noImpl
|
public fun min(vararg values: Float): Float
|
||||||
public fun min(vararg values: Double): Double = noImpl
|
public fun min(vararg values: Double): Double
|
||||||
public fun sqrt(value: Double): Double = noImpl
|
public fun sqrt(value: Double): Double
|
||||||
public fun tan(value: Double): Double = noImpl
|
public fun tan(value: Double): Double
|
||||||
public fun log(value: Double): Double = noImpl
|
public fun log(value: Double): Double
|
||||||
public fun pow(base: Double, exp: Double): Double = noImpl
|
public fun pow(base: Double, exp: Double): Double
|
||||||
public fun round(value: Number): Int = noImpl
|
public fun round(value: Number): Int
|
||||||
public fun floor(value: Number): Int = noImpl
|
public fun floor(value: Number): Int
|
||||||
public fun ceil(value: Number): Int = noImpl
|
public fun ceil(value: Number): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun Math.min(a: Long, b: Long): Long = if (a <= b) a else b
|
public fun Math.min(a: Long, b: Long): Long = if (a <= b) a else b
|
||||||
|
|||||||
@@ -17,22 +17,22 @@
|
|||||||
package kotlin.text.js
|
package kotlin.text.js
|
||||||
|
|
||||||
|
|
||||||
public external class RegExp(pattern: String, flags: String? = noImpl) {
|
public external class RegExp(pattern: String, flags: String? = definedExternally) {
|
||||||
|
|
||||||
public fun test(str: String): Boolean = noImpl
|
public fun test(str: String): Boolean
|
||||||
|
|
||||||
public fun exec(str: String): RegExpMatch? = noImpl
|
public fun exec(str: String): RegExpMatch?
|
||||||
|
|
||||||
public override fun toString(): String = noImpl
|
public override fun toString(): String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The lastIndex is a read/write integer property of regular expressions that specifies the index at which to start the next match.
|
* The lastIndex is a read/write integer property of regular expressions that specifies the index at which to start the next match.
|
||||||
*/
|
*/
|
||||||
public var lastIndex: Int
|
public var lastIndex: Int
|
||||||
|
|
||||||
public val global: Boolean get() = noImpl
|
public val global: Boolean
|
||||||
public val ignoreCase: Boolean get() = noImpl
|
public val ignoreCase: Boolean
|
||||||
public val multiline: Boolean get() = noImpl
|
public val multiline: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun RegExp.reset() {
|
public fun RegExp.reset() {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public inline fun String.concat(str: String): String = asDynamic().concat(str)
|
|||||||
|
|
||||||
public inline fun String.match(regex: String): Array<String> = asDynamic().match(regex)
|
public inline fun String.match(regex: String): Array<String> = asDynamic().match(regex)
|
||||||
|
|
||||||
//native public fun String.trim() : String = noImpl
|
//native public fun String.trim(): String
|
||||||
//TODO: String.replace to implement effective trimLeading and trimTrailing
|
//TODO: String.replace to implement effective trimLeading and trimTrailing
|
||||||
|
|
||||||
public inline val CharSequence.size: Int get() = asDynamic().length
|
public inline val CharSequence.size: Int get() = asDynamic().length
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package jquery
|
|||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
|
|
||||||
public external class JQuery() {
|
public external class JQuery() {
|
||||||
public fun addClass(className: String): JQuery = noImpl;
|
public fun addClass(className: String): JQuery
|
||||||
public fun addClass(f: Element.(Int, String) -> String): JQuery = noImpl;
|
public fun addClass(f: Element.(Int, String) -> String): JQuery
|
||||||
|
|
||||||
public fun attr(attrName: String): String
|
public fun attr(attrName: String): String
|
||||||
public fun attr(attrName: String, value: String): JQuery
|
public fun attr(attrName: String, value: String): JQuery
|
||||||
@@ -37,9 +37,9 @@ public external class JQuery() {
|
|||||||
public fun slideUp(): JQuery
|
public fun slideUp(): JQuery
|
||||||
public fun hover(handlerInOut: Element.() -> Unit): JQuery
|
public fun hover(handlerInOut: Element.() -> Unit): JQuery
|
||||||
public fun hover(handlerIn: Element.() -> Unit, handlerOut: Element.() -> Unit): JQuery
|
public fun hover(handlerIn: Element.() -> Unit, handlerOut: Element.() -> Unit): JQuery
|
||||||
public fun next(): JQuery = noImpl
|
public fun next(): JQuery
|
||||||
public fun parent(): JQuery = noImpl
|
public fun parent(): JQuery
|
||||||
public fun `val`(): String? = noImpl
|
public fun `val`(): String?
|
||||||
}
|
}
|
||||||
|
|
||||||
open public external class MouseEvent() {
|
open public external class MouseEvent() {
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ package QUnit
|
|||||||
* The [QUnit](http://qunitjs.com/) API
|
* The [QUnit](http://qunitjs.com/) API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public external fun ok(actual: Boolean, message: String?): Unit = noImpl
|
public external fun ok(actual: Boolean, message: String?): Unit
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ external interface JsClass<T : Any> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("T::class.js"))
|
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("T::class.js"))
|
||||||
external fun <T : Any> jsClass(): JsClass<T> = noImpl
|
external fun <T : Any> jsClass(): JsClass<T>
|
||||||
|
|
||||||
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"))
|
@Deprecated("Use class literal and extension property `js` instead.", replaceWith = ReplaceWith("this::class.js"))
|
||||||
val <T : Any> T.jsClass: JsClass<T>
|
val <T : Any> T.jsClass: JsClass<T>
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ package QUnit
|
|||||||
* The [QUnit](http://qunitjs.com/) API
|
* The [QUnit](http://qunitjs.com/) API
|
||||||
*/
|
*/
|
||||||
|
|
||||||
external fun ok(actual: Boolean, message: String?): Unit = noImpl
|
external fun ok(actual: Boolean, message: String?): Unit
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user