Hide deprecated JS Math object from public API and rename to JsMath

KT-41318

- Rename Math to JsMath and remove unused functions
- Fix return types, remove duplicating JsMath from longjs.kt

Co-authored-by: Abduqodiri Qurbonzoda <abduqodiri.qurbonzoda@jetbrains.com>
This commit is contained in:
Ilya Gorbunov
2021-04-06 07:20:02 +03:00
parent d9ab96126d
commit d70edeb38b
10 changed files with 109 additions and 375 deletions
@@ -27,9 +27,8 @@ public actual fun <T : Comparable<T>> maxOf(a: T, b: T): T {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Byte, b: Byte): Byte {
return Math.max(a.toInt(), b.toInt()).unsafeCast<Byte>()
return maxOf(a.toInt(), b.toInt()).unsafeCast<Byte>()
}
/**
@@ -37,9 +36,8 @@ public actual inline fun maxOf(a: Byte, b: Byte): Byte {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Short, b: Short): Short {
return Math.max(a.toInt(), b.toInt()).unsafeCast<Short>()
return maxOf(a.toInt(), b.toInt()).unsafeCast<Short>()
}
/**
@@ -47,16 +45,15 @@ public actual inline fun maxOf(a: Short, b: Short): Short {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Int, b: Int): Int {
return Math.max(a, b)
return JsMath.max(a, b)
}
/**
* Returns the greater of two values.
*/
@SinceKotlin("1.1")
@Suppress("DEPRECATION_ERROR", "NOTHING_TO_INLINE")
@Suppress("NOTHING_TO_INLINE")
public actual inline fun maxOf(a: Long, b: Long): Long {
return if (a >= b) a else b
}
@@ -68,9 +65,8 @@ public actual inline fun maxOf(a: Long, b: Long): Long {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Float, b: Float): Float {
return Math.max(a, b)
return JsMath.max(a, b)
}
/**
@@ -80,9 +76,8 @@ public actual inline fun maxOf(a: Float, b: Float): Float {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Double, b: Double): Double {
return Math.max(a, b)
return JsMath.max(a, b)
}
/**
@@ -100,9 +95,8 @@ public actual fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
return JsMath.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
}
/**
@@ -110,9 +104,8 @@ public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
return JsMath.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
}
/**
@@ -120,9 +113,8 @@ public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
return Math.max(a, b, c)
return JsMath.max(a, b, c)
}
/**
@@ -141,9 +133,8 @@ public actual inline fun maxOf(a: Long, b: Long, c: Long): Long {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
return Math.max(a, b, c)
return JsMath.max(a, b, c)
}
/**
@@ -153,9 +144,8 @@ public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
return Math.max(a, b, c)
return JsMath.max(a, b, c)
}
/**
@@ -249,9 +239,8 @@ public actual fun <T : Comparable<T>> minOf(a: T, b: T): T {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Byte, b: Byte): Byte {
return Math.min(a.toInt(), b.toInt()).unsafeCast<Byte>()
return minOf(a.toInt(), b.toInt()).unsafeCast<Byte>()
}
/**
@@ -259,9 +248,8 @@ public actual inline fun minOf(a: Byte, b: Byte): Byte {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Short, b: Short): Short {
return Math.min(a.toInt(), b.toInt()).unsafeCast<Short>()
return minOf(a.toInt(), b.toInt()).unsafeCast<Short>()
}
/**
@@ -269,16 +257,15 @@ public actual inline fun minOf(a: Short, b: Short): Short {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Int, b: Int): Int {
return Math.min(a, b)
return JsMath.min(a, b)
}
/**
* Returns the smaller of two values.
*/
@SinceKotlin("1.1")
@Suppress("DEPRECATION_ERROR", "NOTHING_TO_INLINE")
@Suppress("NOTHING_TO_INLINE")
public actual inline fun minOf(a: Long, b: Long): Long {
return if (a <= b) a else b
}
@@ -290,9 +277,8 @@ public actual inline fun minOf(a: Long, b: Long): Long {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Float, b: Float): Float {
return Math.min(a, b)
return JsMath.min(a, b)
}
/**
@@ -302,9 +288,8 @@ public actual inline fun minOf(a: Float, b: Float): Float {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Double, b: Double): Double {
return Math.min(a, b)
return JsMath.min(a, b)
}
/**
@@ -322,9 +307,8 @@ public actual fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
return JsMath.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
}
/**
@@ -332,9 +316,8 @@ public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
return JsMath.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
}
/**
@@ -342,9 +325,8 @@ public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
return Math.min(a, b, c)
return JsMath.min(a, b, c)
}
/**
@@ -363,9 +345,8 @@ public actual inline fun minOf(a: Long, b: Long, c: Long): Long {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
return Math.min(a, b, c)
return JsMath.min(a, b, c)
}
/**
@@ -375,9 +356,8 @@ public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
@Suppress("DEPRECATION_ERROR")
public actual inline fun minOf(a: Double, b: Double, c: Double): Double {
return Math.min(a, b, c)
return JsMath.min(a, b, c)
}
/**