Compile unsigned types sourceset with 1.3 and annotate them with SinceKotlin("1.3")
This commit is contained in:
@@ -42,6 +42,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
out.println()
|
||||
|
||||
out.println("@Suppress(\"NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS\")")
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("public inline class $className internal constructor(private val data: $storageType) : Comparable<$className> {")
|
||||
out.println()
|
||||
out.println(""" companion object {
|
||||
@@ -196,6 +197,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
for (otherType in UnsignedType.values()) {
|
||||
val otherSigned = otherType.asSigned.capitalized
|
||||
val thisSigned = type.asSigned.capitalized
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.print("public fun $otherSigned.to$className(): $className = ")
|
||||
out.println(when {
|
||||
otherType < type -> "$className(this.to$thisSigned() and ${otherType.mask})"
|
||||
@@ -238,6 +240,7 @@ class UnsignedIteratorsGenerator(out: PrintWriter) : BuiltInsSourceGenerator(out
|
||||
for (type in UnsignedType.values()) {
|
||||
val s = type.capitalized
|
||||
out.println("/** An iterator over a sequence of values of type `$s`. */")
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("public abstract class ${s}Iterator : Iterator<$s> {")
|
||||
// TODO: Sort modifiers
|
||||
out.println(" override final fun next() = next$s()")
|
||||
@@ -258,6 +261,7 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn
|
||||
val storageArrayType = storageElementType + "Array"
|
||||
override fun generateBody() {
|
||||
out.println("@Suppress(\"NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS\")")
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("public inline class $arrayType internal constructor(private val storage: $storageArrayType) : Collection<$elementType> {")
|
||||
out.println(
|
||||
"""
|
||||
@@ -290,12 +294,14 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn
|
||||
|
||||
out.println("}")
|
||||
|
||||
out.println("""
|
||||
public /*inline*/ fun $arrayType(size: Int, init: (Int) -> $elementType): $arrayType {
|
||||
out.println()
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("""public /*inline*/ fun $arrayType(size: Int, init: (Int) -> $elementType): $arrayType {
|
||||
return $arrayType($storageArrayType(size) { index -> init(index).to$storageElementType() })
|
||||
}
|
||||
|
||||
@Suppress("FORBIDDEN_VARARG_PARAMETER_TYPE")
|
||||
@SinceKotlin("1.3")
|
||||
public fun $arrayTypeOf(vararg elements: $elementType): $arrayType {
|
||||
return $arrayType(elements.size) { index -> elements[index] }
|
||||
}"""
|
||||
@@ -322,6 +328,7 @@ import kotlin.internal.*
|
||||
/**
|
||||
* A range of values of type `$elementType`.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public class ${elementType}Range(start: $elementType, endInclusive: $elementType) : ${elementType}Progression(start, endInclusive, 1), ClosedRange<${elementType}> {
|
||||
override val start: $elementType get() = first
|
||||
override val endInclusive: $elementType get() = last
|
||||
@@ -348,6 +355,7 @@ public class ${elementType}Range(start: $elementType, endInclusive: $elementType
|
||||
/**
|
||||
* A progression of values of type `$elementType`.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
public open class ${elementType}Progression
|
||||
internal constructor(
|
||||
start: $elementType,
|
||||
@@ -403,6 +411,7 @@ internal constructor(
|
||||
* An iterator over a progression of values of type `$elementType`.
|
||||
* @property step the number by which the value is incremented on each step.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
private class ${elementType}ProgressionIterator(first: $elementType, last: $elementType, step: $stepType) : ${elementType}Iterator() {
|
||||
private val finalElement = last
|
||||
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
|
||||
|
||||
Reference in New Issue
Block a user