Remove deprecated and not stabilized primitive unsigned iterators

This commit is contained in:
Ilya Gorbunov
2022-04-08 08:01:39 +03:00
committed by Space
parent 4598552e46
commit 2303730d57
11 changed files with 18 additions and 211 deletions
+4 -30
View File
@@ -26,10 +26,6 @@ fun generateUnsignedTypes(
for (type in listOf(UnsignedType.UINT, UnsignedType.ULONG)) {
generate(File(targetDir, "kotlin/${type.capitalized}Range.kt")) { UnsignedRangeGenerator(type, it) }
}
generate(File(targetDir, "kotlin/UIterators.kt"), ::UnsignedIteratorsGenerator)
}
class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltInsSourceGenerator(out) {
@@ -444,26 +440,6 @@ 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("@Deprecated(\"This class is not going to be stabilized and is to be removed soon.\", level = DeprecationLevel.ERROR)")
out.println("@SinceKotlin(\"1.3\")")
out.println("public abstract class ${s}Iterator : Iterator<$s> {")
out.println(" final override 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()
}
}
}
class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltInsSourceGenerator(out) {
val elementType = type.capitalized
val arrayType = elementType + "Array"
@@ -509,11 +485,10 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn
/** Creates an iterator over the elements of the array. */
public override operator fun iterator(): kotlin.collections.Iterator<$elementType> = Iterator(storage)
@Suppress("DEPRECATION_ERROR")
private class Iterator(private val array: $storageArrayType) : ${elementType}Iterator() {
private class Iterator(private val array: $storageArrayType) : kotlin.collections.Iterator<${elementType}> {
private var index = 0
override fun hasNext() = index < array.size
override fun next$elementType() = if (index < array.size) array[index++].to$elementType() else throw NoSuchElementException(index.toString())
override fun next() = if (index < array.size) array[index++].to$elementType() else throw NoSuchElementException(index.toString())
}
override fun contains(element: $elementType): Boolean {
@@ -677,8 +652,7 @@ internal constructor(
* @property step the number by which the value is incremented on each step.
*/
@SinceKotlin("1.3")
@Suppress("DEPRECATION_ERROR")
private class ${elementType}ProgressionIterator(first: $elementType, last: $elementType, step: $stepType) : ${elementType}Iterator() {
private class ${elementType}ProgressionIterator(first: $elementType, last: $elementType, step: $stepType) : Iterator<${elementType}> {
private val finalElement = last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
private val step = step.to$elementType() // use 2-complement math for negative steps
@@ -686,7 +660,7 @@ private class ${elementType}ProgressionIterator(first: $elementType, last: $elem
override fun hasNext(): Boolean = hasNext
override fun next$elementType(): $elementType {
override fun next(): $elementType {
val value = next
if (value == finalElement) {
if (!hasNext) throw kotlin.NoSuchElementException()
@@ -11097,51 +11097,11 @@ public abstract class ShortIterator : kotlin.collections.Iterator<kotlin.Short>
public abstract fun nextShort(): kotlin.Short
}
/*∆*/
/*∆*/ public abstract class ShortIterator : kotlin.collections.Iterator<kotlin.Short> {
/*∆*/ public constructor ShortIterator()
/*∆*/
/*∆*/ public final override operator fun next(): kotlin.Short
/*∆*/
/*∆*/ public abstract fun nextShort(): kotlin.Short
/*∆*/ }
/*∆*/
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class UByteIterator : kotlin.collections.Iterator<kotlin.UByte> {
public constructor UByteIterator()
public final override operator fun next(): kotlin.UByte
public abstract fun nextUByte(): kotlin.UByte
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class UIntIterator : kotlin.collections.Iterator<kotlin.UInt> {
public constructor UIntIterator()
public final override operator fun next(): kotlin.UInt
public abstract fun nextUInt(): kotlin.UInt
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class ULongIterator : kotlin.collections.Iterator<kotlin.ULong> {
public constructor ULongIterator()
public final override operator fun next(): kotlin.ULong
public abstract fun nextULong(): kotlin.ULong
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class UShortIterator : kotlin.collections.Iterator<kotlin.UShort> {
public constructor UShortIterator()
public final override operator fun next(): kotlin.UShort
public abstract fun nextUShort(): kotlin.UShort
}
/*∆*/ }
@@ -10808,44 +10808,4 @@ public abstract class ShortIterator : kotlin.collections.Iterator<kotlin.Short>
public final override operator fun next(): kotlin.Short
public abstract fun nextShort(): kotlin.Short
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class UByteIterator : kotlin.collections.Iterator<kotlin.UByte> {
public constructor UByteIterator()
public final override operator fun next(): kotlin.UByte
public abstract fun nextUByte(): kotlin.UByte
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class UIntIterator : kotlin.collections.Iterator<kotlin.UInt> {
public constructor UIntIterator()
public final override operator fun next(): kotlin.UInt
public abstract fun nextUInt(): kotlin.UInt
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class ULongIterator : kotlin.collections.Iterator<kotlin.ULong> {
public constructor ULongIterator()
public final override operator fun next(): kotlin.ULong
public abstract fun nextULong(): kotlin.ULong
}
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.")
@kotlin.SinceKotlin(version = "1.3")
public abstract class UShortIterator : kotlin.collections.Iterator<kotlin.UShort> {
public constructor UShortIterator()
public final override operator fun next(): kotlin.UShort
public abstract fun nextUShort(): kotlin.UShort
}
@@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: ByteArray) : Collection
/** Creates an iterator over the elements of the array. */
public override operator fun iterator(): kotlin.collections.Iterator<UByte> = Iterator(storage)
@Suppress("DEPRECATION_ERROR")
private class Iterator(private val array: ByteArray) : UByteIterator() {
private class Iterator(private val array: ByteArray) : kotlin.collections.Iterator<UByte> {
private var index = 0
override fun hasNext() = index < array.size
override fun nextUByte() = if (index < array.size) array[index++].toUByte() else throw NoSuchElementException(index.toString())
override fun next() = if (index < array.size) array[index++].toUByte() else throw NoSuchElementException(index.toString())
}
override fun contains(element: UByte): Boolean {
@@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: IntArray) : Collection<
/** Creates an iterator over the elements of the array. */
public override operator fun iterator(): kotlin.collections.Iterator<UInt> = Iterator(storage)
@Suppress("DEPRECATION_ERROR")
private class Iterator(private val array: IntArray) : UIntIterator() {
private class Iterator(private val array: IntArray) : kotlin.collections.Iterator<UInt> {
private var index = 0
override fun hasNext() = index < array.size
override fun nextUInt() = if (index < array.size) array[index++].toUInt() else throw NoSuchElementException(index.toString())
override fun next() = if (index < array.size) array[index++].toUInt() else throw NoSuchElementException(index.toString())
}
override fun contains(element: UInt): Boolean {
@@ -113,8 +113,7 @@ internal constructor(
* @property step the number by which the value is incremented on each step.
*/
@SinceKotlin("1.3")
@Suppress("DEPRECATION_ERROR")
private class UIntProgressionIterator(first: UInt, last: UInt, step: Int) : UIntIterator() {
private class UIntProgressionIterator(first: UInt, last: UInt, step: Int) : Iterator<UInt> {
private val finalElement = last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
private val step = step.toUInt() // use 2-complement math for negative steps
@@ -122,7 +121,7 @@ private class UIntProgressionIterator(first: UInt, last: UInt, step: Int) : UInt
override fun hasNext(): Boolean = hasNext
override fun nextUInt(): UInt {
override fun next(): UInt {
val value = next
if (value == finalElement) {
if (!hasNext) throw kotlin.NoSuchElementException()
@@ -1,49 +0,0 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* 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`. */
@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR)
@SinceKotlin("1.3")
public abstract class UByteIterator : Iterator<UByte> {
final override 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`. */
@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR)
@SinceKotlin("1.3")
public abstract class UShortIterator : Iterator<UShort> {
final override 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`. */
@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR)
@SinceKotlin("1.3")
public abstract class UIntIterator : Iterator<UInt> {
final override 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`. */
@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR)
@SinceKotlin("1.3")
public abstract class ULongIterator : Iterator<ULong> {
final override fun next() = nextULong()
/** Returns the next value in the sequence without boxing. */
public abstract fun nextULong(): ULong
}
@@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: LongArray) : Collection
/** Creates an iterator over the elements of the array. */
public override operator fun iterator(): kotlin.collections.Iterator<ULong> = Iterator(storage)
@Suppress("DEPRECATION_ERROR")
private class Iterator(private val array: LongArray) : ULongIterator() {
private class Iterator(private val array: LongArray) : kotlin.collections.Iterator<ULong> {
private var index = 0
override fun hasNext() = index < array.size
override fun nextULong() = if (index < array.size) array[index++].toULong() else throw NoSuchElementException(index.toString())
override fun next() = if (index < array.size) array[index++].toULong() else throw NoSuchElementException(index.toString())
}
override fun contains(element: ULong): Boolean {
@@ -113,8 +113,7 @@ internal constructor(
* @property step the number by which the value is incremented on each step.
*/
@SinceKotlin("1.3")
@Suppress("DEPRECATION_ERROR")
private class ULongProgressionIterator(first: ULong, last: ULong, step: Long) : ULongIterator() {
private class ULongProgressionIterator(first: ULong, last: ULong, step: Long) : Iterator<ULong> {
private val finalElement = last
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
private val step = step.toULong() // use 2-complement math for negative steps
@@ -122,7 +121,7 @@ private class ULongProgressionIterator(first: ULong, last: ULong, step: Long) :
override fun hasNext(): Boolean = hasNext
override fun nextULong(): ULong {
override fun next(): ULong {
val value = next
if (value == finalElement) {
if (!hasNext) throw kotlin.NoSuchElementException()
@@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: ShortArray) : Collectio
/** Creates an iterator over the elements of the array. */
public override operator fun iterator(): kotlin.collections.Iterator<UShort> = Iterator(storage)
@Suppress("DEPRECATION_ERROR")
private class Iterator(private val array: ShortArray) : UShortIterator() {
private class Iterator(private val array: ShortArray) : kotlin.collections.Iterator<UShort> {
private var index = 0
override fun hasNext() = index < array.size
override fun nextUShort() = if (index < array.size) array[index++].toUShort() else throw NoSuchElementException(index.toString())
override fun next() = if (index < array.size) array[index++].toUShort() else throw NoSuchElementException(index.toString())
}
override fun contains(element: UShort): Boolean {
@@ -2627,14 +2627,6 @@ public abstract class kotlin/collections/ShortIterator : java/util/Iterator, kot
public fun remove ()V
}
public abstract class kotlin/collections/UByteIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker {
public fun <init> ()V
public synthetic fun next ()Ljava/lang/Object;
public final fun next-w2LRezQ ()B
public abstract fun nextUByte-w2LRezQ ()B
public fun remove ()V
}
public final class kotlin/collections/UCollectionsKt {
public static final fun sumOfUByte (Ljava/lang/Iterable;)I
public static final fun sumOfUInt (Ljava/lang/Iterable;)I
@@ -2646,30 +2638,6 @@ public final class kotlin/collections/UCollectionsKt {
public static final fun toUShortArray (Ljava/util/Collection;)[S
}
public abstract class kotlin/collections/UIntIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker {
public fun <init> ()V
public synthetic fun next ()Ljava/lang/Object;
public final fun next-pVg5ArA ()I
public abstract fun nextUInt-pVg5ArA ()I
public fun remove ()V
}
public abstract class kotlin/collections/ULongIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker {
public fun <init> ()V
public synthetic fun next ()Ljava/lang/Object;
public final fun next-s-VKNKU ()J
public abstract fun nextULong-s-VKNKU ()J
public fun remove ()V
}
public abstract class kotlin/collections/UShortIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker {
public fun <init> ()V
public synthetic fun next ()Ljava/lang/Object;
public final fun next-Mh2AYeg ()S
public abstract fun nextUShort-Mh2AYeg ()S
public fun remove ()V
}
public final class kotlin/collections/unsigned/UArraysKt {
public static final fun asList--ajY-9A ([I)Ljava/util/List;
public static final fun asList-GBYM_sE ([B)Ljava/util/List;