aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/java
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2016-11-17 16:48:38 -0800
committerGravatar Adam Cozzette <acozzette@google.com>2016-11-17 16:59:59 -0800
commit5a76e633ea9b5adb215e93fdc11e1c0c08b3fc74 (patch)
tree0276f81f8848a05d84cd7e287b43d665e30f04e3 /src/google/protobuf/compiler/java
parente28286fa05d8327fd6c5aa70cfb3be558f0932b8 (diff)
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/compiler/java')
-rw-r--r--src/google/protobuf/compiler/java/java_context.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_context.h8
-rw-r--r--src/google/protobuf/compiler/java/java_doc_comment.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_enum.cc68
-rw-r--r--src/google/protobuf/compiler/java/java_enum.h4
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_enum_lite.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_enum_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_extension.cc12
-rw-r--r--src/google/protobuf/compiler/java/java_extension.h2
-rw-r--r--src/google/protobuf/compiler/java/java_extension_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_field.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_field.h8
-rw-r--r--src/google/protobuf/compiler/java/java_file.cc10
-rw-r--r--src/google/protobuf/compiler/java/java_file.h4
-rw-r--r--src/google/protobuf/compiler/java/java_generator.cc8
-rw-r--r--src/google/protobuf/compiler/java/java_helpers.cc9
-rw-r--r--src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc3
-rw-r--r--src/google/protobuf/compiler/java/java_map_field.cc137
-rw-r--r--src/google/protobuf/compiler/java/java_map_field.h2
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.h2
-rw-r--r--src/google/protobuf/compiler/java/java_message.cc28
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder.cc4
-rw-r--r--src/google/protobuf/compiler/java/java_message_builder_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc72
-rw-r--r--src/google/protobuf/compiler/java/java_name_resolver.h2
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.h4
-rw-r--r--src/google/protobuf/compiler/java/java_service.cc14
-rw-r--r--src/google/protobuf/compiler/java/java_shared_code_generator.cc6
-rw-r--r--src/google/protobuf/compiler/java/java_shared_code_generator.h5
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.h4
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.cc5
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.h4
45 files changed, 251 insertions, 257 deletions
diff --git a/src/google/protobuf/compiler/java/java_context.cc b/src/google/protobuf/compiler/java/java_context.cc
index 6cfa14a0..b82fb3dd 100644
--- a/src/google/protobuf/compiler/java/java_context.cc
+++ b/src/google/protobuf/compiler/java/java_context.cc
@@ -108,7 +108,7 @@ void Context::InitializeFieldGeneratorInfoForMessage(
for (int i = 0; i < message->nested_type_count(); ++i) {
InitializeFieldGeneratorInfoForMessage(message->nested_type(i));
}
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
for (int i = 0; i < message->field_count(); ++i) {
fields.push_back(message->field(i));
}
@@ -124,11 +124,11 @@ void Context::InitializeFieldGeneratorInfoForMessage(
}
void Context::InitializeFieldGeneratorInfoForFields(
- const vector<const FieldDescriptor*>& fields) {
+ const std::vector<const FieldDescriptor*>& fields) {
// Find out all fields that conflict with some other field in the same
// message.
- vector<bool> is_conflict(fields.size());
- vector<string> conflict_reason(fields.size());
+ std::vector<bool> is_conflict(fields.size());
+ std::vector<string> conflict_reason(fields.size());
for (int i = 0; i < fields.size(); ++i) {
const FieldDescriptor* field = fields[i];
const string& name = UnderscoresToCapitalizedCamelCase(field);
diff --git a/src/google/protobuf/compiler/java/java_context.h b/src/google/protobuf/compiler/java/java_context.h
index f92ae87e..b22e7e3a 100644
--- a/src/google/protobuf/compiler/java/java_context.h
+++ b/src/google/protobuf/compiler/java/java_context.h
@@ -95,11 +95,13 @@ class Context {
void InitializeFieldGeneratorInfo(const FileDescriptor* file);
void InitializeFieldGeneratorInfoForMessage(const Descriptor* message);
void InitializeFieldGeneratorInfoForFields(
- const vector<const FieldDescriptor*>& fields);
+ const std::vector<const FieldDescriptor*>& fields);
google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;
- map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_;
- map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_;
+ std::map<const FieldDescriptor*, FieldGeneratorInfo>
+ field_generator_info_map_;
+ std::map<const OneofDescriptor*, OneofGeneratorInfo>
+ oneof_generator_info_map_;
Options options_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);
};
diff --git a/src/google/protobuf/compiler/java/java_doc_comment.cc b/src/google/protobuf/compiler/java/java_doc_comment.cc
index 0b5caba4..59c04ad4 100644
--- a/src/google/protobuf/compiler/java/java_doc_comment.cc
+++ b/src/google/protobuf/compiler/java/java_doc_comment.cc
@@ -115,7 +115,7 @@ static void WriteDocCommentBodyForLocation(
// HTML-escape them so that they don't accidentally close the doc comment.
comments = EscapeJavadoc(comments);
- vector<string> lines = Split(comments, "\n");
+ std::vector<string> lines = Split(comments, "\n");
while (!lines.empty() && lines.back().empty()) {
lines.pop_back();
}
diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc
index b46cfe9c..b9ee00ff 100644
--- a/src/google/protobuf/compiler/java/java_enum.cc
+++ b/src/google/protobuf/compiler/java/java_enum.cc
@@ -49,17 +49,6 @@ namespace protobuf {
namespace compiler {
namespace java {
-namespace {
-bool EnumHasCustomOptions(const EnumDescriptor* descriptor) {
- if (descriptor->options().unknown_fields().field_count() > 0) return true;
- for (int i = 0; i < descriptor->value_count(); ++i) {
- const EnumValueDescriptor* value = descriptor->value(i);
- if (value->options().unknown_fields().field_count() > 0) return true;
- }
- return false;
-}
-} // namespace
-
EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
bool immutable_api,
Context* context)
@@ -105,7 +94,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < canonical_values_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = canonical_values_[i]->name();
vars["index"] = SimpleItoa(canonical_values_[i]->index());
vars["number"] = SimpleItoa(canonical_values_[i]->number());
@@ -137,7 +126,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = descriptor_->name();
vars["name"] = aliases_[i].value->name();
vars["canonical_name"] = aliases_[i].canonical_value->name();
@@ -147,7 +136,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->value_count(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = descriptor_->value(i)->name();
vars["number"] = SimpleItoa(descriptor_->value(i)->number());
WriteEnumValueDocComment(printer, descriptor_->value(i));
@@ -243,49 +232,14 @@ void EnumGenerator::Generate(io::Printer* printer) {
// at module init time because it wouldn't work with descriptor.proto, but
// we can cache the value the first time getDescriptor() is called.
if (descriptor_->containing_type() == NULL) {
- if (!MultipleJavaFiles(descriptor_->file(), immutable_api_)) {
- printer->Print(
- " return $file$.getDescriptor().getEnumTypes().get($index$);\n",
- "file", name_resolver_->GetClassName(descriptor_->file(),
- immutable_api_),
- "index", SimpleItoa(descriptor_->index()));
- } else {
- printer->Indent();
- if (EnumHasCustomOptions(descriptor_)) {
- // We need to load the immutable classes in order to parse custom
- // options. However, since file level enums (no outer class) are
- // shared by immutable code and mutable code, the immutable classes
- // may not exist. So we try to use Java reflection to retrieve the
- // descriptor from immutable classes.
- printer->Print(
- "try {\n"
- " java.lang.Class immutableFileClass =\n"
- " java.lang.Class.forName(\"$immutable_file_class_name$\");\n"
- " @java.lang.SuppressWarnings(\"unchecked\")\n"
- " java.lang.reflect.Method m =\n"
- " immutableFileClass.getMethod(\"getDescriptor\");\n"
- " com.google.protobuf.Descriptors.FileDescriptor file =\n"
- " (com.google.protobuf.Descriptors.FileDescriptor)\n"
- " m.invoke(immutableFileClass);\n"
- " return file.getEnumTypes().get($index$);\n"
- "} catch (java.lang.Exception e) {\n"
- // Immutable classes cannot be found. Proceed as if custom options
- // don't exist.
- "}\n",
- "immutable_file_class_name",
- name_resolver_->GetImmutableClassName(descriptor_->file()),
- "index", SimpleItoa(descriptor_->index()));
- }
- printer->Print(
- "return $immutable_package$.$descriptor_class$.$descriptor$\n"
- " .getEnumTypes().get($index$);\n",
- "immutable_package", FileJavaPackage(descriptor_->file(), true),
- "descriptor_class",
- name_resolver_->GetDescriptorClassName(descriptor_->file()),
- "descriptor", "getDescriptor()",
- "index", SimpleItoa(descriptor_->index()));
- printer->Outdent();
- }
+ // The class generated for the File fully populates the descriptor with
+ // extensions in both the mutable and immutable cases. (In the mutable api
+ // this is accomplished by attempting to load the immutable outer class).
+ printer->Print(
+ " return $file$.getDescriptor().getEnumTypes().get($index$);\n",
+ "file", name_resolver_->GetClassName(descriptor_->file(),
+ immutable_api_),
+ "index", SimpleItoa(descriptor_->index()));
} else {
printer->Print(
" return $parent$.$descriptor$.getEnumTypes().get($index$);\n",
diff --git a/src/google/protobuf/compiler/java/java_enum.h b/src/google/protobuf/compiler/java/java_enum.h
index c33e713d..13dfc32d 100644
--- a/src/google/protobuf/compiler/java/java_enum.h
+++ b/src/google/protobuf/compiler/java/java_enum.h
@@ -72,13 +72,13 @@ class EnumGenerator {
// considered equivalent. We treat the first defined constant for any
// given numeric value as "canonical" and the rest as aliases of that
// canonical value.
- vector<const EnumValueDescriptor*> canonical_values_;
+ std::vector<const EnumValueDescriptor*> canonical_values_;
struct Alias {
const EnumValueDescriptor* value;
const EnumValueDescriptor* canonical_value;
};
- vector<Alias> aliases_;
+ std::vector<Alias> aliases_;
bool immutable_api_;
diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc
index 2e916c56..279b9da4 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
@@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] = SimpleItoa(
descriptor->default_value_enum()->number());
- (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
diff --git a/src/google/protobuf/compiler/java/java_enum_field.h b/src/google/protobuf/compiler/java/java_enum_field.h
index b8ff7343..924ff281 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.h
+++ b/src/google/protobuf/compiler/java/java_enum_field.h
@@ -82,7 +82,7 @@ class ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -143,7 +143,7 @@ class RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index aa0eb5e8..f1dc47fc 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
@@ -58,7 +58,7 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
@@ -68,7 +68,8 @@ void SetEnumVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["default_number"] = SimpleItoa(
descriptor->default_value_enum()->number());
- (*variables)["tag"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(internal::WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
// TODO(birdo): Add @deprecated javadoc when generating javadoc is supported
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.h b/src/google/protobuf/compiler/java/java_enum_field_lite.h
index 9201b8d6..fa004720 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.h
@@ -81,7 +81,7 @@ class ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -142,7 +142,7 @@ class RepeatedImmutableEnumFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_enum_lite.cc b/src/google/protobuf/compiler/java/java_enum_lite.cc
index 99f52d40..96815920 100644
--- a/src/google/protobuf/compiler/java/java_enum_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_lite.cc
@@ -95,7 +95,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
printer->Indent();
for (int i = 0; i < canonical_values_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = canonical_values_[i]->name();
vars["number"] = SimpleItoa(canonical_values_[i]->number());
WriteEnumValueDocComment(printer, canonical_values_[i]);
@@ -117,7 +117,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
for (int i = 0; i < aliases_.size(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["classname"] = descriptor_->name();
vars["name"] = aliases_[i].value->name();
vars["canonical_name"] = aliases_[i].canonical_value->name();
@@ -127,7 +127,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
}
for (int i = 0; i < descriptor_->value_count(); i++) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = descriptor_->value(i)->name();
vars["number"] = SimpleItoa(descriptor_->value(i)->number());
WriteEnumValueDocComment(printer, descriptor_->value(i));
diff --git a/src/google/protobuf/compiler/java/java_enum_lite.h b/src/google/protobuf/compiler/java/java_enum_lite.h
index f27cb76f..b7be912c 100644
--- a/src/google/protobuf/compiler/java/java_enum_lite.h
+++ b/src/google/protobuf/compiler/java/java_enum_lite.h
@@ -72,13 +72,13 @@ class EnumLiteGenerator {
// considered equivalent. We treat the first defined constant for any
// given numeric value as "canonical" and the rest as aliases of that
// canonical value.
- vector<const EnumValueDescriptor*> canonical_values_;
+ std::vector<const EnumValueDescriptor*> canonical_values_;
struct Alias {
const EnumValueDescriptor* value;
const EnumValueDescriptor* canonical_value;
};
- vector<Alias> aliases_;
+ std::vector<Alias> aliases_;
bool immutable_api_;
diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc
index 46b5faaa..cb237bf6 100644
--- a/src/google/protobuf/compiler/java/java_extension.cc
+++ b/src/google/protobuf/compiler/java/java_extension.cc
@@ -61,12 +61,10 @@ ImmutableExtensionGenerator::ImmutableExtensionGenerator(
ImmutableExtensionGenerator::~ImmutableExtensionGenerator() {}
// Initializes the vars referenced in the generated code templates.
-void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor,
- const string& scope,
- bool immutable,
- ClassNameResolver* name_resolver,
- map<string, string>* vars_pointer) {
- map<string, string> &vars = *vars_pointer;
+void ExtensionGenerator::InitTemplateVars(
+ const FieldDescriptor* descriptor, const string& scope, bool immutable,
+ ClassNameResolver* name_resolver, std::map<string, string>* vars_pointer) {
+ std::map<string, string> &vars = *vars_pointer;
vars["scope"] = scope;
vars["name"] = UnderscoresToCamelCase(descriptor);
vars["containing_type"] =
@@ -110,7 +108,7 @@ void ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor,
}
void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
&vars);
diff --git a/src/google/protobuf/compiler/java/java_extension.h b/src/google/protobuf/compiler/java/java_extension.h
index bdd42263..fb8d5201 100644
--- a/src/google/protobuf/compiler/java/java_extension.h
+++ b/src/google/protobuf/compiler/java/java_extension.h
@@ -79,7 +79,7 @@ class ExtensionGenerator {
const string& scope,
bool immutable,
ClassNameResolver* name_resolver,
- map<string, string>* vars_pointer);
+ std::map<string, string>* vars_pointer);
private:
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);
diff --git a/src/google/protobuf/compiler/java/java_extension_lite.cc b/src/google/protobuf/compiler/java/java_extension_lite.cc
index 23261bac..c48c92e9 100644
--- a/src/google/protobuf/compiler/java/java_extension_lite.cc
+++ b/src/google/protobuf/compiler/java/java_extension_lite.cc
@@ -57,7 +57,7 @@ ImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(
ImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}
void ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {
- map<string, string> vars;
+ std::map<string, string> vars;
const bool kUseImmutableNames = true;
InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,
&vars);
diff --git a/src/google/protobuf/compiler/java/java_field.cc b/src/google/protobuf/compiler/java/java_field.cc
index 3c7bc5c4..04917296 100644
--- a/src/google/protobuf/compiler/java/java_field.cc
+++ b/src/google/protobuf/compiler/java/java_field.cc
@@ -290,7 +290,7 @@ FieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
(*variables)["field_name"] = descriptor->name();
(*variables)["name"] = info->name;
(*variables)["capitalized_name"] = info->capitalized_name;
@@ -301,7 +301,7 @@ void SetCommonFieldVariables(const FieldDescriptor* descriptor,
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
(*variables)["oneof_name"] = info->name;
(*variables)["oneof_capitalized_name"] = info->capitalized_name;
(*variables)["oneof_index"] =
@@ -314,9 +314,9 @@ void SetCommonOneofVariables(const FieldDescriptor* descriptor,
"Case_ == " + SimpleItoa(descriptor->number());
}
-void PrintExtraFieldInfo(const map<string, string>& variables,
+void PrintExtraFieldInfo(const std::map<string, string>& variables,
io::Printer* printer) {
- const map<string, string>::const_iterator it =
+ const std::map<string, string>::const_iterator it =
variables.find("disambiguated_reason");
if (it != variables.end() && !it->second.empty()) {
printer->Print(
diff --git a/src/google/protobuf/compiler/java/java_field.h b/src/google/protobuf/compiler/java/java_field.h
index 4dd4f57f..434e610c 100644
--- a/src/google/protobuf/compiler/java/java_field.h
+++ b/src/google/protobuf/compiler/java/java_field.h
@@ -169,7 +169,7 @@ struct FieldGeneratorInfo {
string disambiguated_reason;
};
-// Oneof information used in OneofFieldGeneartors.
+// Oneof information used in OneofFieldGenerators.
struct OneofGeneratorInfo {
string name;
string capitalized_name;
@@ -178,15 +178,15 @@ struct OneofGeneratorInfo {
// Set some common variables used in variable FieldGenerators.
void SetCommonFieldVariables(const FieldDescriptor* descriptor,
const FieldGeneratorInfo* info,
- map<string, string>* variables);
+ std::map<string, string>* variables);
// Set some common oneof variables used in OneofFieldGenerators.
void SetCommonOneofVariables(const FieldDescriptor* descriptor,
const OneofGeneratorInfo* info,
- map<string, string>* variables);
+ std::map<string, string>* variables);
// Print useful comments before a field's accessors.
-void PrintExtraFieldInfo(const map<string, string>& variables,
+void PrintExtraFieldInfo(const std::map<string, string>& variables,
io::Printer* printer);
} // namespace java
diff --git a/src/google/protobuf/compiler/java/java_file.cc b/src/google/protobuf/compiler/java/java_file.cc
index 3cbc530e..cb4503f6 100644
--- a/src/google/protobuf/compiler/java/java_file.cc
+++ b/src/google/protobuf/compiler/java/java_file.cc
@@ -90,7 +90,7 @@ bool CollectExtensions(const Message& message,
// There are unknown fields that could be extensions, thus this call fails.
if (reflection->GetUnknownFields(message).field_count() > 0) return false;
- vector<const FieldDescriptor*> fields;
+ std::vector<const FieldDescriptor*> fields;
reflection->ListFields(message, &fields);
for (int i = 0; i < fields.size(); i++) {
@@ -541,8 +541,8 @@ static void GenerateSibling(const string& package_dir,
const string& java_package,
const DescriptorClass* descriptor,
GeneratorContext* context,
- vector<string>* file_list, bool annotate_code,
- vector<string>* annotation_list,
+ std::vector<string>* file_list, bool annotate_code,
+ std::vector<string>* annotation_list,
const string& name_suffix,
GeneratorClass* generator,
void (GeneratorClass::*pfn)(io::Printer* printer)) {
@@ -581,8 +581,8 @@ static void GenerateSibling(const string& package_dir,
void FileGenerator::GenerateSiblings(const string& package_dir,
GeneratorContext* context,
- vector<string>* file_list,
- vector<string>* annotation_list) {
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_list) {
if (MultipleJavaFiles(file_, immutable_api_)) {
for (int i = 0; i < file_->enum_type_count(); i++) {
if (HasDescriptorMethods(file_, context_->EnforceLite())) {
diff --git a/src/google/protobuf/compiler/java/java_file.h b/src/google/protobuf/compiler/java/java_file.h
index 1e643f79..e95aef09 100644
--- a/src/google/protobuf/compiler/java/java_file.h
+++ b/src/google/protobuf/compiler/java/java_file.h
@@ -84,8 +84,8 @@ class FileGenerator {
// service type).
void GenerateSiblings(const string& package_dir,
GeneratorContext* generator_context,
- vector<string>* file_list,
- vector<string>* annotation_list);
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_list);
const string& java_package() { return java_package_; }
const string& classname() { return classname_; }
diff --git a/src/google/protobuf/compiler/java/java_generator.cc b/src/google/protobuf/compiler/java/java_generator.cc
index b1ab4043..2c02d996 100644
--- a/src/google/protobuf/compiler/java/java_generator.cc
+++ b/src/google/protobuf/compiler/java/java_generator.cc
@@ -66,7 +66,7 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
// parse generator options
- vector<pair<string, string> > options;
+ std::vector<std::pair<string, string> > options;
ParseGeneratorParameter(parameter, &options);
Options file_options;
@@ -105,11 +105,11 @@ bool JavaGenerator::Generate(const FileDescriptor* file,
// -----------------------------------------------------------------
- vector<string> all_files;
- vector<string> all_annotations;
+ std::vector<string> all_files;
+ std::vector<string> all_annotations;
- vector<FileGenerator*> file_generators;
+ std::vector<FileGenerator*> file_generators;
if (file_options.generate_immutable_code) {
file_generators.push_back(new FileGenerator(file, file_options,
/* immutable = */ true));
diff --git a/src/google/protobuf/compiler/java/java_helpers.cc b/src/google/protobuf/compiler/java/java_helpers.cc
index c31df265..efb5fd45 100644
--- a/src/google/protobuf/compiler/java/java_helpers.cc
+++ b/src/google/protobuf/compiler/java/java_helpers.cc
@@ -360,6 +360,7 @@ const char* BoxedPrimitiveTypeName(JavaType type) {
return NULL;
}
+
const char* FieldTypeName(FieldDescriptor::Type field_type) {
switch (field_type) {
case FieldDescriptor::TYPE_INT32 : return "INT32";
@@ -415,9 +416,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable,
"L";
case FieldDescriptor::CPPTYPE_DOUBLE: {
double value = field->default_value_double();
- if (value == numeric_limits<double>::infinity()) {
+ if (value == std::numeric_limits<double>::infinity()) {
return "Double.POSITIVE_INFINITY";
- } else if (value == -numeric_limits<double>::infinity()) {
+ } else if (value == -std::numeric_limits<double>::infinity()) {
return "Double.NEGATIVE_INFINITY";
} else if (value != value) {
return "Double.NaN";
@@ -427,9 +428,9 @@ string DefaultValue(const FieldDescriptor* field, bool immutable,
}
case FieldDescriptor::CPPTYPE_FLOAT: {
float value = field->default_value_float();
- if (value == numeric_limits<float>::infinity()) {
+ if (value == std::numeric_limits<float>::infinity()) {
return "Float.POSITIVE_INFINITY";
- } else if (value == -numeric_limits<float>::infinity()) {
+ } else if (value == -std::numeric_limits<float>::infinity()) {
return "Float.NEGATIVE_INFINITY";
} else if (value != value) {
return "Float.NaN";
diff --git a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
index dac1b51f..49070ba0 100644
--- a/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc
@@ -446,8 +446,7 @@ GenerateMembers(io::Printer* printer) const {
" for (com.google.protobuf.LazyFieldLite lf : $name$_) {\n"
" list.add(($type$) lf.getValue($type$.getDefaultInstance()));\n"
" }\n"
- // TODO(dweis): Make this list immutable?
- " return list;\n"
+ " return java.util.Collections.unmodifiableList(list);\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc
index 07aa3565..3fe68ae3 100644
--- a/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/src/google/protobuf/compiler/java/java_map_field.cc
@@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
Context* context,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
@@ -308,6 +308,16 @@ GenerateMembers(io::Printer* printer) const {
" com.google.protobuf.Internal.MapAdapter.newEnumConverter(\n"
" $value_enum_type$.internalGetValueMap(),\n"
" $unrecognized_value$);\n");
+ printer->Print(
+ variables_,
+ "private static final java.util.Map<$boxed_key_type$, "
+ "$value_enum_type$>\n"
+ "internalGetAdapted$capitalized_name$Map(\n"
+ " java.util.Map<$boxed_key_type$, $boxed_value_type$> map) {\n"
+ " return new com.google.protobuf.Internal.MapAdapter<\n"
+ " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
+ " map, $name$ValueConverter);\n"
+ "}\n");
}
GenerateMapGetters(printer);
}
@@ -339,23 +349,23 @@ GenerateBuilderMembers(io::Printer* printer) const {
" return $name$_;\n"
"}\n");
GenerateMapGetters(printer);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public Builder clear$capitalized_name$() {\n"
- " getMutable$capitalized_name$().clear();\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder clear$capitalized_name$() {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .clear();\n"
+ " return this;\n"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public Builder remove$capitalized_name$(\n"
- " $key_type$ key) {\n"
- " $key_null_check$\n"
- " getMutable$capitalized_name$().remove(key);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder remove$capitalized_name$(\n"
+ " $key_type$ key) {\n"
+ " $key_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .remove(key);\n"
+ " return this;\n"
+ "}\n");
if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {
printer->Print(
variables_,
@@ -365,30 +375,28 @@ GenerateBuilderMembers(io::Printer* printer) const {
"@java.lang.Deprecated\n"
"public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
"getMutable$capitalized_name$() {\n"
- " return new com.google.protobuf.Internal.MapAdapter<\n"
- " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
- " internalGetMutable$capitalized_name$().getMutableMap(),\n"
- " $name$ValueConverter);\n"
+ " return internalGetAdapted$capitalized_name$Map(\n"
+ " internalGetMutable$capitalized_name$().getMutableMap());\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$public Builder put$capitalized_name$(\n"
- " $key_type$ key,\n"
- " $value_enum_type$ value) {\n"
- " $key_null_check$\n"
- " $value_null_check$\n"
- " getMutable$capitalized_name$().put(key, value);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$public Builder put$capitalized_name$(\n"
+ " $key_type$ key,\n"
+ " $value_enum_type$ value) {\n"
+ " $key_null_check$\n"
+ " $value_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, $name$ValueConverter.doBackward(value));\n"
+ " return this;\n"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- // TODO(arielb): null check map keys/values here and everywhere else
- // related to putAll
"$deprecation$public Builder putAll$capitalized_name$(\n"
" java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\n"
- " getMutable$capitalized_name$().putAll(values);\n"
+ " internalGetAdapted$capitalized_name$Map(\n"
+ " internalGetMutable$capitalized_name$().getMutableMap())\n"
+ " .putAll(values);\n"
" return this;\n"
"}\n");
if (SupportUnknownEnumValue(descriptor_->file())) {
@@ -412,7 +420,8 @@ GenerateBuilderMembers(io::Printer* printer) const {
" if ($value_enum_type$.forNumber(value) == null) {\n"
" throw new java.lang.IllegalArgumentException();\n"
" }\n"
- " getMutable$capitalized_name$Value().put(key, value);\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, value);\n"
" return this;\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
@@ -420,7 +429,8 @@ GenerateBuilderMembers(io::Printer* printer) const {
variables_,
"$deprecation$public Builder putAll$capitalized_name$Value(\n"
" java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\n"
- " getMutable$capitalized_name$Value().putAll(values);\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .putAll(values);\n"
" return this;\n"
"}\n");
}
@@ -436,26 +446,26 @@ GenerateBuilderMembers(io::Printer* printer) const {
" return internalGetMutable$capitalized_name$().getMutableMap();\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$"
- "public Builder put$capitalized_name$(\n"
- " $key_type$ key,\n"
- " $value_type$ value) {\n"
- " $key_null_check$\n"
- " $value_null_check$\n"
- " getMutable$capitalized_name$().put(key, value);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$"
+ "public Builder put$capitalized_name$(\n"
+ " $key_type$ key,\n"
+ " $value_type$ value) {\n"
+ " $key_null_check$\n"
+ " $value_null_check$\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .put(key, value);\n"
+ " return this;\n"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public Builder putAll$capitalized_name$(\n"
- " java.util.Map<$type_parameters$> values) {\n"
- " getMutable$capitalized_name$().putAll(values);\n"
- " return this;\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public Builder putAll$capitalized_name$(\n"
+ " java.util.Map<$type_parameters$> values) {\n"
+ " internalGetMutable$capitalized_name$().getMutableMap()\n"
+ " .putAll(values);\n"
+ " return this;\n"
+ "}\n");
}
}
@@ -488,16 +498,13 @@ GenerateMapGetters(io::Printer* printer) const {
" return get$capitalized_name$Map();\n"
"}\n");
WriteFieldDocComment(printer, descriptor_);
- printer->Print(
- variables_,
- "$deprecation$\n"
- "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
- "get$capitalized_name$Map() {\n"
- " return new com.google.protobuf.Internal.MapAdapter<\n"
- " $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\n"
- " internalGet$capitalized_name$().getMap(),\n"
- " $name$ValueConverter);\n"
- "}\n");
+ printer->Print(variables_,
+ "$deprecation$\n"
+ "public java.util.Map<$boxed_key_type$, $value_enum_type$>\n"
+ "get$capitalized_name$Map() {\n"
+ " return internalGetAdapted$capitalized_name$Map(\n"
+ " internalGet$capitalized_name$().getMap());"
+ "}\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
diff --git a/src/google/protobuf/compiler/java/java_map_field.h b/src/google/protobuf/compiler/java/java_map_field.h
index ae7ce7c5..47021740 100644
--- a/src/google/protobuf/compiler/java/java_map_field.h
+++ b/src/google/protobuf/compiler/java/java_map_field.h
@@ -67,7 +67,7 @@ class ImmutableMapFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
ClassNameResolver* name_resolver_;
void GenerateMapGetters(io::Printer* printer) const;
};
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc
index 5f102e07..523052cc 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -80,7 +80,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
Context* context,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
ClassNameResolver* name_resolver = context->GetNameResolver();
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.h b/src/google/protobuf/compiler/java/java_map_field_lite.h
index 555b5c5b..63dedbc2 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.h
@@ -66,7 +66,7 @@ class ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
ClassNameResolver* name_resolver_;
};
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 68d28b05..df4db463 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -110,7 +110,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
// the outermost class in the file. This way, they will be initialized in
// a deterministic order.
- map<string, string> vars;
+ std::map<string, string> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
vars["index"] = SimpleItoa(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
@@ -154,7 +154,7 @@ void ImmutableMessageGenerator::GenerateStaticVariables(
int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
io::Printer* printer) {
int bytecode_estimate = 0;
- map<string, string> vars;
+ std::map<string, string> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
vars["index"] = SimpleItoa(descriptor_->index());
vars["classname"] = name_resolver_->GetImmutableClassName(descriptor_);
@@ -191,7 +191,7 @@ int ImmutableMessageGenerator::GenerateStaticVariableInitializers(
void ImmutableMessageGenerator::
GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["identifier"] = UniqueFileScopeIdentifier(descriptor_);
if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {
// We can only make these package-private since the classes that use them
@@ -299,7 +299,7 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- map<string, string> variables;
+ std::map<string, string> variables;
variables["static"] = is_own_file ? " " : " static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
@@ -409,7 +409,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
}
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->name;
@@ -561,13 +561,12 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(
SortFieldsByNumber(descriptor_));
- vector<const Descriptor::ExtensionRange*> sorted_extensions;
+ std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i));
}
std::sort(sorted_extensions.begin(), sorted_extensions.end(),
ExtensionRangeOrdering());
-
printer->Print(
"public void writeTo(com.google.protobuf.CodedOutputStream output)\n"
" throws java.io.IOException {\n");
@@ -799,7 +798,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
}
- vector<const FieldDescriptor*> map_fields;
+ std::vector<const FieldDescriptor*> map_fields;
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (GetJavaType(field) == JAVATYPE_MESSAGE &&
@@ -1093,7 +1092,12 @@ GenerateEqualsAndHashCode(io::Printer* printer) {
"}\n"
"int hash = 41;\n");
- printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n");
+ // If we output a getDescriptor() method, use that as it is more efficient.
+ if (descriptor_->options().no_standard_descriptor_accessor()) {
+ printer->Print("hash = (19 * hash) + getDescriptorForType().hashCode();\n");
+ } else {
+ printer->Print("hash = (19 * hash) + getDescriptor().hashCode();\n");
+ }
// hashCode non-oneofs.
for (int i = 0; i < descriptor_->field_count(); i++) {
@@ -1254,7 +1258,7 @@ GenerateParsingConstructor(io::Printer* printer) {
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(tag));
+ "tag", SimpleItoa(static_cast<int32>(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
@@ -1271,7 +1275,7 @@ GenerateParsingConstructor(io::Printer* printer) {
WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(packed_tag));
+ "tag", SimpleItoa(static_cast<int32>(packed_tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
@@ -1417,7 +1421,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
"}\n"
"\n"
"/**\n"
- " * Packs a message uisng the given type URL prefix. The type URL will\n"
+ " * Packs a message using the given type URL prefix. The type URL will\n"
" * be constructed by concatenating the message type's full name to the\n"
" * prefix with an optional \"/\" separator if the prefix doesn't end\n"
" * with \"/\" already.\n"
diff --git a/src/google/protobuf/compiler/java/java_message_builder.cc b/src/google/protobuf/compiler/java/java_message_builder.cc
index cd82c51a..f5643abc 100644
--- a/src/google/protobuf/compiler/java/java_message_builder.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder.cc
@@ -122,7 +122,7 @@ Generate(io::Printer* printer) {
}
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->name;
@@ -225,7 +225,7 @@ GenerateDescriptorMethods(io::Printer* printer) {
"fileclass", name_resolver_->GetImmutableClassName(descriptor_->file()),
"identifier", UniqueFileScopeIdentifier(descriptor_));
}
- vector<const FieldDescriptor*> map_fields;
+ std::vector<const FieldDescriptor*> map_fields;
for (int i = 0; i < descriptor_->field_count(); i++) {
const FieldDescriptor* field = descriptor_->field(i);
if (GetJavaType(field) == JAVATYPE_MESSAGE &&
diff --git a/src/google/protobuf/compiler/java/java_message_builder_lite.cc b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
index dd429dc9..7e404ba1 100644
--- a/src/google/protobuf/compiler/java/java_message_builder_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_builder_lite.cc
@@ -106,7 +106,7 @@ Generate(io::Printer* printer) {
GenerateCommonBuilderMethods(printer);
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
vars["oneof_name"] = context_->GetOneofGeneratorInfo(
descriptor_->oneof_decl(i))->name;
diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc
index c9865dda..ae84db1c 100644
--- a/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/src/google/protobuf/compiler/java/java_message_field.cc
@@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
diff --git a/src/google/protobuf/compiler/java/java_message_field.h b/src/google/protobuf/compiler/java/java_message_field.h
index ea8225a5..7ee0edb2 100644
--- a/src/google/protobuf/compiler/java/java_message_field.h
+++ b/src/google/protobuf/compiler/java/java_message_field.h
@@ -82,7 +82,7 @@ class ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -148,7 +148,7 @@ class RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc
index cba18360..fd78f75a 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc
@@ -56,7 +56,7 @@ void SetMessageVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] =
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.h b/src/google/protobuf/compiler/java/java_message_field_lite.h
index 61321547..dbb263de 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.h
@@ -81,7 +81,7 @@ class ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -139,7 +139,7 @@ class RepeatedImmutableMessageFieldLiteGenerator
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index 0c5a1f8a..8cc0f01d 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -170,7 +170,7 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);
- map<string, string> variables;
+ std::map<string, string> variables;
variables["static"] = is_own_file ? " " : " static ";
variables["classname"] = descriptor_->name();
variables["extra_interfaces"] = ExtraMessageInterfaces(descriptor_);
@@ -236,13 +236,13 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
}
// oneof
- map<string, string> vars;
+ std::map<string, string> vars;
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
- vars["oneof_name"] = context_->GetOneofGeneratorInfo(
- descriptor_->oneof_decl(i))->name;
+ const OneofDescriptor* oneof = descriptor_->oneof_decl(i);
+ vars["oneof_name"] = context_->GetOneofGeneratorInfo(oneof)->name;
vars["oneof_capitalized_name"] = context_->GetOneofGeneratorInfo(
- descriptor_->oneof_decl(i))->capitalized_name;
- vars["oneof_index"] = SimpleItoa(descriptor_->oneof_decl(i)->index());
+ oneof)->capitalized_name;
+ vars["oneof_index"] = SimpleItoa(oneof->index());
// oneofCase_ and oneof_
printer->Print(vars,
"private int $oneof_name$Case_ = 0;\n"
@@ -252,8 +252,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"public enum $oneof_capitalized_name$Case\n"
" implements com.google.protobuf.Internal.EnumLite {\n");
printer->Indent();
- for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
- const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
printer->Print(
"$field_name$($field_number$),\n",
"field_name",
@@ -281,8 +281,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
"\n"
"public static $oneof_capitalized_name$Case forNumber(int value) {\n"
" switch (value) {\n");
- for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
- const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
+ for (int j = 0; j < oneof->field_count(); j++) {
+ const FieldDescriptor* field = oneof->field(j);
printer->Print(
" case $field_number$: return $field_name$;\n",
"field_number",
@@ -467,7 +467,7 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(
SortFieldsByNumber(descriptor_));
- vector<const Descriptor::ExtensionRange*> sorted_extensions;
+ std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i));
}
@@ -523,8 +523,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
}
if (PreserveUnknownFields(descriptor_)) {
- printer->Print(
- "unknownFields.writeTo(output);\n");
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "unknownFields.writeAsMessageSetTo(output);\n");
+ } else {
+ printer->Print(
+ "unknownFields.writeTo(output);\n");
+ }
}
printer->Outdent();
@@ -553,8 +558,13 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
}
if (PreserveUnknownFields(descriptor_)) {
- printer->Print(
- "size += unknownFields.getSerializedSize();\n");
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "size += unknownFields.getSerializedSizeAsMessageSet();\n");
+ } else {
+ printer->Print(
+ "size += unknownFields.getSerializedSize();\n");
+ }
}
printer->Outdent();
@@ -939,14 +949,26 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
if (PreserveUnknownFields(descriptor_)) {
if (descriptor_->extension_range_count() > 0) {
- printer->Print(
- "default: {\n"
- " if (!parseUnknownField(getDefaultInstanceForType(),\n"
- " input, extensionRegistry, tag)) {\n"
- " done = true;\n" // it's an endgroup tag
- " }\n"
- " break;\n"
- "}\n");
+ if (descriptor_->options().message_set_wire_format()) {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownFieldAsMessageSet(\n"
+ " getDefaultInstanceForType(), input, extensionRegistry,\n"
+ " tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ } else {
+ printer->Print(
+ "default: {\n"
+ " if (!parseUnknownField(getDefaultInstanceForType(),\n"
+ " input, extensionRegistry, tag)) {\n"
+ " done = true;\n" // it's an endgroup tag
+ " }\n"
+ " break;\n"
+ "}\n");
+ }
} else {
printer->Print(
"default: {\n"
@@ -975,7 +997,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(tag));
+ "tag", SimpleItoa(static_cast<int32>(tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCode(printer);
@@ -992,7 +1014,7 @@ void ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(
WireFormatLite::WIRETYPE_LENGTH_DELIMITED);
printer->Print(
"case $tag$: {\n",
- "tag", SimpleItoa(packed_tag));
+ "tag", SimpleItoa(static_cast<int32>(packed_tag)));
printer->Indent();
field_generators_.get(field).GenerateParsingCodeFromPacked(printer);
diff --git a/src/google/protobuf/compiler/java/java_name_resolver.h b/src/google/protobuf/compiler/java/java_name_resolver.h
index 570d8d8f..28b049d1 100644
--- a/src/google/protobuf/compiler/java/java_name_resolver.h
+++ b/src/google/protobuf/compiler/java/java_name_resolver.h
@@ -112,7 +112,7 @@ class ClassNameResolver {
const FileDescriptor* file,
bool immutable);
// Caches the result to provide better performance.
- map<const FileDescriptor*, string> file_immutable_outer_class_names_;
+ std::map<const FileDescriptor*, string> file_immutable_outer_class_names_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);
};
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc
index 877baf0a..fa1047e8 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field.cc
@@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["type"] = PrimitiveTypeName(GetJavaType(descriptor));
@@ -75,7 +75,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
"" : ("= " + ImmutableDefaultValue(descriptor, name_resolver));
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
if (IsReferenceType(GetJavaType(descriptor))) {
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.h b/src/google/protobuf/compiler/java/java_primitive_field.h
index d0cd12d9..7ac9bbfb 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field.h
@@ -82,7 +82,7 @@ class ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -143,7 +143,7 @@ class RepeatedImmutablePrimitiveFieldGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index ad2db30c..ac39f4cf 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -61,7 +61,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
JavaType javaType = GetJavaType(descriptor);
(*variables)["type"] = PrimitiveTypeName(javaType);
@@ -70,7 +70,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["default"] = ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] =
GetCapitalizedType(descriptor, /* immutable = */ true);
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.h b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
index 6cfbbb98..dc59f0cf 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.h
@@ -84,7 +84,7 @@ class ImmutablePrimitiveFieldLiteGenerator
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -146,7 +146,7 @@ class RepeatedImmutablePrimitiveFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_service.cc b/src/google/protobuf/compiler/java/java_service.cc
index cfa8295d..988e1942 100644
--- a/src/google/protobuf/compiler/java/java_service.cc
+++ b/src/google/protobuf/compiler/java/java_service.cc
@@ -208,7 +208,7 @@ void ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(
@@ -255,7 +255,7 @@ void ImmutableServiceGenerator::GenerateCallBlockingMethod(
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(
@@ -301,7 +301,7 @@ void ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,
for (int i = 0; i < descriptor_->method_count(); i++) {
const MethodDescriptor* method = descriptor_->method(i);
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["type"] = name_resolver_->GetImmutableClassName(
(which == REQUEST) ? method->input_type() : method->output_type());
@@ -353,7 +353,7 @@ void ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
@@ -417,7 +417,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
printer->Print(" {\n");
printer->Indent();
- map<string, string> vars;
+ std::map<string, string> vars;
vars["index"] = SimpleItoa(i);
vars["output"] = GetOutput(method);
printer->Print(vars,
@@ -440,7 +440,7 @@ void ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {
void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer,
const MethodDescriptor* method,
IsAbstract is_abstract) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["name"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
@@ -455,7 +455,7 @@ void ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer,
void ImmutableServiceGenerator::GenerateBlockingMethodSignature(
io::Printer* printer,
const MethodDescriptor* method) {
- map<string, string> vars;
+ std::map<string, string> vars;
vars["method"] = UnderscoresToCamelCase(method);
vars["input"] = name_resolver_->GetImmutableClassName(method->input_type());
vars["output"] = GetOutput(method);
diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc
index 18bf1f51..5fe68245 100644
--- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc
+++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc
@@ -59,8 +59,8 @@ SharedCodeGenerator::~SharedCodeGenerator() {
}
void SharedCodeGenerator::Generate(GeneratorContext* context,
- vector<string>* file_list,
- vector<string>* annotation_file_list) {
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_file_list) {
string java_package = FileJavaPackage(file_);
string package_dir = JavaPackageToDir(java_package);
@@ -179,7 +179,7 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
// -----------------------------------------------------------------
// Find out all dependencies.
- vector<pair<string, string> > dependencies;
+ std::vector<std::pair<string, string> > dependencies;
for (int i = 0; i < file_->dependency_count(); i++) {
if (ShouldIncludeDependency(file_->dependency(i))) {
string filename = file_->dependency(i)->name();
diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.h b/src/google/protobuf/compiler/java/java_shared_code_generator.h
index 7e1e1f17..c8ead47a 100644
--- a/src/google/protobuf/compiler/java/java_shared_code_generator.h
+++ b/src/google/protobuf/compiler/java/java_shared_code_generator.h
@@ -70,8 +70,9 @@ class SharedCodeGenerator {
SharedCodeGenerator(const FileDescriptor* file, const Options& options);
~SharedCodeGenerator();
- void Generate(GeneratorContext* generator_context, vector<string>* file_list,
- vector<string>* annotation_file_list);
+ void Generate(GeneratorContext* generator_context,
+ std::vector<string>* file_list,
+ std::vector<string>* annotation_file_list);
void GenerateDescriptors(io::Printer* printer);
diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc
index ff1865b1..5c2900ce 100644
--- a/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/src/google/protobuf/compiler/java/java_string_field.cc
@@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] = "com.google.protobuf.LazyStringArrayList.EMPTY";
@@ -71,7 +71,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["default_init"] =
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "String";
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
diff --git a/src/google/protobuf/compiler/java/java_string_field.h b/src/google/protobuf/compiler/java/java_string_field.h
index a3b57351..0f7c705b 100644
--- a/src/google/protobuf/compiler/java/java_string_field.h
+++ b/src/google/protobuf/compiler/java/java_string_field.h
@@ -83,7 +83,7 @@ class ImmutableStringFieldGenerator : public ImmutableFieldGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -142,7 +142,7 @@ class RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc
index 0b92c021..4d2dcad8 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -62,7 +62,7 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
int builderBitIndex,
const FieldGeneratorInfo* info,
ClassNameResolver* name_resolver,
- map<string, string>* variables) {
+ std::map<string, string>* variables) {
SetCommonFieldVariables(descriptor, info, variables);
(*variables)["empty_list"] =
@@ -72,7 +72,8 @@ void SetPrimitiveVariables(const FieldDescriptor* descriptor,
(*variables)["default_init"] =
"= " + ImmutableDefaultValue(descriptor, name_resolver);
(*variables)["capitalized_type"] = "String";
- (*variables)["tag"] = SimpleItoa(WireFormat::MakeTag(descriptor));
+ (*variables)["tag"] =
+ SimpleItoa(static_cast<int32>(WireFormat::MakeTag(descriptor)));
(*variables)["tag_size"] = SimpleItoa(
WireFormat::TagSize(descriptor->number(), GetType(descriptor)));
(*variables)["null_check"] =
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.h b/src/google/protobuf/compiler/java/java_string_field_lite.h
index 4148aa4d..80496c87 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.h
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.h
@@ -82,7 +82,7 @@ class ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {
protected:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;
@@ -140,7 +140,7 @@ class RepeatedImmutableStringFieldLiteGenerator
private:
const FieldDescriptor* descriptor_;
- map<string, string> variables_;
+ std::map<string, string> variables_;
const int messageBitIndex_;
const int builderBitIndex_;
Context* context_;