recompiling proto files and lib
This commit is contained in:
@@ -1,182 +0,0 @@
|
||||
class DirectionRequest private constructor (command: Command = DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
var command : Command
|
||||
private set
|
||||
|
||||
|
||||
init {
|
||||
this.command = command
|
||||
}
|
||||
enum class Command(val ord: Int) {
|
||||
stop (0),
|
||||
forward (1),
|
||||
backward (2),
|
||||
left (3),
|
||||
right (4);
|
||||
|
||||
companion object {
|
||||
fun fromIntToCommand (ord: Int): Command {
|
||||
return when (ord) {
|
||||
0 -> Command.stop
|
||||
1 -> Command.forward
|
||||
2 -> Command.backward
|
||||
3 -> Command.left
|
||||
4 -> Command.right
|
||||
else -> throw InvalidProtocolBufferException("Error: got unexpected int ${ord} while parsing Command ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun writeTo (output: CodedOutputStream): Unit {
|
||||
output.writeEnum (1, command.ord)
|
||||
}
|
||||
|
||||
class BuilderDirectionRequest constructor (command: Command = DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
var command : Command
|
||||
private set
|
||||
fun setCommand(value: Command): DirectionRequest.BuilderDirectionRequest {
|
||||
command = value
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
this.command = command
|
||||
}
|
||||
|
||||
fun readFrom (input: CodedInputStream): DirectionRequest.BuilderDirectionRequest {
|
||||
command = Command.fromIntToCommand(input.readEnum(1))
|
||||
return this
|
||||
}
|
||||
|
||||
fun build(): DirectionRequest {
|
||||
return DirectionRequest(command)
|
||||
}
|
||||
|
||||
fun parseFieldFrom(input: CodedInputStream): Boolean {
|
||||
if (input.isAtEnd()) { return false }
|
||||
val tag = input.readInt32NoTag()
|
||||
if (tag == 0) { return false }
|
||||
val fieldNumber = WireFormat.getTagFieldNumber(tag)
|
||||
val wireType = WireFormat.getTagWireType(tag)
|
||||
when(fieldNumber) {
|
||||
1 -> command = Command.fromIntToCommand(input.readEnumNoTag())
|
||||
}
|
||||
return true}
|
||||
fun parseFrom(input: CodedInputStream): DirectionRequest.BuilderDirectionRequest {
|
||||
while(parseFieldFrom(input)) {}
|
||||
return this
|
||||
}
|
||||
fun getSize(): Int {
|
||||
var size = 0
|
||||
size += WireFormat.getEnumSize(1, command.ord)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun mergeWith (other: DirectionRequest) {
|
||||
command = other.command
|
||||
}
|
||||
|
||||
fun mergeFrom (input: CodedInputStream) {
|
||||
val builder = DirectionRequest.BuilderDirectionRequest()
|
||||
mergeWith(builder.parseFrom(input).build())}
|
||||
fun getSize(): Int {
|
||||
var size = 0
|
||||
size += WireFormat.getEnumSize(1, command.ord)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DirectionResponse private constructor (code: Int = 0, errorMsg: kotlin.String = "") {
|
||||
var code : Int
|
||||
private set
|
||||
|
||||
var errorMsg : kotlin.String
|
||||
private set
|
||||
|
||||
|
||||
init {
|
||||
this.code = code
|
||||
this.errorMsg = errorMsg
|
||||
}
|
||||
|
||||
fun writeTo (output: CodedOutputStream): Unit {
|
||||
output.writeInt32 (1, code)
|
||||
output.writeString (2, errorMsg)
|
||||
}
|
||||
|
||||
class BuilderDirectionResponse constructor (code: Int = 0, errorMsg: kotlin.String = "") {
|
||||
var code : Int
|
||||
private set
|
||||
fun setCode(value: Int): DirectionResponse.BuilderDirectionResponse {
|
||||
code = value
|
||||
return this
|
||||
}
|
||||
|
||||
var errorMsg : kotlin.String
|
||||
private set
|
||||
fun setErrorMsg(value: kotlin.String): DirectionResponse.BuilderDirectionResponse {
|
||||
errorMsg = value
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
this.code = code
|
||||
this.errorMsg = errorMsg
|
||||
}
|
||||
|
||||
fun readFrom (input: CodedInputStream): DirectionResponse.BuilderDirectionResponse {
|
||||
code = input.readInt32(1)
|
||||
errorMsg = input.readString(2)
|
||||
return this
|
||||
}
|
||||
|
||||
fun build(): DirectionResponse {
|
||||
return DirectionResponse(code, errorMsg)
|
||||
}
|
||||
|
||||
fun parseFieldFrom(input: CodedInputStream): Boolean {
|
||||
if (input.isAtEnd()) { return false }
|
||||
val tag = input.readInt32NoTag()
|
||||
if (tag == 0) { return false }
|
||||
val fieldNumber = WireFormat.getTagFieldNumber(tag)
|
||||
val wireType = WireFormat.getTagWireType(tag)
|
||||
when(fieldNumber) {
|
||||
1 -> code = input.readInt32NoTag()
|
||||
2 -> errorMsg = input.readStringNoTag()
|
||||
}
|
||||
return true}
|
||||
fun parseFrom(input: CodedInputStream): DirectionResponse.BuilderDirectionResponse {
|
||||
while(parseFieldFrom(input)) {}
|
||||
return this
|
||||
}
|
||||
fun getSize(): Int {
|
||||
var size = 0
|
||||
size += WireFormat.getInt32Size(1, code)
|
||||
size += WireFormat.getStringSize(2, errorMsg)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun mergeWith (other: DirectionResponse) {
|
||||
code = other.code
|
||||
errorMsg = other.errorMsg
|
||||
}
|
||||
|
||||
fun mergeFrom (input: CodedInputStream) {
|
||||
val builder = DirectionResponse.BuilderDirectionResponse()
|
||||
mergeWith(builder.parseFrom(input).build())}
|
||||
fun getSize(): Int {
|
||||
var size = 0
|
||||
size += WireFormat.getInt32Size(1, code)
|
||||
size += WireFormat.getStringSize(2, errorMsg)
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,11 +104,15 @@ object WireFormat {
|
||||
}
|
||||
|
||||
fun getStringSize(fieldNumber: Int, value: String): Int {
|
||||
if (value.length == 0)
|
||||
return 0
|
||||
val encodedStringSize = value.toByteArray(Charsets.UTF_8).size //TODO: not sure if it's the best way to do it
|
||||
return encodedStringSize + getTagSize(fieldNumber, WireType.LENGTH_DELIMITED) + getVarint32Size(encodedStringSize)
|
||||
}
|
||||
|
||||
fun getBytesSize(fieldNumber: Int, value: ByteArray): Int {
|
||||
if (value.size == 0)
|
||||
return 0
|
||||
return value.size + getTagSize(fieldNumber, WireType.LENGTH_DELIMITED) + getVarint32Size(value.size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
class DirectionRequest private constructor (command: DirectionRequest.Command = DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
var command : DirectionRequest.Command
|
||||
private set
|
||||
|
||||
|
||||
init {
|
||||
this.command = command
|
||||
}
|
||||
enum class Command(val ord: Int) {
|
||||
stop (0),
|
||||
forward (1),
|
||||
backward (2),
|
||||
left (3),
|
||||
right (4);
|
||||
|
||||
companion object {
|
||||
fun fromIntToCommand (ord: Int): Command {
|
||||
return when (ord) {
|
||||
0 -> Command.stop
|
||||
1 -> Command.forward
|
||||
2 -> Command.backward
|
||||
3 -> Command.left
|
||||
4 -> Command.right
|
||||
else -> throw InvalidProtocolBufferException("Error: got unexpected int ${ord} while parsing Command ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun writeTo (output: CodedOutputStream) {
|
||||
if (command != DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
output.writeEnum (1, command.ord)
|
||||
}
|
||||
}
|
||||
|
||||
class BuilderDirectionRequest constructor (command: DirectionRequest.Command = DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
var command : DirectionRequest.Command
|
||||
private set
|
||||
fun setCommand(value: DirectionRequest.Command): DirectionRequest.BuilderDirectionRequest {
|
||||
command = value
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
this.command = command
|
||||
}
|
||||
|
||||
fun writeTo (output: CodedOutputStream) {
|
||||
if (command != DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
output.writeEnum (1, command.ord)
|
||||
}
|
||||
}
|
||||
|
||||
fun build(): DirectionRequest {
|
||||
return DirectionRequest(command)
|
||||
}
|
||||
|
||||
fun parseFieldFrom(input: CodedInputStream): Boolean {
|
||||
if (input.isAtEnd()) { return false }
|
||||
val tag = input.readInt32NoTag()
|
||||
if (tag == 0) { return false }
|
||||
val fieldNumber = WireFormat.getTagFieldNumber(tag)
|
||||
val wireType = WireFormat.getTagWireType(tag)
|
||||
when(fieldNumber) {
|
||||
1 -> {
|
||||
if (wireType != WireType.VARINT) {
|
||||
throw InvalidProtocolBufferException("Error: Field number 1 has wire type WireType.VARINT but read ${wireType.toString()}")}
|
||||
command = DirectionRequest.Command.fromIntToCommand(input.readEnumNoTag())
|
||||
}
|
||||
}
|
||||
return true}
|
||||
fun parseFromWithSize(input: CodedInputStream, expectedSize: Int): DirectionRequest.BuilderDirectionRequest {
|
||||
while(getSizeNoTag() < expectedSize) {
|
||||
parseFieldFrom(input)
|
||||
}
|
||||
if (getSizeNoTag() > expectedSize) { throw InvalidProtocolBufferException("Error: expected size of message $expectedSize, but have read at least ${getSizeNoTag()}") }
|
||||
return this
|
||||
}
|
||||
fun parseFrom(input: CodedInputStream): DirectionRequest.BuilderDirectionRequest {
|
||||
while(parseFieldFrom(input)) {}
|
||||
return this
|
||||
}
|
||||
fun getSize(fieldNumber: Int): Int {
|
||||
var size = 0
|
||||
if (command != DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
size += WireFormat.getEnumSize(1, command.ord)
|
||||
}
|
||||
size += WireFormat.getVarint32Size(size) + WireFormat.getTagSize(fieldNumber, WireType.LENGTH_DELIMITED)
|
||||
return size
|
||||
}
|
||||
fun getSizeNoTag(): Int {
|
||||
var size = 0
|
||||
if (command != DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
size += WireFormat.getEnumSize(1, command.ord)
|
||||
}
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun mergeWith (other: DirectionRequest) {
|
||||
command = other.command
|
||||
}
|
||||
|
||||
fun mergeFromWithSize (input: CodedInputStream, expectedSize: Int) {
|
||||
val builder = DirectionRequest.BuilderDirectionRequest()
|
||||
mergeWith(builder.parseFromWithSize(input, expectedSize).build())}
|
||||
|
||||
fun mergeFrom (input: CodedInputStream) {
|
||||
val builder = DirectionRequest.BuilderDirectionRequest()
|
||||
mergeWith(builder.parseFrom(input).build())}
|
||||
fun getSize(fieldNumber: Int): Int {
|
||||
var size = 0
|
||||
if (command != DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
size += WireFormat.getEnumSize(1, command.ord)
|
||||
}
|
||||
size += WireFormat.getVarint32Size(size) + WireFormat.getTagSize(fieldNumber, WireType.LENGTH_DELIMITED)
|
||||
return size
|
||||
}
|
||||
fun getSizeNoTag(): Int {
|
||||
var size = 0
|
||||
if (command != DirectionRequest.Command.fromIntToCommand(0)) {
|
||||
size += WireFormat.getEnumSize(1, command.ord)
|
||||
}
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DirectionResponse private constructor (code: Int = 0, errorMsg: String = "") {
|
||||
var code : Int
|
||||
private set
|
||||
|
||||
var errorMsg : String
|
||||
private set
|
||||
|
||||
|
||||
init {
|
||||
this.code = code
|
||||
this.errorMsg = errorMsg
|
||||
}
|
||||
|
||||
fun writeTo (output: CodedOutputStream) {
|
||||
if (code != 0) {
|
||||
output.writeInt32 (1, code)
|
||||
}
|
||||
if (errorMsg != "") {
|
||||
output.writeString (2, errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
class BuilderDirectionResponse constructor (code: Int = 0, errorMsg: String = "") {
|
||||
var code : Int
|
||||
private set
|
||||
fun setCode(value: Int): DirectionResponse.BuilderDirectionResponse {
|
||||
code = value
|
||||
return this
|
||||
}
|
||||
|
||||
var errorMsg : String
|
||||
private set
|
||||
fun setErrorMsg(value: String): DirectionResponse.BuilderDirectionResponse {
|
||||
errorMsg = value
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
this.code = code
|
||||
this.errorMsg = errorMsg
|
||||
}
|
||||
|
||||
fun writeTo (output: CodedOutputStream) {
|
||||
if (code != 0) {
|
||||
output.writeInt32 (1, code)
|
||||
}
|
||||
if (errorMsg != "") {
|
||||
output.writeString (2, errorMsg)
|
||||
}
|
||||
}
|
||||
|
||||
fun build(): DirectionResponse {
|
||||
return DirectionResponse(code, errorMsg)
|
||||
}
|
||||
|
||||
fun parseFieldFrom(input: CodedInputStream): Boolean {
|
||||
if (input.isAtEnd()) { return false }
|
||||
val tag = input.readInt32NoTag()
|
||||
if (tag == 0) { return false }
|
||||
val fieldNumber = WireFormat.getTagFieldNumber(tag)
|
||||
val wireType = WireFormat.getTagWireType(tag)
|
||||
when(fieldNumber) {
|
||||
1 -> {
|
||||
if (wireType != WireType.VARINT) {
|
||||
throw InvalidProtocolBufferException("Error: Field number 1 has wire type WireType.VARINT but read ${wireType.toString()}")}
|
||||
code = input.readInt32NoTag()
|
||||
}
|
||||
2 -> {
|
||||
if (wireType != WireType.LENGTH_DELIMITED) {
|
||||
throw InvalidProtocolBufferException("Error: Field number 2 has wire type WireType.LENGTH_DELIMITED but read ${wireType.toString()}")}
|
||||
errorMsg = input.readStringNoTag()
|
||||
}
|
||||
}
|
||||
return true}
|
||||
fun parseFromWithSize(input: CodedInputStream, expectedSize: Int): DirectionResponse.BuilderDirectionResponse {
|
||||
while(getSizeNoTag() < expectedSize) {
|
||||
parseFieldFrom(input)
|
||||
}
|
||||
if (getSizeNoTag() > expectedSize) { throw InvalidProtocolBufferException("Error: expected size of message $expectedSize, but have read at least ${getSizeNoTag()}") }
|
||||
return this
|
||||
}
|
||||
fun parseFrom(input: CodedInputStream): DirectionResponse.BuilderDirectionResponse {
|
||||
while(parseFieldFrom(input)) {}
|
||||
return this
|
||||
}
|
||||
fun getSize(fieldNumber: Int): Int {
|
||||
var size = 0
|
||||
if (code != 0) {
|
||||
size += WireFormat.getInt32Size(1, code)
|
||||
}
|
||||
if (errorMsg != "") {
|
||||
size += WireFormat.getStringSize(2, errorMsg)
|
||||
}
|
||||
size += WireFormat.getVarint32Size(size) + WireFormat.getTagSize(fieldNumber, WireType.LENGTH_DELIMITED)
|
||||
return size
|
||||
}
|
||||
fun getSizeNoTag(): Int {
|
||||
var size = 0
|
||||
if (code != 0) {
|
||||
size += WireFormat.getInt32Size(1, code)
|
||||
}
|
||||
if (errorMsg != "") {
|
||||
size += WireFormat.getStringSize(2, errorMsg)
|
||||
}
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun mergeWith (other: DirectionResponse) {
|
||||
code = other.code
|
||||
errorMsg = other.errorMsg
|
||||
}
|
||||
|
||||
fun mergeFromWithSize (input: CodedInputStream, expectedSize: Int) {
|
||||
val builder = DirectionResponse.BuilderDirectionResponse()
|
||||
mergeWith(builder.parseFromWithSize(input, expectedSize).build())}
|
||||
|
||||
fun mergeFrom (input: CodedInputStream) {
|
||||
val builder = DirectionResponse.BuilderDirectionResponse()
|
||||
mergeWith(builder.parseFrom(input).build())}
|
||||
fun getSize(fieldNumber: Int): Int {
|
||||
var size = 0
|
||||
if (code != 0) {
|
||||
size += WireFormat.getInt32Size(1, code)
|
||||
}
|
||||
if (errorMsg != "") {
|
||||
size += WireFormat.getStringSize(2, errorMsg)
|
||||
}
|
||||
size += WireFormat.getVarint32Size(size) + WireFormat.getTagSize(fieldNumber, WireType.LENGTH_DELIMITED)
|
||||
return size
|
||||
}
|
||||
fun getSizeNoTag(): Int {
|
||||
var size = 0
|
||||
if (code != 0) {
|
||||
size += WireFormat.getInt32Size(1, code)
|
||||
}
|
||||
if (errorMsg != "") {
|
||||
size += WireFormat.getStringSize(2, errorMsg)
|
||||
}
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user