Remove special source generation for js stdlib, use same template, rename generated file.
This commit is contained in:
+297
-293
@@ -1,3 +1,6 @@
|
||||
@file:kotlin.jvm.JvmMultifileClass
|
||||
@file:kotlin.jvm.JvmName("ArraysKt")
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
//
|
||||
@@ -5,6 +8,7 @@ package kotlin.collections
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
import kotlin.comparisons.*
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -14,13 +18,6 @@ public fun <T> Array<out T>.asList(): List<T> {
|
||||
return ArrayList<T>(this as Array<Any?>)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun BooleanArray.asList(): List<Boolean> {
|
||||
return (this as Array<Boolean>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
@@ -31,22 +28,8 @@ public inline fun ByteArray.asList(): List<Byte> {
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun CharArray.asList(): List<Char> {
|
||||
return (this as Array<Char>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun DoubleArray.asList(): List<Double> {
|
||||
return (this as Array<Double>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun FloatArray.asList(): List<Float> {
|
||||
return (this as Array<Float>).asList()
|
||||
public inline fun ShortArray.asList(): List<Short> {
|
||||
return (this as Array<Short>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,8 +49,157 @@ public inline fun LongArray.asList(): List<Long> {
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun ShortArray.asList(): List<Short> {
|
||||
return (this as Array<Short>).asList()
|
||||
public inline fun FloatArray.asList(): List<Float> {
|
||||
return (this as Array<Float>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun DoubleArray.asList(): List<Double> {
|
||||
return (this as Array<Double>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun BooleanArray.asList(): List<Boolean> {
|
||||
return (this as Array<Boolean>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [List] that wraps the original array.
|
||||
*/
|
||||
public inline fun CharArray.asList(): List<Char> {
|
||||
return (this as Array<Char>).asList()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun ByteArray.toTypedArray(): Array<Byte> {
|
||||
return copyOf() as Array<Byte>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun ShortArray.toTypedArray(): Array<Short> {
|
||||
return copyOf() as Array<Short>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun IntArray.toTypedArray(): Array<Int> {
|
||||
return copyOf() as Array<Int>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun LongArray.toTypedArray(): Array<Long> {
|
||||
return copyOf() as Array<Long>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun FloatArray.toTypedArray(): Array<Float> {
|
||||
return copyOf() as Array<Float>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun DoubleArray.toTypedArray(): Array<Double> {
|
||||
return copyOf() as Array<Double>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun BooleanArray.toTypedArray(): Array<Boolean> {
|
||||
return copyOf() as Array<Boolean>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
*/
|
||||
public fun CharArray.toTypedArray(): Array<Char> {
|
||||
return copyOf() as Array<Char>
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun <T> Array<out T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T> {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,14 +210,6 @@ public inline fun <T> Array<out T>.copyOf(): Array<T> {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun BooleanArray.copyOf(): BooleanArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@@ -98,23 +222,7 @@ public inline fun ByteArray.copyOf(): ByteArray {
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun CharArray.copyOf(): CharArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun DoubleArray.copyOf(): DoubleArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun FloatArray.copyOf(): FloatArray {
|
||||
public inline fun ShortArray.copyOf(): ShortArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
@@ -138,7 +246,31 @@ public inline fun LongArray.copyOf(): LongArray {
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ShortArray.copyOf(): ShortArray {
|
||||
public inline fun FloatArray.copyOf(): FloatArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun DoubleArray.copyOf(): DoubleArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun BooleanArray.copyOf(): BooleanArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of the original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun CharArray.copyOf(): CharArray {
|
||||
return this.asDynamic().slice()
|
||||
}
|
||||
|
||||
@@ -205,83 +337,11 @@ public fun <T> Array<out T>.copyOf(newSize: Int): Array<T?> {
|
||||
return arrayCopyResize(this, newSize, null)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun <T> Array<out T>.copyOfRange(fromIndex: Int, toIndex: Int): Array<T> {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun BooleanArray.copyOfRange(fromIndex: Int, toIndex: Int): BooleanArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ByteArray.copyOfRange(fromIndex: Int, toIndex: Int): ByteArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun CharArray.copyOfRange(fromIndex: Int, toIndex: Int): CharArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun DoubleArray.copyOfRange(fromIndex: Int, toIndex: Int): DoubleArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun FloatArray.copyOfRange(fromIndex: Int, toIndex: Int): FloatArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun IntArray.copyOfRange(fromIndex: Int, toIndex: Int): IntArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun LongArray.copyOfRange(fromIndex: Int, toIndex: Int): LongArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns new array which is a copy of range of original array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun ShortArray.copyOfRange(fromIndex: Int, toIndex: Int): ShortArray {
|
||||
return this.asDynamic().slice(fromIndex, toIndex)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun <T> Array<out T>.plus(element: T): Array<T> {
|
||||
public inline fun <T> Array<out T>.plusElement(element: T): Array<T> {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
@@ -289,7 +349,7 @@ public inline operator fun <T> Array<out T>.plus(element: T): Array<T> {
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun BooleanArray.plus(element: Boolean): BooleanArray {
|
||||
public inline operator fun <T> Array<out T>.plus(element: T): Array<T> {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
@@ -305,23 +365,7 @@ public inline operator fun ByteArray.plus(element: Byte): ByteArray {
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun CharArray.plus(element: Char): CharArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun DoubleArray.plus(element: Double): DoubleArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun FloatArray.plus(element: Float): FloatArray {
|
||||
public inline operator fun ShortArray.plus(element: Short): ShortArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
@@ -345,7 +389,31 @@ public inline operator fun LongArray.plus(element: Long): LongArray {
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun ShortArray.plus(element: Short): ShortArray {
|
||||
public inline operator fun FloatArray.plus(element: Float): FloatArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun DoubleArray.plus(element: Double): DoubleArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun BooleanArray.plus(element: Boolean): BooleanArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun CharArray.plus(element: Char): CharArray {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
}
|
||||
|
||||
@@ -356,13 +424,6 @@ public operator fun <T> Array<out T>.plus(elements: Collection<T>): Array<T> {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun BooleanArray.plus(elements: Collection<Boolean>): BooleanArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
@@ -373,21 +434,7 @@ public operator fun ByteArray.plus(elements: Collection<Byte>): ByteArray {
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun CharArray.plus(elements: Collection<Char>): CharArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun FloatArray.plus(elements: Collection<Float>): FloatArray {
|
||||
public operator fun ShortArray.plus(elements: Collection<Short>): ShortArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
@@ -408,7 +455,28 @@ public operator fun LongArray.plus(elements: Collection<Long>): LongArray {
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun ShortArray.plus(elements: Collection<Short>): ShortArray {
|
||||
public operator fun FloatArray.plus(elements: Collection<Float>): FloatArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun DoubleArray.plus(elements: Collection<Double>): DoubleArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun BooleanArray.plus(elements: Collection<Boolean>): BooleanArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] collection.
|
||||
*/
|
||||
public operator fun CharArray.plus(elements: Collection<Char>): CharArray {
|
||||
return arrayPlusCollection(this, elements)
|
||||
}
|
||||
|
||||
@@ -420,14 +488,6 @@ public inline operator fun <T> Array<out T>.plus(elements: Array<out T>): Array<
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@@ -440,23 +500,7 @@ public inline operator fun ByteArray.plus(elements: ByteArray): ByteArray {
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun CharArray.plus(elements: CharArray): CharArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun FloatArray.plus(elements: FloatArray): FloatArray {
|
||||
public inline operator fun ShortArray.plus(elements: ShortArray): ShortArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
@@ -480,80 +524,32 @@ public inline operator fun LongArray.plus(elements: LongArray): LongArray {
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun ShortArray.plus(elements: ShortArray): ShortArray {
|
||||
public inline operator fun FloatArray.plus(elements: FloatArray): FloatArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing all elements of the original array and then the given [element].
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline fun <T> Array<out T>.plusElement(element: T): Array<T> {
|
||||
return this.asDynamic().concat(arrayOf(element))
|
||||
public inline operator fun DoubleArray.plus(elements: DoubleArray): DoubleArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@library("primitiveArraySort")
|
||||
public fun ByteArray.sort(): Unit {
|
||||
noImpl
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun BooleanArray.plus(elements: BooleanArray): BooleanArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
* Returns an array containing all elements of the original array and then all elements of the given [elements] array.
|
||||
*/
|
||||
@library("primitiveArraySort")
|
||||
public fun CharArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
@library("primitiveArraySort")
|
||||
public fun DoubleArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
@library("primitiveArraySort")
|
||||
public fun FloatArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
@library("primitiveArraySort")
|
||||
public fun IntArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
@library("primitiveArraySort")
|
||||
public fun ShortArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun <T: Comparable<T>> Array<out T>.sort(): Unit {
|
||||
if (size > 1)
|
||||
sort { a: T, b: T -> a.compareTo(b) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun LongArray.sort(): Unit {
|
||||
if (size > 1)
|
||||
sort { a: Long, b: Long -> a.compareTo(b) }
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
public inline operator fun CharArray.plus(elements: CharArray): CharArray {
|
||||
return this.asDynamic().concat(elements)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -576,23 +572,7 @@ public fun ByteArray.sort(comparison: (Byte, Byte) -> Int): Unit {
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*/
|
||||
@native
|
||||
public fun CharArray.sort(comparison: (Char, Char) -> Int): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*/
|
||||
@native
|
||||
public fun DoubleArray.sort(comparison: (Double, Double) -> Int): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*/
|
||||
@native
|
||||
public fun FloatArray.sort(comparison: (Float, Float) -> Int): Unit {
|
||||
public fun ShortArray.sort(comparison: (Short, Short) -> Int): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
@@ -616,7 +596,23 @@ public fun LongArray.sort(comparison: (Long, Long) -> Int): Unit {
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*/
|
||||
@native
|
||||
public fun ShortArray.sort(comparison: (Short, Short) -> Int): Unit {
|
||||
public fun FloatArray.sort(comparison: (Float, Float) -> Int): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*/
|
||||
@native
|
||||
public fun DoubleArray.sort(comparison: (Double, Double) -> Int): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the array in-place according to the order specified by the given [comparison] function.
|
||||
*/
|
||||
@native
|
||||
public fun CharArray.sort(comparison: (Char, Char) -> Int): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
@@ -629,58 +625,66 @@ public fun <T> Array<out T>.sortWith(comparator: Comparator<in T>): Unit {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun BooleanArray.toTypedArray(): Array<Boolean> {
|
||||
return copyOf() as Array<Boolean>
|
||||
@library("primitiveArraySort")
|
||||
public fun ByteArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun ByteArray.toTypedArray(): Array<Byte> {
|
||||
return copyOf() as Array<Byte>
|
||||
@library("primitiveArraySort")
|
||||
public fun ShortArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun CharArray.toTypedArray(): Array<Char> {
|
||||
return copyOf() as Array<Char>
|
||||
@library("primitiveArraySort")
|
||||
public fun IntArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun DoubleArray.toTypedArray(): Array<Double> {
|
||||
return copyOf() as Array<Double>
|
||||
@library("primitiveArraySort")
|
||||
public fun FloatArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun FloatArray.toTypedArray(): Array<Float> {
|
||||
return copyOf() as Array<Float>
|
||||
@library("primitiveArraySort")
|
||||
public fun DoubleArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun IntArray.toTypedArray(): Array<Int> {
|
||||
return copyOf() as Array<Int>
|
||||
@library("primitiveArraySort")
|
||||
public fun CharArray.sort(): Unit {
|
||||
noImpl
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun LongArray.toTypedArray(): Array<Long> {
|
||||
return copyOf() as Array<Long>
|
||||
public fun <T: Comparable<T>> Array<out T>.sort(): Unit {
|
||||
if (size > 1)
|
||||
sort { a: T, b: T -> a.compareTo(b) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a *typed* object array containing all of the elements of this primitive array.
|
||||
* Sorts the array in-place.
|
||||
*/
|
||||
public fun ShortArray.toTypedArray(): Array<Short> {
|
||||
return copyOf() as Array<Short>
|
||||
public fun LongArray.sort(): Unit {
|
||||
if (size > 1)
|
||||
sort { a: Long, b: Long -> a.compareTo(b) }
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package generators
|
||||
|
||||
import java.io.*
|
||||
import templates.Family.*
|
||||
import templates.*
|
||||
import templates.PrimitiveType.*
|
||||
|
||||
fun generateCollectionsAPI(outDir: File) {
|
||||
val templates = sequenceOf(
|
||||
::elements,
|
||||
::filtering,
|
||||
::ordering,
|
||||
::arrays,
|
||||
::snapshots,
|
||||
::mapping,
|
||||
::sets,
|
||||
::aggregates,
|
||||
::guards,
|
||||
::generators,
|
||||
::strings,
|
||||
::sequences,
|
||||
::specialJVM,
|
||||
::ranges,
|
||||
::numeric,
|
||||
::comparables
|
||||
).flatMap { it().sortedBy { it.signature }.asSequence() }
|
||||
|
||||
val groupedConcreteFunctions = templates.flatMap { it.instantiate().asSequence() }.groupBy { it.sourceFile }
|
||||
|
||||
for ((sourceFile, functions) in groupedConcreteFunctions) {
|
||||
functions.writeTo(outDir, sourceFile)
|
||||
}
|
||||
}
|
||||
|
||||
fun generateCollectionsJsAPI(outDir: File) {
|
||||
specialJS().writeTo(File(outDir, "kotlin_special.kt")) { build() }
|
||||
}
|
||||
@@ -18,11 +18,12 @@ private val COMMON_AUTOGENERATED_WARNING: String = """//
|
||||
*/
|
||||
fun main(args: Array<String>) {
|
||||
require(args.size == 1) { "Expecting Kotlin project home path as an argument" }
|
||||
val baseDir = File(args.first())
|
||||
|
||||
val outDir = File(File(args[0]), "libraries/stdlib/src/generated")
|
||||
val outDir = baseDir.resolve("libraries/stdlib/src/generated")
|
||||
require(outDir.exists()) { "$outDir doesn't exist!" }
|
||||
|
||||
val jsCoreDir = File(args[0], "js/js.libraries/src/core")
|
||||
val jsCoreDir = baseDir.resolve("js/js.libraries/src/core/generated")
|
||||
require(jsCoreDir.exists()) { "$jsCoreDir doesn't exist!" }
|
||||
|
||||
generateCollectionsAPI(outDir)
|
||||
@@ -30,37 +31,60 @@ fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
|
||||
fun List<GenericFunction>.writeTo(file: File, builder: GenericFunction.() -> String) {
|
||||
println("Generating file: $file")
|
||||
val its = FileWriter(file)
|
||||
fun generateCollectionsAPI(outDir: File) {
|
||||
val templates = sequenceOf(
|
||||
::elements,
|
||||
::filtering,
|
||||
::ordering,
|
||||
::arrays,
|
||||
::snapshots,
|
||||
::mapping,
|
||||
::sets,
|
||||
::aggregates,
|
||||
::guards,
|
||||
::generators,
|
||||
::strings,
|
||||
::sequences,
|
||||
::specialJVM,
|
||||
::ranges,
|
||||
::numeric,
|
||||
::comparables
|
||||
).flatMap { it().sortedBy { it.signature }.asSequence() }
|
||||
|
||||
its.use {
|
||||
its.append("package kotlin.collections\n\n")
|
||||
its.append("$COMMON_AUTOGENERATED_WARNING\n\n")
|
||||
its.append("import java.util.*\n\n")
|
||||
for (t in this.sortedBy { it.signature }) {
|
||||
its.append(t.builder())
|
||||
}
|
||||
templates.groupByFileAndWrite(outDir)
|
||||
}
|
||||
|
||||
fun generateCollectionsJsAPI(outDir: File) {
|
||||
specialJS().asSequence().groupByFileAndWrite(outDir, { "_${it.name.capitalize()}Js.kt"})
|
||||
}
|
||||
|
||||
|
||||
private fun Sequence<GenericFunction>.groupByFileAndWrite(
|
||||
outDir: File,
|
||||
fileNameBuilder: (SourceFile) -> String = { "_${it.name.capitalize()}.kt" }
|
||||
) {
|
||||
val groupedConcreteFunctions = flatMap { it.instantiate().asSequence() }.groupBy { it.sourceFile }
|
||||
|
||||
for ((sourceFile, functions) in groupedConcreteFunctions) {
|
||||
val file = outDir.resolve(fileNameBuilder(sourceFile))
|
||||
functions.writeTo(file, sourceFile)
|
||||
}
|
||||
}
|
||||
|
||||
fun List<ConcreteFunction>.writeTo(outDir: File, sourceFile: SourceFile) {
|
||||
val file = File(outDir, sourceFile.fileName)
|
||||
private fun List<ConcreteFunction>.writeTo(file: File, sourceFile: SourceFile) {
|
||||
println("Generating file: $file")
|
||||
val its = FileWriter(file)
|
||||
|
||||
its.use {
|
||||
FileWriter(file).use { writer ->
|
||||
if (sourceFile.multifile) {
|
||||
its.append("@file:kotlin.jvm.JvmMultifileClass\n")
|
||||
writer.append("@file:kotlin.jvm.JvmMultifileClass\n")
|
||||
}
|
||||
its.append("@file:kotlin.jvm.JvmName(\"${sourceFile.jvmClassName}\")\n\n")
|
||||
its.append("package ${sourceFile.packageName ?: "kotlin"}\n\n")
|
||||
its.append("$COMMON_AUTOGENERATED_WARNING\n\n")
|
||||
its.append("import kotlin.comparisons.*\n")
|
||||
its.append("import java.util.*\n\n")
|
||||
|
||||
writer.append("@file:kotlin.jvm.JvmName(\"${sourceFile.jvmClassName}\")\n\n")
|
||||
writer.append("package ${sourceFile.packageName ?: "kotlin"}\n\n")
|
||||
writer.append("$COMMON_AUTOGENERATED_WARNING\n\n")
|
||||
writer.append("import kotlin.comparisons.*\n")
|
||||
writer.append("import java.util.*\n\n")
|
||||
for (f in this) {
|
||||
f.textBuilder(its)
|
||||
f.textBuilder(writer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,4 @@ enum class SourceFile(jvmClassName: String? = null, val multifile: Boolean = tru
|
||||
;
|
||||
|
||||
val jvmClassName = jvmClassName ?: (name.capitalize() + "Kt")
|
||||
|
||||
val fileName: String get() = "_${name.capitalize()}.kt"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user