| OLD | NEW |
| 1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
| 2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
| 3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
| 4 // | 4 // |
| 5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
| 6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
| 7 // met: | 7 // met: |
| 8 // | 8 // |
| 9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
| 10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 builderBitIndex += generator->GetNumBitsForBuilder(); | 283 builderBitIndex += generator->GetNumBitsForBuilder(); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 template<> | 287 template<> |
| 288 FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {} | 288 FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {} |
| 289 | 289 |
| 290 | 290 |
| 291 void SetCommonFieldVariables(const FieldDescriptor* descriptor, | 291 void SetCommonFieldVariables(const FieldDescriptor* descriptor, |
| 292 const FieldGeneratorInfo* info, | 292 const FieldGeneratorInfo* info, |
| 293 map<string, string>* variables) { | 293 std::map<string, string>* variables) { |
| 294 (*variables)["field_name"] = descriptor->name(); | 294 (*variables)["field_name"] = descriptor->name(); |
| 295 (*variables)["name"] = info->name; | 295 (*variables)["name"] = info->name; |
| 296 (*variables)["capitalized_name"] = info->capitalized_name; | 296 (*variables)["capitalized_name"] = info->capitalized_name; |
| 297 (*variables)["disambiguated_reason"] = info->disambiguated_reason; | 297 (*variables)["disambiguated_reason"] = info->disambiguated_reason; |
| 298 (*variables)["constant_name"] = FieldConstantName(descriptor); | 298 (*variables)["constant_name"] = FieldConstantName(descriptor); |
| 299 (*variables)["number"] = SimpleItoa(descriptor->number()); | 299 (*variables)["number"] = SimpleItoa(descriptor->number()); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void SetCommonOneofVariables(const FieldDescriptor* descriptor, | 302 void SetCommonOneofVariables(const FieldDescriptor* descriptor, |
| 303 const OneofGeneratorInfo* info, | 303 const OneofGeneratorInfo* info, |
| 304 map<string, string>* variables) { | 304 std::map<string, string>* variables) { |
| 305 (*variables)["oneof_name"] = info->name; | 305 (*variables)["oneof_name"] = info->name; |
| 306 (*variables)["oneof_capitalized_name"] = info->capitalized_name; | 306 (*variables)["oneof_capitalized_name"] = info->capitalized_name; |
| 307 (*variables)["oneof_index"] = | 307 (*variables)["oneof_index"] = |
| 308 SimpleItoa(descriptor->containing_oneof()->index()); | 308 SimpleItoa(descriptor->containing_oneof()->index()); |
| 309 (*variables)["set_oneof_case_message"] = info->name + | 309 (*variables)["set_oneof_case_message"] = info->name + |
| 310 "Case_ = " + SimpleItoa(descriptor->number()); | 310 "Case_ = " + SimpleItoa(descriptor->number()); |
| 311 (*variables)["clear_oneof_case_message"] = info->name + | 311 (*variables)["clear_oneof_case_message"] = info->name + |
| 312 "Case_ = 0"; | 312 "Case_ = 0"; |
| 313 (*variables)["has_oneof_case_message"] = info->name + | 313 (*variables)["has_oneof_case_message"] = info->name + |
| 314 "Case_ == " + SimpleItoa(descriptor->number()); | 314 "Case_ == " + SimpleItoa(descriptor->number()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void PrintExtraFieldInfo(const map<string, string>& variables, | 317 void PrintExtraFieldInfo(const std::map<string, string>& variables, |
| 318 io::Printer* printer) { | 318 io::Printer* printer) { |
| 319 const map<string, string>::const_iterator it = | 319 const std::map<string, string>::const_iterator it = |
| 320 variables.find("disambiguated_reason"); | 320 variables.find("disambiguated_reason"); |
| 321 if (it != variables.end() && !it->second.empty()) { | 321 if (it != variables.end() && !it->second.empty()) { |
| 322 printer->Print( | 322 printer->Print( |
| 323 variables, | 323 variables, |
| 324 "// An alternative name is used for field \"$field_name$\" because:\n" | 324 "// An alternative name is used for field \"$field_name$\" because:\n" |
| 325 "// $disambiguated_reason$\n"); | 325 "// $disambiguated_reason$\n"); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 | 328 |
| 329 } // namespace java | 329 } // namespace java |
| 330 } // namespace compiler | 330 } // namespace compiler |
| 331 } // namespace protobuf | 331 } // namespace protobuf |
| 332 } // namespace google | 332 } // namespace google |
| OLD | NEW |