Minor: reorder primitive specializations in generated code (according to the order they defined in java).

This commit is contained in:
Ilya Gorbunov
2016-02-02 00:54:44 +03:00
parent 7a50562a4e
commit 947fd84f1e
6 changed files with 4846 additions and 4846 deletions
+14 -14
View File
@@ -146,13 +146,6 @@ public inline fun ShortArray.copyOf(): ShortArray {
return this.asDynamic().slice(0)
}
/**
* Returns new array which is a copy of the original array.
*/
public fun BooleanArray.copyOf(newSize: Int): BooleanArray {
return arrayCopyResize(this, newSize, false)
}
/**
* Returns new array which is a copy of the original array.
*/
@@ -160,13 +153,6 @@ public fun ByteArray.copyOf(newSize: Int): ByteArray {
return arrayCopyResize(this, newSize, 0)
}
/**
* Returns new array which is a copy of the original array.
*/
public fun CharArray.copyOf(newSize: Int): CharArray {
return arrayCopyResize(this, newSize, '\u0000')
}
/**
* Returns new array which is a copy of the original array.
*/
@@ -202,6 +188,20 @@ public fun DoubleArray.copyOf(newSize: Int): DoubleArray {
return arrayCopyResize(this, newSize, 0.0)
}
/**
* Returns new array which is a copy of the original array.
*/
public fun BooleanArray.copyOf(newSize: Int): BooleanArray {
return arrayCopyResize(this, newSize, false)
}
/**
* Returns new array which is a copy of the original array.
*/
public fun CharArray.copyOf(newSize: Int): CharArray {
return arrayCopyResize(this, newSize, '\u0000')
}
/**
* Returns new array which is a copy of the original array.
*/
File diff suppressed because it is too large Load Diff
+38 -38
View File
@@ -1943,23 +1943,8 @@ public fun Iterable<Byte>.average(): Double {
/**
* Returns an average value of elements in the collection.
*/
@kotlin.jvm.JvmName("averageOfDouble")
public fun Iterable<Double>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
count += 1
}
return if (count == 0) 0.0 else sum / count
}
/**
* Returns an average value of elements in the collection.
*/
@kotlin.jvm.JvmName("averageOfFloat")
public fun Iterable<Float>.average(): Double {
@kotlin.jvm.JvmName("averageOfShort")
public fun Iterable<Short>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
@@ -2003,8 +1988,23 @@ public fun Iterable<Long>.average(): Double {
/**
* Returns an average value of elements in the collection.
*/
@kotlin.jvm.JvmName("averageOfShort")
public fun Iterable<Short>.average(): Double {
@kotlin.jvm.JvmName("averageOfFloat")
public fun Iterable<Float>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
count += 1
}
return if (count == 0) 0.0 else sum / count
}
/**
* Returns an average value of elements in the collection.
*/
@kotlin.jvm.JvmName("averageOfDouble")
public fun Iterable<Double>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
@@ -2031,23 +2031,10 @@ public fun Iterable<Byte>.sum(): Int {
/**
* Returns the sum of all elements in the collection.
*/
@kotlin.jvm.JvmName("sumOfDouble")
public fun Iterable<Double>.sum(): Double {
@kotlin.jvm.JvmName("sumOfShort")
public fun Iterable<Short>.sum(): Int {
val iterator = iterator()
var sum: Double = 0.0
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
/**
* Returns the sum of all elements in the collection.
*/
@kotlin.jvm.JvmName("sumOfFloat")
public fun Iterable<Float>.sum(): Float {
val iterator = iterator()
var sum: Float = 0.0f
var sum: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
}
@@ -2083,10 +2070,23 @@ public fun Iterable<Long>.sum(): Long {
/**
* Returns the sum of all elements in the collection.
*/
@kotlin.jvm.JvmName("sumOfShort")
public fun Iterable<Short>.sum(): Int {
@kotlin.jvm.JvmName("sumOfFloat")
public fun Iterable<Float>.sum(): Float {
val iterator = iterator()
var sum: Int = 0
var sum: Float = 0.0f
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
/**
* Returns the sum of all elements in the collection.
*/
@kotlin.jvm.JvmName("sumOfDouble")
public fun Iterable<Double>.sum(): Double {
val iterator = iterator()
var sum: Double = 0.0
while (iterator.hasNext()) {
sum += iterator.next()
}
+44 -44
View File
@@ -389,13 +389,6 @@ public infix fun Short.downTo(to: Short): IntProgression {
return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1)
}
/**
* Returns a progression that goes over the same range in the opposite direction with the same step.
*/
public fun CharProgression.reversed(): CharProgression {
return CharProgression.fromClosedRange(last, first, -step)
}
/**
* Returns a progression that goes over the same range in the opposite direction with the same step.
*/
@@ -411,11 +404,10 @@ public fun LongProgression.reversed(): LongProgression {
}
/**
* Returns a progression that goes over the same range with the given step.
* Returns a progression that goes over the same range in the opposite direction with the same step.
*/
public infix fun CharProgression.step(step: Int): CharProgression {
checkStepIsPositive(step > 0, step)
return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
public fun CharProgression.reversed(): CharProgression {
return CharProgression.fromClosedRange(last, first, -step)
}
/**
@@ -434,6 +426,14 @@ public infix fun LongProgression.step(step: Long): LongProgression {
return LongProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
* Returns a progression that goes over the same range with the given step.
*/
public infix fun CharProgression.step(step: Int): CharProgression {
checkStepIsPositive(step > 0, step)
return CharProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
}
/**
* Returns a range from this value up to but excluding the specified [to] value.
*/
@@ -597,15 +597,7 @@ public fun Byte.coerceAtLeast(minimumValue: Byte): Byte {
* Ensures that this value is not less than the specified [minimumValue].
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
*/
public fun Double.coerceAtLeast(minimumValue: Double): Double {
return if (this < minimumValue) minimumValue else this
}
/**
* Ensures that this value is not less than the specified [minimumValue].
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
*/
public fun Float.coerceAtLeast(minimumValue: Float): Float {
public fun Short.coerceAtLeast(minimumValue: Short): Short {
return if (this < minimumValue) minimumValue else this
}
@@ -629,7 +621,15 @@ public fun Long.coerceAtLeast(minimumValue: Long): Long {
* Ensures that this value is not less than the specified [minimumValue].
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
*/
public fun Short.coerceAtLeast(minimumValue: Short): Short {
public fun Float.coerceAtLeast(minimumValue: Float): Float {
return if (this < minimumValue) minimumValue else this
}
/**
* Ensures that this value is not less than the specified [minimumValue].
* @return this value if it's greater than or equal to the [minimumValue] or the [minimumValue] otherwise.
*/
public fun Double.coerceAtLeast(minimumValue: Double): Double {
return if (this < minimumValue) minimumValue else this
}
@@ -653,15 +653,7 @@ public fun Byte.coerceAtMost(maximumValue: Byte): Byte {
* Ensures that this value is not greater than the specified [maximumValue].
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
*/
public fun Double.coerceAtMost(maximumValue: Double): Double {
return if (this > maximumValue) maximumValue else this
}
/**
* Ensures that this value is not greater than the specified [maximumValue].
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
*/
public fun Float.coerceAtMost(maximumValue: Float): Float {
public fun Short.coerceAtMost(maximumValue: Short): Short {
return if (this > maximumValue) maximumValue else this
}
@@ -685,7 +677,15 @@ public fun Long.coerceAtMost(maximumValue: Long): Long {
* Ensures that this value is not greater than the specified [maximumValue].
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
*/
public fun Short.coerceAtMost(maximumValue: Short): Short {
public fun Float.coerceAtMost(maximumValue: Float): Float {
return if (this > maximumValue) maximumValue else this
}
/**
* Ensures that this value is not greater than the specified [maximumValue].
* @return this value if it's less than or equal to the [maximumValue] or the [maximumValue] otherwise.
*/
public fun Double.coerceAtMost(maximumValue: Double): Double {
return if (this > maximumValue) maximumValue else this
}
@@ -721,18 +721,7 @@ public fun Byte.coerceIn(minimumValue: Byte, maximumValue: Byte): Byte {
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
*/
public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
if (this < minimumValue) return minimumValue
if (this > maximumValue) return maximumValue
return this
}
/**
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
*/
public fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float {
public fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short {
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
if (this < minimumValue) return minimumValue
if (this > maximumValue) return maximumValue
@@ -765,7 +754,18 @@ public fun Long.coerceIn(minimumValue: Long, maximumValue: Long): Long {
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
*/
public fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short {
public fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float {
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
if (this < minimumValue) return minimumValue
if (this > maximumValue) return maximumValue
return this
}
/**
* Ensures that this value lies in the specified range [minimumValue]..[maximumValue].
* @return this value if it's in the range, or [minimumValue] if this value is less than [minimumValue], or [maximumValue] if this value is greater than [maximumValue].
*/
public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double {
if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.")
if (this < minimumValue) return minimumValue
if (this > maximumValue) return maximumValue
+38 -38
View File
@@ -1235,23 +1235,8 @@ public fun Sequence<Byte>.average(): Double {
/**
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfDouble")
public fun Sequence<Double>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
count += 1
}
return if (count == 0) 0.0 else sum / count
}
/**
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfFloat")
public fun Sequence<Float>.average(): Double {
@kotlin.jvm.JvmName("averageOfShort")
public fun Sequence<Short>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
@@ -1295,8 +1280,23 @@ public fun Sequence<Long>.average(): Double {
/**
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfShort")
public fun Sequence<Short>.average(): Double {
@kotlin.jvm.JvmName("averageOfFloat")
public fun Sequence<Float>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
count += 1
}
return if (count == 0) 0.0 else sum / count
}
/**
* Returns an average value of elements in the sequence.
*/
@kotlin.jvm.JvmName("averageOfDouble")
public fun Sequence<Double>.average(): Double {
val iterator = iterator()
var sum: Double = 0.0
var count: Int = 0
@@ -1323,23 +1323,10 @@ public fun Sequence<Byte>.sum(): Int {
/**
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfDouble")
public fun Sequence<Double>.sum(): Double {
@kotlin.jvm.JvmName("sumOfShort")
public fun Sequence<Short>.sum(): Int {
val iterator = iterator()
var sum: Double = 0.0
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
/**
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfFloat")
public fun Sequence<Float>.sum(): Float {
val iterator = iterator()
var sum: Float = 0.0f
var sum: Int = 0
while (iterator.hasNext()) {
sum += iterator.next()
}
@@ -1375,10 +1362,23 @@ public fun Sequence<Long>.sum(): Long {
/**
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfShort")
public fun Sequence<Short>.sum(): Int {
@kotlin.jvm.JvmName("sumOfFloat")
public fun Sequence<Float>.sum(): Float {
val iterator = iterator()
var sum: Int = 0
var sum: Float = 0.0f
while (iterator.hasNext()) {
sum += iterator.next()
}
return sum
}
/**
* Returns the sum of all elements in the sequence.
*/
@kotlin.jvm.JvmName("sumOfDouble")
public fun Sequence<Double>.sum(): Double {
val iterator = iterator()
var sum: Double = 0.0
while (iterator.hasNext()) {
sum += iterator.next()
}
@@ -32,14 +32,14 @@ enum class Family {
}
enum class PrimitiveType {
Boolean,
Byte,
Char,
Short,
Int,
Long,
Float,
Double;
Double,
Boolean,
Char;
companion object {
val defaultPrimitives = PrimitiveType.values().toSet()
@@ -208,7 +208,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
val onlyPrimitives = buildFamilyPrimitives[f]
if (f.isPrimitiveSpecialization || onlyPrimitives != null) {
return (onlyPrimitives ?: buildPrimitives).sortedBy { it.name }
return (onlyPrimitives ?: buildPrimitives).sortedBy { it.ordinal }
.map { primitive -> ConcreteFunction( { build(it, f, primitive) }, sourceFileFor(f) ) }
} else {
return listOf(ConcreteFunction( { build(it, f, null) }, sourceFileFor(f) ))