From ad6babd0358155144123be2a01a9c7b5fd312824 Mon Sep 17 00:00:00 2001 From: Alexey Stepanov Date: Tue, 16 Aug 2016 11:05:37 +0300 Subject: [PATCH] translator: add println for ByteArray --- kotstd/include/ByteArray.kt | 10 ++++++++++ kotstd/include/Console.kt | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/kotstd/include/ByteArray.kt b/kotstd/include/ByteArray.kt index a483bd5bd5b..1e439622e66 100644 --- a/kotstd/include/ByteArray.kt +++ b/kotstd/include/ByteArray.kt @@ -40,6 +40,16 @@ class ByteArray(var size: Int) { } +fun ByteArray.print() { + println() + var index = 0 + while (index < size) { + println(get(index)) + index++ + } + println() +} + fun ByteArray.copyOf(newSize: Int): ByteArray { val newInstance = ByteArray(newSize) var index = 0 diff --git a/kotstd/include/Console.kt b/kotstd/include/Console.kt index 0e68dd99d47..fa3cbc15d32 100644 --- a/kotstd/include/Console.kt +++ b/kotstd/include/Console.kt @@ -1,3 +1,6 @@ +import ByteArray +import IntArray + /* * Library for console interaction */ @@ -113,6 +116,11 @@ fun println(message: String) { kotlinclib_println_string(message) } +/** Prints the given message and newline to the standard output stream. */ +fun println(message: ByteArray) { + message.print() +} + /** Prints newline to the standard output stream. */ fun println() { kotlinclib_println()