Merge pull request #1392 from anandolee/master
Sync the manually integrate changes in google3/third_party
This commit is contained in:
commit
09292d5759
@ -151,6 +151,10 @@ void EnumGenerator::Generate(io::Printer* printer) {
|
||||
"}\n"
|
||||
"\n"
|
||||
"public static $classname$ valueOf(int value) {\n"
|
||||
" return forNumber(value);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"public static $classname$ forNumber(int value) {\n"
|
||||
" switch (value) {\n",
|
||||
"classname", descriptor_->name());
|
||||
printer->Indent();
|
||||
@ -178,7 +182,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
|
||||
" $classname$> internalValueMap =\n"
|
||||
" new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
|
||||
" public $classname$ findValueByNumber(int number) {\n"
|
||||
" return $classname$.valueOf(number);\n"
|
||||
" return $classname$.forNumber(number);\n"
|
||||
" }\n"
|
||||
" };\n"
|
||||
"\n",
|
||||
|
@ -198,7 +198,7 @@ GenerateMembers(io::Printer* printer) const {
|
||||
WriteFieldDocComment(printer, descriptor_);
|
||||
printer->Print(variables_,
|
||||
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
||||
" $type$ result = $type$.valueOf($name$_);\n"
|
||||
" $type$ result = $type$.forNumber($name$_);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
"}\n");
|
||||
}
|
||||
@ -231,7 +231,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
|
||||
WriteFieldDocComment(printer, descriptor_);
|
||||
printer->Print(variables_,
|
||||
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
||||
" $type$ result = $type$.valueOf($name$_);\n"
|
||||
" $type$ result = $type$.forNumber($name$_);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
"}\n");
|
||||
WriteFieldDocComment(printer, descriptor_);
|
||||
@ -311,7 +311,7 @@ GenerateParsingCode(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"int rawValue = input.readEnum();\n"
|
||||
"$type$ value = $type$.valueOf(rawValue);\n"
|
||||
"$type$ value = $type$.forNumber(rawValue);\n"
|
||||
"if (value == null) {\n");
|
||||
if (PreserveUnknownFields(descriptor_->containing_type())) {
|
||||
printer->Print(variables_,
|
||||
@ -405,7 +405,7 @@ GenerateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
||||
" if ($has_oneof_case_message$) {\n"
|
||||
" $type$ result = $type$.valueOf((java.lang.Integer) $oneof_name$_);\n"
|
||||
" $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
" }\n"
|
||||
" return $default$;\n"
|
||||
@ -443,7 +443,7 @@ GenerateBuilderMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
||||
" if ($has_oneof_case_message$) {\n"
|
||||
" $type$ result = $type$.valueOf((java.lang.Integer) $oneof_name$_);\n"
|
||||
" $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
" }\n"
|
||||
" return $default$;\n"
|
||||
@ -500,7 +500,7 @@ GenerateParsingCode(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"int rawValue = input.readEnum();\n"
|
||||
"$type$ value = $type$.valueOf(rawValue);\n"
|
||||
"$type$ value = $type$.forNumber(rawValue);\n"
|
||||
"if (value == null) {\n");
|
||||
if (PreserveUnknownFields(descriptor_->containing_type())) {
|
||||
printer->Print(variables_,
|
||||
@ -613,7 +613,7 @@ GenerateMembers(io::Printer* printer) const {
|
||||
" new com.google.protobuf.Internal.ListAdapter.Converter<\n"
|
||||
" java.lang.Integer, $type$>() {\n"
|
||||
" public $type$ convert(java.lang.Integer from) {\n"
|
||||
" $type$ result = $type$.valueOf(from);\n"
|
||||
" $type$ result = $type$.forNumber(from);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
" }\n"
|
||||
" };\n");
|
||||
@ -846,7 +846,7 @@ GenerateParsingCode(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"int rawValue = input.readEnum();\n"
|
||||
"$type$ value = $type$.valueOf(rawValue);\n"
|
||||
"$type$ value = $type$.forNumber(rawValue);\n"
|
||||
"if (value == null) {\n");
|
||||
if (PreserveUnknownFields(descriptor_->containing_type())) {
|
||||
printer->Print(variables_,
|
||||
|
@ -179,7 +179,7 @@ GenerateMembers(io::Printer* printer) const {
|
||||
WriteFieldDocComment(printer, descriptor_);
|
||||
printer->Print(variables_,
|
||||
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
||||
" $type$ result = $type$.valueOf($name$_);\n"
|
||||
" $type$ result = $type$.forNumber($name$_);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
"}\n");
|
||||
|
||||
@ -295,7 +295,7 @@ GenerateParsingCode(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"int rawValue = input.readEnum();\n"
|
||||
"$type$ value = $type$.valueOf(rawValue);\n"
|
||||
"$type$ value = $type$.forNumber(rawValue);\n"
|
||||
"if (value == null) {\n");
|
||||
if (PreserveUnknownFields(descriptor_->containing_type())) {
|
||||
printer->Print(variables_,
|
||||
@ -389,7 +389,7 @@ GenerateMembers(io::Printer* printer) const {
|
||||
printer->Print(variables_,
|
||||
"$deprecation$public $type$ get$capitalized_name$() {\n"
|
||||
" if ($has_oneof_case_message$) {\n"
|
||||
" $type$ result = $type$.valueOf((java.lang.Integer) $oneof_name$_);\n"
|
||||
" $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
" }\n"
|
||||
" return $default$;\n"
|
||||
@ -488,7 +488,7 @@ GenerateParsingCode(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"int rawValue = input.readEnum();\n"
|
||||
"$type$ value = $type$.valueOf(rawValue);\n"
|
||||
"$type$ value = $type$.forNumber(rawValue);\n"
|
||||
"if (value == null) {\n");
|
||||
if (PreserveUnknownFields(descriptor_->containing_type())) {
|
||||
printer->Print(variables_,
|
||||
@ -602,7 +602,7 @@ GenerateMembers(io::Printer* printer) const {
|
||||
" new com.google.protobuf.Internal.ListAdapter.Converter<\n"
|
||||
" java.lang.Integer, $type$>() {\n"
|
||||
" public $type$ convert(java.lang.Integer from) {\n"
|
||||
" $type$ result = $type$.valueOf(from);\n"
|
||||
" $type$ result = $type$.forNumber(from);\n"
|
||||
" return result == null ? $unknown$ : result;\n"
|
||||
" }\n"
|
||||
" };\n");
|
||||
@ -844,7 +844,7 @@ GenerateParsingCode(io::Printer* printer) const {
|
||||
} else {
|
||||
printer->Print(variables_,
|
||||
"int rawValue = input.readEnum();\n"
|
||||
"$type$ value = $type$.valueOf(rawValue);\n"
|
||||
"$type$ value = $type$.forNumber(rawValue);\n"
|
||||
"if (value == null) {\n");
|
||||
if (PreserveUnknownFields(descriptor_->containing_type())) {
|
||||
printer->Print(variables_,
|
||||
|
@ -142,6 +142,10 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
|
||||
"}\n"
|
||||
"\n"
|
||||
"public static $classname$ valueOf(int value) {\n"
|
||||
" return forNumber(value);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"public static $classname$ forNumber(int value) {\n"
|
||||
" switch (value) {\n",
|
||||
"classname", descriptor_->name());
|
||||
printer->Indent();
|
||||
@ -169,7 +173,7 @@ void EnumLiteGenerator::Generate(io::Printer* printer) {
|
||||
" $classname$> internalValueMap =\n"
|
||||
" new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\n"
|
||||
" public $classname$ findValueByNumber(int number) {\n"
|
||||
" return $classname$.valueOf(number);\n"
|
||||
" return $classname$.forNumber(number);\n"
|
||||
" }\n"
|
||||
" };\n"
|
||||
"\n",
|
||||
|
@ -414,6 +414,10 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
|
||||
"}\n");
|
||||
printer->Print(vars,
|
||||
"public static $oneof_capitalized_name$Case valueOf(int value) {\n"
|
||||
" return forNumber(value);\n"
|
||||
"}\n"
|
||||
"\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);
|
||||
@ -440,7 +444,7 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
|
||||
printer->Print(vars,
|
||||
"public $oneof_capitalized_name$Case\n"
|
||||
"get$oneof_capitalized_name$Case() {\n"
|
||||
" return $oneof_capitalized_name$Case.valueOf(\n"
|
||||
" return $oneof_capitalized_name$Case.forNumber(\n"
|
||||
" $oneof_name$Case_);\n"
|
||||
"}\n"
|
||||
"\n");
|
||||
|
@ -134,7 +134,7 @@ Generate(io::Printer* printer) {
|
||||
printer->Print(vars,
|
||||
"public $oneof_capitalized_name$Case\n"
|
||||
" get$oneof_capitalized_name$Case() {\n"
|
||||
" return $oneof_capitalized_name$Case.valueOf(\n"
|
||||
" return $oneof_capitalized_name$Case.forNumber(\n"
|
||||
" $oneof_name$Case_);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
@ -265,6 +265,10 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
|
||||
"}\n");
|
||||
printer->Print(vars,
|
||||
"public static $oneof_capitalized_name$Case valueOf(int value) {\n"
|
||||
" return forNumber(value);\n"
|
||||
"}\n"
|
||||
"\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);
|
||||
@ -291,7 +295,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
|
||||
printer->Print(vars,
|
||||
"public $oneof_capitalized_name$Case\n"
|
||||
"get$oneof_capitalized_name$Case() {\n"
|
||||
" return $oneof_capitalized_name$Case.valueOf(\n"
|
||||
" return $oneof_capitalized_name$Case.forNumber(\n"
|
||||
" $oneof_name$Case_);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
|
@ -253,6 +253,12 @@ class DynamicMessage : public Message {
|
||||
DynamicMessage(const TypeInfo* type_info);
|
||||
~DynamicMessage();
|
||||
|
||||
#ifndef _MSC_VER
|
||||
void operator delete(void *p) {
|
||||
::operator delete(p); // non-sized deallocation
|
||||
}
|
||||
#endif
|
||||
|
||||
// Called on the prototype after construction to initialize message fields.
|
||||
void CrossLinkPrototypes();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user