KJS: add external declaration for parseFloat; remove obsolete safeParseInt and safeParseDouble

This commit is contained in:
Zalim Bashorov
2016-12-26 01:11:41 +03:00
parent d0c7c8022e
commit 6f56079f7e
3 changed files with 3 additions and 21 deletions
+3 -8
View File
@@ -8,14 +8,9 @@ public external fun eval(expr: String): dynamic = noImpl
public external val undefined: Nothing? = noImpl
//TODO: consistent parseInt
public external fun parseInt(s: String, radix: Int = noImpl): Int = noImpl
public external fun parseInt(s: String, radix: Int = noImpl): Int
@library
public fun safeParseInt(s: String): Int? = noImpl
@library
public fun safeParseDouble(s: String): Double? = noImpl
public external fun parseFloat(s: String, radix: Int = noImpl): Double
public external fun js(code: String): dynamic = noImpl
@@ -24,6 +19,6 @@ public external fun js(code: String): dynamic = noImpl
*/
public inline fun jsTypeOf(a: Any?): String = js("typeof a")
internal inline fun deleteProperty(obj: Any, property: Any){
internal inline fun deleteProperty(obj: Any, property: Any) {
js("delete obj[property]")
}
-10
View File
@@ -203,16 +203,6 @@ function getStringHashCode(str) {
return hash;
}
Kotlin.safeParseInt = function (str) {
var r = parseInt(str, 10);
return isNaN(r) ? null : r;
};
Kotlin.safeParseDouble = function (str) {
var r = parseFloat(str);
return isNaN(r) ? null : r;
};
Kotlin.arrayEquals = function (a, b) {
if (a === b) {
return true;
@@ -33,9 +33,6 @@ fun box(): String {
val longX: Long = 9223372034707292481L
assertEquals("9223372034707292481", longX.toString())
val doubleX: Double = safeParseDouble("9223372034707292481")!!
assertEquals(doubleX, longX.toDouble())
assertEquals(doubleX, longX.toFloat())
assertEquals(-2147483327, longX.toInt())
assertEquals(321, longX.toShort())