Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2008 Google Inc. All rights reserved. |
| 3 | // https://developers.google.com/protocol-buffers/ |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are |
| 7 | // met: |
| 8 | // |
| 9 | // * Redistributions of source code must retain the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer. |
| 11 | // * Redistributions in binary form must reproduce the above |
| 12 | // copyright notice, this list of conditions and the following disclaimer |
| 13 | // in the documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // * Neither the name of Google Inc. nor the names of its |
| 16 | // contributors may be used to endorse or promote products derived from |
| 17 | // this software without specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | // Author: kenton@google.com (Kenton Varda) |
| 32 | // Based on original Protocol Buffers design by |
| 33 | // Sanjay Ghemawat, Jeff Dean, and others. |
| 34 | |
| 35 | #include <map> |
| 36 | #include <string> |
| 37 | |
Feng Xiao | eee38b0 | 2015-08-22 18:25:48 -0700 | [diff] [blame] | 38 | #include <google/protobuf/stubs/logging.h> |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 39 | #include <google/protobuf/stubs/common.h> |
| 40 | #include <google/protobuf/compiler/java/java_context.h> |
| 41 | #include <google/protobuf/compiler/java/java_doc_comment.h> |
| 42 | #include <google/protobuf/compiler/java/java_helpers.h> |
| 43 | #include <google/protobuf/compiler/java/java_name_resolver.h> |
| 44 | #include <google/protobuf/compiler/java/java_primitive_field_lite.h> |
| 45 | #include <google/protobuf/io/printer.h> |
| 46 | #include <google/protobuf/wire_format.h> |
| 47 | #include <google/protobuf/stubs/strutil.h> |
| 48 | |
| 49 | namespace google { |
| 50 | namespace protobuf { |
| 51 | namespace compiler { |
| 52 | namespace java { |
| 53 | |
| 54 | using internal::WireFormat; |
| 55 | using internal::WireFormatLite; |
| 56 | |
| 57 | namespace { |
| 58 | |
| 59 | void SetPrimitiveVariables(const FieldDescriptor* descriptor, |
| 60 | int messageBitIndex, |
| 61 | int builderBitIndex, |
| 62 | const FieldGeneratorInfo* info, |
| 63 | ClassNameResolver* name_resolver, |
| 64 | map<string, string>* variables) { |
| 65 | SetCommonFieldVariables(descriptor, info, variables); |
| 66 | |
| 67 | (*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor)); |
| 68 | (*variables)["boxed_type"] = BoxedPrimitiveTypeName(GetJavaType(descriptor)); |
| 69 | (*variables)["field_type"] = (*variables)["type"]; |
| 70 | (*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver); |
| 71 | (*variables)["default_init"] = IsDefaultValueJavaDefault(descriptor) ? |
| 72 | "" : ("= " + ImmutableDefaultValue(descriptor, name_resolver)); |
| 73 | (*variables)["capitalized_type"] = |
| 74 | GetCapitalizedType(descriptor, /* immutable = */ true); |
| 75 | (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor)); |
| 76 | (*variables)["tag_size"] = SimpleItoa( |
| 77 | WireFormat::TagSize(descriptor->number(), GetType(descriptor))); |
| 78 | |
| 79 | string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName( |
| 80 | GetJavaType(descriptor)), true /* cap_next_letter */); |
| 81 | switch (GetJavaType(descriptor)) { |
| 82 | case JAVATYPE_INT: |
| 83 | case JAVATYPE_LONG: |
| 84 | case JAVATYPE_FLOAT: |
| 85 | case JAVATYPE_DOUBLE: |
| 86 | case JAVATYPE_BOOLEAN: |
| 87 | (*variables)["field_list_type"] = |
| 88 | "com.google.protobuf.Internal." + capitalized_type + "List"; |
| 89 | (*variables)["new_list"] = "new" + capitalized_type + "List"; |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 90 | (*variables)["new_list_with_capacity"] = |
| 91 | "new" + capitalized_type + "ListWithCapacity"; |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 92 | (*variables)["empty_list"] = "empty" + capitalized_type + "List()"; |
| 93 | (*variables)["make_name_unmodifiable"] = |
| 94 | (*variables)["name"] + "_.makeImmutable()"; |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 95 | (*variables)["repeated_get"] = |
| 96 | (*variables)["name"] + "_.get" + capitalized_type; |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 97 | (*variables)["repeated_add"] = |
| 98 | (*variables)["name"] + "_.add" + capitalized_type; |
| 99 | (*variables)["repeated_set"] = |
| 100 | (*variables)["name"] + "_.set" + capitalized_type; |
| 101 | break; |
| 102 | default: |
| 103 | (*variables)["field_list_type"] = |
| 104 | "com.google.protobuf.Internal.ProtobufList<" + |
| 105 | (*variables)["boxed_type"] + ">"; |
| 106 | (*variables)["new_list"] = "newProtobufList"; |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 107 | (*variables)["new_list_with_capacity"] = "newProtobufListWithCapacity"; |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 108 | (*variables)["empty_list"] = "emptyProtobufList()"; |
| 109 | (*variables)["make_name_unmodifiable"] = |
| 110 | (*variables)["name"] + "_.makeImmutable()"; |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 111 | (*variables)["repeated_get"] = (*variables)["name"] + "_.get"; |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 112 | (*variables)["repeated_add"] = (*variables)["name"] + "_.add"; |
| 113 | (*variables)["repeated_set"] = (*variables)["name"] + "_.set"; |
| 114 | } |
| 115 | |
| 116 | if (IsReferenceType(GetJavaType(descriptor))) { |
| 117 | (*variables)["null_check"] = |
| 118 | " if (value == null) {\n" |
| 119 | " throw new NullPointerException();\n" |
| 120 | " }\n"; |
| 121 | } else { |
| 122 | (*variables)["null_check"] = ""; |
| 123 | } |
| 124 | // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported |
| 125 | // by the proto compiler |
| 126 | (*variables)["deprecation"] = descriptor->options().deprecated() |
| 127 | ? "@java.lang.Deprecated " : ""; |
| 128 | int fixed_size = FixedSize(GetType(descriptor)); |
| 129 | if (fixed_size != -1) { |
| 130 | (*variables)["fixed_size"] = SimpleItoa(fixed_size); |
| 131 | } |
| 132 | (*variables)["on_changed"] = |
| 133 | HasDescriptorMethods(descriptor->containing_type()) ? "onChanged();" : ""; |
| 134 | |
| 135 | if (SupportFieldPresence(descriptor->file())) { |
| 136 | // For singular messages and builders, one bit is used for the hasField bit. |
| 137 | (*variables)["get_has_field_bit_message"] = GenerateGetBit(messageBitIndex); |
| 138 | |
| 139 | // Note that these have a trailing ";". |
| 140 | (*variables)["set_has_field_bit_message"] = |
| 141 | GenerateSetBit(messageBitIndex) + ";"; |
| 142 | (*variables)["clear_has_field_bit_message"] = |
| 143 | GenerateClearBit(messageBitIndex) + ";"; |
| 144 | |
| 145 | (*variables)["is_field_present_message"] = GenerateGetBit(messageBitIndex); |
| 146 | } else { |
| 147 | (*variables)["set_has_field_bit_message"] = ""; |
| 148 | (*variables)["set_has_field_bit_message"] = ""; |
| 149 | (*variables)["clear_has_field_bit_message"] = ""; |
| 150 | |
| 151 | if (descriptor->type() == FieldDescriptor::TYPE_BYTES) { |
| 152 | (*variables)["is_field_present_message"] = |
| 153 | "!" + (*variables)["name"] + "_.isEmpty()"; |
| 154 | } else { |
| 155 | (*variables)["is_field_present_message"] = |
| 156 | (*variables)["name"] + "_ != " + (*variables)["default"]; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | // For repeated builders, the underlying list tracks mutability state. |
| 161 | (*variables)["is_mutable"] = (*variables)["name"] + "_.isModifiable()"; |
| 162 | |
| 163 | (*variables)["get_has_field_bit_from_local"] = |
| 164 | GenerateGetBitFromLocal(builderBitIndex); |
| 165 | (*variables)["set_has_field_bit_to_local"] = |
| 166 | GenerateSetBitToLocal(messageBitIndex); |
| 167 | } |
| 168 | |
| 169 | } // namespace |
| 170 | |
| 171 | // =================================================================== |
| 172 | |
| 173 | ImmutablePrimitiveFieldLiteGenerator:: |
| 174 | ImmutablePrimitiveFieldLiteGenerator(const FieldDescriptor* descriptor, |
| 175 | int messageBitIndex, |
| 176 | int builderBitIndex, |
| 177 | Context* context) |
| 178 | : descriptor_(descriptor), messageBitIndex_(messageBitIndex), |
| 179 | builderBitIndex_(builderBitIndex), context_(context), |
| 180 | name_resolver_(context->GetNameResolver()) { |
| 181 | SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, |
| 182 | context->GetFieldGeneratorInfo(descriptor), |
| 183 | name_resolver_, &variables_); |
| 184 | } |
| 185 | |
| 186 | ImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {} |
| 187 | |
| 188 | int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const { |
| 189 | return 1; |
| 190 | } |
| 191 | |
| 192 | int ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForBuilder() const { |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 197 | GenerateInterfaceMembers(io::Printer* printer) const { |
| 198 | if (SupportFieldPresence(descriptor_->file())) { |
| 199 | WriteFieldDocComment(printer, descriptor_); |
| 200 | printer->Print(variables_, |
| 201 | "$deprecation$boolean has$capitalized_name$();\n"); |
| 202 | } |
| 203 | WriteFieldDocComment(printer, descriptor_); |
| 204 | printer->Print(variables_, |
| 205 | "$deprecation$$type$ get$capitalized_name$();\n"); |
| 206 | } |
| 207 | |
| 208 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 209 | GenerateMembers(io::Printer* printer) const { |
| 210 | printer->Print(variables_, |
| 211 | "private $field_type$ $name$_;\n"); |
| 212 | PrintExtraFieldInfo(variables_, printer); |
| 213 | if (SupportFieldPresence(descriptor_->file())) { |
| 214 | WriteFieldDocComment(printer, descriptor_); |
| 215 | printer->Print(variables_, |
| 216 | "$deprecation$public boolean has$capitalized_name$() {\n" |
| 217 | " return $get_has_field_bit_message$;\n" |
| 218 | "}\n"); |
| 219 | } |
| 220 | |
| 221 | WriteFieldDocComment(printer, descriptor_); |
| 222 | printer->Print(variables_, |
| 223 | "$deprecation$public $type$ get$capitalized_name$() {\n" |
| 224 | " return $name$_;\n" |
| 225 | "}\n"); |
| 226 | |
| 227 | WriteFieldDocComment(printer, descriptor_); |
| 228 | printer->Print(variables_, |
| 229 | "private void set$capitalized_name$($type$ value) {\n" |
| 230 | "$null_check$" |
| 231 | " $set_has_field_bit_message$\n" |
| 232 | " $name$_ = value;\n" |
| 233 | "}\n"); |
| 234 | |
| 235 | WriteFieldDocComment(printer, descriptor_); |
| 236 | printer->Print(variables_, |
| 237 | "private void clear$capitalized_name$() {\n" |
| 238 | " $clear_has_field_bit_message$\n"); |
| 239 | JavaType type = GetJavaType(descriptor_); |
| 240 | if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) { |
| 241 | // The default value is not a simple literal so we want to avoid executing |
| 242 | // it multiple times. Instead, get the default out of the default instance. |
| 243 | printer->Print(variables_, |
| 244 | " $name$_ = getDefaultInstance().get$capitalized_name$();\n"); |
| 245 | } else { |
| 246 | printer->Print(variables_, |
| 247 | " $name$_ = $default$;\n"); |
| 248 | } |
| 249 | printer->Print(variables_, |
| 250 | "}\n"); |
| 251 | } |
| 252 | |
| 253 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 254 | GenerateBuilderMembers(io::Printer* printer) const { |
| 255 | if (SupportFieldPresence(descriptor_->file())) { |
| 256 | WriteFieldDocComment(printer, descriptor_); |
| 257 | printer->Print(variables_, |
| 258 | "$deprecation$public boolean has$capitalized_name$() {\n" |
| 259 | " return instance.has$capitalized_name$();\n" |
| 260 | "}\n"); |
| 261 | } |
| 262 | |
| 263 | WriteFieldDocComment(printer, descriptor_); |
| 264 | printer->Print(variables_, |
| 265 | "$deprecation$public $type$ get$capitalized_name$() {\n" |
| 266 | " return instance.get$capitalized_name$();\n" |
| 267 | "}\n"); |
| 268 | |
| 269 | WriteFieldDocComment(printer, descriptor_); |
| 270 | printer->Print(variables_, |
| 271 | "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" |
| 272 | " copyOnWrite();\n" |
| 273 | " instance.set$capitalized_name$(value);\n" |
| 274 | " return this;\n" |
| 275 | "}\n"); |
| 276 | |
| 277 | WriteFieldDocComment(printer, descriptor_); |
| 278 | printer->Print(variables_, |
| 279 | "$deprecation$public Builder clear$capitalized_name$() {\n" |
| 280 | " copyOnWrite();\n" |
| 281 | " instance.clear$capitalized_name$();\n" |
| 282 | " return this;\n" |
| 283 | "}\n"); |
| 284 | } |
| 285 | |
| 286 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 287 | GenerateFieldBuilderInitializationCode(io::Printer* printer) const { |
| 288 | // noop for primitives |
| 289 | } |
| 290 | |
| 291 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 292 | GenerateInitializationCode(io::Printer* printer) const { |
| 293 | printer->Print(variables_, "$name$_ = $default$;\n"); |
| 294 | } |
| 295 | |
| 296 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 297 | GenerateBuilderClearCode(io::Printer* printer) const { |
| 298 | // noop for primitives |
| 299 | } |
| 300 | |
| 301 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 302 | GenerateMergingCode(io::Printer* printer) const { |
| 303 | if (SupportFieldPresence(descriptor_->file())) { |
| 304 | printer->Print(variables_, |
| 305 | "if (other.has$capitalized_name$()) {\n" |
| 306 | " set$capitalized_name$(other.get$capitalized_name$());\n" |
| 307 | "}\n"); |
| 308 | } else { |
| 309 | printer->Print(variables_, |
| 310 | "if (other.get$capitalized_name$() != $default$) {\n" |
| 311 | " set$capitalized_name$(other.get$capitalized_name$());\n" |
| 312 | "}\n"); |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 317 | GenerateBuildingCode(io::Printer* printer) const { |
| 318 | // noop for primitives |
| 319 | } |
| 320 | |
| 321 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 322 | GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const { |
| 323 | // noop for scalars |
| 324 | } |
| 325 | |
| 326 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 327 | GenerateParsingCode(io::Printer* printer) const { |
| 328 | printer->Print(variables_, |
| 329 | "$set_has_field_bit_message$\n" |
| 330 | "$name$_ = input.read$capitalized_type$();\n"); |
| 331 | } |
| 332 | |
| 333 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 334 | GenerateParsingDoneCode(io::Printer* printer) const { |
| 335 | // noop for primitives. |
| 336 | } |
| 337 | |
| 338 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 339 | GenerateSerializationCode(io::Printer* printer) const { |
| 340 | printer->Print(variables_, |
| 341 | "if ($is_field_present_message$) {\n" |
| 342 | " output.write$capitalized_type$($number$, $name$_);\n" |
| 343 | "}\n"); |
| 344 | } |
| 345 | |
| 346 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 347 | GenerateSerializedSizeCode(io::Printer* printer) const { |
| 348 | printer->Print(variables_, |
| 349 | "if ($is_field_present_message$) {\n" |
| 350 | " size += com.google.protobuf.CodedOutputStream\n" |
| 351 | " .compute$capitalized_type$Size($number$, $name$_);\n" |
| 352 | "}\n"); |
| 353 | } |
| 354 | |
| 355 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 356 | GenerateEqualsCode(io::Printer* printer) const { |
| 357 | switch (GetJavaType(descriptor_)) { |
| 358 | case JAVATYPE_INT: |
| 359 | case JAVATYPE_LONG: |
| 360 | case JAVATYPE_BOOLEAN: |
| 361 | printer->Print(variables_, |
| 362 | "result = result && (get$capitalized_name$()\n" |
| 363 | " == other.get$capitalized_name$());\n"); |
| 364 | break; |
| 365 | |
| 366 | case JAVATYPE_FLOAT: |
| 367 | printer->Print(variables_, |
| 368 | "result = result && (\n" |
| 369 | " java.lang.Float.floatToIntBits(get$capitalized_name$())\n" |
| 370 | " == java.lang.Float.floatToIntBits(\n" |
| 371 | " other.get$capitalized_name$()));\n"); |
| 372 | break; |
| 373 | |
| 374 | case JAVATYPE_DOUBLE: |
| 375 | printer->Print(variables_, |
| 376 | "result = result && (\n" |
| 377 | " java.lang.Double.doubleToLongBits(get$capitalized_name$())\n" |
| 378 | " == java.lang.Double.doubleToLongBits(\n" |
| 379 | " other.get$capitalized_name$()));\n"); |
| 380 | break; |
| 381 | |
| 382 | case JAVATYPE_STRING: |
| 383 | case JAVATYPE_BYTES: |
| 384 | printer->Print(variables_, |
| 385 | "result = result && get$capitalized_name$()\n" |
| 386 | " .equals(other.get$capitalized_name$());\n"); |
| 387 | break; |
| 388 | |
| 389 | case JAVATYPE_ENUM: |
| 390 | case JAVATYPE_MESSAGE: |
| 391 | default: |
| 392 | GOOGLE_LOG(FATAL) << "Can't get here."; |
| 393 | break; |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | void ImmutablePrimitiveFieldLiteGenerator:: |
| 398 | GenerateHashCode(io::Printer* printer) const { |
| 399 | printer->Print(variables_, |
| 400 | "hash = (37 * hash) + $constant_name$;\n"); |
| 401 | switch (GetJavaType(descriptor_)) { |
| 402 | case JAVATYPE_INT: |
| 403 | printer->Print(variables_, |
| 404 | "hash = (53 * hash) + get$capitalized_name$();\n"); |
| 405 | break; |
| 406 | |
| 407 | case JAVATYPE_LONG: |
| 408 | printer->Print(variables_, |
| 409 | "hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n" |
| 410 | " get$capitalized_name$());\n"); |
| 411 | break; |
| 412 | |
| 413 | case JAVATYPE_BOOLEAN: |
| 414 | printer->Print(variables_, |
| 415 | "hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\n" |
| 416 | " get$capitalized_name$());\n"); |
| 417 | break; |
| 418 | |
| 419 | case JAVATYPE_FLOAT: |
| 420 | printer->Print(variables_, |
| 421 | "hash = (53 * hash) + java.lang.Float.floatToIntBits(\n" |
| 422 | " get$capitalized_name$());\n"); |
| 423 | break; |
| 424 | |
| 425 | case JAVATYPE_DOUBLE: |
| 426 | printer->Print(variables_, |
| 427 | "hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\n" |
| 428 | " java.lang.Double.doubleToLongBits(get$capitalized_name$()));\n"); |
| 429 | break; |
| 430 | |
| 431 | case JAVATYPE_STRING: |
| 432 | case JAVATYPE_BYTES: |
| 433 | printer->Print(variables_, |
| 434 | "hash = (53 * hash) + get$capitalized_name$().hashCode();\n"); |
| 435 | break; |
| 436 | |
| 437 | case JAVATYPE_ENUM: |
| 438 | case JAVATYPE_MESSAGE: |
| 439 | default: |
| 440 | GOOGLE_LOG(FATAL) << "Can't get here."; |
| 441 | break; |
| 442 | } |
| 443 | } |
| 444 | |
| 445 | string ImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const { |
| 446 | return BoxedPrimitiveTypeName(GetJavaType(descriptor_)); |
| 447 | } |
| 448 | |
| 449 | // =================================================================== |
| 450 | |
| 451 | ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 452 | ImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor, |
| 453 | int messageBitIndex, |
| 454 | int builderBitIndex, |
| 455 | Context* context) |
| 456 | : ImmutablePrimitiveFieldLiteGenerator( |
| 457 | descriptor, messageBitIndex, builderBitIndex, context) { |
| 458 | const OneofGeneratorInfo* info = |
| 459 | context->GetOneofGeneratorInfo(descriptor->containing_oneof()); |
| 460 | SetCommonOneofVariables(descriptor, info, &variables_); |
| 461 | } |
| 462 | |
| 463 | ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 464 | ~ImmutablePrimitiveOneofFieldLiteGenerator() {} |
| 465 | |
| 466 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 467 | GenerateMembers(io::Printer* printer) const { |
| 468 | PrintExtraFieldInfo(variables_, printer); |
| 469 | if (SupportFieldPresence(descriptor_->file())) { |
| 470 | WriteFieldDocComment(printer, descriptor_); |
| 471 | printer->Print(variables_, |
| 472 | "$deprecation$public boolean has$capitalized_name$() {\n" |
| 473 | " return $has_oneof_case_message$;\n" |
| 474 | "}\n"); |
| 475 | } |
| 476 | |
| 477 | WriteFieldDocComment(printer, descriptor_); |
| 478 | printer->Print(variables_, |
| 479 | "$deprecation$public $type$ get$capitalized_name$() {\n" |
| 480 | " if ($has_oneof_case_message$) {\n" |
| 481 | " return ($boxed_type$) $oneof_name$_;\n" |
| 482 | " }\n" |
| 483 | " return $default$;\n" |
| 484 | "}\n"); |
| 485 | |
| 486 | WriteFieldDocComment(printer, descriptor_); |
| 487 | printer->Print(variables_, |
| 488 | "private void set$capitalized_name$($type$ value) {\n" |
| 489 | "$null_check$" |
| 490 | " $set_oneof_case_message$;\n" |
| 491 | " $oneof_name$_ = value;\n" |
| 492 | "}\n"); |
| 493 | |
| 494 | WriteFieldDocComment(printer, descriptor_); |
| 495 | printer->Print(variables_, |
| 496 | "private void clear$capitalized_name$() {\n" |
| 497 | " if ($has_oneof_case_message$) {\n" |
| 498 | " $clear_oneof_case_message$;\n" |
| 499 | " $oneof_name$_ = null;\n" |
| 500 | " }\n" |
| 501 | "}\n"); |
| 502 | } |
| 503 | |
| 504 | |
| 505 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 506 | GenerateBuilderMembers(io::Printer* printer) const { |
| 507 | if (SupportFieldPresence(descriptor_->file())) { |
| 508 | WriteFieldDocComment(printer, descriptor_); |
| 509 | printer->Print(variables_, |
| 510 | "$deprecation$public boolean has$capitalized_name$() {\n" |
| 511 | " return instance.has$capitalized_name$();\n" |
| 512 | "}\n"); |
| 513 | } |
| 514 | |
| 515 | WriteFieldDocComment(printer, descriptor_); |
| 516 | printer->Print(variables_, |
| 517 | "$deprecation$public $type$ get$capitalized_name$() {\n" |
| 518 | " return instance.get$capitalized_name$();\n" |
| 519 | "}\n"); |
| 520 | |
| 521 | WriteFieldDocComment(printer, descriptor_); |
| 522 | printer->Print(variables_, |
| 523 | "$deprecation$public Builder set$capitalized_name$($type$ value) {\n" |
| 524 | " copyOnWrite();\n" |
| 525 | " instance.set$capitalized_name$(value);\n" |
| 526 | " return this;\n" |
| 527 | "}\n"); |
| 528 | |
| 529 | WriteFieldDocComment(printer, descriptor_); |
| 530 | printer->Print(variables_, |
| 531 | "$deprecation$public Builder clear$capitalized_name$() {\n" |
| 532 | " copyOnWrite();\n" |
| 533 | " instance.clear$capitalized_name$();\n" |
| 534 | " return this;\n" |
| 535 | "}\n"); |
| 536 | } |
| 537 | |
| 538 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 539 | GenerateBuildingCode(io::Printer* printer) const { |
| 540 | // noop for primitives |
| 541 | } |
| 542 | |
| 543 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 544 | GenerateMergingCode(io::Printer* printer) const { |
| 545 | printer->Print(variables_, |
| 546 | "set$capitalized_name$(other.get$capitalized_name$());\n"); |
| 547 | } |
| 548 | |
| 549 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 550 | GenerateParsingCode(io::Printer* printer) const { |
| 551 | printer->Print(variables_, |
| 552 | "$set_oneof_case_message$;\n" |
| 553 | "$oneof_name$_ = input.read$capitalized_type$();\n"); |
| 554 | } |
| 555 | |
| 556 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 557 | GenerateSerializationCode(io::Printer* printer) const { |
| 558 | printer->Print(variables_, |
| 559 | "if ($has_oneof_case_message$) {\n" |
| 560 | " output.write$capitalized_type$(\n" |
| 561 | " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n" |
| 562 | "}\n"); |
| 563 | } |
| 564 | |
| 565 | void ImmutablePrimitiveOneofFieldLiteGenerator:: |
| 566 | GenerateSerializedSizeCode(io::Printer* printer) const { |
| 567 | printer->Print(variables_, |
| 568 | "if ($has_oneof_case_message$) {\n" |
| 569 | " size += com.google.protobuf.CodedOutputStream\n" |
| 570 | " .compute$capitalized_type$Size(\n" |
| 571 | " $number$, ($type$)(($boxed_type$) $oneof_name$_));\n" |
| 572 | "}\n"); |
| 573 | } |
| 574 | |
| 575 | // =================================================================== |
| 576 | |
| 577 | RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 578 | RepeatedImmutablePrimitiveFieldLiteGenerator(const FieldDescriptor* descriptor, |
| 579 | int messageBitIndex, |
| 580 | int builderBitIndex, |
| 581 | Context* context) |
| 582 | : descriptor_(descriptor), messageBitIndex_(messageBitIndex), |
| 583 | builderBitIndex_(builderBitIndex), context_(context), |
| 584 | name_resolver_(context->GetNameResolver()) { |
| 585 | SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex, |
| 586 | context->GetFieldGeneratorInfo(descriptor), |
| 587 | name_resolver_, &variables_); |
| 588 | } |
| 589 | |
| 590 | RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 591 | ~RepeatedImmutablePrimitiveFieldLiteGenerator() {} |
| 592 | |
| 593 | int RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const { |
| 594 | return 0; |
| 595 | } |
| 596 | |
| 597 | int RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForBuilder() const { |
| 598 | return 0; |
| 599 | } |
| 600 | |
| 601 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 602 | GenerateInterfaceMembers(io::Printer* printer) const { |
| 603 | WriteFieldDocComment(printer, descriptor_); |
| 604 | printer->Print(variables_, |
| 605 | "$deprecation$java.util.List<$boxed_type$> get$capitalized_name$List();\n"); |
| 606 | WriteFieldDocComment(printer, descriptor_); |
| 607 | printer->Print(variables_, |
| 608 | "$deprecation$int get$capitalized_name$Count();\n"); |
| 609 | WriteFieldDocComment(printer, descriptor_); |
| 610 | printer->Print(variables_, |
| 611 | "$deprecation$$type$ get$capitalized_name$(int index);\n"); |
| 612 | } |
| 613 | |
| 614 | |
| 615 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 616 | GenerateMembers(io::Printer* printer) const { |
| 617 | printer->Print(variables_, |
| 618 | "private $field_list_type$ $name$_;\n"); |
| 619 | PrintExtraFieldInfo(variables_, printer); |
| 620 | WriteFieldDocComment(printer, descriptor_); |
| 621 | printer->Print(variables_, |
| 622 | "$deprecation$public java.util.List<$boxed_type$>\n" |
| 623 | " get$capitalized_name$List() {\n" |
| 624 | " return $name$_;\n" // note: unmodifiable list |
| 625 | "}\n"); |
| 626 | WriteFieldDocComment(printer, descriptor_); |
| 627 | printer->Print(variables_, |
| 628 | "$deprecation$public int get$capitalized_name$Count() {\n" |
| 629 | " return $name$_.size();\n" |
| 630 | "}\n"); |
| 631 | WriteFieldDocComment(printer, descriptor_); |
| 632 | printer->Print(variables_, |
| 633 | "$deprecation$public $type$ get$capitalized_name$(int index) {\n" |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 634 | " return $repeated_get$(index);\n" |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 635 | "}\n"); |
| 636 | |
| 637 | if (descriptor_->options().packed() && |
| 638 | HasGeneratedMethods(descriptor_->containing_type())) { |
| 639 | printer->Print(variables_, |
| 640 | "private int $name$MemoizedSerializedSize = -1;\n"); |
| 641 | } |
| 642 | |
| 643 | printer->Print(variables_, |
| 644 | "private void ensure$capitalized_name$IsMutable() {\n" |
| 645 | " if (!$is_mutable$) {\n" |
| 646 | " $name$_ = $new_list$($name$_);\n" |
| 647 | " }\n" |
| 648 | "}\n"); |
| 649 | |
| 650 | WriteFieldDocComment(printer, descriptor_); |
| 651 | printer->Print(variables_, |
| 652 | "private void set$capitalized_name$(\n" |
| 653 | " int index, $type$ value) {\n" |
| 654 | "$null_check$" |
| 655 | " ensure$capitalized_name$IsMutable();\n" |
| 656 | " $repeated_set$(index, value);\n" |
| 657 | "}\n"); |
| 658 | WriteFieldDocComment(printer, descriptor_); |
| 659 | printer->Print(variables_, |
| 660 | "private void add$capitalized_name$($type$ value) {\n" |
| 661 | "$null_check$" |
| 662 | " ensure$capitalized_name$IsMutable();\n" |
| 663 | " $repeated_add$(value);\n" |
| 664 | "}\n"); |
| 665 | WriteFieldDocComment(printer, descriptor_); |
| 666 | printer->Print(variables_, |
| 667 | "private void addAll$capitalized_name$(\n" |
| 668 | " java.lang.Iterable<? extends $boxed_type$> values) {\n" |
| 669 | " ensure$capitalized_name$IsMutable();\n" |
| 670 | " com.google.protobuf.AbstractMessageLite.addAll(\n" |
| 671 | " values, $name$_);\n" |
| 672 | "}\n"); |
| 673 | WriteFieldDocComment(printer, descriptor_); |
| 674 | printer->Print(variables_, |
| 675 | "private void clear$capitalized_name$() {\n" |
| 676 | " $name$_ = $empty_list$;\n" |
| 677 | "}\n"); |
| 678 | } |
| 679 | |
| 680 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 681 | GenerateBuilderMembers(io::Printer* printer) const { |
| 682 | WriteFieldDocComment(printer, descriptor_); |
| 683 | printer->Print(variables_, |
| 684 | "$deprecation$public java.util.List<$boxed_type$>\n" |
| 685 | " get$capitalized_name$List() {\n" |
| 686 | " return java.util.Collections.unmodifiableList(\n" |
| 687 | " instance.get$capitalized_name$List());\n" |
| 688 | "}\n"); |
| 689 | WriteFieldDocComment(printer, descriptor_); |
| 690 | printer->Print(variables_, |
| 691 | "$deprecation$public int get$capitalized_name$Count() {\n" |
| 692 | " return instance.get$capitalized_name$Count();\n" |
| 693 | "}\n"); |
| 694 | WriteFieldDocComment(printer, descriptor_); |
| 695 | printer->Print(variables_, |
| 696 | "$deprecation$public $type$ get$capitalized_name$(int index) {\n" |
| 697 | " return instance.get$capitalized_name$(index);\n" |
| 698 | "}\n"); |
| 699 | WriteFieldDocComment(printer, descriptor_); |
| 700 | printer->Print(variables_, |
| 701 | "$deprecation$public Builder set$capitalized_name$(\n" |
| 702 | " int index, $type$ value) {\n" |
| 703 | " copyOnWrite();\n" |
| 704 | " instance.set$capitalized_name$(index, value);\n" |
| 705 | " return this;\n" |
| 706 | "}\n"); |
| 707 | WriteFieldDocComment(printer, descriptor_); |
| 708 | printer->Print(variables_, |
| 709 | "$deprecation$public Builder add$capitalized_name$($type$ value) {\n" |
| 710 | " copyOnWrite();\n" |
| 711 | " instance.add$capitalized_name$(value);\n" |
| 712 | " return this;\n" |
| 713 | "}\n"); |
| 714 | WriteFieldDocComment(printer, descriptor_); |
| 715 | printer->Print(variables_, |
| 716 | "$deprecation$public Builder addAll$capitalized_name$(\n" |
| 717 | " java.lang.Iterable<? extends $boxed_type$> values) {\n" |
| 718 | " copyOnWrite();\n" |
| 719 | " instance.addAll$capitalized_name$(values);\n" |
| 720 | " return this;\n" |
| 721 | "}\n"); |
| 722 | WriteFieldDocComment(printer, descriptor_); |
| 723 | printer->Print(variables_, |
| 724 | "$deprecation$public Builder clear$capitalized_name$() {\n" |
| 725 | " copyOnWrite();\n" |
| 726 | " instance.clear$capitalized_name$();\n" |
| 727 | " return this;\n" |
| 728 | "}\n"); |
| 729 | } |
| 730 | |
| 731 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 732 | GenerateFieldBuilderInitializationCode(io::Printer* printer) const { |
| 733 | // noop for primitives |
| 734 | } |
| 735 | |
| 736 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 737 | GenerateInitializationCode(io::Printer* printer) const { |
| 738 | printer->Print(variables_, "$name$_ = $empty_list$;\n"); |
| 739 | } |
| 740 | |
| 741 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 742 | GenerateBuilderClearCode(io::Printer* printer) const { |
| 743 | // noop for primitives |
| 744 | } |
| 745 | |
| 746 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 747 | GenerateMergingCode(io::Printer* printer) const { |
| 748 | // The code below does two optimizations: |
| 749 | // 1. If the other list is empty, there's nothing to do. This ensures we |
| 750 | // don't allocate a new array if we already have an immutable one. |
| 751 | // 2. If the other list is non-empty and our current list is empty, we can |
| 752 | // reuse the other list which is guaranteed to be immutable. |
| 753 | printer->Print(variables_, |
| 754 | "if (!other.$name$_.isEmpty()) {\n" |
| 755 | " if ($name$_.isEmpty()) {\n" |
| 756 | " $name$_ = other.$name$_;\n" |
| 757 | " } else {\n" |
| 758 | " ensure$capitalized_name$IsMutable();\n" |
| 759 | " $name$_.addAll(other.$name$_);\n" |
| 760 | " }\n" |
| 761 | " $on_changed$\n" |
| 762 | "}\n"); |
| 763 | } |
| 764 | |
| 765 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 766 | GenerateBuildingCode(io::Printer* printer) const { |
| 767 | // noop for primitives |
| 768 | } |
| 769 | |
| 770 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 771 | GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const { |
| 772 | printer->Print(variables_, |
| 773 | "$name$_.makeImmutable();\n"); |
| 774 | } |
| 775 | |
| 776 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 777 | GenerateParsingCode(io::Printer* printer) const { |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 778 | // TODO(dweis): Scan the input buffer to count, then initialize |
| 779 | // appropriately. |
| 780 | // TODO(dweis): Scan the input buffer to count and ensure capacity. |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 781 | printer->Print(variables_, |
| 782 | "if (!$is_mutable$) {\n" |
| 783 | " $name$_ = $new_list$();\n" |
| 784 | "}\n" |
| 785 | "$repeated_add$(input.read$capitalized_type$());\n"); |
| 786 | } |
| 787 | |
| 788 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 789 | GenerateParsingCodeFromPacked(io::Printer* printer) const { |
| 790 | printer->Print(variables_, |
| 791 | "int length = input.readRawVarint32();\n" |
| 792 | "int limit = input.pushLimit(length);\n" |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 793 | "if (!$is_mutable$ && input.getBytesUntilLimit() > 0) {\n"); |
| 794 | |
| 795 | int fixed_size = FixedSize(GetType(descriptor_)); |
| 796 | if (fixed_size == -1) { |
| 797 | // TODO(dweis): Scan the input buffer to count, then initialize |
| 798 | // appropriately. |
| 799 | printer->Print(variables_, |
| 800 | " $name$_ = $new_list$();\n"); |
| 801 | } else { |
| 802 | printer->Print(variables_, |
| 803 | " $name$_ = $new_list_with_capacity$(length/$fixed_size$);\n"); |
| 804 | } |
| 805 | |
| 806 | // TODO(dweis): Scan the input buffer to count and ensure capacity. |
| 807 | printer->Print(variables_, |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 808 | "}\n" |
| 809 | "while (input.getBytesUntilLimit() > 0) {\n" |
| 810 | " $repeated_add$(input.read$capitalized_type$());\n" |
| 811 | "}\n" |
| 812 | "input.popLimit(limit);\n"); |
| 813 | } |
| 814 | |
| 815 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 816 | GenerateParsingDoneCode(io::Printer* printer) const { |
| 817 | printer->Print(variables_, |
| 818 | "if ($is_mutable$) {\n" |
| 819 | " $make_name_unmodifiable$;\n" |
| 820 | "}\n"); |
| 821 | } |
| 822 | |
| 823 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 824 | GenerateSerializationCode(io::Printer* printer) const { |
| 825 | if (descriptor_->options().packed()) { |
| 826 | // We invoke getSerializedSize in writeTo for messages that have packed |
| 827 | // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods. |
| 828 | // That makes it safe to rely on the memoized size here. |
| 829 | printer->Print(variables_, |
| 830 | "if (get$capitalized_name$List().size() > 0) {\n" |
| 831 | " output.writeRawVarint32($tag$);\n" |
| 832 | " output.writeRawVarint32($name$MemoizedSerializedSize);\n" |
| 833 | "}\n" |
| 834 | "for (int i = 0; i < $name$_.size(); i++) {\n" |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 835 | " output.write$capitalized_type$NoTag($repeated_get$(i));\n" |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 836 | "}\n"); |
| 837 | } else { |
| 838 | printer->Print(variables_, |
| 839 | "for (int i = 0; i < $name$_.size(); i++) {\n" |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 840 | " output.write$capitalized_type$($number$, $repeated_get$(i));\n" |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 841 | "}\n"); |
| 842 | } |
| 843 | } |
| 844 | |
| 845 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 846 | GenerateSerializedSizeCode(io::Printer* printer) const { |
| 847 | printer->Print(variables_, |
| 848 | "{\n" |
| 849 | " int dataSize = 0;\n"); |
| 850 | printer->Indent(); |
| 851 | |
| 852 | if (FixedSize(GetType(descriptor_)) == -1) { |
| 853 | printer->Print(variables_, |
| 854 | "for (int i = 0; i < $name$_.size(); i++) {\n" |
| 855 | " dataSize += com.google.protobuf.CodedOutputStream\n" |
Feng Xiao | e841bac | 2015-12-11 17:09:20 -0800 | [diff] [blame] | 856 | " .compute$capitalized_type$SizeNoTag($repeated_get$(i));\n" |
Bo Yang | 5db2173 | 2015-05-21 14:28:59 -0700 | [diff] [blame] | 857 | "}\n"); |
| 858 | } else { |
| 859 | printer->Print(variables_, |
| 860 | "dataSize = $fixed_size$ * get$capitalized_name$List().size();\n"); |
| 861 | } |
| 862 | |
| 863 | printer->Print( |
| 864 | "size += dataSize;\n"); |
| 865 | |
| 866 | if (descriptor_->options().packed()) { |
| 867 | printer->Print(variables_, |
| 868 | "if (!get$capitalized_name$List().isEmpty()) {\n" |
| 869 | " size += $tag_size$;\n" |
| 870 | " size += com.google.protobuf.CodedOutputStream\n" |
| 871 | " .computeInt32SizeNoTag(dataSize);\n" |
| 872 | "}\n"); |
| 873 | } else { |
| 874 | printer->Print(variables_, |
| 875 | "size += $tag_size$ * get$capitalized_name$List().size();\n"); |
| 876 | } |
| 877 | |
| 878 | // cache the data size for packed fields. |
| 879 | if (descriptor_->options().packed()) { |
| 880 | printer->Print(variables_, |
| 881 | "$name$MemoizedSerializedSize = dataSize;\n"); |
| 882 | } |
| 883 | |
| 884 | printer->Outdent(); |
| 885 | printer->Print("}\n"); |
| 886 | } |
| 887 | |
| 888 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 889 | GenerateEqualsCode(io::Printer* printer) const { |
| 890 | printer->Print(variables_, |
| 891 | "result = result && get$capitalized_name$List()\n" |
| 892 | " .equals(other.get$capitalized_name$List());\n"); |
| 893 | } |
| 894 | |
| 895 | void RepeatedImmutablePrimitiveFieldLiteGenerator:: |
| 896 | GenerateHashCode(io::Printer* printer) const { |
| 897 | printer->Print(variables_, |
| 898 | "if (get$capitalized_name$Count() > 0) {\n" |
| 899 | " hash = (37 * hash) + $constant_name$;\n" |
| 900 | " hash = (53 * hash) + get$capitalized_name$List().hashCode();\n" |
| 901 | "}\n"); |
| 902 | } |
| 903 | |
| 904 | string RepeatedImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const { |
| 905 | return BoxedPrimitiveTypeName(GetJavaType(descriptor_)); |
| 906 | } |
| 907 | |
| 908 | } // namespace java |
| 909 | } // namespace compiler |
| 910 | } // namespace protobuf |
| 911 | } // namespace google |