From a0099d5bb98fe766abefd8ea5bc73593c493147b Mon Sep 17 00:00:00 2001 From: dsavvinov Date: Thu, 18 Aug 2016 10:50:36 +0300 Subject: [PATCH] Protobuf: fixed little typos in README.md. Added note about error codes and moved file with their descriptions to carkot/proto/compiler --- proto/compiler/README.md | 12 +++++++++--- .../compiler/kotlin/error_codes => error_codes.txt} | 0 2 files changed, 9 insertions(+), 3 deletions(-) rename proto/compiler/{google/src/google/protobuf/compiler/kotlin/error_codes => error_codes.txt} (100%) diff --git a/proto/compiler/README.md b/proto/compiler/README.md index 74772f04049..b09ef20848a 100644 --- a/proto/compiler/README.md +++ b/proto/compiler/README.md @@ -44,7 +44,8 @@ Example: ```java // All messages are immutable. Use Builders for creating new messages -// Currently you have to pass default arguments to Builders constructor by yourself. This will be changed in future. +// Currently you have to pass default arguments to Builders constructor by yourself. +// This will be changed in future. val msg = Person.BuilderPerson("", 0, "") // all setters return "this" builder so you can chain modifiers in LINQ-style .setEmail("wtf@dasda.com") @@ -60,14 +61,19 @@ val byteArray = ByteArray(msg.getSizeNoTag()) val outs = CodedOutputStream(byteArray) msg.writeTo(outs) -// InputStreams are created in some manner. +// InputStreams are created in the same manner. // WARNING! You have to pass reference to the buffer containing *ONLY* message and *NOTHING* except the message. -// That mean, trailing cells containing some trash are forbidden - you will be getting errors if you try to parse message from such buffer. +// That mean, trailing cells containing some trash are forbidden - +// - you will be getting errors if you try to parse message from such buffer. var ins = CodedInputStream(byteArray) // Parse message from input stream var readMsg = Person.BuilderPerson(0, "", 0).parseFrom(ins).build() +// Check is parse succeeded +// Note that currently exceptions are not supported, errors are reported using Message.errorCode field +// You can find description of error codes in carkot/proto/compiler/error_codes.txt +assert(readMsg.errorCode == 0) assert(msg == readMsg) ``` diff --git a/proto/compiler/google/src/google/protobuf/compiler/kotlin/error_codes b/proto/compiler/error_codes.txt similarity index 100% rename from proto/compiler/google/src/google/protobuf/compiler/kotlin/error_codes rename to proto/compiler/error_codes.txt