|
|
@ -233,9 +233,11 @@ GenerateMergingCode(io::Printer* printer) const { |
|
|
|
printer->Print(variables_, |
|
|
|
printer->Print(variables_, |
|
|
|
"int arrayLength = com.google.protobuf.nano.WireFormatNano" |
|
|
|
"int arrayLength = com.google.protobuf.nano.WireFormatNano" |
|
|
|
" .getRepeatedFieldArrayLength(input, $tag$);\n" |
|
|
|
" .getRepeatedFieldArrayLength(input, $tag$);\n" |
|
|
|
"int i = this.$name$.length;\n" |
|
|
|
"int i = this.$name$ == null ? 0 : this.$name$.length;\n" |
|
|
|
"$type$[] newArray = new $type$[i + arrayLength];\n" |
|
|
|
"$type$[] newArray = new $type$[i + arrayLength];\n" |
|
|
|
"System.arraycopy(this.$name$, 0, newArray, 0, i);\n" |
|
|
|
"if (this.$name$ != null) {\n" |
|
|
|
|
|
|
|
" System.arraycopy(this.$name$, 0, newArray, 0, i);\n" |
|
|
|
|
|
|
|
"}\n" |
|
|
|
"this.$name$ = newArray;\n" |
|
|
|
"this.$name$ = newArray;\n" |
|
|
|
"for (; i < this.$name$.length - 1; i++) {\n" |
|
|
|
"for (; i < this.$name$.length - 1; i++) {\n" |
|
|
|
" this.$name$[i] = new $type$();\n"); |
|
|
|
" this.$name$[i] = new $type$();\n"); |
|
|
@ -266,17 +268,21 @@ GenerateMergingCode(io::Printer* printer) const { |
|
|
|
void RepeatedMessageFieldGenerator:: |
|
|
|
void RepeatedMessageFieldGenerator:: |
|
|
|
GenerateSerializationCode(io::Printer* printer) const { |
|
|
|
GenerateSerializationCode(io::Printer* printer) const { |
|
|
|
printer->Print(variables_, |
|
|
|
printer->Print(variables_, |
|
|
|
"for ($type$ element : this.$name$) {\n" |
|
|
|
"if (this.$name$ != null) {\n" |
|
|
|
" output.write$group_or_message$($number$, element);\n" |
|
|
|
" for ($type$ element : this.$name$) {\n" |
|
|
|
|
|
|
|
" output.write$group_or_message$($number$, element);\n" |
|
|
|
|
|
|
|
" }\n" |
|
|
|
"}\n"); |
|
|
|
"}\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RepeatedMessageFieldGenerator:: |
|
|
|
void RepeatedMessageFieldGenerator:: |
|
|
|
GenerateSerializedSizeCode(io::Printer* printer) const { |
|
|
|
GenerateSerializedSizeCode(io::Printer* printer) const { |
|
|
|
printer->Print(variables_, |
|
|
|
printer->Print(variables_, |
|
|
|
"for ($type$ element : this.$name$) {\n" |
|
|
|
"if (this.$name$ != null) {\n" |
|
|
|
" size += com.google.protobuf.nano.CodedOutputByteBufferNano\n" |
|
|
|
" for ($type$ element : this.$name$) {\n" |
|
|
|
" .compute$group_or_message$Size($number$, element);\n" |
|
|
|
" size += com.google.protobuf.nano.CodedOutputByteBufferNano\n" |
|
|
|
|
|
|
|
" .compute$group_or_message$Size($number$, element);\n" |
|
|
|
|
|
|
|
" }\n" |
|
|
|
"}\n"); |
|
|
|
"}\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|