Skip to content

Commit

Permalink
Remove usage of deprecated methods.
Browse files Browse the repository at this point in the history
Fixes #123
  • Loading branch information
thesamet committed Jun 5, 2016
1 parent e7e5b1e commit 545b0cd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ class ProtobufGenerator(val params: GeneratorParams) extends DescriptorPimps {
if (field.isMessage) {
fp.addM(
s"""output.writeTag(${field.getNumber}, 2)
|output.writeRawVarint32($valueExpr.serializedSize)
|output.writeUInt32NoTag($valueExpr.serializedSize)
|$valueExpr.writeTo(output)""")
} else if (field.isEnum)
fp.add(s"output.writeEnum(${field.getNumber}, $valueExpr.value)")
Expand All @@ -315,7 +315,7 @@ class ProtobufGenerator(val params: GeneratorParams) extends DescriptorPimps {
def sizeExpressionForSingleField(field: FieldDescriptor, expr: String): String =
if (field.isMessage) {
val size = s"$expr.serializedSize"
CodedOutputStream.computeTagSize(field.getNumber) + s" + com.google.protobuf.CodedOutputStream.computeRawVarint32Size($size) + $size"
CodedOutputStream.computeTagSize(field.getNumber) + s" + com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag($size) + $size"
} else if(field.isEnum)
s"com.google.protobuf.CodedOutputStream.computeEnumSize(${field.getNumber}, ${expr}.value)"
else {
Expand Down Expand Up @@ -370,7 +370,7 @@ class ProtobufGenerator(val params: GeneratorParams) extends DescriptorPimps {
.addM(
s"""if($fieldNameSymbol.nonEmpty) {
| val __localsize = ${fieldName}SerializedSize
| __size += $tagSize + com.google.protobuf.CodedOutputStream.computeRawVarint32Size(__localsize) + __localsize
| __size += $tagSize + com.google.protobuf.CodedOutputStream.computeUInt32SizeNoTag(__localsize) + __localsize
|}""")
}
} else throw new RuntimeException("Should not reach here.")
Expand Down Expand Up @@ -454,7 +454,7 @@ class ProtobufGenerator(val params: GeneratorParams) extends DescriptorPimps {
printer.addM(
s"""if (${fieldNameSymbol}.nonEmpty) {
| output.writeTag(${field.getNumber}, 2)
| output.writeRawVarint32(${fieldNameSymbol}SerializedSize)
| output.writeUInt32NoTag(${fieldNameSymbol}SerializedSize)
| ${fieldNameSymbol}.foreach($writeFunc)
|};""")
} else if (field.isRequired) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ trait GeneratedMessage extends Serializable {
def writeDelimitedTo(output: OutputStream): Unit = {
val serialized: Int = serializedSize
val bufferSize: Int = LiteParser.preferredCodedOutputStreamBufferSize(
CodedOutputStream.computeRawVarint32Size(serialized) + serialized)
CodedOutputStream.computeUInt32SizeNoTag(serialized) + serialized)
val codedOutput: CodedOutputStream =
CodedOutputStream.newInstance(output, bufferSize)
codedOutput.writeRawVarint32(serialized)
codedOutput.writeUInt32NoTag(serialized)
writeTo(codedOutput)
codedOutput.flush()
}
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.5.29-SNAPSHOT"
version in ThisBuild := "0.5.29-SNAPSHOT"

0 comments on commit 545b0cd

Please # to comment.