Generate range downTos with templates DSL
This commit is contained in:
@@ -1,460 +0,0 @@
|
||||
package kotlin
|
||||
|
||||
//
|
||||
// NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt
|
||||
// See: https://github.com/JetBrains/kotlin/tree/master/libraries/stdlib
|
||||
//
|
||||
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Byte): ByteProgression {
|
||||
return ByteProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Byte.downTo(to: Char): CharProgression {
|
||||
return CharProgression(this.toChar(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Short): ShortProgression {
|
||||
return ShortProgression(this.toShort(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Char.downTo(to: Byte): CharProgression {
|
||||
return CharProgression(this, to.toChar(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Char.downTo(to: Char): CharProgression {
|
||||
return CharProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Char.downTo(to: Short): ShortProgression {
|
||||
return ShortProgression(this.toShort(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Char.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Char.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Char.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Char.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Byte): ShortProgression {
|
||||
return ShortProgression(this, to.toShort(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Short.downTo(to: Char): ShortProgression {
|
||||
return ShortProgression(this, to.toShort(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Short): ShortProgression {
|
||||
return ShortProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Byte): IntProgression {
|
||||
return IntProgression(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Int.downTo(to: Char): IntProgression {
|
||||
return IntProgression(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Short): IntProgression {
|
||||
return IntProgression(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Byte): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Long.downTo(to: Char): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Short): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Int): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this, to, -1.toLong())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Byte): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Float.downTo(to: Char): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Short): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Int): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Long): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this, to, -1.toFloat())
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Byte): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")
|
||||
public fun Double.downTo(to: Char): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Short): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Int): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Long): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Float): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this, to, -1.0)
|
||||
}
|
||||
@@ -10,6 +10,302 @@ import java.util.*
|
||||
|
||||
import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Byte): IntProgression {
|
||||
return IntProgression(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Byte): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Byte): ByteProgression {
|
||||
return ByteProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Byte): ShortProgression {
|
||||
return ShortProgression(this, to.toShort(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Byte): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Byte): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Char.downTo(to: Char): CharProgression {
|
||||
return CharProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this, to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Double): DoubleProgression {
|
||||
return DoubleProgression(this.toDouble(), to, -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this.toFloat(), to, -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Float): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Float): FloatProgression {
|
||||
return FloatProgression(this, to, -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Int): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Int): IntProgression {
|
||||
return IntProgression(this.toInt(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Int): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Int): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this, to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Long): LongProgression {
|
||||
return LongProgression(this.toLong(), to, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Long): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Long): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Int.downTo(to: Short): IntProgression {
|
||||
return IntProgression(this, to.toInt(), -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Long.downTo(to: Short): LongProgression {
|
||||
return LongProgression(this, to.toLong(), -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Byte.downTo(to: Short): ShortProgression {
|
||||
return ShortProgression(this.toShort(), to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Short.downTo(to: Short): ShortProgression {
|
||||
return ShortProgression(this, to, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Double.downTo(to: Short): DoubleProgression {
|
||||
return DoubleProgression(this, to.toDouble(), -1.0)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
public fun Float.downTo(to: Short): FloatProgression {
|
||||
return FloatProgression(this, to.toFloat(), -1.0F)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range in the opposite direction with the same step.
|
||||
*/
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package generators
|
||||
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.io.PrintWriter
|
||||
|
||||
private fun generateDownTos(outputFile: File, header: String) {
|
||||
|
||||
fun getMaxType(fromType: String, toType: String): String {
|
||||
return when {
|
||||
fromType == "Double" || toType == "Double" -> "Double"
|
||||
fromType == "Float" || toType == "Float" -> "Float"
|
||||
fromType == "Long" || toType == "Long" -> "Long"
|
||||
fromType == "Int" || toType == "Int" -> "Int"
|
||||
fromType == "Short" || toType == "Short" -> "Short"
|
||||
fromType == "Char" || toType == "Char" -> "Char"
|
||||
else -> "Byte"
|
||||
}
|
||||
}
|
||||
|
||||
fun generateDownTo(writer: PrintWriter, fromType: String, toType: String) {
|
||||
val elementType = getMaxType(fromType, toType)
|
||||
val progressionType = elementType + "Progression"
|
||||
|
||||
val fromExpr = if (elementType == fromType) "this" else "this.to$elementType()"
|
||||
val toExpr = if (elementType == toType) "to" else "to.to$elementType()"
|
||||
val incrementExpr = when (elementType) {
|
||||
"Long" -> "-1.toLong()"
|
||||
"Float" -> "-1.toFloat()"
|
||||
"Double" -> "-1.0"
|
||||
else -> "-1"
|
||||
}
|
||||
|
||||
val deprecated =
|
||||
if ((fromType == "Char") != (toType == "Char")) {
|
||||
"""deprecated("This operation doesn't make sense and shall be removed in M13. Consider converting Char operand to Int or other operand to Char.")"""
|
||||
} else ""
|
||||
|
||||
writer.println("""
|
||||
/**
|
||||
* Returns a progression from this value down to the specified [to] value.
|
||||
*
|
||||
* The [to] value has to be less than this value.
|
||||
*/
|
||||
$deprecated
|
||||
public fun $fromType.downTo(to: $toType): $progressionType {
|
||||
return $progressionType($fromExpr, $toExpr, $incrementExpr)
|
||||
}""".replace("\n\n","\n"))
|
||||
}
|
||||
|
||||
println("Writing $outputFile")
|
||||
|
||||
outputFile.getParentFile()?.mkdirs()
|
||||
val writer = PrintWriter(FileWriter(outputFile))
|
||||
try {
|
||||
writer.println(header)
|
||||
|
||||
writer.println("""
|
||||
$COMMON_AUTOGENERATED_WARNING
|
||||
""")
|
||||
|
||||
val types = arrayOf("Byte", "Char", "Short", "Int", "Long", "Float", "Double")
|
||||
for (fromType in types) {
|
||||
for (toType in types) {
|
||||
generateDownTo(writer, fromType, toType)
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
writer.close()
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ fun main(args: Array<String>) {
|
||||
generateCollectionsAPI(outDir)
|
||||
generateCollectionsJsAPI(jsCoreDir)
|
||||
|
||||
generateDownTos(File(outDir, "_DownTo.kt"), "package kotlin")
|
||||
}
|
||||
|
||||
fun List<GenericFunction>.writeTo(file: File, builder: GenericFunction.() -> String) {
|
||||
|
||||
@@ -44,7 +44,13 @@ enum class PrimitiveType {
|
||||
|
||||
companion object {
|
||||
val defaultPrimitives = PrimitiveType.values().toSet()
|
||||
val numericPrimitives = setOf(PrimitiveType.Int, PrimitiveType.Long, PrimitiveType.Byte, PrimitiveType.Short, PrimitiveType.Double, PrimitiveType.Float)
|
||||
val numericPrimitives = setOf(Int, Long, Byte, Short, Double, Float)
|
||||
|
||||
val descendingByDomainCapacity = listOf(Double, Float, Long, Int, Short, Char, Byte)
|
||||
|
||||
fun getMaxCapacityType(fromType: PrimitiveType, toType: PrimitiveType): PrimitiveType = descendingByDomainCapacity.first { it == fromType || it == toType }
|
||||
|
||||
val primitivePermutations = numericPrimitives.flatMap { fromType -> numericPrimitives map { toType -> fromType to toType } } + (Char to Char)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,5 +46,32 @@ fun ranges(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
fun downTo(fromType: PrimitiveType, toType: PrimitiveType) = f("downTo(to: $toType)") {
|
||||
only(Primitives)
|
||||
only(fromType)
|
||||
val elementType = PrimitiveType.getMaxCapacityType(fromType, toType)
|
||||
val progressionType = elementType.name + "Progression"
|
||||
returns(progressionType)
|
||||
|
||||
doc {
|
||||
"""
|
||||
Returns a progression from this value down to the specified [to] value with the increment -1.
|
||||
The [to] value has to be less than this value.
|
||||
"""
|
||||
}
|
||||
|
||||
val fromExpr = if (elementType == fromType) "this" else "this.to$elementType()"
|
||||
val toExpr = if (elementType == toType) "to" else "to.to$elementType()"
|
||||
val incrementExpr = when (elementType) {
|
||||
PrimitiveType.Long -> "-1L"
|
||||
PrimitiveType.Float -> "-1.0F"
|
||||
PrimitiveType.Double -> "-1.0"
|
||||
else -> "-1"
|
||||
}
|
||||
body { "return $progressionType($fromExpr, $toExpr, $incrementExpr)" }
|
||||
}
|
||||
|
||||
templates addAll PrimitiveType.primitivePermutations.map { downTo(it.first, it.second) }
|
||||
|
||||
return templates
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user