From faf96e581c85351dcae9fb1714b6d464c1fa6e3f Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Wed, 10 Aug 2016 09:39:56 +0300 Subject: [PATCH] translator: add support square brackets to standart arrays --- kotstd/include/BooleanArray.kt | 5 ++--- kotstd/include/ByteArray.kt | 5 ++--- kotstd/include/IntArray.kt | 5 ++--- kotstd/include/ShortArray.kt | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/kotstd/include/BooleanArray.kt b/kotstd/include/BooleanArray.kt index ed72625ba31..3b2200059f1 100644 --- a/kotstd/include/BooleanArray.kt +++ b/kotstd/include/BooleanArray.kt @@ -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. */ - fun get(index: Int): Boolean { + operator fun get(index: Int): Boolean { val res = kotlinclib_get_byte(this.data, index) == 1.toByte() return res } /** 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) { kotlinclib_set_byte(this.data, index, 1.toByte()) } @@ -39,4 +39,3 @@ class BooleanArray(var size: Int) { } } - diff --git a/kotstd/include/ByteArray.kt b/kotstd/include/ByteArray.kt index 6cf457c6f8e..904ecd1f6f1 100644 --- a/kotstd/include/ByteArray.kt +++ b/kotstd/include/ByteArray.kt @@ -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. */ - fun get(index: Int): Byte { + operator fun get(index: Int): Byte { 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. */ - fun set(index: Int, value: Byte) { + operator fun set(index: Int, value: Byte) { kotlinclib_set_byte(this.data, index, value) } @@ -38,4 +38,3 @@ class ByteArray(var size: Int) { } } - diff --git a/kotstd/include/IntArray.kt b/kotstd/include/IntArray.kt index 27a808a888b..c2a03b4940c 100644 --- a/kotstd/include/IntArray.kt +++ b/kotstd/include/IntArray.kt @@ -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. */ - fun get(index: Int): Int { + operator fun get(index: Int): Int { 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. */ - fun set(index: Int, value: Int) { + operator fun set(index: Int, value: Int) { kotlinclib_set_int(this.data, index, value) } @@ -37,4 +37,3 @@ class IntArray(var size: Int) { } } - diff --git a/kotstd/include/ShortArray.kt b/kotstd/include/ShortArray.kt index f27f087df32..b9c6bf07070 100644 --- a/kotstd/include/ShortArray.kt +++ b/kotstd/include/ShortArray.kt @@ -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. */ - fun get(index: Int): Short { + operator fun get(index: Int): Short { 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. */ - fun set(index: Int, value: Short) { + operator fun set(index: Int, value: Short) { kotlinclib_set_short(this.data, index, value) } @@ -37,4 +37,3 @@ class ShortArray(var size: Int) { } } -