From e67d9d4065f6144c1a61cc8af952532541c09148 Mon Sep 17 00:00:00 2001 From: Nikolay Igotti Date: Wed, 15 Mar 2017 16:20:50 +0300 Subject: [PATCH] Remove Cloneable interface (#347) --- runtime/src/main/cpp/Arrays.cpp | 99 --------------------- runtime/src/main/kotlin/kotlin/Array.kt | 5 +- runtime/src/main/kotlin/kotlin/Arrays.kt | 40 ++------- runtime/src/main/kotlin/kotlin/Cloneable.kt | 6 -- 4 files changed, 9 insertions(+), 141 deletions(-) delete mode 100644 runtime/src/main/kotlin/kotlin/Cloneable.kt diff --git a/runtime/src/main/cpp/Arrays.cpp b/runtime/src/main/cpp/Arrays.cpp index 33d4d4acd95..89dcd783143 100644 --- a/runtime/src/main/cpp/Arrays.cpp +++ b/runtime/src/main/cpp/Arrays.cpp @@ -44,17 +44,6 @@ void Kotlin_Array_set(KRef thiz, KInt index, KConstRef value) { UpdateGlobalRef(ArrayAddressOfElementAt(array, index), value); } -OBJ_GETTER(Kotlin_Array_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - for (int index = 0; index < array->count_; index++) { - SetGlobalRef( - ArrayAddressOfElementAt(result, index), *ArrayAddressOfElementAt(array, index)); - } - RETURN_OBJ(result->obj()); -} - KInt Kotlin_Array_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -109,17 +98,6 @@ void Kotlin_ByteArray_set(KRef thiz, KInt index, KByte value) { *ByteArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_ByteArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - ByteArrayAddressOfElementAt(result, 0), - ByteArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_ByteArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -141,17 +119,6 @@ void Kotlin_CharArray_set(KRef thiz, KInt index, KChar value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_CharArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - OBJ_GETTER(Kotlin_CharArray_copyOf, KConstRef thiz, KInt newSize) { const ArrayHeader* array = thiz->array(); ArrayHeader* result = ArrayContainer( @@ -185,17 +152,6 @@ void Kotlin_ShortArray_set(KRef thiz, KInt index, KShort value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_ShortArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_ShortArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -217,17 +173,6 @@ void Kotlin_IntArray_set(KRef thiz, KInt index, KInt value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_IntArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_IntArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -300,17 +245,6 @@ void Kotlin_LongArray_set(KRef thiz, KInt index, KLong value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_LongArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_LongArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -332,17 +266,6 @@ void Kotlin_FloatArray_set(KRef thiz, KInt index, KFloat value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_FloatArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_FloatArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -364,17 +287,6 @@ void Kotlin_DoubleArray_set(KRef thiz, KInt index, KDouble value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_DoubleArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_DoubleArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; @@ -396,17 +308,6 @@ void Kotlin_BooleanArray_set(KRef thiz, KInt index, KBoolean value) { *PrimitiveArrayAddressOfElementAt(array, index) = value; } -OBJ_GETTER(Kotlin_BooleanArray_clone, KConstRef thiz) { - const ArrayHeader* array = thiz->array(); - ArrayHeader* result = AllocArrayInstance( - array->type_info(), array->count_, OBJ_RESULT)->array(); - memcpy( - PrimitiveArrayAddressOfElementAt(result, 0), - PrimitiveArrayAddressOfElementAt(array, 0), - ArrayDataSizeBytes(array)); - RETURN_OBJ(result->obj()); -} - KInt Kotlin_BooleanArray_getArrayLength(KConstRef thiz) { const ArrayHeader* array = thiz->array(); return array->count_; diff --git a/runtime/src/main/kotlin/kotlin/Array.kt b/runtime/src/main/kotlin/kotlin/Array.kt index ae4b694176e..a77f6d55484 100644 --- a/runtime/src/main/kotlin/kotlin/Array.kt +++ b/runtime/src/main/kotlin/kotlin/Array.kt @@ -3,7 +3,7 @@ import konan.internal.ExportForCompiler // TODO: remove that, as RTTI shall be per instantiation. @ExportTypeInfo("theArrayTypeInfo") -public final class Array : Cloneable { +public final class Array { // Constructors are handled with compiler magic. public constructor(size: Int, init: (Int) -> T) { var index = 0 @@ -19,9 +19,6 @@ public final class Array : Cloneable { public val size: Int get() = getArrayLength() - @SymbolName("Kotlin_Array_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_Array_get") external public operator fun get(index: Int): T diff --git a/runtime/src/main/kotlin/kotlin/Arrays.kt b/runtime/src/main/kotlin/kotlin/Arrays.kt index cc21eb45c71..10be86fed21 100644 --- a/runtime/src/main/kotlin/kotlin/Arrays.kt +++ b/runtime/src/main/kotlin/kotlin/Arrays.kt @@ -11,7 +11,7 @@ import kotlin.util.sortArrayWith * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ @ExportTypeInfo("theByteArrayTypeInfo") -public final class ByteArray : Cloneable { +public final class ByteArray { // Constructors are handled with compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -24,9 +24,6 @@ public final class ByteArray : Cloneable { @SymbolName("Kotlin_ByteArray_set") external public operator fun set(index: Int, value: Byte): Unit - @SymbolName("Kotlin_ByteArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_ByteArray_getArrayLength") external private fun getArrayLength(): Int @@ -54,7 +51,7 @@ private class ByteIteratorImpl(val collection: ByteArray) : ByteIterator() { * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ @ExportTypeInfo("theCharArrayTypeInfo") -public final class CharArray : Cloneable { +public final class CharArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -67,9 +64,6 @@ public final class CharArray : Cloneable { @SymbolName("Kotlin_CharArray_set") external public operator fun set(index: Int, value: Char): Unit - @SymbolName("Kotlin_CharArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_CharArray_copyOf") external public fun copyOf(newSize: Int): CharArray @@ -99,7 +93,7 @@ private class CharIteratorImpl(val collection: CharArray) : CharIterator() { * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ @ExportTypeInfo("theShortArrayTypeInfo") -public final class ShortArray : Cloneable { +public final class ShortArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -112,9 +106,6 @@ public final class ShortArray : Cloneable { @SymbolName("Kotlin_ShortArray_set") external public operator fun set(index: Int, value: Short): Unit - @SymbolName("Kotlin_ShortArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_ShortArray_getArrayLength") external private fun getArrayLength(): Int @@ -141,7 +132,7 @@ private class ShortIteratorImpl(val collection: ShortArray) : ShortIterator() { * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ @ExportTypeInfo("theIntArrayTypeInfo") -public final class IntArray : Cloneable { +public final class IntArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -154,9 +145,6 @@ public final class IntArray : Cloneable { @SymbolName("Kotlin_IntArray_set") external public operator fun set(index: Int, value: Int): Unit - @SymbolName("Kotlin_IntArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_IntArray_getArrayLength") external private fun getArrayLength(): Int @@ -183,7 +171,7 @@ private class IntIteratorImpl(val collection: IntArray) : IntIterator() { * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ @ExportTypeInfo("theLongArrayTypeInfo") -public final class LongArray : Cloneable { +public final class LongArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -196,9 +184,6 @@ public final class LongArray : Cloneable { @SymbolName("Kotlin_LongArray_set") external public operator fun set(index: Int, value: Long): Unit - @SymbolName("Kotlin_LongArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_LongArray_getArrayLength") external private fun getArrayLength(): Int @@ -225,7 +210,7 @@ private class LongIteratorImpl(val collection: LongArray) : LongIterator() { * @constructor Creates a new array of the specified [size], with all elements initialized to zero. */ @ExportTypeInfo("theFloatArrayTypeInfo") -public final class FloatArray : Cloneable { +public final class FloatArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -238,9 +223,6 @@ public final class FloatArray : Cloneable { @SymbolName("Kotlin_FloatArray_set") external public operator fun set(index: Int, value: Float): Unit - @SymbolName("Kotlin_FloatArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_FloatArray_getArrayLength") external private fun getArrayLength(): Int @@ -263,7 +245,7 @@ private class FloatIteratorImpl(val collection: FloatArray) : FloatIterator() { } @ExportTypeInfo("theDoubleArrayTypeInfo") -public final class DoubleArray : Cloneable { +public final class DoubleArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -276,9 +258,6 @@ public final class DoubleArray : Cloneable { @SymbolName("Kotlin_DoubleArray_set") external public operator fun set(index: Int, value: Double): Unit - @SymbolName("Kotlin_DoubleArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_DoubleArray_getArrayLength") external private fun getArrayLength(): Int @@ -301,7 +280,7 @@ private class DoubleIteratorImpl(val collection: DoubleArray) : DoubleIterator() } @ExportTypeInfo("theBooleanArrayTypeInfo") -public final class BooleanArray : Cloneable { +public final class BooleanArray { // Constructors are handled with the compiler magic. public constructor(@Suppress("UNUSED_PARAMETER") size: Int) {} @@ -314,9 +293,6 @@ public final class BooleanArray : Cloneable { @SymbolName("Kotlin_BooleanArray_set") external public operator fun set(index: Int, value: Boolean): Unit - @SymbolName("Kotlin_BooleanArray_clone") - external public override fun clone(): Any - @SymbolName("Kotlin_BooleanArray_getArrayLength") external private fun getArrayLength(): Int diff --git a/runtime/src/main/kotlin/kotlin/Cloneable.kt b/runtime/src/main/kotlin/kotlin/Cloneable.kt deleted file mode 100644 index 8ee1142e21d..00000000000 --- a/runtime/src/main/kotlin/kotlin/Cloneable.kt +++ /dev/null @@ -1,6 +0,0 @@ -package kotlin - -@ExportTypeInfo("theCloneableTypeInfo") -public interface Cloneable { - public fun clone(): Any -}