kotstd: update runtime

This commit is contained in:
e5l
2016-08-18 12:59:30 +03:00
parent bdf0a34829
commit 35de4525cf
4 changed files with 48 additions and 15 deletions
-1
View File
@@ -187,7 +187,6 @@ class DirectionRequest private constructor (var command: DirectionRequest.Comman
}
class DirectionResponse private constructor (var code: Int) {
//========== Properties ===========
//int32 code = 1
+28 -10
View File
@@ -247,16 +247,25 @@ class RouteRequest private constructor (var distances: IntArray, var angles: Int
return false
}
val expectedByteSize = input.readInt32NoTag()
var newArray = IntArray(0)
var readSize = 0
var arraySize = 0
input.mark()
do {
var i = 0
while(readSize < expectedByteSize) {
var tmp = IntArray(1)
tmp[0] = input.readInt32NoTag()
newArray = newArray.plus(tmp)
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
var tmp = 0
tmp = input.readInt32NoTag()
arraySize += 1
readSize += WireFormat.getInt32SizeNoTag(tmp)
}
} while (false)
var newArray = IntArray(arraySize)
input.reset()
do {
var i = 0
while(i < arraySize) {
newArray[i] = input.readInt32NoTag()
i += 1}
distances = newArray
} while (false)
}
@@ -266,16 +275,25 @@ class RouteRequest private constructor (var distances: IntArray, var angles: Int
return false
}
val expectedByteSize = input.readInt32NoTag()
var newArray = IntArray(0)
var readSize = 0
var arraySize = 0
input.mark()
do {
var i = 0
while(readSize < expectedByteSize) {
var tmp = IntArray(1)
tmp[0] = input.readInt32NoTag()
newArray = newArray.plus(tmp)
readSize += WireFormat.getInt32SizeNoTag(tmp[0])
var tmp = 0
tmp = input.readInt32NoTag()
arraySize += 1
readSize += WireFormat.getInt32SizeNoTag(tmp)
}
} while (false)
var newArray = IntArray(arraySize)
input.reset()
do {
var i = 0
while(i < arraySize) {
newArray[i] = input.readInt32NoTag()
i += 1}
angles = newArray
} while (false)
}
+9 -1
View File
@@ -12,7 +12,15 @@
class CodedInputStream(val buffer: ByteArray) {
val inputStream: KotlinInputStream
init {
inputStream = KotlinInputStream(buffer) // TODO: Java's realization uses hand-written buffers. Why?
inputStream = KotlinInputStream(buffer)
}
fun mark() {
inputStream.mark()
}
fun reset() {
inputStream.reset()
}
fun readInt32(expectedFieldNumber: Int): Int {
+11 -3
View File
@@ -4,14 +4,22 @@
class KotlinInputStream(val buffer: ByteArray) {
var pos = 0
var mark_ = 0
fun read(): Byte {
val result = buffer[pos]
pos++
return result
pos += 1
return buffer[pos - 1]
}
fun isAtEnd(): Boolean {
return pos >= buffer.size
}
fun mark() {
mark_ = pos
}
fun reset() {
pos = mark_
}
}