Generate specialized abstract iterators for unsigned types
This commit is contained in:
@@ -21,6 +21,8 @@ fun generateUnsignedTypes(
|
||||
generate(File(targetDir, "kotlin/${type.capitalized}.kt")) { UnsignedTypeGenerator(type, it) }
|
||||
}
|
||||
|
||||
generate(File(targetDir, "kotlin/UIterators.kt"), ::UnsignedIteratorsGenerator)
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -171,3 +173,23 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TODO: reuse generator
|
||||
class UnsignedIteratorsGenerator(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
override fun getPackage() = "kotlin.collections"
|
||||
override fun generateBody() {
|
||||
for (type in UnsignedType.values()) {
|
||||
val s = type.capitalized
|
||||
out.println("/** An iterator over a sequence of values of type `$s`. */")
|
||||
out.println("public abstract class ${s}Iterator : Iterator<$s> {")
|
||||
// TODO: Sort modifiers
|
||||
out.println(" override final fun next() = next$s()")
|
||||
out.println()
|
||||
out.println(" /** Returns the next value in the sequence without boxing. */")
|
||||
out.println(" public abstract fun next$s(): $s")
|
||||
out.println("}")
|
||||
out.println()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
// Auto-generated file. DO NOT EDIT!
|
||||
|
||||
package kotlin.collections
|
||||
|
||||
/** An iterator over a sequence of values of type `UByte`. */
|
||||
public abstract class UByteIterator : Iterator<UByte> {
|
||||
override final fun next() = nextUByte()
|
||||
|
||||
/** Returns the next value in the sequence without boxing. */
|
||||
public abstract fun nextUByte(): UByte
|
||||
}
|
||||
|
||||
/** An iterator over a sequence of values of type `UShort`. */
|
||||
public abstract class UShortIterator : Iterator<UShort> {
|
||||
override final fun next() = nextUShort()
|
||||
|
||||
/** Returns the next value in the sequence without boxing. */
|
||||
public abstract fun nextUShort(): UShort
|
||||
}
|
||||
|
||||
/** An iterator over a sequence of values of type `UInt`. */
|
||||
public abstract class UIntIterator : Iterator<UInt> {
|
||||
override final fun next() = nextUInt()
|
||||
|
||||
/** Returns the next value in the sequence without boxing. */
|
||||
public abstract fun nextUInt(): UInt
|
||||
}
|
||||
|
||||
/** An iterator over a sequence of values of type `ULong`. */
|
||||
public abstract class ULongIterator : Iterator<ULong> {
|
||||
override final fun next() = nextULong()
|
||||
|
||||
/** Returns the next value in the sequence without boxing. */
|
||||
public abstract fun nextULong(): ULong
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user