translator: add support square brackets to standart arrays

This commit is contained in:
Alexey Stepanov
2016-08-10 09:39:56 +03:00
parent ab8c4e1848
commit faf96e581c
4 changed files with 8 additions and 12 deletions
+2 -3
View File
@@ -9,14 +9,14 @@ class BooleanArray(var size: Int) {
} }
/** Returns the array element at the given [index]. This method can be called using the index operator. */ /** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Boolean { operator fun get(index: Int): Boolean {
val res = kotlinclib_get_byte(this.data, index) == 1.toByte() val res = kotlinclib_get_byte(this.data, index) == 1.toByte()
return res return res
} }
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Boolean) { operator fun set(index: Int, value: Boolean) {
if (value == true) { if (value == true) {
kotlinclib_set_byte(this.data, index, 1.toByte()) kotlinclib_set_byte(this.data, index, 1.toByte())
} }
@@ -39,4 +39,3 @@ class BooleanArray(var size: Int) {
} }
} }
+2 -3
View File
@@ -14,13 +14,13 @@ class ByteArray(var size: Int) {
} }
/** Returns the array element at the given [index]. This method can be called using the index operator. */ /** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Byte { operator fun get(index: Int): Byte {
return kotlinclib_get_byte(this.data, index) return kotlinclib_get_byte(this.data, index)
} }
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Byte) { operator fun set(index: Int, value: Byte) {
kotlinclib_set_byte(this.data, index, value) kotlinclib_set_byte(this.data, index, value)
} }
@@ -38,4 +38,3 @@ class ByteArray(var size: Int) {
} }
} }
+2 -3
View File
@@ -13,13 +13,13 @@ class IntArray(var size: Int) {
} }
/** Returns the array element at the given [index]. This method can be called using the index operator. */ /** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Int { operator fun get(index: Int): Int {
return kotlinclib_get_int(this.data, index) return kotlinclib_get_int(this.data, index)
} }
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Int) { operator fun set(index: Int, value: Int) {
kotlinclib_set_int(this.data, index, value) kotlinclib_set_int(this.data, index, value)
} }
@@ -37,4 +37,3 @@ class IntArray(var size: Int) {
} }
} }
+2 -3
View File
@@ -13,13 +13,13 @@ class ShortArray(var size: Int) {
} }
/** Returns the array element at the given [index]. This method can be called using the index operator. */ /** Returns the array element at the given [index]. This method can be called using the index operator. */
fun get(index: Int): Short { operator fun get(index: Int): Short {
return kotlinclib_get_short(this.data, index) return kotlinclib_get_short(this.data, index)
} }
/** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */ /** Sets the element at the given [index] to the given [value]. This method can be called using the index operator. */
fun set(index: Int, value: Short) { operator fun set(index: Int, value: Short) {
kotlinclib_set_short(this.data, index, value) kotlinclib_set_short(this.data, index, value)
} }
@@ -37,4 +37,3 @@ class ShortArray(var size: Int) {
} }
} }