aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD11
-rw-r--r--Makefile.am1
-rw-r--r--cmake/extract_includes.bat.in1
-rw-r--r--conformance/failure_list_ruby.txt2
-rw-r--r--csharp/src/AddressBook/AddPerson.cs6
-rw-r--r--csharp/src/AddressBook/Addressbook.cs16
-rw-r--r--csharp/src/AddressBook/ListPeople.cs6
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Conformance.cs50
-rw-r--r--csharp/src/Google.Protobuf.Conformance/Program.cs4
-rw-r--r--csharp/src/Google.Protobuf.Test/FieldCodecTest.cs2
-rw-r--r--csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs32
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs10
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonParserTest.cs14
-rw-r--r--csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs2
-rw-r--r--csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs4
-rw-r--r--csharp/src/Google.Protobuf.Test/SampleMessages.cs16
-rw-r--r--csharp/src/Google.Protobuf.Test/TestCornerCases.cs4
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs8
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs8
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs32
-rw-r--r--csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs94
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.csproj1
-rw-r--r--csharp/src/Google.Protobuf/Google.Protobuf.nuspec2
-rw-r--r--csharp/src/Google.Protobuf/JsonFormatter.cs45
-rw-r--r--csharp/src/Google.Protobuf/Reflection/Descriptor.cs235
-rw-r--r--csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs38
-rw-r--r--csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs58
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Any.cs43
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Api.cs20
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs7
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs7
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs27
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs13
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs7
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Type.cs90
-rw-r--r--csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs8
-rw-r--r--js/gulpfile.js6
-rw-r--r--js/package.json2
-rwxr-xr-xobjectivec/DevTools/full_mac_build.sh40
-rw-r--r--objectivec/GPBCodedOutputStream.h30
-rwxr-xr-xobjectivec/generate_well_known_types.sh29
-rw-r--r--objectivec/google/protobuf/Any.pbobjc.h41
-rw-r--r--objectivec/google/protobuf/Any.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Api.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/Api.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Duration.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/Duration.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Empty.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/Empty.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/FieldMask.pbobjc.h32
-rw-r--r--objectivec/google/protobuf/FieldMask.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/SourceContext.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/SourceContext.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Struct.pbobjc.h7
-rw-r--r--objectivec/google/protobuf/Struct.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Timestamp.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/Timestamp.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Type.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/Type.pbobjc.m5
-rw-r--r--objectivec/google/protobuf/Wrappers.pbobjc.h5
-rw-r--r--objectivec/google/protobuf/Wrappers.pbobjc.m5
-rw-r--r--ruby/README.md28
-rw-r--r--ruby/ext/google/protobuf_c/defs.c5
-rw-r--r--ruby/ext/google/protobuf_c/encode_decode.c45
-rw-r--r--ruby/ext/google/protobuf_c/message.c2
-rw-r--r--ruby/ext/google/protobuf_c/protobuf.h3
-rw-r--r--ruby/ext/google/protobuf_c/upb.c1150
-rw-r--r--ruby/ext/google/protobuf_c/upb.h1818
-rw-r--r--ruby/tests/basic.rb5
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_enum.cc20
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_field_base.cc4
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_generator.cc3
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc20
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.cc98
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_helpers.h5
-rw-r--r--src/google/protobuf/compiler/csharp/csharp_options.h9
-rw-r--r--src/google/protobuf/stubs/stringprintf.cc1
-rw-r--r--src/google/protobuf/util/field_mask_util_test.cc2
78 files changed, 2564 insertions, 1850 deletions
diff --git a/BUILD b/BUILD
index 09d917b7..ab147e5c 100644
--- a/BUILD
+++ b/BUILD
@@ -266,6 +266,7 @@ cc_library(
"src/google/protobuf/compiler/java/java_enum_field_lite.cc",
"src/google/protobuf/compiler/java/java_enum_lite.cc",
"src/google/protobuf/compiler/java/java_extension.cc",
+ "src/google/protobuf/compiler/java/java_extension_lite.cc",
"src/google/protobuf/compiler/java/java_field.cc",
"src/google/protobuf/compiler/java/java_file.cc",
"src/google/protobuf/compiler/java/java_generator.cc",
@@ -438,6 +439,7 @@ cc_test(
"src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
"src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
"src/google/protobuf/compiler/cpp/cpp_unittest.cc",
+ "src/google/protobuf/compiler/cpp/metadata_test.cc",
"src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
"src/google/protobuf/compiler/importer_unittest.cc",
"src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
@@ -539,9 +541,9 @@ java_library(
"java/util/src/main/java/com/google/protobuf/util/*.java",
]),
deps = [
- "protobuf_java",
- "//external:gson",
- "//external:guava",
+ "protobuf_java",
+ "//external:gson",
+ "//external:guava",
],
visibility = ["//visibility:public"],
)
@@ -562,6 +564,7 @@ py_library(
"python/google/protobuf/internal/test_util.py",
],
),
+ srcs_version = "PY2AND3",
imports = ["python"],
)
@@ -646,6 +649,7 @@ py_proto_library(
include = "src",
default_runtime = "",
protoc = ":protoc",
+ srcs_version = "PY2AND3",
deps = [":protobuf_python"],
)
@@ -658,6 +662,7 @@ py_proto_library(
include = "python",
default_runtime = ":protobuf_python",
protoc = ":protoc",
+ srcs_version = "PY2AND3",
deps = [":python_common_test_protos"],
)
diff --git a/Makefile.am b/Makefile.am
index cadc7d8d..a7a1f413 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -154,6 +154,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs \
csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs \
csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs \
+ csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs \
csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs \
csharp/src/Google.Protobuf/Reflection/PartialClasses.cs \
csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs \
diff --git a/cmake/extract_includes.bat.in b/cmake/extract_includes.bat.in
index c76973c9..b593e0c9 100644
--- a/cmake/extract_includes.bat.in
+++ b/cmake/extract_includes.bat.in
@@ -23,7 +23,6 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h include\google\protobuf\compiler\csharp\csharp_names.h
-copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_options.h include\google\protobuf\compiler\csharp\csharp_options.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h
diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt
index ade0ff4c..7c12da06 100644
--- a/conformance/failure_list_ruby.txt
+++ b/conformance/failure_list_ruby.txt
@@ -80,7 +80,6 @@ JsonInput.Int32FieldMaxFloatValue.JsonOutput
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
JsonInput.Int32FieldMinFloatValue.JsonOutput
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
-JsonInput.Int32FieldMinValue.JsonOutput
JsonInput.Int32FieldStringValue.JsonOutput
JsonInput.Int32FieldStringValue.ProtobufOutput
JsonInput.Int32FieldStringValueEscaped.JsonOutput
@@ -125,7 +124,6 @@ JsonInput.OptionalUint64Wrapper.ProtobufOutput
JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
JsonInput.OriginalProtoFieldName.JsonOutput
-JsonInput.OriginalProtoFieldName.ProtobufOutput
JsonInput.PrimitiveRepeatedField.JsonOutput
JsonInput.PrimitiveRepeatedField.ProtobufOutput
JsonInput.RepeatedBoolWrapper.JsonOutput
diff --git a/csharp/src/AddressBook/AddPerson.cs b/csharp/src/AddressBook/AddPerson.cs
index 6eeb9f6e..62d1788d 100644
--- a/csharp/src/AddressBook/AddPerson.cs
+++ b/csharp/src/AddressBook/AddPerson.cs
@@ -73,13 +73,13 @@ namespace Google.Protobuf.Examples.AddressBook
switch (type)
{
case "mobile":
- phoneNumber.Type = Person.Types.PhoneType.MOBILE;
+ phoneNumber.Type = Person.Types.PhoneType.Mobile;
break;
case "home":
- phoneNumber.Type = Person.Types.PhoneType.HOME;
+ phoneNumber.Type = Person.Types.PhoneType.Home;
break;
case "work":
- phoneNumber.Type = Person.Types.PhoneType.WORK;
+ phoneNumber.Type = Person.Types.PhoneType.Work;
break;
default:
output.Write("Unknown phone type. Using default.");
diff --git a/csharp/src/AddressBook/Addressbook.cs b/csharp/src/AddressBook/Addressbook.cs
index 166dd49a..362e1cb6 100644
--- a/csharp/src/AddressBook/Addressbook.cs
+++ b/csharp/src/AddressBook/Addressbook.cs
@@ -228,9 +228,9 @@ namespace Google.Protobuf.Examples.AddressBook {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Types {
public enum PhoneType {
- MOBILE = 0,
- HOME = 1,
- WORK = 2,
+ [pbr::OriginalName("MOBILE")] Mobile = 0,
+ [pbr::OriginalName("HOME")] Home = 1,
+ [pbr::OriginalName("WORK")] Work = 2,
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -273,7 +273,7 @@ namespace Google.Protobuf.Examples.AddressBook {
/// <summary>Field number for the "type" field.</summary>
public const int TypeFieldNumber = 2;
- private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE;
+ private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = 0;
public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
get { return type_; }
set {
@@ -300,7 +300,7 @@ namespace Google.Protobuf.Examples.AddressBook {
public override int GetHashCode() {
int hash = 1;
if (Number.Length != 0) hash ^= Number.GetHashCode();
- if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) hash ^= Type.GetHashCode();
+ if (Type != 0) hash ^= Type.GetHashCode();
return hash;
}
@@ -313,7 +313,7 @@ namespace Google.Protobuf.Examples.AddressBook {
output.WriteRawTag(10);
output.WriteString(Number);
}
- if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
+ if (Type != 0) {
output.WriteRawTag(16);
output.WriteEnum((int) Type);
}
@@ -324,7 +324,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (Number.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(Number);
}
- if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
+ if (Type != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
}
return size;
@@ -337,7 +337,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if (other.Number.Length != 0) {
Number = other.Number;
}
- if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
+ if (other.Type != 0) {
Type = other.Type;
}
}
diff --git a/csharp/src/AddressBook/ListPeople.cs b/csharp/src/AddressBook/ListPeople.cs
index 3979430f..3758c1bc 100644
--- a/csharp/src/AddressBook/ListPeople.cs
+++ b/csharp/src/AddressBook/ListPeople.cs
@@ -55,13 +55,13 @@ namespace Google.Protobuf.Examples.AddressBook
{
switch (phoneNumber.Type)
{
- case Person.Types.PhoneType.MOBILE:
+ case Person.Types.PhoneType.Mobile:
Console.Write(" Mobile phone #: ");
break;
- case Person.Types.PhoneType.HOME:
+ case Person.Types.PhoneType.Home:
Console.Write(" Home phone #: ");
break;
- case Person.Types.PhoneType.WORK:
+ case Person.Types.PhoneType.Work:
Console.Write(" Work phone #: ");
break;
}
diff --git a/csharp/src/Google.Protobuf.Conformance/Conformance.cs b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
index 7d85d28c..1674a673 100644
--- a/csharp/src/Google.Protobuf.Conformance/Conformance.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Conformance.cs
@@ -199,15 +199,15 @@ namespace Conformance {
}
#region Enums
public enum WireFormat {
- UNSPECIFIED = 0,
- PROTOBUF = 1,
- JSON = 2,
+ [pbr::OriginalName("UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("PROTOBUF")] Protobuf = 1,
+ [pbr::OriginalName("JSON")] Json = 2,
}
public enum ForeignEnum {
- FOREIGN_FOO = 0,
- FOREIGN_BAR = 1,
- FOREIGN_BAZ = 2,
+ [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 0,
+ [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 1,
+ [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 2,
}
#endregion
@@ -278,7 +278,7 @@ namespace Conformance {
/// <summary>Field number for the "requested_output_format" field.</summary>
public const int RequestedOutputFormatFieldNumber = 3;
- private global::Conformance.WireFormat requestedOutputFormat_ = global::Conformance.WireFormat.UNSPECIFIED;
+ private global::Conformance.WireFormat requestedOutputFormat_ = 0;
/// <summary>
/// Which format should the testee serialize its message to?
/// </summary>
@@ -328,7 +328,7 @@ namespace Conformance {
int hash = 1;
if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode();
if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
- if (RequestedOutputFormat != global::Conformance.WireFormat.UNSPECIFIED) hash ^= RequestedOutputFormat.GetHashCode();
+ if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode();
hash ^= (int) payloadCase_;
return hash;
}
@@ -346,7 +346,7 @@ namespace Conformance {
output.WriteRawTag(18);
output.WriteString(JsonPayload);
}
- if (RequestedOutputFormat != global::Conformance.WireFormat.UNSPECIFIED) {
+ if (RequestedOutputFormat != 0) {
output.WriteRawTag(24);
output.WriteEnum((int) RequestedOutputFormat);
}
@@ -360,7 +360,7 @@ namespace Conformance {
if (payloadCase_ == PayloadOneofCase.JsonPayload) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(JsonPayload);
}
- if (RequestedOutputFormat != global::Conformance.WireFormat.UNSPECIFIED) {
+ if (RequestedOutputFormat != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) RequestedOutputFormat);
}
return size;
@@ -370,7 +370,7 @@ namespace Conformance {
if (other == null) {
return;
}
- if (other.RequestedOutputFormat != global::Conformance.WireFormat.UNSPECIFIED) {
+ if (other.RequestedOutputFormat != 0) {
RequestedOutputFormat = other.RequestedOutputFormat;
}
switch (other.PayloadCase) {
@@ -1044,7 +1044,7 @@ namespace Conformance {
/// <summary>Field number for the "optional_nested_enum" field.</summary>
public const int OptionalNestedEnumFieldNumber = 21;
- private global::Conformance.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = global::Conformance.TestAllTypes.Types.NestedEnum.FOO;
+ private global::Conformance.TestAllTypes.Types.NestedEnum optionalNestedEnum_ = 0;
public global::Conformance.TestAllTypes.Types.NestedEnum OptionalNestedEnum {
get { return optionalNestedEnum_; }
set {
@@ -1054,7 +1054,7 @@ namespace Conformance {
/// <summary>Field number for the "optional_foreign_enum" field.</summary>
public const int OptionalForeignEnumFieldNumber = 22;
- private global::Conformance.ForeignEnum optionalForeignEnum_ = global::Conformance.ForeignEnum.FOREIGN_FOO;
+ private global::Conformance.ForeignEnum optionalForeignEnum_ = 0;
public global::Conformance.ForeignEnum OptionalForeignEnum {
get { return optionalForeignEnum_; }
set {
@@ -2079,8 +2079,8 @@ namespace Conformance {
if (OptionalBytes.Length != 0) hash ^= OptionalBytes.GetHashCode();
if (optionalNestedMessage_ != null) hash ^= OptionalNestedMessage.GetHashCode();
if (optionalForeignMessage_ != null) hash ^= OptionalForeignMessage.GetHashCode();
- if (OptionalNestedEnum != global::Conformance.TestAllTypes.Types.NestedEnum.FOO) hash ^= OptionalNestedEnum.GetHashCode();
- if (OptionalForeignEnum != global::Conformance.ForeignEnum.FOREIGN_FOO) hash ^= OptionalForeignEnum.GetHashCode();
+ if (OptionalNestedEnum != 0) hash ^= OptionalNestedEnum.GetHashCode();
+ if (OptionalForeignEnum != 0) hash ^= OptionalForeignEnum.GetHashCode();
if (OptionalStringPiece.Length != 0) hash ^= OptionalStringPiece.GetHashCode();
if (OptionalCord.Length != 0) hash ^= OptionalCord.GetHashCode();
if (recursiveMessage_ != null) hash ^= RecursiveMessage.GetHashCode();
@@ -2247,11 +2247,11 @@ namespace Conformance {
output.WriteRawTag(154, 1);
output.WriteMessage(OptionalForeignMessage);
}
- if (OptionalNestedEnum != global::Conformance.TestAllTypes.Types.NestedEnum.FOO) {
+ if (OptionalNestedEnum != 0) {
output.WriteRawTag(168, 1);
output.WriteEnum((int) OptionalNestedEnum);
}
- if (OptionalForeignEnum != global::Conformance.ForeignEnum.FOREIGN_FOO) {
+ if (OptionalForeignEnum != 0) {
output.WriteRawTag(176, 1);
output.WriteEnum((int) OptionalForeignEnum);
}
@@ -2492,10 +2492,10 @@ namespace Conformance {
if (optionalForeignMessage_ != null) {
size += 2 + pb::CodedOutputStream.ComputeMessageSize(OptionalForeignMessage);
}
- if (OptionalNestedEnum != global::Conformance.TestAllTypes.Types.NestedEnum.FOO) {
+ if (OptionalNestedEnum != 0) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalNestedEnum);
}
- if (OptionalForeignEnum != global::Conformance.ForeignEnum.FOREIGN_FOO) {
+ if (OptionalForeignEnum != 0) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) OptionalForeignEnum);
}
if (OptionalStringPiece.Length != 0) {
@@ -2719,10 +2719,10 @@ namespace Conformance {
}
OptionalForeignMessage.MergeFrom(other.OptionalForeignMessage);
}
- if (other.OptionalNestedEnum != global::Conformance.TestAllTypes.Types.NestedEnum.FOO) {
+ if (other.OptionalNestedEnum != 0) {
OptionalNestedEnum = other.OptionalNestedEnum;
}
- if (other.OptionalForeignEnum != global::Conformance.ForeignEnum.FOREIGN_FOO) {
+ if (other.OptionalForeignEnum != 0) {
OptionalForeignEnum = other.OptionalForeignEnum;
}
if (other.OptionalStringPiece.Length != 0) {
@@ -3448,13 +3448,13 @@ namespace Conformance {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Types {
public enum NestedEnum {
- FOO = 0,
- BAR = 1,
- BAZ = 2,
+ [pbr::OriginalName("FOO")] Foo = 0,
+ [pbr::OriginalName("BAR")] Bar = 1,
+ [pbr::OriginalName("BAZ")] Baz = 2,
/// <summary>
/// Intentionally negative.
/// </summary>
- NEG = -1,
+ [pbr::OriginalName("NEG")] Neg = -1,
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
diff --git a/csharp/src/Google.Protobuf.Conformance/Program.cs b/csharp/src/Google.Protobuf.Conformance/Program.cs
index f3f7e295..19827c48 100644
--- a/csharp/src/Google.Protobuf.Conformance/Program.cs
+++ b/csharp/src/Google.Protobuf.Conformance/Program.cs
@@ -109,10 +109,10 @@ namespace Google.Protobuf.Conformance
{
switch (request.RequestedOutputFormat)
{
- case global::Conformance.WireFormat.JSON:
+ case global::Conformance.WireFormat.Json:
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, typeRegistry));
return new ConformanceResponse { JsonPayload = formatter.Format(message) };
- case global::Conformance.WireFormat.PROTOBUF:
+ case global::Conformance.WireFormat.Protobuf:
return new ConformanceResponse { ProtobufPayload = message.ToByteString() };
default:
throw new Exception("Unsupported request output format: " + request.PayloadCase);
diff --git a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
index 38ba227f..c616470e 100644
--- a/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
+++ b/csharp/src/Google.Protobuf.Test/FieldCodecTest.cs
@@ -58,7 +58,7 @@ namespace Google.Protobuf
new FieldCodecTestData<float>(FieldCodec.ForFloat(100), 1234.5f, "Float"),
new FieldCodecTestData<double>(FieldCodec.ForDouble(100), 1234567890.5d, "Double"),
new FieldCodecTestData<ForeignEnum>(
- FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.FOREIGN_BAZ, "Enum"),
+ FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.ForeignBaz, "Enum"),
new FieldCodecTestData<ForeignMessage>(
FieldCodec.ForMessage(100, ForeignMessage.Parser), new ForeignMessage { C = 10 }, "Message"),
};
diff --git a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
index 5c2a052b..8b153d69 100644
--- a/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
+++ b/csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs
@@ -66,13 +66,13 @@ namespace Google.Protobuf
Assert.AreEqual(0, message.SingleFixed32);
Assert.AreEqual(0L, message.SingleFixed64);
Assert.AreEqual(0.0f, message.SingleFloat);
- Assert.AreEqual(ForeignEnum.FOREIGN_UNSPECIFIED, message.SingleForeignEnum);
+ Assert.AreEqual(ForeignEnum.ForeignUnspecified, message.SingleForeignEnum);
Assert.IsNull(message.SingleForeignMessage);
- Assert.AreEqual(ImportEnum.IMPORT_ENUM_UNSPECIFIED, message.SingleImportEnum);
+ Assert.AreEqual(ImportEnum.Unspecified, message.SingleImportEnum);
Assert.IsNull(message.SingleImportMessage);
Assert.AreEqual(0, message.SingleInt32);
Assert.AreEqual(0L, message.SingleInt64);
- Assert.AreEqual(TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED, message.SingleNestedEnum);
+ Assert.AreEqual(TestAllTypes.Types.NestedEnum.Unspecified, message.SingleNestedEnum);
Assert.IsNull(message.SingleNestedMessage);
Assert.IsNull(message.SinglePublicImportMessage);
Assert.AreEqual(0, message.SingleSfixed32);
@@ -145,13 +145,13 @@ namespace Google.Protobuf
SingleFixed32 = 23,
SingleFixed64 = 1234567890123,
SingleFloat = 12.25f,
- SingleForeignEnum = ForeignEnum.FOREIGN_BAR,
+ SingleForeignEnum = ForeignEnum.ForeignBar,
SingleForeignMessage = new ForeignMessage { C = 10 },
- SingleImportEnum = ImportEnum.IMPORT_BAZ,
+ SingleImportEnum = ImportEnum.ImportBaz,
SingleImportMessage = new ImportMessage { D = 20 },
SingleInt32 = 100,
SingleInt64 = 3210987654321,
- SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
SinglePublicImportMessage = new PublicImportMessage { E = 54 },
SingleSfixed32 = -123,
@@ -179,13 +179,13 @@ namespace Google.Protobuf
RepeatedFixed32 = { uint.MaxValue, 23 },
RepeatedFixed64 = { ulong.MaxValue, 1234567890123 },
RepeatedFloat = { 100f, 12.25f },
- RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR },
+ RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar },
RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } },
- RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED },
+ RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified },
RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } },
RepeatedInt32 = { 100, 200 },
RepeatedInt64 = { 3210987654321, long.MaxValue },
- RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG },
+ RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } },
RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } },
RepeatedSfixed32 = { -123, 123 },
@@ -224,8 +224,8 @@ namespace Google.Protobuf
{ 5, new ForeignMessage() },
},
MapInt32Enum = {
- { 1, MapEnum.MAP_ENUM_BAR },
- { 2000, MapEnum.MAP_ENUM_FOO }
+ { 1, MapEnum.Bar },
+ { 2000, MapEnum.Foo }
}
};
@@ -249,7 +249,7 @@ namespace Google.Protobuf
Assert.AreEqual(1, parsed.MapInt32Bytes.Count);
Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]);
}
-
+
[Test]
public void MapWithOnlyValue()
{
@@ -449,7 +449,7 @@ namespace Google.Protobuf
SingleFloat = 12.25f,
SingleInt32 = 100,
SingleInt64 = 3210987654321,
- SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
SingleSfixed32 = -123,
SingleSfixed64 = -12345678901234,
SingleSint32 = -456,
@@ -479,7 +479,7 @@ namespace Google.Protobuf
RepeatedFloat = { 100f, 12.25f },
RepeatedInt32 = { 100, 200 },
RepeatedInt64 = { 3210987654321, long.MaxValue },
- RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG },
+ RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
RepeatedSfixed32 = { -123, 123 },
RepeatedSfixed64 = { -12345678901234, 12345678901234 },
RepeatedSint32 = { -456, 100 },
@@ -670,7 +670,7 @@ namespace Google.Protobuf
{
// 130, 3 is the message tag
// 1 is the data length - but there's no data.
- var data = new byte[] { 130, 3, 1 };
+ var data = new byte[] { 130, 3, 1 };
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(data));
}
@@ -720,4 +720,4 @@ namespace Google.Protobuf
Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
}
}
-}
+} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
index 344d727b..0b6cd7e6 100644
--- a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
@@ -75,13 +75,13 @@ namespace Google.Protobuf
SingleFixed32 = 23,
SingleFixed64 = 1234567890123,
SingleFloat = 12.25f,
- SingleForeignEnum = ForeignEnum.FOREIGN_BAR,
+ SingleForeignEnum = ForeignEnum.ForeignBar,
SingleForeignMessage = new ForeignMessage { C = 10 },
- SingleImportEnum = ImportEnum.IMPORT_BAZ,
+ SingleImportEnum = ImportEnum.ImportBaz,
SingleImportMessage = new ImportMessage { D = 20 },
SingleInt32 = 100,
SingleInt64 = 3210987654321,
- SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
SinglePublicImportMessage = new PublicImportMessage { E = 54 },
SingleSfixed32 = -123,
@@ -174,14 +174,14 @@ namespace Google.Protobuf
[Test]
public void UnknownEnumValueNumeric_RepeatedField()
{
- var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.FOREIGN_BAZ, (ForeignEnum) 100, ForeignEnum.FOREIGN_FOO } };
+ var message = new TestAllTypes { RepeatedForeignEnum = { ForeignEnum.ForeignBaz, (ForeignEnum) 100, ForeignEnum.ForeignFoo } };
AssertJson("{ 'repeatedForeignEnum': [ 'FOREIGN_BAZ', 100, 'FOREIGN_FOO' ] }", JsonFormatter.Default.Format(message));
}
[Test]
public void UnknownEnumValueNumeric_MapField()
{
- var message = new TestMap { MapInt32Enum = { { 1, MapEnum.MAP_ENUM_FOO }, { 2, (MapEnum) 100 }, { 3, MapEnum.MAP_ENUM_BAR } } };
+ var message = new TestMap { MapInt32Enum = { { 1, MapEnum.Foo }, { 2, (MapEnum) 100 }, { 3, MapEnum.Bar } } };
AssertJson("{ 'mapInt32Enum': { '1': 'MAP_ENUM_FOO', '2': 100, '3': 'MAP_ENUM_BAR' } }", JsonFormatter.Default.Format(message));
}
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
index d21da58a..684f52b4 100644
--- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -142,8 +142,8 @@ namespace Google.Protobuf
[TestCase(typeof(DoubleValue), "1.5", 1.5d)]
public void Wrappers_Standalone(System.Type wrapperType, string json, object expectedValue)
{
- IMessage parsed = (IMessage) Activator.CreateInstance(wrapperType);
- IMessage expected = (IMessage) Activator.CreateInstance(wrapperType);
+ IMessage parsed = (IMessage)Activator.CreateInstance(wrapperType);
+ IMessage expected = (IMessage)Activator.CreateInstance(wrapperType);
JsonParser.Default.Merge(parsed, "null");
Assert.AreEqual(expected, parsed);
@@ -640,7 +640,7 @@ namespace Google.Protobuf
var parsed = Timestamp.Parser.ParseJson(json);
Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString());
}
-
+
[Test]
[TestCase("2015-10-09 14:46:23.123456789Z", Description = "No T between date and time")]
[TestCase("2015/10/09T14:46:23.123456789Z", Description = "Wrong date separators")]
@@ -886,9 +886,9 @@ namespace Google.Protobuf
}
[Test]
- [TestCase("\"FOREIGN_BAR\"", ForeignEnum.FOREIGN_BAR)]
- [TestCase("5", ForeignEnum.FOREIGN_BAR)]
- [TestCase("100", (ForeignEnum) 100)]
+ [TestCase("\"FOREIGN_BAR\"", ForeignEnum.ForeignBar)]
+ [TestCase("5", ForeignEnum.ForeignBar)]
+ [TestCase("100", (ForeignEnum)100)]
public void EnumValid(string value, ForeignEnum expectedValue)
{
string json = "{ \"singleForeignEnum\": " + value + " }";
@@ -922,4 +922,4 @@ namespace Google.Protobuf
return '"' + text + '"';
}
}
-}
+} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
index 086a4e98..52d5a676 100644
--- a/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
@@ -195,7 +195,7 @@ namespace Google.Protobuf.Reflection
Assert.AreEqual(value, enumType.Values[1]);
Assert.AreEqual("FOREIGN_FOO", value.Name);
Assert.AreEqual(4, value.Number);
- Assert.AreEqual((int) ForeignEnum.FOREIGN_FOO, value.Number);
+ Assert.AreEqual((int) ForeignEnum.ForeignFoo, value.Number);
Assert.AreEqual(value, enumType.FindValueByNumber(4));
Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE"));
for (int i = 0; i < enumType.Values.Count; i++)
diff --git a/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs b/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
index 936e41c6..a488af30 100644
--- a/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
+++ b/csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs
@@ -128,7 +128,7 @@ namespace Google.Protobuf.Reflection
fields[TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(message, 500);
fields[TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(message, "It's a string");
fields[TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(message, ByteString.CopyFrom(99, 98, 97));
- fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue(message, ForeignEnum.FOREIGN_FOO);
+ fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue(message, ForeignEnum.ForeignFoo);
fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetValue(message, new ForeignMessage { C = 12345 });
fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(message, 20150701.5);
@@ -138,7 +138,7 @@ namespace Google.Protobuf.Reflection
SingleInt32 = 500,
SingleString = "It's a string",
SingleBytes = ByteString.CopyFrom(99, 98, 97),
- SingleForeignEnum = ForeignEnum.FOREIGN_FOO,
+ SingleForeignEnum = ForeignEnum.ForeignFoo,
SingleForeignMessage = new ForeignMessage { C = 12345 },
SingleDouble = 20150701.5
};
diff --git a/csharp/src/Google.Protobuf.Test/SampleMessages.cs b/csharp/src/Google.Protobuf.Test/SampleMessages.cs
index 8a9c7f86..ffa4e2a7 100644
--- a/csharp/src/Google.Protobuf.Test/SampleMessages.cs
+++ b/csharp/src/Google.Protobuf.Test/SampleMessages.cs
@@ -54,13 +54,13 @@ namespace Google.Protobuf
SingleFixed32 = 23,
SingleFixed64 = 1234567890123,
SingleFloat = 12.25f,
- SingleForeignEnum = ForeignEnum.FOREIGN_BAR,
+ SingleForeignEnum = ForeignEnum.ForeignBar,
SingleForeignMessage = new ForeignMessage { C = 10 },
- SingleImportEnum = ImportEnum.IMPORT_BAZ,
+ SingleImportEnum = ImportEnum.ImportBaz,
SingleImportMessage = new ImportMessage { D = 20 },
SingleInt32 = 100,
SingleInt64 = 3210987654321,
- SingleNestedEnum = TestAllTypes.Types.NestedEnum.FOO,
+ SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
SinglePublicImportMessage = new PublicImportMessage { E = 54 },
SingleSfixed32 = -123,
@@ -76,13 +76,13 @@ namespace Google.Protobuf
RepeatedFixed32 = { UInt32.MaxValue, 23 },
RepeatedFixed64 = { UInt64.MaxValue, 1234567890123 },
RepeatedFloat = { 100f, 12.25f },
- RepeatedForeignEnum = { ForeignEnum.FOREIGN_FOO, ForeignEnum.FOREIGN_BAR },
+ RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar },
RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } },
- RepeatedImportEnum = { ImportEnum.IMPORT_BAZ, ImportEnum.IMPORT_ENUM_UNSPECIFIED },
+ RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified },
RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } },
RepeatedInt32 = { 100, 200 },
RepeatedInt64 = { 3210987654321, Int64.MaxValue },
- RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.FOO, TestAllTypes.Types.NestedEnum.NEG },
+ RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } },
RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } },
RepeatedSfixed32 = { -123, 123 },
@@ -92,8 +92,8 @@ namespace Google.Protobuf
RepeatedString = { "foo", "bar" },
RepeatedUint32 = { UInt32.MaxValue, UInt32.MinValue },
RepeatedUint64 = { UInt64.MaxValue, UInt32.MinValue },
- OneofString = "Oneof string"
+ OneofString = "Oneof string"
};
}
}
-}
+} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf.Test/TestCornerCases.cs b/csharp/src/Google.Protobuf.Test/TestCornerCases.cs
index 03fa1855..248f5fa9 100644
--- a/csharp/src/Google.Protobuf.Test/TestCornerCases.cs
+++ b/csharp/src/Google.Protobuf.Test/TestCornerCases.cs
@@ -43,8 +43,8 @@ namespace Google.Protobuf
NegativeEnumMessage msg = new NegativeEnumMessage
{
Value = NegativeEnum.MinusOne,
- Values = { NegativeEnum.NEGATIVE_ENUM_ZERO, NegativeEnum.MinusOne, NegativeEnum.FiveBelow },
- PackedValues = { NegativeEnum.NEGATIVE_ENUM_ZERO, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }
+ Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow },
+ PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }
};
Assert.AreEqual(58, msg.CalculateSize());
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
index 27c04787..3ba4a2b6 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
@@ -164,9 +164,9 @@ namespace Google.Protobuf.TestProtos {
}
#region Enums
public enum MapEnum {
- MAP_ENUM_FOO = 0,
- MAP_ENUM_BAR = 1,
- MAP_ENUM_BAZ = 2,
+ [pbr::OriginalName("MAP_ENUM_FOO")] Foo = 0,
+ [pbr::OriginalName("MAP_ENUM_BAR")] Bar = 1,
+ [pbr::OriginalName("MAP_ENUM_BAZ")] Baz = 2,
}
#endregion
@@ -1358,7 +1358,7 @@ namespace Google.Protobuf.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Types {
public enum Type {
- TYPE_FOO = 0,
+ [pbr::OriginalName("TYPE_FOO")] Foo = 0,
}
}
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
index 7b824dc7..263e17c0 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
@@ -42,10 +42,10 @@ namespace Google.Protobuf.TestProtos {
}
#region Enums
public enum ImportEnum {
- IMPORT_ENUM_UNSPECIFIED = 0,
- IMPORT_FOO = 7,
- IMPORT_BAR = 8,
- IMPORT_BAZ = 9,
+ [pbr::OriginalName("IMPORT_ENUM_UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("IMPORT_FOO")] ImportFoo = 7,
+ [pbr::OriginalName("IMPORT_BAR")] ImportBar = 8,
+ [pbr::OriginalName("IMPORT_BAZ")] ImportBaz = 9,
}
#endregion
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
index 586f01c8..7d4451b0 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
@@ -66,14 +66,14 @@ namespace UnitTest.Issues.TestProtos {
}
#region Enums
public enum NegativeEnum {
- NEGATIVE_ENUM_ZERO = 0,
- FiveBelow = -5,
- MinusOne = -1,
+ [pbr::OriginalName("NEGATIVE_ENUM_ZERO")] Zero = 0,
+ [pbr::OriginalName("FiveBelow")] FiveBelow = -5,
+ [pbr::OriginalName("MinusOne")] MinusOne = -1,
}
public enum DeprecatedEnum {
- DEPRECATED_ZERO = 0,
- one = 1,
+ [pbr::OriginalName("DEPRECATED_ZERO")] DeprecatedZero = 0,
+ [pbr::OriginalName("one")] One = 1,
}
#endregion
@@ -356,7 +356,7 @@ namespace UnitTest.Issues.TestProtos {
/// <summary>Field number for the "value" field.</summary>
public const int ValueFieldNumber = 1;
- private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO;
+ private global::UnitTest.Issues.TestProtos.NegativeEnum value_ = 0;
public global::UnitTest.Issues.TestProtos.NegativeEnum Value {
get { return value_; }
set {
@@ -401,7 +401,7 @@ namespace UnitTest.Issues.TestProtos {
public override int GetHashCode() {
int hash = 1;
- if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) hash ^= Value.GetHashCode();
+ if (Value != 0) hash ^= Value.GetHashCode();
hash ^= values_.GetHashCode();
hash ^= packedValues_.GetHashCode();
return hash;
@@ -412,7 +412,7 @@ namespace UnitTest.Issues.TestProtos {
}
public void WriteTo(pb::CodedOutputStream output) {
- if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) {
+ if (Value != 0) {
output.WriteRawTag(8);
output.WriteEnum((int) Value);
}
@@ -422,7 +422,7 @@ namespace UnitTest.Issues.TestProtos {
public int CalculateSize() {
int size = 0;
- if (Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) {
+ if (Value != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Value);
}
size += values_.CalculateSize(_repeated_values_codec);
@@ -434,7 +434,7 @@ namespace UnitTest.Issues.TestProtos {
if (other == null) {
return;
}
- if (other.Value != global::UnitTest.Issues.TestProtos.NegativeEnum.NEGATIVE_ENUM_ZERO) {
+ if (other.Value != 0) {
Value = other.Value;
}
values_.Add(other.values_);
@@ -620,7 +620,7 @@ namespace UnitTest.Issues.TestProtos {
/// <summary>Field number for the "EnumValue" field.</summary>
public const int EnumValueFieldNumber = 5;
- private global::UnitTest.Issues.TestProtos.DeprecatedEnum enumValue_ = global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO;
+ private global::UnitTest.Issues.TestProtos.DeprecatedEnum enumValue_ = 0;
[global::System.ObsoleteAttribute()]
public global::UnitTest.Issues.TestProtos.DeprecatedEnum EnumValue {
get { return enumValue_; }
@@ -665,7 +665,7 @@ namespace UnitTest.Issues.TestProtos {
hash ^= primitiveArray_.GetHashCode();
if (messageValue_ != null) hash ^= MessageValue.GetHashCode();
hash ^= messageArray_.GetHashCode();
- if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) hash ^= EnumValue.GetHashCode();
+ if (EnumValue != 0) hash ^= EnumValue.GetHashCode();
hash ^= enumArray_.GetHashCode();
return hash;
}
@@ -685,7 +685,7 @@ namespace UnitTest.Issues.TestProtos {
output.WriteMessage(MessageValue);
}
messageArray_.WriteTo(output, _repeated_messageArray_codec);
- if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) {
+ if (EnumValue != 0) {
output.WriteRawTag(40);
output.WriteEnum((int) EnumValue);
}
@@ -702,7 +702,7 @@ namespace UnitTest.Issues.TestProtos {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(MessageValue);
}
size += messageArray_.CalculateSize(_repeated_messageArray_codec);
- if (EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) {
+ if (EnumValue != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumValue);
}
size += enumArray_.CalculateSize(_repeated_enumArray_codec);
@@ -724,7 +724,7 @@ namespace UnitTest.Issues.TestProtos {
MessageValue.MergeFrom(other.MessageValue);
}
messageArray_.Add(other.messageArray_);
- if (other.EnumValue != global::UnitTest.Issues.TestProtos.DeprecatedEnum.DEPRECATED_ZERO) {
+ if (other.EnumValue != 0) {
EnumValue = other.EnumValue;
}
enumArray_.Add(other.enumArray_);
@@ -1435,7 +1435,7 @@ namespace UnitTest.Issues.TestProtos {
public const int NameFieldNumber = 1;
private string name_ = "";
/// <summary>
- /// json_name field options are not properly handled during deserialization
+ /// Message for testing the effects for of the json_name option
/// </summary>
public string Name {
get { return name_; }
diff --git a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
index d8465448..b8d159bb 100644
--- a/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
+++ b/csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
@@ -193,39 +193,39 @@ namespace Google.Protobuf.TestProtos {
}
#region Enums
public enum ForeignEnum {
- FOREIGN_UNSPECIFIED = 0,
- FOREIGN_FOO = 4,
- FOREIGN_BAR = 5,
- FOREIGN_BAZ = 6,
+ [pbr::OriginalName("FOREIGN_UNSPECIFIED")] ForeignUnspecified = 0,
+ [pbr::OriginalName("FOREIGN_FOO")] ForeignFoo = 4,
+ [pbr::OriginalName("FOREIGN_BAR")] ForeignBar = 5,
+ [pbr::OriginalName("FOREIGN_BAZ")] ForeignBaz = 6,
}
/// <summary>
/// Test an enum that has multiple values with the same number.
/// </summary>
public enum TestEnumWithDupValue {
- TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0,
- FOO1 = 1,
- BAR1 = 2,
- BAZ = 3,
- FOO2 = 1,
- BAR2 = 2,
+ [pbr::OriginalName("TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("FOO1")] Foo1 = 1,
+ [pbr::OriginalName("BAR1")] Bar1 = 2,
+ [pbr::OriginalName("BAZ")] Baz = 3,
+ [pbr::OriginalName("FOO2")] Foo2 = 1,
+ [pbr::OriginalName("BAR2")] Bar2 = 2,
}
/// <summary>
/// Test an enum with large, unordered values.
/// </summary>
public enum TestSparseEnum {
- TEST_SPARSE_ENUM_UNSPECIFIED = 0,
- SPARSE_A = 123,
- SPARSE_B = 62374,
- SPARSE_C = 12589234,
- SPARSE_D = -15,
- SPARSE_E = -53452,
+ [pbr::OriginalName("TEST_SPARSE_ENUM_UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("SPARSE_A")] SparseA = 123,
+ [pbr::OriginalName("SPARSE_B")] SparseB = 62374,
+ [pbr::OriginalName("SPARSE_C")] SparseC = 12589234,
+ [pbr::OriginalName("SPARSE_D")] SparseD = -15,
+ [pbr::OriginalName("SPARSE_E")] SparseE = -53452,
/// <summary>
/// In proto3, value 0 must be the first one specified
/// SPARSE_F = 0;
/// </summary>
- SPARSE_G = 2,
+ [pbr::OriginalName("SPARSE_G")] SparseG = 2,
}
#endregion
@@ -505,7 +505,7 @@ namespace Google.Protobuf.TestProtos {
/// <summary>Field number for the "single_nested_enum" field.</summary>
public const int SingleNestedEnumFieldNumber = 21;
- private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED;
+ private global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum singleNestedEnum_ = 0;
public global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum SingleNestedEnum {
get { return singleNestedEnum_; }
set {
@@ -515,7 +515,7 @@ namespace Google.Protobuf.TestProtos {
/// <summary>Field number for the "single_foreign_enum" field.</summary>
public const int SingleForeignEnumFieldNumber = 22;
- private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED;
+ private global::Google.Protobuf.TestProtos.ForeignEnum singleForeignEnum_ = 0;
public global::Google.Protobuf.TestProtos.ForeignEnum SingleForeignEnum {
get { return singleForeignEnum_; }
set {
@@ -525,7 +525,7 @@ namespace Google.Protobuf.TestProtos {
/// <summary>Field number for the "single_import_enum" field.</summary>
public const int SingleImportEnumFieldNumber = 23;
- private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED;
+ private global::Google.Protobuf.TestProtos.ImportEnum singleImportEnum_ = 0;
public global::Google.Protobuf.TestProtos.ImportEnum SingleImportEnum {
get { return singleImportEnum_; }
set {
@@ -892,9 +892,9 @@ namespace Google.Protobuf.TestProtos {
if (singleNestedMessage_ != null) hash ^= SingleNestedMessage.GetHashCode();
if (singleForeignMessage_ != null) hash ^= SingleForeignMessage.GetHashCode();
if (singleImportMessage_ != null) hash ^= SingleImportMessage.GetHashCode();
- if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) hash ^= SingleNestedEnum.GetHashCode();
- if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) hash ^= SingleForeignEnum.GetHashCode();
- if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) hash ^= SingleImportEnum.GetHashCode();
+ if (SingleNestedEnum != 0) hash ^= SingleNestedEnum.GetHashCode();
+ if (SingleForeignEnum != 0) hash ^= SingleForeignEnum.GetHashCode();
+ if (SingleImportEnum != 0) hash ^= SingleImportEnum.GetHashCode();
if (singlePublicImportMessage_ != null) hash ^= SinglePublicImportMessage.GetHashCode();
hash ^= repeatedInt32_.GetHashCode();
hash ^= repeatedInt64_.GetHashCode();
@@ -1003,15 +1003,15 @@ namespace Google.Protobuf.TestProtos {
output.WriteRawTag(162, 1);
output.WriteMessage(SingleImportMessage);
}
- if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) {
+ if (SingleNestedEnum != 0) {
output.WriteRawTag(168, 1);
output.WriteEnum((int) SingleNestedEnum);
}
- if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) {
+ if (SingleForeignEnum != 0) {
output.WriteRawTag(176, 1);
output.WriteEnum((int) SingleForeignEnum);
}
- if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) {
+ if (SingleImportEnum != 0) {
output.WriteRawTag(184, 1);
output.WriteEnum((int) SingleImportEnum);
}
@@ -1115,13 +1115,13 @@ namespace Google.Protobuf.TestProtos {
if (singleImportMessage_ != null) {
size += 2 + pb::CodedOutputStream.ComputeMessageSize(SingleImportMessage);
}
- if (SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) {
+ if (SingleNestedEnum != 0) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleNestedEnum);
}
- if (SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) {
+ if (SingleForeignEnum != 0) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleForeignEnum);
}
- if (SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) {
+ if (SingleImportEnum != 0) {
size += 2 + pb::CodedOutputStream.ComputeEnumSize((int) SingleImportEnum);
}
if (singlePublicImportMessage_ != null) {
@@ -1231,13 +1231,13 @@ namespace Google.Protobuf.TestProtos {
}
SingleImportMessage.MergeFrom(other.SingleImportMessage);
}
- if (other.SingleNestedEnum != global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedEnum.NESTED_ENUM_UNSPECIFIED) {
+ if (other.SingleNestedEnum != 0) {
SingleNestedEnum = other.SingleNestedEnum;
}
- if (other.SingleForeignEnum != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) {
+ if (other.SingleForeignEnum != 0) {
SingleForeignEnum = other.SingleForeignEnum;
}
- if (other.SingleImportEnum != global::Google.Protobuf.TestProtos.ImportEnum.IMPORT_ENUM_UNSPECIFIED) {
+ if (other.SingleImportEnum != 0) {
SingleImportEnum = other.SingleImportEnum;
}
if (other.singlePublicImportMessage_ != null) {
@@ -1526,14 +1526,14 @@ namespace Google.Protobuf.TestProtos {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public static partial class Types {
public enum NestedEnum {
- NESTED_ENUM_UNSPECIFIED = 0,
- FOO = 1,
- BAR = 2,
- BAZ = 3,
+ [pbr::OriginalName("NESTED_ENUM_UNSPECIFIED")] Unspecified = 0,
+ [pbr::OriginalName("FOO")] Foo = 1,
+ [pbr::OriginalName("BAR")] Bar = 2,
+ [pbr::OriginalName("BAZ")] Baz = 3,
/// <summary>
/// Intentionally negative.
/// </summary>
- NEG = -1,
+ [pbr::OriginalName("NEG")] Neg = -1,
}
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
@@ -2793,7 +2793,7 @@ namespace Google.Protobuf.TestProtos {
/// <summary>Field number for the "EnumField" field.</summary>
public const int EnumFieldFieldNumber = 3;
- private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED;
+ private global::Google.Protobuf.TestProtos.ForeignEnum enumField_ = 0;
public global::Google.Protobuf.TestProtos.ForeignEnum EnumField {
get { return enumField_; }
set {
@@ -2873,7 +2873,7 @@ namespace Google.Protobuf.TestProtos {
int hash = 1;
if (PrimitiveField != 0) hash ^= PrimitiveField.GetHashCode();
if (StringField.Length != 0) hash ^= StringField.GetHashCode();
- if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) hash ^= EnumField.GetHashCode();
+ if (EnumField != 0) hash ^= EnumField.GetHashCode();
if (messageField_ != null) hash ^= MessageField.GetHashCode();
hash ^= repeatedPrimitiveField_.GetHashCode();
hash ^= repeatedStringField_.GetHashCode();
@@ -2895,7 +2895,7 @@ namespace Google.Protobuf.TestProtos {
output.WriteRawTag(18);
output.WriteString(StringField);
}
- if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) {
+ if (EnumField != 0) {
output.WriteRawTag(24);
output.WriteEnum((int) EnumField);
}
@@ -2917,7 +2917,7 @@ namespace Google.Protobuf.TestProtos {
if (StringField.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(StringField);
}
- if (EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) {
+ if (EnumField != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) EnumField);
}
if (messageField_ != null) {
@@ -2940,7 +2940,7 @@ namespace Google.Protobuf.TestProtos {
if (other.StringField.Length != 0) {
StringField = other.StringField;
}
- if (other.EnumField != global::Google.Protobuf.TestProtos.ForeignEnum.FOREIGN_UNSPECIFIED) {
+ if (other.EnumField != 0) {
EnumField = other.EnumField;
}
if (other.messageField_ != null) {
@@ -3370,7 +3370,7 @@ namespace Google.Protobuf.TestProtos {
/// <summary>Field number for the "sparse_enum" field.</summary>
public const int SparseEnumFieldNumber = 1;
- private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED;
+ private global::Google.Protobuf.TestProtos.TestSparseEnum sparseEnum_ = 0;
public global::Google.Protobuf.TestProtos.TestSparseEnum SparseEnum {
get { return sparseEnum_; }
set {
@@ -3395,7 +3395,7 @@ namespace Google.Protobuf.TestProtos {
public override int GetHashCode() {
int hash = 1;
- if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) hash ^= SparseEnum.GetHashCode();
+ if (SparseEnum != 0) hash ^= SparseEnum.GetHashCode();
return hash;
}
@@ -3404,7 +3404,7 @@ namespace Google.Protobuf.TestProtos {
}
public void WriteTo(pb::CodedOutputStream output) {
- if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) {
+ if (SparseEnum != 0) {
output.WriteRawTag(8);
output.WriteEnum((int) SparseEnum);
}
@@ -3412,7 +3412,7 @@ namespace Google.Protobuf.TestProtos {
public int CalculateSize() {
int size = 0;
- if (SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) {
+ if (SparseEnum != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) SparseEnum);
}
return size;
@@ -3422,7 +3422,7 @@ namespace Google.Protobuf.TestProtos {
if (other == null) {
return;
}
- if (other.SparseEnum != global::Google.Protobuf.TestProtos.TestSparseEnum.TEST_SPARSE_ENUM_UNSPECIFIED) {
+ if (other.SparseEnum != 0) {
SparseEnum = other.SparseEnum;
}
}
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.csproj b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
index ef524baf..5557612a 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.csproj
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.csproj
@@ -117,6 +117,7 @@
<Compile Include="Reflection\MethodDescriptor.cs" />
<Compile Include="Reflection\OneofAccessor.cs" />
<Compile Include="Reflection\OneofDescriptor.cs" />
+ <Compile Include="Reflection\OriginalNameAttribute.cs" />
<Compile Include="Reflection\PackageDescriptor.cs" />
<Compile Include="Reflection\PartialClasses.cs" />
<Compile Include="Reflection\ReflectionUtil.cs" />
diff --git a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec
index f51bc89a..2892b8bf 100644
--- a/csharp/src/Google.Protobuf/Google.Protobuf.nuspec
+++ b/csharp/src/Google.Protobuf/Google.Protobuf.nuspec
@@ -33,10 +33,12 @@
<dependency id="System.Linq.Expressions" version="4.0.0" />
<dependency id="System.ObjectModel" version="4.0.0" />
<dependency id="System.Reflection" version="4.0.0" />
+ <dependency id="System.Reflection.Extensions" version="4.0.0" />
<dependency id="System.Runtime" version="4.0.0" />
<dependency id="System.Runtime.Extensions" version="4.0.0" />
<dependency id="System.Text.Encoding" version="4.0.0" />
<dependency id="System.Text.RegularExpressions" version="4.0.0" />
+ <dependency id="System.Threading" version="4.0.0" />
</group>
</dependencies>
</metadata>
diff --git a/csharp/src/Google.Protobuf/JsonFormatter.cs b/csharp/src/Google.Protobuf/JsonFormatter.cs
index cbd9366c..73a4f64b 100644
--- a/csharp/src/Google.Protobuf/JsonFormatter.cs
+++ b/csharp/src/Google.Protobuf/JsonFormatter.cs
@@ -39,6 +39,7 @@ using Google.Protobuf.WellKnownTypes;
using System.IO;
using System.Linq;
using System.Collections.Generic;
+using System.Reflection;
namespace Google.Protobuf
{
@@ -420,9 +421,10 @@ namespace Google.Protobuf
}
else if (value is System.Enum)
{
- if (System.Enum.IsDefined(value.GetType(), value))
+ string name = OriginalEnumValueHelper.GetOriginalName(value);
+ if (name != null)
{
- WriteString(writer, value.ToString());
+ WriteString(writer, name);
}
else
{
@@ -877,5 +879,44 @@ namespace Google.Protobuf
TypeRegistry = ProtoPreconditions.CheckNotNull(typeRegistry, nameof(typeRegistry));
}
}
+
+ // Effectively a cache of mapping from enum values to the original name as specified in the proto file,
+ // fetched by reflection.
+ // The need for this is unfortunate, as is its unbounded size, but realistically it shouldn't cause issues.
+ private static class OriginalEnumValueHelper
+ {
+ // TODO: In the future we might want to use ConcurrentDictionary, at the point where all
+ // the platforms we target have it.
+ private static readonly Dictionary<System.Type, Dictionary<object, string>> dictionaries
+ = new Dictionary<System.Type, Dictionary<object, string>>();
+
+ internal static string GetOriginalName(object value)
+ {
+ var enumType = value.GetType();
+ Dictionary<object, string> nameMapping;
+ lock (dictionaries)
+ {
+ if (!dictionaries.TryGetValue(enumType, out nameMapping))
+ {
+ nameMapping = GetNameMapping(enumType);
+ dictionaries[enumType] = nameMapping;
+ }
+ }
+
+ string originalName;
+ // If this returns false, originalName will be null, which is what we want.
+ nameMapping.TryGetValue(value, out originalName);
+ return originalName;
+ }
+
+ private static Dictionary<object, string> GetNameMapping(System.Type enumType) =>
+ enumType.GetTypeInfo().DeclaredFields
+ .Where(f => f.IsStatic)
+ .ToDictionary(f => f.GetValue(null),
+ f => f.GetCustomAttributes<OriginalNameAttribute>()
+ .FirstOrDefault()
+ // If the attribute hasn't been applied, fall back to the name of the field.
+ ?.Name ?? f.Name);
+ }
}
}
diff --git a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
index 7de7b5fc..fa138dfe 100644
--- a/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/Descriptor.cs
@@ -80,7 +80,7 @@ namespace Google.Protobuf.Reflection {
"EhMKC291dHB1dF90eXBlGAMgASgJEi8KB29wdGlvbnMYBCABKAsyHi5nb29n",
"bGUucHJvdG9idWYuTWV0aG9kT3B0aW9ucxIfChBjbGllbnRfc3RyZWFtaW5n",
"GAUgASgIOgVmYWxzZRIfChBzZXJ2ZXJfc3RyZWFtaW5nGAYgASgIOgVmYWxz",
- "ZSKuBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGph",
+ "ZSKHBQoLRmlsZU9wdGlvbnMSFAoMamF2YV9wYWNrYWdlGAEgASgJEhwKFGph",
"dmFfb3V0ZXJfY2xhc3NuYW1lGAggASgJEiIKE2phdmFfbXVsdGlwbGVfZmls",
"ZXMYCiABKAg6BWZhbHNlEiwKHWphdmFfZ2VuZXJhdGVfZXF1YWxzX2FuZF9o",
"YXNoGBQgASgIOgVmYWxzZRIlChZqYXZhX3N0cmluZ19jaGVja191dGY4GBsg",
@@ -91,54 +91,53 @@ namespace Google.Protobuf.Reflection {
"cHlfZ2VuZXJpY19zZXJ2aWNlcxgSIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl",
"ZBgXIAEoCDoFZmFsc2USHwoQY2NfZW5hYmxlX2FyZW5hcxgfIAEoCDoFZmFs",
"c2USGQoRb2JqY19jbGFzc19wcmVmaXgYJCABKAkSGAoQY3NoYXJwX25hbWVz",
- "cGFjZRglIAEoCRIrCh9qYXZhbmFub191c2VfZGVwcmVjYXRlZF9wYWNrYWdl",
- "GCYgASgIQgIYARJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n",
+ "cGFjZRglIAEoCRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5n",
"b29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbiI6CgxPcHRpbWl6",
"ZU1vZGUSCQoFU1BFRUQQARINCglDT0RFX1NJWkUQAhIQCgxMSVRFX1JVTlRJ",
- "TUUQAyoJCOgHEICAgIACIuYBCg5NZXNzYWdlT3B0aW9ucxImChdtZXNzYWdl",
- "X3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3RhbmRhcmRf",
- "ZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVwcmVjYXRl",
- "ZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVuaW50ZXJw",
- "cmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVy",
- "cHJldGVkT3B0aW9uKgkI6AcQgICAgAIimAMKDEZpZWxkT3B0aW9ucxI6CgVj",
- "dHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlvbnMuQ1R5",
- "cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0eXBlGAYgASgOMiQu",
- "Z29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5cGU6CUpTX05PUk1B",
- "TBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMgASgIOgVm",
- "YWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29w",
+ "TUUQAyoJCOgHEICAgIACSgQIJhAnIuYBCg5NZXNzYWdlT3B0aW9ucxImChdt",
+ "ZXNzYWdlX3NldF93aXJlX2Zvcm1hdBgBIAEoCDoFZmFsc2USLgofbm9fc3Rh",
+ "bmRhcmRfZGVzY3JpcHRvcl9hY2Nlc3NvchgCIAEoCDoFZmFsc2USGQoKZGVw",
+ "cmVjYXRlZBgDIAEoCDoFZmFsc2USEQoJbWFwX2VudHJ5GAcgASgIEkMKFHVu",
+ "aW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5V",
+ "bmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIimAMKDEZpZWxkT3B0aW9u",
+ "cxI6CgVjdHlwZRgBIAEoDjIjLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE9wdGlv",
+ "bnMuQ1R5cGU6BlNUUklORxIOCgZwYWNrZWQYAiABKAgSPwoGanN0eXBlGAYg",
+ "ASgOMiQuZ29vZ2xlLnByb3RvYnVmLkZpZWxkT3B0aW9ucy5KU1R5cGU6CUpT",
+ "X05PUk1BTBITCgRsYXp5GAUgASgIOgVmYWxzZRIZCgpkZXByZWNhdGVkGAMg",
+ "ASgIOgVmYWxzZRITCgR3ZWFrGAogASgIOgVmYWxzZRJDChR1bmludGVycHJl",
+ "dGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnBy",
+ "ZXRlZE9wdGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoM",
+ "U1RSSU5HX1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpT",
+ "X1NUUklORxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAIijQEKC0VudW1P",
+ "cHRpb25zEhMKC2FsbG93X2FsaWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyAB",
+ "KAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdv",
+ "b2dsZS5wcm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIi",
+ "fQoQRW51bVZhbHVlT3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVmYWxz",
+ "ZRJDChR1bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJv",
+ "dG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNlcnZp",
+ "Y2VPcHRpb25zEhkKCmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVuaW50",
+ "ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5Vbmlu",
+ "dGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIiegoNTWV0aG9kT3B0aW9ucxIZ",
+ "CgpkZXByZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29w",
"dGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9w",
- "dGlvbiIvCgVDVHlwZRIKCgZTVFJJTkcQABIICgRDT1JEEAESEAoMU1RSSU5H",
- "X1BJRUNFEAIiNQoGSlNUeXBlEg0KCUpTX05PUk1BTBAAEg0KCUpTX1NUUklO",
- "RxABEg0KCUpTX05VTUJFUhACKgkI6AcQgICAgAIijQEKC0VudW1PcHRpb25z",
- "EhMKC2FsbG93X2FsaWFzGAIgASgIEhkKCmRlcHJlY2F0ZWQYAyABKAg6BWZh",
- "bHNlEkMKFHVuaW50ZXJwcmV0ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5w",
- "cm90b2J1Zi5VbmludGVycHJldGVkT3B0aW9uKgkI6AcQgICAgAIifQoQRW51",
- "bVZhbHVlT3B0aW9ucxIZCgpkZXByZWNhdGVkGAEgASgIOgVmYWxzZRJDChR1",
- "bmludGVycHJldGVkX29wdGlvbhjnByADKAsyJC5nb29nbGUucHJvdG9idWYu",
- "VW5pbnRlcnByZXRlZE9wdGlvbioJCOgHEICAgIACInsKDlNlcnZpY2VPcHRp",
- "b25zEhkKCmRlcHJlY2F0ZWQYISABKAg6BWZhbHNlEkMKFHVuaW50ZXJwcmV0",
- "ZWRfb3B0aW9uGOcHIAMoCzIkLmdvb2dsZS5wcm90b2J1Zi5VbmludGVycHJl",
- "dGVkT3B0aW9uKgkI6AcQgICAgAIiegoNTWV0aG9kT3B0aW9ucxIZCgpkZXBy",
- "ZWNhdGVkGCEgASgIOgVmYWxzZRJDChR1bmludGVycHJldGVkX29wdGlvbhjn",
- "ByADKAsyJC5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbioJ",
- "COgHEICAgIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsKBG5hbWUYAiAD",
- "KAsyLS5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlvbi5OYW1l",
- "UGFydBIYChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBvc2l0aXZlX2lu",
- "dF92YWx1ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUYBSABKAMSFAoM",
- "ZG91YmxlX3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEoDBIXCg9h",
- "Z2dyZWdhdGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFtZV9wYXJ0",
- "GAEgAigJEhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNlQ29kZUlu",
- "Zm8SOgoIbG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYuU291cmNl",
- "Q29kZUluZm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgYASADKAVC",
- "AhABEhAKBHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVudHMYAyAB",
- "KAkSGQoRdHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGluZ19kZXRh",
- "Y2hlZF9jb21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUluZm8SQQoK",
- "YW5ub3RhdGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5lcmF0ZWRD",
- "b2RlSW5mby5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0aBgBIAMo",
- "BUICEAESEwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyABKAUSCwoD",
- "ZW5kGAQgASgFQlgKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2NyaXB0b3JQ",
- "cm90b3NIAVoKZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Qcm90b2J1Zi5S",
- "ZWZsZWN0aW9u"));
+ "dGlvbioJCOgHEICAgIACIp4CChNVbmludGVycHJldGVkT3B0aW9uEjsKBG5h",
+ "bWUYAiADKAsyLS5nb29nbGUucHJvdG9idWYuVW5pbnRlcnByZXRlZE9wdGlv",
+ "bi5OYW1lUGFydBIYChBpZGVudGlmaWVyX3ZhbHVlGAMgASgJEhoKEnBvc2l0",
+ "aXZlX2ludF92YWx1ZRgEIAEoBBIaChJuZWdhdGl2ZV9pbnRfdmFsdWUYBSAB",
+ "KAMSFAoMZG91YmxlX3ZhbHVlGAYgASgBEhQKDHN0cmluZ192YWx1ZRgHIAEo",
+ "DBIXCg9hZ2dyZWdhdGVfdmFsdWUYCCABKAkaMwoITmFtZVBhcnQSEQoJbmFt",
+ "ZV9wYXJ0GAEgAigJEhQKDGlzX2V4dGVuc2lvbhgCIAIoCCLVAQoOU291cmNl",
+ "Q29kZUluZm8SOgoIbG9jYXRpb24YASADKAsyKC5nb29nbGUucHJvdG9idWYu",
+ "U291cmNlQ29kZUluZm8uTG9jYXRpb24ahgEKCExvY2F0aW9uEhAKBHBhdGgY",
+ "ASADKAVCAhABEhAKBHNwYW4YAiADKAVCAhABEhgKEGxlYWRpbmdfY29tbWVu",
+ "dHMYAyABKAkSGQoRdHJhaWxpbmdfY29tbWVudHMYBCABKAkSIQoZbGVhZGlu",
+ "Z19kZXRhY2hlZF9jb21tZW50cxgGIAMoCSKnAQoRR2VuZXJhdGVkQ29kZUlu",
+ "Zm8SQQoKYW5ub3RhdGlvbhgBIAMoCzItLmdvb2dsZS5wcm90b2J1Zi5HZW5l",
+ "cmF0ZWRDb2RlSW5mby5Bbm5vdGF0aW9uGk8KCkFubm90YXRpb24SEAoEcGF0",
+ "aBgBIAMoBUICEAESEwoLc291cmNlX2ZpbGUYAiABKAkSDQoFYmVnaW4YAyAB",
+ "KAUSCwoDZW5kGAQgASgFQlgKE2NvbS5nb29nbGUucHJvdG9idWZCEERlc2Ny",
+ "aXB0b3JQcm90b3NIAVoKZGVzY3JpcHRvcqICA0dQQqoCGkdvb2dsZS5Qcm90",
+ "b2J1Zi5SZWZsZWN0aW9u"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -152,7 +151,7 @@ namespace Google.Protobuf.Reflection {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumValueDescriptorProto), global::Google.Protobuf.Reflection.EnumValueDescriptorProto.Parser, new[]{ "Name", "Number", "Options" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.ServiceDescriptorProto), global::Google.Protobuf.Reflection.ServiceDescriptorProto.Parser, new[]{ "Name", "Method", "Options" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MethodDescriptorProto), global::Google.Protobuf.Reflection.MethodDescriptorProto.Parser, new[]{ "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming" }, null, null, null),
- new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "JavananoUseDeprecatedPackage", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
+ new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FileOptions), global::Google.Protobuf.Reflection.FileOptions.Parser, new[]{ "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.MessageOptions), global::Google.Protobuf.Reflection.MessageOptions.Parser, new[]{ "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "UninterpretedOption" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.FieldOptions), global::Google.Protobuf.Reflection.FieldOptions.Parser, new[]{ "Ctype", "Packed", "Jstype", "Lazy", "Deprecated", "Weak", "UninterpretedOption" }, null, new[]{ typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.CType), typeof(global::Google.Protobuf.Reflection.FieldOptions.Types.JSType) }, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Reflection.EnumOptions), global::Google.Protobuf.Reflection.EnumOptions.Parser, new[]{ "AllowAlias", "Deprecated", "UninterpretedOption" }, null, null, null),
@@ -1291,7 +1290,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Field number for the "label" field.</summary>
public const int LabelFieldNumber = 4;
- private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL;
+ private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label label_ = 0;
public global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label Label {
get { return label_; }
set {
@@ -1301,7 +1300,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Field number for the "type" field.</summary>
public const int TypeFieldNumber = 5;
- private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE;
+ private global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type type_ = 0;
/// <summary>
/// If type_name is set, this need not be set. If both this and type_name
/// are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.
@@ -1429,8 +1428,8 @@ namespace Google.Protobuf.Reflection {
int hash = 1;
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (Number != 0) hash ^= Number.GetHashCode();
- if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) hash ^= Label.GetHashCode();
- if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) hash ^= Type.GetHashCode();
+ if (Label != 0) hash ^= Label.GetHashCode();
+ if (Type != 0) hash ^= Type.GetHashCode();
if (TypeName.Length != 0) hash ^= TypeName.GetHashCode();
if (Extendee.Length != 0) hash ^= Extendee.GetHashCode();
if (DefaultValue.Length != 0) hash ^= DefaultValue.GetHashCode();
@@ -1457,11 +1456,11 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(24);
output.WriteInt32(Number);
}
- if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) {
+ if (Label != 0) {
output.WriteRawTag(32);
output.WriteEnum((int) Label);
}
- if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) {
+ if (Type != 0) {
output.WriteRawTag(40);
output.WriteEnum((int) Type);
}
@@ -1495,10 +1494,10 @@ namespace Google.Protobuf.Reflection {
if (Number != 0) {
size += 1 + pb::CodedOutputStream.ComputeInt32Size(Number);
}
- if (Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) {
+ if (Label != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Label);
}
- if (Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) {
+ if (Type != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
}
if (TypeName.Length != 0) {
@@ -1532,10 +1531,10 @@ namespace Google.Protobuf.Reflection {
if (other.Number != 0) {
Number = other.Number;
}
- if (other.Label != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Label.LABEL_OPTIONAL) {
+ if (other.Label != 0) {
Label = other.Label;
}
- if (other.Type != global::Google.Protobuf.Reflection.FieldDescriptorProto.Types.Type.TYPE_DOUBLE) {
+ if (other.Type != 0) {
Type = other.Type;
}
if (other.TypeName.Length != 0) {
@@ -1624,59 +1623,59 @@ namespace Google.Protobuf.Reflection {
/// 0 is reserved for errors.
/// Order is weird for historical reasons.
/// </summary>
- TYPE_DOUBLE = 1,
- TYPE_FLOAT = 2,
+ [pbr::OriginalName("TYPE_DOUBLE")] Double = 1,
+ [pbr::OriginalName("TYPE_FLOAT")] Float = 2,
/// <summary>
/// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
/// negative values are likely.
/// </summary>
- TYPE_INT64 = 3,
- TYPE_UINT64 = 4,
+ [pbr::OriginalName("TYPE_INT64")] Int64 = 3,
+ [pbr::OriginalName("TYPE_UINT64")] Uint64 = 4,
/// <summary>
/// Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
/// negative values are likely.
/// </summary>
- TYPE_INT32 = 5,
- TYPE_FIXED64 = 6,
- TYPE_FIXED32 = 7,
- TYPE_BOOL = 8,
- TYPE_STRING = 9,
+ [pbr::OriginalName("TYPE_INT32")] Int32 = 5,
+ [pbr::OriginalName("TYPE_FIXED64")] Fixed64 = 6,
+ [pbr::OriginalName("TYPE_FIXED32")] Fixed32 = 7,
+ [pbr::OriginalName("TYPE_BOOL")] Bool = 8,
+ [pbr::OriginalName("TYPE_STRING")] String = 9,
/// <summary>
/// Tag-delimited aggregate.
/// </summary>
- TYPE_GROUP = 10,
+ [pbr::OriginalName("TYPE_GROUP")] Group = 10,
/// <summary>
/// Length-delimited aggregate.
/// </summary>
- TYPE_MESSAGE = 11,
+ [pbr::OriginalName("TYPE_MESSAGE")] Message = 11,
/// <summary>
/// New in version 2.
/// </summary>
- TYPE_BYTES = 12,
- TYPE_UINT32 = 13,
- TYPE_ENUM = 14,
- TYPE_SFIXED32 = 15,
- TYPE_SFIXED64 = 16,
+ [pbr::OriginalName("TYPE_BYTES")] Bytes = 12,
+ [pbr::OriginalName("TYPE_UINT32")] Uint32 = 13,
+ [pbr::OriginalName("TYPE_ENUM")] Enum = 14,
+ [pbr::OriginalName("TYPE_SFIXED32")] Sfixed32 = 15,
+ [pbr::OriginalName("TYPE_SFIXED64")] Sfixed64 = 16,
/// <summary>
/// Uses ZigZag encoding.
/// </summary>
- TYPE_SINT32 = 17,
+ [pbr::OriginalName("TYPE_SINT32")] Sint32 = 17,
/// <summary>
/// Uses ZigZag encoding.
/// </summary>
- TYPE_SINT64 = 18,
+ [pbr::OriginalName("TYPE_SINT64")] Sint64 = 18,
}
internal enum Label {
/// <summary>
/// 0 is reserved for errors
/// </summary>
- LABEL_OPTIONAL = 1,
- LABEL_REQUIRED = 2,
+ [pbr::OriginalName("LABEL_OPTIONAL")] Optional = 1,
+ [pbr::OriginalName("LABEL_REQUIRED")] Required = 2,
/// <summary>
/// TODO(sanjay): Should we add LABEL_MAP?
/// </summary>
- LABEL_REPEATED = 3,
+ [pbr::OriginalName("LABEL_REPEATED")] Repeated = 3,
}
}
@@ -2563,7 +2562,6 @@ namespace Google.Protobuf.Reflection {
ccEnableArenas_ = other.ccEnableArenas_;
objcClassPrefix_ = other.objcClassPrefix_;
csharpNamespace_ = other.csharpNamespace_;
- javananoUseDeprecatedPackage_ = other.javananoUseDeprecatedPackage_;
uninterpretedOption_ = other.uninterpretedOption_.Clone();
}
@@ -2666,7 +2664,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Field number for the "optimize_for" field.</summary>
public const int OptimizeForFieldNumber = 9;
- private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED;
+ private global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode optimizeFor_ = 0;
public global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode OptimizeFor {
get { return optimizeFor_; }
set {
@@ -2790,21 +2788,6 @@ namespace Google.Protobuf.Reflection {
}
}
- /// <summary>Field number for the "javanano_use_deprecated_package" field.</summary>
- public const int JavananoUseDeprecatedPackageFieldNumber = 38;
- private bool javananoUseDeprecatedPackage_;
- /// <summary>
- /// Whether the nano proto compiler should generate in the deprecated non-nano
- /// suffixed package.
- /// </summary>
- [global::System.ObsoleteAttribute()]
- public bool JavananoUseDeprecatedPackage {
- get { return javananoUseDeprecatedPackage_; }
- set {
- javananoUseDeprecatedPackage_ = value;
- }
- }
-
/// <summary>Field number for the "uninterpreted_option" field.</summary>
public const int UninterpretedOptionFieldNumber = 999;
private static readonly pb::FieldCodec<global::Google.Protobuf.Reflection.UninterpretedOption> _repeated_uninterpretedOption_codec
@@ -2842,7 +2825,6 @@ namespace Google.Protobuf.Reflection {
if (CcEnableArenas != other.CcEnableArenas) return false;
if (ObjcClassPrefix != other.ObjcClassPrefix) return false;
if (CsharpNamespace != other.CsharpNamespace) return false;
- if (JavananoUseDeprecatedPackage != other.JavananoUseDeprecatedPackage) return false;
if(!uninterpretedOption_.Equals(other.uninterpretedOption_)) return false;
return true;
}
@@ -2854,7 +2836,7 @@ namespace Google.Protobuf.Reflection {
if (JavaMultipleFiles != false) hash ^= JavaMultipleFiles.GetHashCode();
if (JavaGenerateEqualsAndHash != false) hash ^= JavaGenerateEqualsAndHash.GetHashCode();
if (JavaStringCheckUtf8 != false) hash ^= JavaStringCheckUtf8.GetHashCode();
- if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) hash ^= OptimizeFor.GetHashCode();
+ if (OptimizeFor != 0) hash ^= OptimizeFor.GetHashCode();
if (GoPackage.Length != 0) hash ^= GoPackage.GetHashCode();
if (CcGenericServices != false) hash ^= CcGenericServices.GetHashCode();
if (JavaGenericServices != false) hash ^= JavaGenericServices.GetHashCode();
@@ -2863,7 +2845,6 @@ namespace Google.Protobuf.Reflection {
if (CcEnableArenas != false) hash ^= CcEnableArenas.GetHashCode();
if (ObjcClassPrefix.Length != 0) hash ^= ObjcClassPrefix.GetHashCode();
if (CsharpNamespace.Length != 0) hash ^= CsharpNamespace.GetHashCode();
- if (JavananoUseDeprecatedPackage != false) hash ^= JavananoUseDeprecatedPackage.GetHashCode();
hash ^= uninterpretedOption_.GetHashCode();
return hash;
}
@@ -2881,7 +2862,7 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(66);
output.WriteString(JavaOuterClassname);
}
- if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) {
+ if (OptimizeFor != 0) {
output.WriteRawTag(72);
output.WriteEnum((int) OptimizeFor);
}
@@ -2929,10 +2910,6 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(170, 2);
output.WriteString(CsharpNamespace);
}
- if (JavananoUseDeprecatedPackage != false) {
- output.WriteRawTag(176, 2);
- output.WriteBool(JavananoUseDeprecatedPackage);
- }
uninterpretedOption_.WriteTo(output, _repeated_uninterpretedOption_codec);
}
@@ -2953,7 +2930,7 @@ namespace Google.Protobuf.Reflection {
if (JavaStringCheckUtf8 != false) {
size += 2 + 1;
}
- if (OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) {
+ if (OptimizeFor != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) OptimizeFor);
}
if (GoPackage.Length != 0) {
@@ -2980,9 +2957,6 @@ namespace Google.Protobuf.Reflection {
if (CsharpNamespace.Length != 0) {
size += 2 + pb::CodedOutputStream.ComputeStringSize(CsharpNamespace);
}
- if (JavananoUseDeprecatedPackage != false) {
- size += 2 + 1;
- }
size += uninterpretedOption_.CalculateSize(_repeated_uninterpretedOption_codec);
return size;
}
@@ -3006,7 +2980,7 @@ namespace Google.Protobuf.Reflection {
if (other.JavaStringCheckUtf8 != false) {
JavaStringCheckUtf8 = other.JavaStringCheckUtf8;
}
- if (other.OptimizeFor != global::Google.Protobuf.Reflection.FileOptions.Types.OptimizeMode.SPEED) {
+ if (other.OptimizeFor != 0) {
OptimizeFor = other.OptimizeFor;
}
if (other.GoPackage.Length != 0) {
@@ -3033,9 +3007,6 @@ namespace Google.Protobuf.Reflection {
if (other.CsharpNamespace.Length != 0) {
CsharpNamespace = other.CsharpNamespace;
}
- if (other.JavananoUseDeprecatedPackage != false) {
- JavananoUseDeprecatedPackage = other.JavananoUseDeprecatedPackage;
- }
uninterpretedOption_.Add(other.uninterpretedOption_);
}
@@ -3102,10 +3073,6 @@ namespace Google.Protobuf.Reflection {
CsharpNamespace = input.ReadString();
break;
}
- case 304: {
- JavananoUseDeprecatedPackage = input.ReadBool();
- break;
- }
case 7994: {
uninterpretedOption_.AddEntriesFrom(input, _repeated_uninterpretedOption_codec);
break;
@@ -3125,15 +3092,15 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Generate complete code for parsing, serialization,
/// </summary>
- SPEED = 1,
+ [pbr::OriginalName("SPEED")] Speed = 1,
/// <summary>
/// etc.
/// </summary>
- CODE_SIZE = 2,
+ [pbr::OriginalName("CODE_SIZE")] CodeSize = 2,
/// <summary>
/// Generate code using MessageLite and the lite runtime.
/// </summary>
- LITE_RUNTIME = 3,
+ [pbr::OriginalName("LITE_RUNTIME")] LiteRuntime = 3,
}
}
@@ -3436,7 +3403,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Field number for the "ctype" field.</summary>
public const int CtypeFieldNumber = 1;
- private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING;
+ private global::Google.Protobuf.Reflection.FieldOptions.Types.CType ctype_ = 0;
/// <summary>
/// The ctype option instructs the C++ code generator to use a different
/// representation of the field than it normally would. See the specific
@@ -3469,7 +3436,7 @@ namespace Google.Protobuf.Reflection {
/// <summary>Field number for the "jstype" field.</summary>
public const int JstypeFieldNumber = 6;
- private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL;
+ private global::Google.Protobuf.Reflection.FieldOptions.Types.JSType jstype_ = 0;
/// <summary>
/// The jstype option determines the JavaScript type used for values of the
/// field. The option is permitted only for 64 bit integral and fixed types
@@ -3591,9 +3558,9 @@ namespace Google.Protobuf.Reflection {
public override int GetHashCode() {
int hash = 1;
- if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) hash ^= Ctype.GetHashCode();
+ if (Ctype != 0) hash ^= Ctype.GetHashCode();
if (Packed != false) hash ^= Packed.GetHashCode();
- if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) hash ^= Jstype.GetHashCode();
+ if (Jstype != 0) hash ^= Jstype.GetHashCode();
if (Lazy != false) hash ^= Lazy.GetHashCode();
if (Deprecated != false) hash ^= Deprecated.GetHashCode();
if (Weak != false) hash ^= Weak.GetHashCode();
@@ -3606,7 +3573,7 @@ namespace Google.Protobuf.Reflection {
}
public void WriteTo(pb::CodedOutputStream output) {
- if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) {
+ if (Ctype != 0) {
output.WriteRawTag(8);
output.WriteEnum((int) Ctype);
}
@@ -3622,7 +3589,7 @@ namespace Google.Protobuf.Reflection {
output.WriteRawTag(40);
output.WriteBool(Lazy);
}
- if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) {
+ if (Jstype != 0) {
output.WriteRawTag(48);
output.WriteEnum((int) Jstype);
}
@@ -3635,13 +3602,13 @@ namespace Google.Protobuf.Reflection {
public int CalculateSize() {
int size = 0;
- if (Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) {
+ if (Ctype != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Ctype);
}
if (Packed != false) {
size += 1 + 1;
}
- if (Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) {
+ if (Jstype != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Jstype);
}
if (Lazy != false) {
@@ -3661,13 +3628,13 @@ namespace Google.Protobuf.Reflection {
if (other == null) {
return;
}
- if (other.Ctype != global::Google.Protobuf.Reflection.FieldOptions.Types.CType.STRING) {
+ if (other.Ctype != 0) {
Ctype = other.Ctype;
}
if (other.Packed != false) {
Packed = other.Packed;
}
- if (other.Jstype != global::Google.Protobuf.Reflection.FieldOptions.Types.JSType.JS_NORMAL) {
+ if (other.Jstype != 0) {
Jstype = other.Jstype;
}
if (other.Lazy != false) {
@@ -3729,24 +3696,24 @@ namespace Google.Protobuf.Reflection {
/// <summary>
/// Default mode.
/// </summary>
- STRING = 0,
- CORD = 1,
- STRING_PIECE = 2,
+ [pbr::OriginalName("STRING")] String = 0,
+ [pbr::OriginalName("CORD")] Cord = 1,
+ [pbr::OriginalName("STRING_PIECE")] StringPiece = 2,
}
internal enum JSType {
/// <summary>
/// Use the default type.
/// </summary>
- JS_NORMAL = 0,
+ [pbr::OriginalName("JS_NORMAL")] JsNormal = 0,
/// <summary>
/// Use JavaScript strings.
/// </summary>
- JS_STRING = 1,
+ [pbr::OriginalName("JS_STRING")] JsString = 1,
/// <summary>
/// Use JavaScript numbers.
/// </summary>
- JS_NUMBER = 2,
+ [pbr::OriginalName("JS_NUMBER")] JsNumber = 2,
}
}
diff --git a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
index de6e5717..6c6f6ee0 100644
--- a/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
+++ b/csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs
@@ -133,41 +133,41 @@ namespace Google.Protobuf.Reflection
{
switch (type)
{
- case FieldDescriptorProto.Types.Type.TYPE_DOUBLE:
+ case FieldDescriptorProto.Types.Type.Double:
return FieldType.Double;
- case FieldDescriptorProto.Types.Type.TYPE_FLOAT:
+ case FieldDescriptorProto.Types.Type.Float:
return FieldType.Float;
- case FieldDescriptorProto.Types.Type.TYPE_INT64:
+ case FieldDescriptorProto.Types.Type.Int64:
return FieldType.Int64;
- case FieldDescriptorProto.Types.Type.TYPE_UINT64:
+ case FieldDescriptorProto.Types.Type.Uint64:
return FieldType.UInt64;
- case FieldDescriptorProto.Types.Type.TYPE_INT32:
+ case FieldDescriptorProto.Types.Type.Int32:
return FieldType.Int32;
- case FieldDescriptorProto.Types.Type.TYPE_FIXED64:
+ case FieldDescriptorProto.Types.Type.Fixed64:
return FieldType.Fixed64;
- case FieldDescriptorProto.Types.Type.TYPE_FIXED32:
+ case FieldDescriptorProto.Types.Type.Fixed32:
return FieldType.Fixed32;
- case FieldDescriptorProto.Types.Type.TYPE_BOOL:
+ case FieldDescriptorProto.Types.Type.Bool:
return FieldType.Bool;
- case FieldDescriptorProto.Types.Type.TYPE_STRING:
+ case FieldDescriptorProto.Types.Type.String:
return FieldType.String;
- case FieldDescriptorProto.Types.Type.TYPE_GROUP:
+ case FieldDescriptorProto.Types.Type.Group:
return FieldType.Group;
- case FieldDescriptorProto.Types.Type.TYPE_MESSAGE:
+ case FieldDescriptorProto.Types.Type.Message:
return FieldType.Message;
- case FieldDescriptorProto.Types.Type.TYPE_BYTES:
+ case FieldDescriptorProto.Types.Type.Bytes:
return FieldType.Bytes;
- case FieldDescriptorProto.Types.Type.TYPE_UINT32:
+ case FieldDescriptorProto.Types.Type.Uint32:
return FieldType.UInt32;
- case FieldDescriptorProto.Types.Type.TYPE_ENUM:
+ case FieldDescriptorProto.Types.Type.Enum:
return FieldType.Enum;
- case FieldDescriptorProto.Types.Type.TYPE_SFIXED32:
+ case FieldDescriptorProto.Types.Type.Sfixed32:
return FieldType.SFixed32;
- case FieldDescriptorProto.Types.Type.TYPE_SFIXED64:
+ case FieldDescriptorProto.Types.Type.Sfixed64:
return FieldType.SFixed64;
- case FieldDescriptorProto.Types.Type.TYPE_SINT32:
+ case FieldDescriptorProto.Types.Type.Sint32:
return FieldType.SInt32;
- case FieldDescriptorProto.Types.Type.TYPE_SINT64:
+ case FieldDescriptorProto.Types.Type.Sint64:
return FieldType.SInt64;
default:
throw new ArgumentException("Invalid type specified");
@@ -177,7 +177,7 @@ namespace Google.Protobuf.Reflection
/// <summary>
/// Returns <c>true</c> if this field is a repeated field; <c>false</c> otherwise.
/// </summary>
- public bool IsRepeated => Proto.Label == FieldDescriptorProto.Types.Label.LABEL_REPEATED;
+ public bool IsRepeated => Proto.Label == FieldDescriptorProto.Types.Label.Repeated;
/// <summary>
/// Returns <c>true</c> if this field is a map field; <c>false</c> otherwise.
diff --git a/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs b/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs
new file mode 100644
index 00000000..27f9ab98
--- /dev/null
+++ b/csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs
@@ -0,0 +1,58 @@
+#region Copyright notice and license
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc. All rights reserved.
+// https://developers.google.com/protocol-buffers/
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#endregion
+
+using System;
+
+namespace Google.Protobuf.Reflection
+{
+ /// <summary>
+ /// Specifies the original name (in the .proto file) of a named element,
+ /// such as an enum value.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Field)]
+ public class OriginalNameAttribute : Attribute
+ {
+ /// <summary>
+ /// The name of the element in the .proto file.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Constructs a new attribute instance for the given name.
+ /// </summary>
+ /// <param name="name">The name of the element in the .proto file.</param>
+ public OriginalNameAttribute(string name)
+ {
+ Name = ProtoPreconditions.CheckNotNull(name, nameof(name));
+ }
+ }
+} \ No newline at end of file
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
index 48cd99a1..fd4e65b5 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Any.cs
@@ -24,9 +24,10 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Chlnb29nbGUvcHJvdG9idWYvYW55LnByb3RvEg9nb29nbGUucHJvdG9idWYi",
- "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQksKE2Nv",
- "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAGgAQGiAgNHUEKqAh5Hb29n",
- "bGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw=="));
+ "JgoDQW55EhAKCHR5cGVfdXJsGAEgASgJEg0KBXZhbHVlGAIgASgMQnIKE2Nv",
+ "bS5nb29nbGUucHJvdG9idWZCCEFueVByb3RvUAFaJWdpdGh1Yi5jb20vZ29s",
+ "YW5nL3Byb3RvYnVmL3B0eXBlcy9hbnmgAQGiAgNHUEKqAh5Hb29nbGUuUHJv",
+ "dG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
@@ -38,8 +39,36 @@ namespace Google.Protobuf.WellKnownTypes {
}
#region Messages
/// <summary>
- /// `Any` contains an arbitrary serialized message along with a URL
- /// that describes the type of the serialized message.
+ /// `Any` contains an arbitrary serialized protocol buffer message along with a
+ /// URL that describes the type of the serialized message.
+ ///
+ /// Protobuf library provides support to pack/unpack Any values in the form
+ /// of utility functions or additional generated methods of the Any type.
+ ///
+ /// Example 1: Pack and unpack a message in C++.
+ ///
+ /// Foo foo = ...;
+ /// Any any;
+ /// any.PackFrom(foo);
+ /// ...
+ /// if (any.UnpackTo(&amp;foo)) {
+ /// ...
+ /// }
+ ///
+ /// Example 2: Pack and unpack a message in Java.
+ ///
+ /// Foo foo = ...;
+ /// Any any = Any.pack(foo);
+ /// ...
+ /// if (any.is(Foo.class)) {
+ /// foo = any.unpack(Foo.class);
+ /// }
+ ///
+ /// The pack methods provided by protobuf library will by default use
+ /// 'type.googleapis.com/full.type.name' as the type URL and the unpack
+ /// methods only use the fully qualified type name after the last '/'
+ /// in the type URL, for example "foo.bar.com/x/y.z" will yield type
+ /// name "y.z".
///
/// JSON
/// ====
@@ -102,7 +131,7 @@ namespace Google.Protobuf.WellKnownTypes {
private string typeUrl_ = "";
/// <summary>
/// A URL/resource name whose content describes the type of the
- /// serialized message.
+ /// serialized protocol buffer message.
///
/// For URLs which use the schema `http`, `https`, or no schema, the
/// following restrictions and interpretations apply:
@@ -132,7 +161,7 @@ namespace Google.Protobuf.WellKnownTypes {
public const int ValueFieldNumber = 2;
private pb::ByteString value_ = pb::ByteString.Empty;
/// <summary>
- /// Must be valid serialized data of the above specified type.
+ /// Must be a valid serialized protocol buffer of the above specified type.
/// </summary>
public pb::ByteString Value {
get { return value_; }
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
index de7aea3a..e568a2c9 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Api.cs
@@ -185,7 +185,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "syntax" field.</summary>
public const int SyntaxFieldNumber = 7;
- private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2;
+ private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
/// The source syntax of the service.
/// </summary>
@@ -225,7 +225,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (Version.Length != 0) hash ^= Version.GetHashCode();
if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
hash ^= mixins_.GetHashCode();
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode();
+ if (Syntax != 0) hash ^= Syntax.GetHashCode();
return hash;
}
@@ -249,7 +249,7 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteMessage(SourceContext);
}
mixins_.WriteTo(output, _repeated_mixins_codec);
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
output.WriteRawTag(56);
output.WriteEnum((int) Syntax);
}
@@ -269,7 +269,7 @@ namespace Google.Protobuf.WellKnownTypes {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext);
}
size += mixins_.CalculateSize(_repeated_mixins_codec);
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
}
return size;
@@ -294,7 +294,7 @@ namespace Google.Protobuf.WellKnownTypes {
SourceContext.MergeFrom(other.SourceContext);
}
mixins_.Add(other.mixins_);
- if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (other.Syntax != 0) {
Syntax = other.Syntax;
}
}
@@ -458,7 +458,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "syntax" field.</summary>
public const int SyntaxFieldNumber = 7;
- private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2;
+ private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
/// The source syntax of this method.
/// </summary>
@@ -498,7 +498,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (ResponseTypeUrl.Length != 0) hash ^= ResponseTypeUrl.GetHashCode();
if (ResponseStreaming != false) hash ^= ResponseStreaming.GetHashCode();
hash ^= options_.GetHashCode();
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode();
+ if (Syntax != 0) hash ^= Syntax.GetHashCode();
return hash;
}
@@ -528,7 +528,7 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteBool(ResponseStreaming);
}
options_.WriteTo(output, _repeated_options_codec);
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
output.WriteRawTag(56);
output.WriteEnum((int) Syntax);
}
@@ -552,7 +552,7 @@ namespace Google.Protobuf.WellKnownTypes {
size += 1 + 1;
}
size += options_.CalculateSize(_repeated_options_codec);
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
}
return size;
@@ -578,7 +578,7 @@ namespace Google.Protobuf.WellKnownTypes {
ResponseStreaming = other.ResponseStreaming;
}
options_.Add(other.options_);
- if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (other.Syntax != 0) {
Syntax = other.Syntax;
}
}
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
index 73e221d4..f17358f4 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs
@@ -25,9 +25,10 @@ namespace Google.Protobuf.WellKnownTypes {
string.Concat(
"Ch5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90",
"b2J1ZiIqCghEdXJhdGlvbhIPCgdzZWNvbmRzGAEgASgDEg0KBW5hbm9zGAIg",
- "ASgFQlAKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAaAB",
- "AaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJv",
- "dG8z"));
+ "ASgFQnwKE2NvbS5nb29nbGUucHJvdG9idWZCDUR1cmF0aW9uUHJvdG9QAVoq",
+ "Z2l0aHViLmNvbS9nb2xhbmcvcHJvdG9idWYvcHR5cGVzL2R1cmF0aW9uoAEB",
+ "ogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90",
+ "bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
index 6cad4124..e08ea240 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs
@@ -24,9 +24,10 @@ namespace Google.Protobuf.WellKnownTypes {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Chtnb29nbGUvcHJvdG9idWYvZW1wdHkucHJvdG8SD2dvb2dsZS5wcm90b2J1",
- "ZiIHCgVFbXB0eUJQChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv",
- "UAGgAQH4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw",
- "ZXNiBnByb3RvMw=="));
+ "ZiIHCgVFbXB0eUJ5ChNjb20uZ29vZ2xlLnByb3RvYnVmQgpFbXB0eVByb3Rv",
+ "UAFaJ2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy9lbXB0eaAB",
+ "AfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IG",
+ "cHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
index 2ba2b96f..79a0319f 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs
@@ -159,6 +159,33 @@ namespace Google.Protobuf.WellKnownTypes {
/// {
/// mask: "user.displayName,photo"
/// }
+ ///
+ /// # Field Masks and Oneof Fields
+ ///
+ /// Field masks treat fields in oneofs just as regular fields. Consider the
+ /// following message:
+ ///
+ /// message SampleMessage {
+ /// oneof test_oneof {
+ /// string name = 4;
+ /// SubMessage sub_message = 9;
+ /// }
+ /// }
+ ///
+ /// The field mask can be:
+ ///
+ /// mask {
+ /// paths: "name"
+ /// }
+ ///
+ /// Or:
+ ///
+ /// mask {
+ /// paths: "sub_message"
+ /// }
+ ///
+ /// Note that oneof type names ("test_oneof" in this case) cannot be used in
+ /// paths.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public sealed partial class FieldMask : pb::IMessage<FieldMask> {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
index 8e2ce8cf..edc8940d 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs
@@ -34,9 +34,10 @@ namespace Google.Protobuf.WellKnownTypes {
"ABIwCgpsaXN0X3ZhbHVlGAYgASgLMhouZ29vZ2xlLnByb3RvYnVmLkxpc3RW",
"YWx1ZUgAQgYKBGtpbmQiMwoJTGlzdFZhbHVlEiYKBnZhbHVlcxgBIAMoCzIW",
"Lmdvb2dsZS5wcm90b2J1Zi5WYWx1ZSobCglOdWxsVmFsdWUSDgoKTlVMTF9W",
- "QUxVRRAAQk4KE2NvbS5nb29nbGUucHJvdG9idWZCC1N0cnVjdFByb3RvUAGg",
- "AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnBy",
- "b3RvMw=="));
+ "QUxVRRAAQoEBChNjb20uZ29vZ2xlLnByb3RvYnVmQgtTdHJ1Y3RQcm90b1AB",
+ "WjFnaXRodWIuY29tL2dvbGFuZy9wcm90b2J1Zi9wdHlwZXMvc3RydWN0O3N0",
+ "cnVjdHBioAEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5",
+ "cGVzYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.WellKnownTypes.NullValue), }, new pbr::GeneratedClrTypeInfo[] {
@@ -59,7 +60,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>
/// Null value.
/// </summary>
- NULL_VALUE = 0,
+ [pbr::OriginalName("NULL_VALUE")] NullValue = 0,
}
#endregion
@@ -108,7 +109,7 @@ namespace Google.Protobuf.WellKnownTypes {
= new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>.Codec(pb::FieldCodec.ForString(10), pb::FieldCodec.ForMessage(18, global::Google.Protobuf.WellKnownTypes.Value.Parser), 10);
private readonly pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> fields_ = new pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value>();
/// <summary>
- /// Map of dynamically typed values.
+ /// Unordered map of dynamically typed values.
/// </summary>
public pbc::MapField<string, global::Google.Protobuf.WellKnownTypes.Value> Fields {
get { return fields_; }
@@ -234,7 +235,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// Represents a null value.
/// </summary>
public global::Google.Protobuf.WellKnownTypes.NullValue NullValue {
- get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : global::Google.Protobuf.WellKnownTypes.NullValue.NULL_VALUE; }
+ get { return kindCase_ == KindOneofCase.NullValue ? (global::Google.Protobuf.WellKnownTypes.NullValue) kind_ : 0; }
set {
kind_ = value;
kindCase_ = KindOneofCase.NullValue;
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
index 318b0f61..053b88bd 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs
@@ -25,9 +25,10 @@ namespace Google.Protobuf.WellKnownTypes {
string.Concat(
"Ch9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnByb3RvEg9nb29nbGUucHJv",
"dG9idWYiKwoJVGltZXN0YW1wEg8KB3NlY29uZHMYASABKAMSDQoFbmFub3MY",
- "AiABKAVCVAoTY29tLmdvb2dsZS5wcm90b2J1ZkIOVGltZXN0YW1wUHJvdG9Q",
- "AaABAfgBAaICA0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBl",
- "c2IGcHJvdG8z"));
+ "AiABKAVCgQEKE2NvbS5nb29nbGUucHJvdG9idWZCDlRpbWVzdGFtcFByb3Rv",
+ "UAFaK2dpdGh1Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy90aW1lc3Rh",
+ "bXCgAQH4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlw",
+ "ZXNiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
index 8faa1d1c..657c2464 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Type.cs
@@ -79,11 +79,11 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>
/// Syntax `proto2`.
/// </summary>
- SYNTAX_PROTO2 = 0,
+ [pbr::OriginalName("SYNTAX_PROTO2")] Proto2 = 0,
/// <summary>
/// Syntax `proto3`.
/// </summary>
- SYNTAX_PROTO3 = 1,
+ [pbr::OriginalName("SYNTAX_PROTO3")] Proto3 = 1,
}
#endregion
@@ -188,7 +188,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "syntax" field.</summary>
public const int SyntaxFieldNumber = 6;
- private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2;
+ private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
/// The source syntax.
/// </summary>
@@ -226,7 +226,7 @@ namespace Google.Protobuf.WellKnownTypes {
hash ^= oneofs_.GetHashCode();
hash ^= options_.GetHashCode();
if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode();
+ if (Syntax != 0) hash ^= Syntax.GetHashCode();
return hash;
}
@@ -246,7 +246,7 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(42);
output.WriteMessage(SourceContext);
}
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
output.WriteRawTag(48);
output.WriteEnum((int) Syntax);
}
@@ -263,7 +263,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (sourceContext_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext);
}
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
}
return size;
@@ -285,7 +285,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
SourceContext.MergeFrom(other.SourceContext);
}
- if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (other.Syntax != 0) {
Syntax = other.Syntax;
}
}
@@ -371,7 +371,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "kind" field.</summary>
public const int KindFieldNumber = 1;
- private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN;
+ private global::Google.Protobuf.WellKnownTypes.Field.Types.Kind kind_ = 0;
/// <summary>
/// The field type.
/// </summary>
@@ -384,7 +384,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "cardinality" field.</summary>
public const int CardinalityFieldNumber = 2;
- private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN;
+ private global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality cardinality_ = 0;
/// <summary>
/// The field cardinality.
/// </summary>
@@ -526,8 +526,8 @@ namespace Google.Protobuf.WellKnownTypes {
public override int GetHashCode() {
int hash = 1;
- if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) hash ^= Kind.GetHashCode();
- if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) hash ^= Cardinality.GetHashCode();
+ if (Kind != 0) hash ^= Kind.GetHashCode();
+ if (Cardinality != 0) hash ^= Cardinality.GetHashCode();
if (Number != 0) hash ^= Number.GetHashCode();
if (Name.Length != 0) hash ^= Name.GetHashCode();
if (TypeUrl.Length != 0) hash ^= TypeUrl.GetHashCode();
@@ -544,11 +544,11 @@ namespace Google.Protobuf.WellKnownTypes {
}
public void WriteTo(pb::CodedOutputStream output) {
- if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) {
+ if (Kind != 0) {
output.WriteRawTag(8);
output.WriteEnum((int) Kind);
}
- if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) {
+ if (Cardinality != 0) {
output.WriteRawTag(16);
output.WriteEnum((int) Cardinality);
}
@@ -585,10 +585,10 @@ namespace Google.Protobuf.WellKnownTypes {
public int CalculateSize() {
int size = 0;
- if (Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) {
+ if (Kind != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Kind);
}
- if (Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) {
+ if (Cardinality != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Cardinality);
}
if (Number != 0) {
@@ -620,10 +620,10 @@ namespace Google.Protobuf.WellKnownTypes {
if (other == null) {
return;
}
- if (other.Kind != global::Google.Protobuf.WellKnownTypes.Field.Types.Kind.TYPE_UNKNOWN) {
+ if (other.Kind != 0) {
Kind = other.Kind;
}
- if (other.Cardinality != global::Google.Protobuf.WellKnownTypes.Field.Types.Cardinality.CARDINALITY_UNKNOWN) {
+ if (other.Cardinality != 0) {
Cardinality = other.Cardinality;
}
if (other.Number != 0) {
@@ -712,79 +712,79 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>
/// Field type unknown.
/// </summary>
- TYPE_UNKNOWN = 0,
+ [pbr::OriginalName("TYPE_UNKNOWN")] TypeUnknown = 0,
/// <summary>
/// Field type double.
/// </summary>
- TYPE_DOUBLE = 1,
+ [pbr::OriginalName("TYPE_DOUBLE")] TypeDouble = 1,
/// <summary>
/// Field type float.
/// </summary>
- TYPE_FLOAT = 2,
+ [pbr::OriginalName("TYPE_FLOAT")] TypeFloat = 2,
/// <summary>
/// Field type int64.
/// </summary>
- TYPE_INT64 = 3,
+ [pbr::OriginalName("TYPE_INT64")] TypeInt64 = 3,
/// <summary>
/// Field type uint64.
/// </summary>
- TYPE_UINT64 = 4,
+ [pbr::OriginalName("TYPE_UINT64")] TypeUint64 = 4,
/// <summary>
/// Field type int32.
/// </summary>
- TYPE_INT32 = 5,
+ [pbr::OriginalName("TYPE_INT32")] TypeInt32 = 5,
/// <summary>
/// Field type fixed64.
/// </summary>
- TYPE_FIXED64 = 6,
+ [pbr::OriginalName("TYPE_FIXED64")] TypeFixed64 = 6,
/// <summary>
/// Field type fixed32.
/// </summary>
- TYPE_FIXED32 = 7,
+ [pbr::OriginalName("TYPE_FIXED32")] TypeFixed32 = 7,
/// <summary>
/// Field type bool.
/// </summary>
- TYPE_BOOL = 8,
+ [pbr::OriginalName("TYPE_BOOL")] TypeBool = 8,
/// <summary>
/// Field type string.
/// </summary>
- TYPE_STRING = 9,
+ [pbr::OriginalName("TYPE_STRING")] TypeString = 9,
/// <summary>
/// Field type group. Proto2 syntax only, and deprecated.
/// </summary>
- TYPE_GROUP = 10,
+ [pbr::OriginalName("TYPE_GROUP")] TypeGroup = 10,
/// <summary>
/// Field type message.
/// </summary>
- TYPE_MESSAGE = 11,
+ [pbr::OriginalName("TYPE_MESSAGE")] TypeMessage = 11,
/// <summary>
/// Field type bytes.
/// </summary>
- TYPE_BYTES = 12,
+ [pbr::OriginalName("TYPE_BYTES")] TypeBytes = 12,
/// <summary>
/// Field type uint32.
/// </summary>
- TYPE_UINT32 = 13,
+ [pbr::OriginalName("TYPE_UINT32")] TypeUint32 = 13,
/// <summary>
/// Field type enum.
/// </summary>
- TYPE_ENUM = 14,
+ [pbr::OriginalName("TYPE_ENUM")] TypeEnum = 14,
/// <summary>
/// Field type sfixed32.
/// </summary>
- TYPE_SFIXED32 = 15,
+ [pbr::OriginalName("TYPE_SFIXED32")] TypeSfixed32 = 15,
/// <summary>
/// Field type sfixed64.
/// </summary>
- TYPE_SFIXED64 = 16,
+ [pbr::OriginalName("TYPE_SFIXED64")] TypeSfixed64 = 16,
/// <summary>
/// Field type sint32.
/// </summary>
- TYPE_SINT32 = 17,
+ [pbr::OriginalName("TYPE_SINT32")] TypeSint32 = 17,
/// <summary>
/// Field type sint64.
/// </summary>
- TYPE_SINT64 = 18,
+ [pbr::OriginalName("TYPE_SINT64")] TypeSint64 = 18,
}
/// <summary>
@@ -794,19 +794,19 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>
/// For fields with unknown cardinality.
/// </summary>
- CARDINALITY_UNKNOWN = 0,
+ [pbr::OriginalName("CARDINALITY_UNKNOWN")] Unknown = 0,
/// <summary>
/// For optional fields.
/// </summary>
- CARDINALITY_OPTIONAL = 1,
+ [pbr::OriginalName("CARDINALITY_OPTIONAL")] Optional = 1,
/// <summary>
/// For required fields. Proto2 syntax only.
/// </summary>
- CARDINALITY_REQUIRED = 2,
+ [pbr::OriginalName("CARDINALITY_REQUIRED")] Required = 2,
/// <summary>
/// For repeated fields.
/// </summary>
- CARDINALITY_REPEATED = 3,
+ [pbr::OriginalName("CARDINALITY_REPEATED")] Repeated = 3,
}
}
@@ -900,7 +900,7 @@ namespace Google.Protobuf.WellKnownTypes {
/// <summary>Field number for the "syntax" field.</summary>
public const int SyntaxFieldNumber = 5;
- private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2;
+ private global::Google.Protobuf.WellKnownTypes.Syntax syntax_ = 0;
/// <summary>
/// The source syntax.
/// </summary>
@@ -936,7 +936,7 @@ namespace Google.Protobuf.WellKnownTypes {
hash ^= enumvalue_.GetHashCode();
hash ^= options_.GetHashCode();
if (sourceContext_ != null) hash ^= SourceContext.GetHashCode();
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) hash ^= Syntax.GetHashCode();
+ if (Syntax != 0) hash ^= Syntax.GetHashCode();
return hash;
}
@@ -955,7 +955,7 @@ namespace Google.Protobuf.WellKnownTypes {
output.WriteRawTag(34);
output.WriteMessage(SourceContext);
}
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
output.WriteRawTag(40);
output.WriteEnum((int) Syntax);
}
@@ -971,7 +971,7 @@ namespace Google.Protobuf.WellKnownTypes {
if (sourceContext_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(SourceContext);
}
- if (Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (Syntax != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Syntax);
}
return size;
@@ -992,7 +992,7 @@ namespace Google.Protobuf.WellKnownTypes {
}
SourceContext.MergeFrom(other.SourceContext);
}
- if (other.Syntax != global::Google.Protobuf.WellKnownTypes.Syntax.SYNTAX_PROTO2) {
+ if (other.Syntax != 0) {
Syntax = other.Syntax;
}
}
diff --git a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
index d6796d1a..c8867d0e 100644
--- a/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
+++ b/csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs
@@ -29,10 +29,10 @@ namespace Google.Protobuf.WellKnownTypes {
"KAMiHAoLVUludDY0VmFsdWUSDQoFdmFsdWUYASABKAQiGwoKSW50MzJWYWx1",
"ZRINCgV2YWx1ZRgBIAEoBSIcCgtVSW50MzJWYWx1ZRINCgV2YWx1ZRgBIAEo",
"DSIaCglCb29sVmFsdWUSDQoFdmFsdWUYASABKAgiHAoLU3RyaW5nVmFsdWUS",
- "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJT",
- "ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAGgAQH4AQGi",
- "AgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3Rv",
- "Mw=="));
+ "DQoFdmFsdWUYASABKAkiGwoKQnl0ZXNWYWx1ZRINCgV2YWx1ZRgBIAEoDEJ/",
+ "ChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAFaKmdpdGh1",
+ "Yi5jb20vZ29sYW5nL3Byb3RvYnVmL3B0eXBlcy93cmFwcGVyc6ABAfgBAaIC",
+ "A0dQQqoCHkdvb2dsZS5Qcm90b2J1Zi5XZWxsS25vd25UeXBlc2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
diff --git a/js/gulpfile.js b/js/gulpfile.js
index 7e44aa76..c5220153 100644
--- a/js/gulpfile.js
+++ b/js/gulpfile.js
@@ -1,7 +1,11 @@
var gulp = require('gulp');
-var exec = require('child_process').exec;
+var execFile = require('child_process').execFile;
var glob = require('glob');
+function exec(command, cb) {
+ execFile('sh', ['-c', command], cb);
+}
+
var protoc = process.env.PROTOC || '../src/protoc';
gulp.task('genproto_closure', function (cb) {
diff --git a/js/package.json b/js/package.json
index 6418e507..c16417ca 100644
--- a/js/package.json
+++ b/js/package.json
@@ -13,7 +13,7 @@
"glob": "~6.0.4"
},
"scripts": {
- "test": "./node_modules/gulp/bin/gulp.js test"
+ "test": "node ./node_modules/gulp/bin/gulp.js test"
},
"repository": {
"type": "git",
diff --git a/objectivec/DevTools/full_mac_build.sh b/objectivec/DevTools/full_mac_build.sh
index 4d4930dc..ff51d9f0 100755
--- a/objectivec/DevTools/full_mac_build.sh
+++ b/objectivec/DevTools/full_mac_build.sh
@@ -26,8 +26,9 @@ OPTIONS:
Issue a clean before the normal build.
-a, --autogen
Start by rerunning autogen & configure.
- -r, --regenerate-cpp-descriptors
- The descriptor.proto is checked in generated, cause it to regenerate.
+ -r, --regenerate-descriptors
+ Run generate_descriptor_proto.sh to regenerate all the checked in
+ proto sources.
-j #, --jobs #
Force the number of parallel jobs (useful for debugging build issues).
--core-only
@@ -71,7 +72,7 @@ fi
DO_AUTOGEN=no
DO_CLEAN=no
-REGEN_CPP_DESCRIPTORS=no
+REGEN_DESCRIPTORS=no
CORE_ONLY=no
DO_XCODE_IOS_TESTS=yes
DO_XCODE_OSX_TESTS=yes
@@ -88,8 +89,8 @@ while [[ $# != 0 ]]; do
-a | --autogen )
DO_AUTOGEN=yes
;;
- -r | --regenerate-cpp-descriptors )
- REGEN_CPP_DESCRIPTORS=yes
+ -r | --regenerate-descriptors )
+ REGEN_DESCRIPTORS=yes
;;
-j | --jobs )
shift
@@ -164,8 +165,8 @@ if [[ "${DO_CLEAN}" == "yes" ]] ; then
fi
fi
-if [[ "${REGEN_CPP_DESCRIPTORS}" == "yes" ]] ; then
- header "Regenerating the C++ descriptor sources."
+if [[ "${REGEN_DESCRIPTORS}" == "yes" ]] ; then
+ header "Regenerating the descriptor sources."
./generate_descriptor_proto.sh -j "${NUM_MAKE_JOBS}"
fi
@@ -184,29 +185,8 @@ else
cd ..
fi
-header "Ensuring the ObjC descriptors are current."
-# Find the newest input file (protos, compiler, and the generator script).
-# (these patterns catch some extra stuff, but better to over sample than under)
-readonly NewestInput=$(find \
- src/google/protobuf/*.proto \
- src/.libs src/*.la src/protoc \
- objectivec/generate_well_known_types.sh \
- -type f -print0 \
- | xargs -0 stat -f "%m %N" \
- | sort -n | tail -n1 | cut -f2- -d" ")
-# Find the oldest output file.
-readonly OldestOutput=$(find \
- "${ProtoRootDir}/objectivec/google" \
- -type f -print0 \
- | xargs -0 stat -f "%m %N" \
- | sort -n -r | tail -n1 | cut -f2- -d" ")
-# If the newest input is newer than the oldest output, regenerate.
-if [[ "${NewestInput}" -nt "${OldestOutput}" ]] ; then
- echo ">> Newest input is newer than oldest output, regenerating."
- objectivec/generate_well_known_types.sh -j "${NUM_MAKE_JOBS}"
-else
- echo ">> Newest input is older than oldest output, no need to regenerating."
-fi
+# Ensure the WKT sources checked in are current.
+objectivec/generate_well_known_types.sh --check-only -j "${NUM_MAKE_JOBS}"
header "Checking on the ObjC Runtime Code"
objectivec/DevTools/pddm_tests.py
diff --git a/objectivec/GPBCodedOutputStream.h b/objectivec/GPBCodedOutputStream.h
index e67efd2d..8272880d 100644
--- a/objectivec/GPBCodedOutputStream.h
+++ b/objectivec/GPBCodedOutputStream.h
@@ -112,7 +112,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a double for the given field number.
- (void)writeDouble:(int32_t)fieldNumber value:(double)value;
-/// Write a packaged array of double for the given field number.
+/// Write a packed array of double for the given field number.
- (void)writeDoubleArray:(int32_t)fieldNumber
values:(GPBDoubleArray *)values
tag:(uint32_t)tag;
@@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a float for the given field number.
- (void)writeFloat:(int32_t)fieldNumber value:(float)value;
-/// Write a packaged array of float for the given field number.
+/// Write a packed array of float for the given field number.
- (void)writeFloatArray:(int32_t)fieldNumber
values:(GPBFloatArray *)values
tag:(uint32_t)tag;
@@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a uint64_t for the given field number.
- (void)writeUInt64:(int32_t)fieldNumber value:(uint64_t)value;
-/// Write a packaged array of uint64_t for the given field number.
+/// Write a packed array of uint64_t for the given field number.
- (void)writeUInt64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
tag:(uint32_t)tag;
@@ -139,7 +139,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int64_t for the given field number.
- (void)writeInt64:(int32_t)fieldNumber value:(int64_t)value;
-/// Write a packaged array of int64_t for the given field number.
+/// Write a packed array of int64_t for the given field number.
- (void)writeInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
@@ -148,7 +148,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int32_t for the given field number.
- (void)writeInt32:(int32_t)fieldNumber value:(int32_t)value;
-/// Write a packaged array of int32_t for the given field number.
+/// Write a packed array of int32_t for the given field number.
- (void)writeInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
@@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a uint32_t for the given field number.
- (void)writeUInt32:(int32_t)fieldNumber value:(uint32_t)value;
-/// Write a packaged array of uint32_t for the given field number.
+/// Write a packed array of uint32_t for the given field number.
- (void)writeUInt32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
tag:(uint32_t)tag;
@@ -166,7 +166,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a uint64_t for the given field number.
- (void)writeFixed64:(int32_t)fieldNumber value:(uint64_t)value;
-/// Write a packaged array of uint64_t for the given field number.
+/// Write a packed array of uint64_t for the given field number.
- (void)writeFixed64Array:(int32_t)fieldNumber
values:(GPBUInt64Array *)values
tag:(uint32_t)tag;
@@ -175,7 +175,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a uint32_t for the given field number.
- (void)writeFixed32:(int32_t)fieldNumber value:(uint32_t)value;
-/// Write a packaged array of uint32_t for the given field number.
+/// Write a packed array of uint32_t for the given field number.
- (void)writeFixed32Array:(int32_t)fieldNumber
values:(GPBUInt32Array *)values
tag:(uint32_t)tag;
@@ -184,7 +184,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int32_t for the given field number.
- (void)writeSInt32:(int32_t)fieldNumber value:(int32_t)value;
-/// Write a packaged array of int32_t for the given field number.
+/// Write a packed array of int32_t for the given field number.
- (void)writeSInt32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
@@ -193,7 +193,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int64_t for the given field number.
- (void)writeSInt64:(int32_t)fieldNumber value:(int64_t)value;
-/// Write a packaged array of int64_t for the given field number.
+/// Write a packed array of int64_t for the given field number.
- (void)writeSInt64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
@@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int64_t for the given field number.
- (void)writeSFixed64:(int32_t)fieldNumber value:(int64_t)value;
-/// Write a packaged array of int64_t for the given field number.
+/// Write a packed array of int64_t for the given field number.
- (void)writeSFixed64Array:(int32_t)fieldNumber
values:(GPBInt64Array *)values
tag:(uint32_t)tag;
@@ -211,7 +211,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int32_t for the given field number.
- (void)writeSFixed32:(int32_t)fieldNumber value:(int32_t)value;
-/// Write a packaged array of int32_t for the given field number.
+/// Write a packed array of int32_t for the given field number.
- (void)writeSFixed32Array:(int32_t)fieldNumber
values:(GPBInt32Array *)values
tag:(uint32_t)tag;
@@ -220,7 +220,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a BOOL for the given field number.
- (void)writeBool:(int32_t)fieldNumber value:(BOOL)value;
-/// Write a packaged array of BOOL for the given field number.
+/// Write a packed array of BOOL for the given field number.
- (void)writeBoolArray:(int32_t)fieldNumber
values:(GPBBoolArray *)values
tag:(uint32_t)tag;
@@ -229,7 +229,7 @@ NS_ASSUME_NONNULL_BEGIN
/// Write a int32_t for the given field number.
- (void)writeEnum:(int32_t)fieldNumber value:(int32_t)value;
-/// Write a packaged array of int32_t for the given field number.
+/// Write a packed array of int32_t for the given field number.
- (void)writeEnumArray:(int32_t)fieldNumber
values:(GPBEnumArray *)values
tag:(uint32_t)tag;
@@ -293,7 +293,7 @@ NS_ASSUME_NONNULL_END
//%PDDM-DEFINE _WRITE_PACKABLE_DECLS(NAME, ARRAY_TYPE, TYPE)
//%/// Write a TYPE for the given field number.
//%- (void)write##NAME:(int32_t)fieldNumber value:(TYPE)value;
-//%/// Write a packaged array of TYPE for the given field number.
+//%/// Write a packed array of TYPE for the given field number.
//%- (void)write##NAME##Array:(int32_t)fieldNumber
//% NAME$S values:(GPB##ARRAY_TYPE##Array *)values
//% NAME$S tag:(uint32_t)tag;
diff --git a/objectivec/generate_well_known_types.sh b/objectivec/generate_well_known_types.sh
index be9b38a5..73be50ff 100755
--- a/objectivec/generate_well_known_types.sh
+++ b/objectivec/generate_well_known_types.sh
@@ -12,6 +12,13 @@ set -eu
readonly ScriptDir=$(dirname "$(echo $0 | sed -e "s,^\([^/]\),$(pwd)/\1,")")
readonly ProtoRootDir="${ScriptDir}/.."
+# Flag for continuous integration to check that everything is current.
+CHECK_ONLY=0
+if [[ $# -ge 1 && ( "$1" == "--check-only" ) ]] ; then
+ CHECK_ONLY=1
+ shift
+fi
+
pushd "${ProtoRootDir}" > /dev/null
if test ! -e src/google/protobuf/stubs/common.h; then
@@ -46,4 +53,24 @@ declare -a RUNTIME_PROTO_FILES=( \
google/protobuf/type.proto \
google/protobuf/wrappers.proto)
-./protoc --objc_out="${ProtoRootDir}/objectivec" ${RUNTIME_PROTO_FILES[@]}
+# Generate to a temp directory to see if they match.
+TMP_DIR=$(mktemp -d)
+trap "rm -rf ${TMP_DIR}" EXIT
+./protoc --objc_out="${TMP_DIR}" ${RUNTIME_PROTO_FILES[@]}
+set +e
+diff -r "${TMP_DIR}/google" "${ProtoRootDir}/objectivec/google" > /dev/null
+if [[ $? -eq 0 ]] ; then
+ echo "Generated source for WellKnownTypes is current."
+ exit 0
+fi
+set -e
+
+# If check only mode, error out.
+if [[ "${CHECK_ONLY}" == 1 ]] ; then
+ echo "ERROR: The WKTs need to be regenerated! Run $0"
+ exit 1
+fi
+
+# Copy them over.
+echo "Copying over updated WellKnownType sources."
+cp -r "${TMP_DIR}/google/" "${ProtoRootDir}/objectivec/google/"
diff --git a/objectivec/google/protobuf/Any.pbobjc.h b/objectivec/google/protobuf/Any.pbobjc.h
index 79ec0fb7..439e3b37 100644
--- a/objectivec/google/protobuf/Any.pbobjc.h
+++ b/objectivec/google/protobuf/Any.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -33,8 +36,36 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
GPBAny_FieldNumber_Value = 2,
};
-/// `Any` contains an arbitrary serialized message along with a URL
-/// that describes the type of the serialized message.
+/// `Any` contains an arbitrary serialized protocol buffer message along with a
+/// URL that describes the type of the serialized message.
+///
+/// Protobuf library provides support to pack/unpack Any values in the form
+/// of utility functions or additional generated methods of the Any type.
+///
+/// Example 1: Pack and unpack a message in C++.
+///
+/// Foo foo = ...;
+/// Any any;
+/// any.PackFrom(foo);
+/// ...
+/// if (any.UnpackTo(&foo)) {
+/// ...
+/// }
+///
+/// Example 2: Pack and unpack a message in Java.
+///
+/// Foo foo = ...;
+/// Any any = Any.pack(foo);
+/// ...
+/// if (any.is(Foo.class)) {
+/// foo = any.unpack(Foo.class);
+/// }
+///
+/// The pack methods provided by protobuf library will by default use
+/// 'type.googleapis.com/full.type.name' as the type URL and the unpack
+/// methods only use the fully qualified type name after the last '/'
+/// in the type URL, for example "foo.bar.com/x/y.z" will yield type
+/// name "y.z".
///
///
/// JSON
@@ -67,7 +98,7 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
@interface GPBAny : GPBMessage
/// A URL/resource name whose content describes the type of the
-/// serialized message.
+/// serialized protocol buffer message.
///
/// For URLs which use the schema `http`, `https`, or no schema, the
/// following restrictions and interpretations apply:
@@ -87,7 +118,7 @@ typedef GPB_ENUM(GPBAny_FieldNumber) {
/// used with implementation specific semantics.
@property(nonatomic, readwrite, copy, null_resettable) NSString *typeURL;
-/// Must be valid serialized data of the above specified type.
+/// Must be a valid serialized protocol buffer of the above specified type.
@property(nonatomic, readwrite, copy, null_resettable) NSData *value;
@end
@@ -96,4 +127,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Any.pbobjc.m b/objectivec/google/protobuf/Any.pbobjc.m
index 7cbf0def..6a1bf894 100644
--- a/objectivec/google/protobuf/Any.pbobjc.m
+++ b/objectivec/google/protobuf/Any.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/Any.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBAnyRoot
@implementation GPBAnyRoot
@@ -85,4 +88,6 @@ typedef struct GPBAny__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Api.pbobjc.h b/objectivec/google/protobuf/Api.pbobjc.h
index 3f7e99c6..d66df629 100644
--- a/objectivec/google/protobuf/Api.pbobjc.h
+++ b/objectivec/google/protobuf/Api.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
@class GPBMethod;
@@ -254,4 +257,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Api.pbobjc.m b/objectivec/google/protobuf/Api.pbobjc.m
index 2b2f62ea..45a06e60 100644
--- a/objectivec/google/protobuf/Api.pbobjc.m
+++ b/objectivec/google/protobuf/Api.pbobjc.m
@@ -7,6 +7,9 @@
#import "google/protobuf/Type.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBApiRoot
@implementation GPBApiRoot
@@ -340,4 +343,6 @@ typedef struct GPBMixin__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Duration.pbobjc.h b/objectivec/google/protobuf/Duration.pbobjc.h
index 3685a614..29888d6c 100644
--- a/objectivec/google/protobuf/Duration.pbobjc.h
+++ b/objectivec/google/protobuf/Duration.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -93,4 +96,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Duration.pbobjc.m b/objectivec/google/protobuf/Duration.pbobjc.m
index bb79c7a3..7dd6b64a 100644
--- a/objectivec/google/protobuf/Duration.pbobjc.m
+++ b/objectivec/google/protobuf/Duration.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/Duration.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBDurationRoot
@implementation GPBDurationRoot
@@ -80,4 +83,6 @@ typedef struct GPBDuration__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Empty.pbobjc.h b/objectivec/google/protobuf/Empty.pbobjc.h
index 6651ef71..f33db017 100644
--- a/objectivec/google/protobuf/Empty.pbobjc.h
+++ b/objectivec/google/protobuf/Empty.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -45,4 +48,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Empty.pbobjc.m b/objectivec/google/protobuf/Empty.pbobjc.m
index 5d7f8f19..88753aaf 100644
--- a/objectivec/google/protobuf/Empty.pbobjc.m
+++ b/objectivec/google/protobuf/Empty.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/Empty.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBEmptyRoot
@implementation GPBEmptyRoot
@@ -56,4 +59,6 @@ typedef struct GPBEmpty__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.h b/objectivec/google/protobuf/FieldMask.pbobjc.h
index 931f664c..47a239ba 100644
--- a/objectivec/google/protobuf/FieldMask.pbobjc.h
+++ b/objectivec/google/protobuf/FieldMask.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -154,6 +157,33 @@ typedef GPB_ENUM(GPBFieldMask_FieldNumber) {
/// {
/// mask: "user.displayName,photo"
/// }
+///
+/// # Field Masks and Oneof Fields
+///
+/// Field masks treat fields in oneofs just as regular fields. Consider the
+/// following message:
+///
+/// message SampleMessage {
+/// oneof test_oneof {
+/// string name = 4;
+/// SubMessage sub_message = 9;
+/// }
+/// }
+///
+/// The field mask can be:
+///
+/// mask {
+/// paths: "name"
+/// }
+///
+/// Or:
+///
+/// mask {
+/// paths: "sub_message"
+/// }
+///
+/// Note that oneof type names ("test_oneof" in this case) cannot be used in
+/// paths.
@interface GPBFieldMask : GPBMessage
/// The set of field mask paths.
@@ -167,4 +197,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/FieldMask.pbobjc.m b/objectivec/google/protobuf/FieldMask.pbobjc.m
index 36fc758e..8c241afc 100644
--- a/objectivec/google/protobuf/FieldMask.pbobjc.m
+++ b/objectivec/google/protobuf/FieldMask.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/FieldMask.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBFieldMaskRoot
@implementation GPBFieldMaskRoot
@@ -69,4 +72,6 @@ typedef struct GPBFieldMask__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.h b/objectivec/google/protobuf/SourceContext.pbobjc.h
index 67b6d479..8775348e 100644
--- a/objectivec/google/protobuf/SourceContext.pbobjc.h
+++ b/objectivec/google/protobuf/SourceContext.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -46,4 +49,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/SourceContext.pbobjc.m b/objectivec/google/protobuf/SourceContext.pbobjc.m
index 4e8bf3d2..95007126 100644
--- a/objectivec/google/protobuf/SourceContext.pbobjc.m
+++ b/objectivec/google/protobuf/SourceContext.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/SourceContext.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBSourceContextRoot
@implementation GPBSourceContextRoot
@@ -69,4 +72,6 @@ typedef struct GPBSourceContext__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Struct.pbobjc.h b/objectivec/google/protobuf/Struct.pbobjc.h
index e2388e22..3924b4b7 100644
--- a/objectivec/google/protobuf/Struct.pbobjc.h
+++ b/objectivec/google/protobuf/Struct.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
@class GPBListValue;
@@ -67,7 +70,7 @@ typedef GPB_ENUM(GPBStruct_FieldNumber) {
/// The JSON representation for `Struct` is JSON object.
@interface GPBStruct : GPBMessage
-/// Map of dynamically typed values.
+/// Unordered map of dynamically typed values.
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, GPBValue*> *fields;
/// The number of items in @c fields without causing the array to be created.
@property(nonatomic, readonly) NSUInteger fields_Count;
@@ -159,4 +162,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Struct.pbobjc.m b/objectivec/google/protobuf/Struct.pbobjc.m
index 0601a4b2..60940027 100644
--- a/objectivec/google/protobuf/Struct.pbobjc.m
+++ b/objectivec/google/protobuf/Struct.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/Struct.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBStructRoot
@implementation GPBStructRoot
@@ -265,4 +268,6 @@ typedef struct GPBListValue__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.h b/objectivec/google/protobuf/Timestamp.pbobjc.h
index b66b323a..925dca84 100644
--- a/objectivec/google/protobuf/Timestamp.pbobjc.h
+++ b/objectivec/google/protobuf/Timestamp.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -105,4 +108,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Timestamp.pbobjc.m b/objectivec/google/protobuf/Timestamp.pbobjc.m
index 14161159..f35e435d 100644
--- a/objectivec/google/protobuf/Timestamp.pbobjc.m
+++ b/objectivec/google/protobuf/Timestamp.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/Timestamp.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBTimestampRoot
@implementation GPBTimestampRoot
@@ -80,4 +83,6 @@ typedef struct GPBTimestamp__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Type.pbobjc.h b/objectivec/google/protobuf/Type.pbobjc.h
index efaeab39..590d970b 100644
--- a/objectivec/google/protobuf/Type.pbobjc.h
+++ b/objectivec/google/protobuf/Type.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
@class GPBAny;
@@ -365,4 +368,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Type.pbobjc.m b/objectivec/google/protobuf/Type.pbobjc.m
index 175c0233..5554a222 100644
--- a/objectivec/google/protobuf/Type.pbobjc.m
+++ b/objectivec/google/protobuf/Type.pbobjc.m
@@ -7,6 +7,9 @@
#import "google/protobuf/SourceContext.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBTypeRoot
@implementation GPBTypeRoot
@@ -685,4 +688,6 @@ typedef struct GPBOption__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.h b/objectivec/google/protobuf/Wrappers.pbobjc.h
index 0ca439a8..46510500 100644
--- a/objectivec/google/protobuf/Wrappers.pbobjc.h
+++ b/objectivec/google/protobuf/Wrappers.pbobjc.h
@@ -9,6 +9,9 @@
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
CF_EXTERN_C_BEGIN
NS_ASSUME_NONNULL_BEGIN
@@ -174,4 +177,6 @@ NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/objectivec/google/protobuf/Wrappers.pbobjc.m b/objectivec/google/protobuf/Wrappers.pbobjc.m
index b1b5be69..5cc6c2e4 100644
--- a/objectivec/google/protobuf/Wrappers.pbobjc.m
+++ b/objectivec/google/protobuf/Wrappers.pbobjc.m
@@ -5,6 +5,9 @@
#import "google/protobuf/Wrappers.pbobjc.h"
// @@protoc_insertion_point(imports)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
#pragma mark - GPBWrappersRoot
@implementation GPBWrappersRoot
@@ -412,4 +415,6 @@ typedef struct GPBBytesValue__storage_ {
@end
+#pragma clang diagnostic pop
+
// @@protoc_insertion_point(global_scope)
diff --git a/ruby/README.md b/ruby/README.md
index 16474322..f28e05a7 100644
--- a/ruby/README.md
+++ b/ruby/README.md
@@ -32,23 +32,25 @@ documentation may be found in the RubyDoc comments (`call-seq` tags) in the
source, and we plan to release separate, more detailed, documentation at a
later date.
- require 'google/protobuf'
+```ruby
+require 'google/protobuf'
- # generated from my_proto_types.proto with protoc:
- # $ protoc --ruby_out=. my_proto_types.proto
- require 'my_proto_types'
+# generated from my_proto_types.proto with protoc:
+# $ protoc --ruby_out=. my_proto_types.proto
+require 'my_proto_types'
- mymessage = MyTestMessage.new(:field1 => 42, :field2 => ["a", "b", "c"])
- mymessage.field1 = 43
- mymessage.field2.push("d")
- mymessage.field3 = SubMessage.new(:foo => 100)
+mymessage = MyTestMessage.new(:field1 => 42, :field2 => ["a", "b", "c"])
+mymessage.field1 = 43
+mymessage.field2.push("d")
+mymessage.field3 = SubMessage.new(:foo => 100)
- encoded_data = MyTestMessage.encode(mymessage)
- decoded = MyTestMessage.decode(encoded_data)
- assert decoded == mymessage
+encoded_data = MyTestMessage.encode(mymessage)
+decoded = MyTestMessage.decode(encoded_data)
+assert decoded == mymessage
- puts "JSON:"
- puts MyTestMessage.encode_json(mymessage)
+puts "JSON:"
+puts MyTestMessage.encode_json(mymessage)
+```
Installation from Source (Building Gem)
---------------------------------------
diff --git a/ruby/ext/google/protobuf_c/defs.c b/ruby/ext/google/protobuf_c/defs.c
index 96ef4953..7e93bafb 100644
--- a/ruby/ext/google/protobuf_c/defs.c
+++ b/ruby/ext/google/protobuf_c/defs.c
@@ -255,6 +255,10 @@ void Descriptor_free(void* _self) {
upb_handlers_unref(self->json_serialize_handlers,
&self->json_serialize_handlers);
}
+ if (self->json_serialize_handlers_preserve) {
+ upb_handlers_unref(self->json_serialize_handlers_preserve,
+ &self->json_serialize_handlers_preserve);
+ }
xfree(self);
}
@@ -278,6 +282,7 @@ VALUE Descriptor_alloc(VALUE klass) {
self->json_fill_method = NULL;
self->pb_serialize_handlers = NULL;
self->json_serialize_handlers = NULL;
+ self->json_serialize_handlers_preserve = NULL;
self->typeclass_references = rb_ary_new();
return ret;
}
diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c
index c2c369eb..9bc7273e 100644
--- a/ruby/ext/google/protobuf_c/encode_decode.c
+++ b/ruby/ext/google/protobuf_c/encode_decode.c
@@ -1130,13 +1130,23 @@ static const upb_handlers* msgdef_pb_serialize_handlers(Descriptor* desc) {
return desc->pb_serialize_handlers;
}
-static const upb_handlers* msgdef_json_serialize_handlers(Descriptor* desc) {
- if (desc->json_serialize_handlers == NULL) {
- desc->json_serialize_handlers =
- upb_json_printer_newhandlers(
- desc->msgdef, &desc->json_serialize_handlers);
+static const upb_handlers* msgdef_json_serialize_handlers(
+ Descriptor* desc, bool preserve_proto_fieldnames) {
+ if (preserve_proto_fieldnames) {
+ if (desc->json_serialize_handlers == NULL) {
+ desc->json_serialize_handlers =
+ upb_json_printer_newhandlers(
+ desc->msgdef, true, &desc->json_serialize_handlers);
+ }
+ return desc->json_serialize_handlers;
+ } else {
+ if (desc->json_serialize_handlers_preserve == NULL) {
+ desc->json_serialize_handlers_preserve =
+ upb_json_printer_newhandlers(
+ desc->msgdef, false, &desc->json_serialize_handlers_preserve);
+ }
+ return desc->json_serialize_handlers_preserve;
}
- return desc->json_serialize_handlers;
}
/*
@@ -1181,16 +1191,33 @@ VALUE Message_encode(VALUE klass, VALUE msg_rb) {
*
* Encodes the given message object into its serialized JSON representation.
*/
-VALUE Message_encode_json(VALUE klass, VALUE msg_rb) {
+VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass) {
VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned);
Descriptor* desc = ruby_to_Descriptor(descriptor);
-
+ VALUE msg_rb;
+ VALUE preserve_proto_fieldnames = Qfalse;
stringsink sink;
+
+ if (argc < 1 || argc > 2) {
+ rb_raise(rb_eArgError, "Expected 1 or 2 arguments.");
+ }
+
+ msg_rb = argv[0];
+
+ if (argc == 2) {
+ VALUE hash_args = argv[1];
+ if (TYPE(hash_args) != T_HASH) {
+ rb_raise(rb_eArgError, "Expected hash arguments.");
+ }
+ preserve_proto_fieldnames = rb_hash_lookup2(
+ hash_args, ID2SYM(rb_intern("preserve_proto_fieldnames")), Qfalse);
+ }
+
stringsink_init(&sink);
{
const upb_handlers* serialize_handlers =
- msgdef_json_serialize_handlers(desc);
+ msgdef_json_serialize_handlers(desc, RTEST(preserve_proto_fieldnames));
upb_json_printer* printer;
stackenv se;
VALUE ret;
diff --git a/ruby/ext/google/protobuf_c/message.c b/ruby/ext/google/protobuf_c/message.c
index 283939c9..3a51fe47 100644
--- a/ruby/ext/google/protobuf_c/message.c
+++ b/ruby/ext/google/protobuf_c/message.c
@@ -475,7 +475,7 @@ VALUE build_class_from_descriptor(Descriptor* desc) {
rb_define_singleton_method(klass, "decode", Message_decode, 1);
rb_define_singleton_method(klass, "encode", Message_encode, 1);
rb_define_singleton_method(klass, "decode_json", Message_decode_json, 1);
- rb_define_singleton_method(klass, "encode_json", Message_encode_json, 1);
+ rb_define_singleton_method(klass, "encode_json", Message_encode_json, -1);
rb_define_singleton_method(klass, "descriptor", Message_descriptor, 0);
return klass;
diff --git a/ruby/ext/google/protobuf_c/protobuf.h b/ruby/ext/google/protobuf_c/protobuf.h
index 21ce7bb3..2834c894 100644
--- a/ruby/ext/google/protobuf_c/protobuf.h
+++ b/ruby/ext/google/protobuf_c/protobuf.h
@@ -115,6 +115,7 @@ struct Descriptor {
const upb_json_parsermethod* json_fill_method;
const upb_handlers* pb_serialize_handlers;
const upb_handlers* json_serialize_handlers;
+ const upb_handlers* json_serialize_handlers_preserve;
// Handlers hold type class references for sub-message fields directly in some
// cases. We need to keep these rooted because they might otherwise be
// collected.
@@ -498,7 +499,7 @@ VALUE Message_descriptor(VALUE klass);
VALUE Message_decode(VALUE klass, VALUE data);
VALUE Message_encode(VALUE klass, VALUE msg_rb);
VALUE Message_decode_json(VALUE klass, VALUE data);
-VALUE Message_encode_json(VALUE klass, VALUE msg_rb);
+VALUE Message_encode_json(int argc, VALUE* argv, VALUE klass);
VALUE Google_Protobuf_deep_copy(VALUE self, VALUE obj);
diff --git a/ruby/ext/google/protobuf_c/upb.c b/ruby/ext/google/protobuf_c/upb.c
index b2a69b66..212f1e0e 100644
--- a/ruby/ext/google/protobuf_c/upb.c
+++ b/ruby/ext/google/protobuf_c/upb.c
@@ -72,6 +72,20 @@ upb_deftype_t upb_def_type(const upb_def *d) { return d->type; }
const char *upb_def_fullname(const upb_def *d) { return d->fullname; }
+const char *upb_def_name(const upb_def *d) {
+ const char *p;
+
+ if (d->fullname == NULL) {
+ return NULL;
+ } else if ((p = strrchr(d->fullname, '.')) == NULL) {
+ /* No '.' in the name, return the full string. */
+ return d->fullname;
+ } else {
+ /* Return one past the last '.'. */
+ return p + 1;
+ }
+}
+
bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
assert(!upb_def_isfrozen(def));
if (!upb_isident(fullname, strlen(fullname), true, s)) return false;
@@ -80,6 +94,8 @@ bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s) {
return true;
}
+const upb_filedef *upb_def_file(const upb_def *d) { return d->file; }
+
upb_def *upb_def_dup(const upb_def *def, const void *o) {
switch (def->type) {
case UPB_DEF_MSG:
@@ -102,6 +118,7 @@ static bool upb_def_init(upb_def *def, upb_deftype_t type,
def->type = type;
def->fullname = NULL;
def->came_from_user = false;
+ def->file = NULL;
return true;
}
@@ -317,11 +334,8 @@ static bool assign_msg_indices(upb_msgdef *m, upb_status *s) {
return true;
}
-bool upb_def_freeze(upb_def *const* defs, int n, upb_status *s) {
- int i;
- int maxdepth;
- bool ret;
- upb_status_clear(s);
+bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s) {
+ size_t i;
/* First perform validation, in two passes so we can check that we have a
* transitive closure without needing to search. */
@@ -347,8 +361,9 @@ bool upb_def_freeze(upb_def *const* defs, int n, upb_status *s) {
/* Second pass of validation. Also assign selector bases and indexes, and
* compact tables. */
for (i = 0; i < n; i++) {
- upb_msgdef *m = upb_dyncast_msgdef_mutable(defs[i]);
- upb_enumdef *e = upb_dyncast_enumdef_mutable(defs[i]);
+ upb_def *def = defs[i];
+ upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
+ upb_enumdef *e = upb_dyncast_enumdef_mutable(def);
if (m) {
upb_inttable_compact(&m->itof);
if (!assign_msg_indices(m, s)) {
@@ -359,23 +374,31 @@ bool upb_def_freeze(upb_def *const* defs, int n, upb_status *s) {
}
}
- /* Def graph contains FieldDefs between each MessageDef, so double the
- * limit. */
- maxdepth = UPB_MAX_MESSAGE_DEPTH * 2;
-
- /* Validation all passed; freeze the defs. */
- ret = upb_refcounted_freeze((upb_refcounted * const *)defs, n, s, maxdepth);
- assert(!(s && ret != upb_ok(s)));
- return ret;
+ return true;
err:
for (i = 0; i < n; i++) {
- defs[i]->came_from_user = false;
+ upb_def *def = defs[i];
+ def->came_from_user = false;
}
assert(!(s && upb_ok(s)));
return false;
}
+bool upb_def_freeze(upb_def *const* defs, size_t n, upb_status *s) {
+ /* Def graph contains FieldDefs between each MessageDef, so double the
+ * limit. */
+ const size_t maxdepth = UPB_MAX_MESSAGE_DEPTH * 2;
+
+ if (!_upb_def_validate(defs, n, s)) {
+ return false;
+ }
+
+
+ /* Validation all passed; freeze the objects. */
+ return upb_refcounted_freeze((upb_refcounted *const*)defs, n, s, maxdepth);
+}
+
/* upb_enumdef ****************************************************************/
@@ -434,6 +457,10 @@ const char *upb_enumdef_fullname(const upb_enumdef *e) {
return upb_def_fullname(upb_enumdef_upcast(e));
}
+const char *upb_enumdef_name(const upb_enumdef *e) {
+ return upb_def_name(upb_enumdef_upcast(e));
+}
+
bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname,
upb_status *s) {
return upb_def_setfullname(upb_enumdef_upcast_mutable(e), fullname, s);
@@ -537,7 +564,7 @@ static void visitfield(const upb_refcounted *r, upb_refcounted_visit *visit,
visit(r, upb_msgdef_upcast2(upb_fielddef_containingtype(f)), closure);
}
if (upb_fielddef_containingoneof(f)) {
- visit(r, upb_oneofdef_upcast2(upb_fielddef_containingoneof(f)), closure);
+ visit(r, upb_oneofdef_upcast(upb_fielddef_containingoneof(f)), closure);
}
if (upb_fielddef_subdef(f)) {
visit(r, upb_def_upcast(upb_fielddef_subdef(f)), closure);
@@ -1263,7 +1290,7 @@ bool upb_fielddef_haspresence(const upb_fielddef *f) {
/* Primitive field: return true unless there is a message that specifies
* presence should not exist. */
if (f->msg_is_symbolic || !f->msg.def) return true;
- return f->msg.def->primitives_have_presence;
+ return f->msg.def->syntax == UPB_SYNTAX_PROTO2;
}
bool upb_fielddef_hassubdef(const upb_fielddef *f) {
@@ -1299,7 +1326,7 @@ static void visitmsg(const upb_refcounted *r, upb_refcounted_visit *visit,
!upb_msg_oneof_done(&o);
upb_msg_oneof_next(&o)) {
upb_oneofdef *f = upb_msg_iter_oneof(&o);
- visit(r, upb_oneofdef_upcast2(f), closure);
+ visit(r, upb_oneofdef_upcast(f), closure);
}
}
@@ -1322,7 +1349,7 @@ upb_msgdef *upb_msgdef_new(const void *owner) {
if (!upb_strtable_init(&m->ntof, UPB_CTYPE_PTR)) goto err2;
if (!upb_strtable_init(&m->ntoo, UPB_CTYPE_PTR)) goto err1;
m->map_entry = false;
- m->primitives_have_presence = true;
+ m->syntax = UPB_SYNTAX_PROTO2;
return m;
err1:
@@ -1345,7 +1372,7 @@ upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner) {
upb_def_fullname(upb_msgdef_upcast(m)),
NULL);
newm->map_entry = m->map_entry;
- newm->primitives_have_presence = m->primitives_have_presence;
+ newm->syntax = m->syntax;
UPB_ASSERT_VAR(ok, ok);
for(upb_msg_field_begin(&i, m);
!upb_msg_field_done(&i);
@@ -1379,6 +1406,10 @@ const char *upb_msgdef_fullname(const upb_msgdef *m) {
return upb_def_fullname(upb_msgdef_upcast(m));
}
+const char *upb_msgdef_name(const upb_msgdef *m) {
+ return upb_def_name(upb_msgdef_upcast(m));
+}
+
bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname,
upb_status *s) {
return upb_def_setfullname(upb_msgdef_upcast_mutable(m), fullname, s);
@@ -1490,11 +1521,6 @@ bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
return true;
}
-void upb_msgdef_setprimitiveshavepresence(upb_msgdef *m, bool have_presence) {
- assert(!upb_msgdef_isfrozen(m));
- m->primitives_have_presence = have_presence;
-}
-
const upb_fielddef *upb_msgdef_itof(const upb_msgdef *m, uint32_t i) {
upb_value val;
return upb_inttable_lookup32(&m->itof, i, &val) ?
@@ -1587,7 +1613,7 @@ static void freeoneof(upb_refcounted *r) {
upb_oneofdef *o = (upb_oneofdef*)r;
upb_strtable_uninit(&o->ntof);
upb_inttable_uninit(&o->itof);
- upb_def_uninit(upb_oneofdef_upcast_mutable(o));
+ free((void*)o->name);
free(o);
}
@@ -1596,9 +1622,9 @@ upb_oneofdef *upb_oneofdef_new(const void *owner) {
upb_oneofdef *o = malloc(sizeof(*o));
o->parent = NULL;
if (!o) return NULL;
- if (!upb_def_init(upb_oneofdef_upcast_mutable(o), UPB_DEF_ONEOF, &vtbl,
- owner))
+ if (!upb_refcounted_init(upb_oneofdef_upcast_mutable(o), &vtbl, owner))
goto err2;
+ o->name = NULL;
if (!upb_inttable_init(&o->itof, UPB_CTYPE_PTR)) goto err2;
if (!upb_strtable_init(&o->ntof, UPB_CTYPE_PTR)) goto err1;
return o;
@@ -1615,8 +1641,7 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
upb_oneof_iter i;
upb_oneofdef *newo = upb_oneofdef_new(owner);
if (!newo) return NULL;
- ok = upb_def_setfullname(upb_oneofdef_upcast_mutable(newo),
- upb_def_fullname(upb_oneofdef_upcast(o)), NULL);
+ ok = upb_oneofdef_setname(newo, upb_oneofdef_name(o), NULL);
UPB_ASSERT_VAR(ok, ok);
for (upb_oneof_begin(&i, o); !upb_oneof_done(&i); upb_oneof_next(&i)) {
upb_fielddef *f = upb_fielddef_dup(upb_oneof_iter_field(&i), &f);
@@ -1628,17 +1653,18 @@ upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner) {
return newo;
}
-const char *upb_oneofdef_name(const upb_oneofdef *o) {
- return upb_def_fullname(upb_oneofdef_upcast(o));
-}
+const char *upb_oneofdef_name(const upb_oneofdef *o) { return o->name; }
-bool upb_oneofdef_setname(upb_oneofdef *o, const char *fullname,
- upb_status *s) {
+bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s) {
+ assert(!upb_oneofdef_isfrozen(o));
if (upb_oneofdef_containingtype(o)) {
upb_status_seterrmsg(s, "oneof already added to a message");
return false;
}
- return upb_def_setfullname(upb_oneofdef_upcast_mutable(o), fullname, s);
+ if (!upb_isident(name, strlen(name), true, s)) return false;
+ free((void*)o->name);
+ o->name = upb_strdup(name);
+ return true;
}
const upb_msgdef *upb_oneofdef_containingtype(const upb_oneofdef *o) {
@@ -1757,6 +1783,191 @@ void upb_oneof_iter_setdone(upb_oneof_iter *iter) {
upb_inttable_iter_setdone(iter);
}
+/* upb_filedef ****************************************************************/
+
+static void visitfiledef(const upb_refcounted *r, upb_refcounted_visit *visit,
+ void *closure) {
+ const upb_filedef *f = (const upb_filedef*)r;
+ size_t i;
+
+ for(i = 0; i < upb_filedef_defcount(f); i++) {
+ visit(r, upb_def_upcast(upb_filedef_def(f, i)), closure);
+ }
+}
+
+static void freefiledef(upb_refcounted *r) {
+ upb_filedef *f = (upb_filedef*)r;
+ size_t i;
+
+ for(i = 0; i < upb_filedef_depcount(f); i++) {
+ upb_filedef_unref(upb_filedef_dep(f, i), f);
+ }
+
+ upb_inttable_uninit(&f->defs);
+ upb_inttable_uninit(&f->deps);
+ free((void*)f->name);
+ free((void*)f->package);
+ free(f);
+}
+
+upb_filedef *upb_filedef_new(const void *owner) {
+ static const struct upb_refcounted_vtbl vtbl = {visitfiledef, freefiledef};
+ upb_filedef *f = malloc(sizeof(*f));
+
+ if (!f) {
+ return NULL;
+ }
+
+ f->package = NULL;
+ f->name = NULL;
+ f->syntax = UPB_SYNTAX_PROTO2;
+
+ if (!upb_refcounted_init(upb_filedef_upcast_mutable(f), &vtbl, owner)) {
+ goto err;
+ }
+
+ if (!upb_inttable_init(&f->defs, UPB_CTYPE_CONSTPTR)) {
+ goto err;
+ }
+
+ if (!upb_inttable_init(&f->deps, UPB_CTYPE_CONSTPTR)) {
+ goto err2;
+ }
+
+ return f;
+
+
+err2:
+ upb_inttable_uninit(&f->defs);
+
+err:
+ free(f);
+ return NULL;
+}
+
+const char *upb_filedef_name(const upb_filedef *f) {
+ return f->name;
+}
+
+const char *upb_filedef_package(const upb_filedef *f) {
+ return f->package;
+}
+
+upb_syntax_t upb_filedef_syntax(const upb_filedef *f) {
+ return f->syntax;
+}
+
+size_t upb_filedef_defcount(const upb_filedef *f) {
+ return upb_inttable_count(&f->defs);
+}
+
+size_t upb_filedef_depcount(const upb_filedef *f) {
+ return upb_inttable_count(&f->deps);
+}
+
+const upb_def *upb_filedef_def(const upb_filedef *f, size_t i) {
+ upb_value v;
+
+ if (upb_inttable_lookup32(&f->defs, i, &v)) {
+ return upb_value_getconstptr(v);
+ } else {
+ return NULL;
+ }
+}
+
+const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i) {
+ upb_value v;
+
+ if (upb_inttable_lookup32(&f->deps, i, &v)) {
+ return upb_value_getconstptr(v);
+ } else {
+ return NULL;
+ }
+}
+
+bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s) {
+ name = upb_strdup(name);
+ if (!name) {
+ upb_status_seterrmsg(s, "Out of memory");
+ return false;
+ }
+ free((void*)f->name);
+ f->name = name;
+ return true;
+}
+
+bool upb_filedef_setpackage(upb_filedef *f, const char *package,
+ upb_status *s) {
+ if (!upb_isident(package, strlen(package), true, s)) return false;
+ package = upb_strdup(package);
+ if (!package) {
+ upb_status_seterrmsg(s, "Out of memory");
+ return false;
+ }
+ free((void*)f->package);
+ f->package = package;
+ return true;
+}
+
+bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax,
+ upb_status *s) {
+ UPB_UNUSED(s);
+ if (syntax != UPB_SYNTAX_PROTO2 &&
+ syntax != UPB_SYNTAX_PROTO3) {
+ upb_status_seterrmsg(s, "Unknown syntax value.");
+ return false;
+ }
+ f->syntax = syntax;
+
+ {
+ /* Set all messages in this file to match. */
+ size_t i;
+ for (i = 0; i < upb_filedef_defcount(f); i++) {
+ /* Casting const away is safe since all defs in mutable filedef must
+ * also be mutable. */
+ upb_def *def = (upb_def*)upb_filedef_def(f, i);
+
+ upb_msgdef *m = upb_dyncast_msgdef_mutable(def);
+ if (m) {
+ m->syntax = syntax;
+ }
+ }
+ }
+
+ return true;
+}
+
+bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
+ upb_status *s) {
+ if (def->file) {
+ upb_status_seterrmsg(s, "Def is already part of another filedef.");
+ return false;
+ }
+
+ if (upb_inttable_push(&f->defs, upb_value_constptr(def))) {
+ def->file = f;
+ upb_ref2(def, f);
+ if (ref_donor) upb_def_unref(def, ref_donor);
+ if (def->type == UPB_DEF_MSG) {
+ upb_downcast_msgdef_mutable(def)->syntax = f->syntax;
+ }
+ return true;
+ } else {
+ upb_status_seterrmsg(s, "Out of memory.");
+ return false;
+ }
+}
+
+bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep) {
+ if (upb_inttable_push(&f->deps, upb_value_constptr(dep))) {
+ /* Regular ref instead of ref2 because files can't form cycles. */
+ upb_filedef_ref(dep, f);
+ return true;
+ } else {
+ return false;
+ }
+}
+
#include <stdlib.h>
#include <stdio.h>
@@ -3550,10 +3761,13 @@ void upb_refcounted_checkref(const upb_refcounted *r, const void *owner) {
bool upb_refcounted_freeze(upb_refcounted *const*roots, int n, upb_status *s,
int maxdepth) {
int i;
+ bool ret;
for (i = 0; i < n; i++) {
assert(!roots[i]->is_frozen);
}
- return freeze(roots, n, s, maxdepth);
+ ret = freeze(roots, n, s, maxdepth);
+ assert(!s || ret == upb_ok(s));
+ return ret;
}
@@ -3834,11 +4048,16 @@ oom:
/* TODO(haberman): we need a lot more testing of error conditions.
* The came_from_user stuff in particular is not tested. */
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
- upb_status *status) {
- int i;
+static bool symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_refcounted *freeze_also,
+ upb_status *status) {
+ size_t i;
+ size_t add_n;
+ size_t freeze_n;
upb_strtable_iter iter;
+ upb_refcounted **add_objs = NULL;
upb_def **add_defs = NULL;
+ size_t add_objs_size;
upb_strtable addtab;
upb_inttable seen;
@@ -3983,15 +4202,38 @@ bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
}
}
- /* We need an array of the defs in addtab, for passing to upb_def_freeze. */
- add_defs = malloc(sizeof(void*) * upb_strtable_count(&addtab));
+ /* We need an array of the defs in addtab, for passing to
+ * upb_refcounted_freeze(). */
+ add_objs_size = upb_strtable_count(&addtab);
+ if (freeze_also) {
+ add_objs_size++;
+ }
+
+ add_defs = malloc(sizeof(void*) * add_objs_size);
if (add_defs == NULL) goto oom_err;
upb_strtable_begin(&iter, &addtab);
- for (n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
- add_defs[n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
+ for (add_n = 0; !upb_strtable_done(&iter); upb_strtable_next(&iter)) {
+ add_defs[add_n++] = upb_value_getptr(upb_strtable_iter_value(&iter));
+ }
+
+ /* Validate defs. */
+ if (!_upb_def_validate(add_defs, add_n, status)) {
+ goto err;
}
- if (!upb_def_freeze(add_defs, n, status)) goto err;
+ /* Cheat a little and give the array a new type.
+ * This is probably undefined behavior, but this code will be deleted soon. */
+ add_objs = (upb_refcounted**)add_defs;
+
+ freeze_n = add_n;
+ if (freeze_also) {
+ add_objs[freeze_n++] = freeze_also;
+ }
+
+ if (!upb_refcounted_freeze(add_objs, freeze_n, status,
+ UPB_MAX_MESSAGE_DEPTH * 2)) {
+ goto err;
+ }
/* This must be delayed until all errors have been detected, since error
* recovery code uses this table to cleanup defs. */
@@ -3999,8 +4241,8 @@ bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
/* TODO(haberman) we don't properly handle errors after this point (like
* OOM in upb_strtable_insert() below). */
- for (i = 0; i < n; i++) {
- upb_def *def = add_defs[i];
+ for (i = 0; i < add_n; i++) {
+ upb_def *def = (upb_def*)add_objs[i];
const char *name = upb_def_fullname(def);
upb_value v;
bool success;
@@ -4012,7 +4254,7 @@ bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
success = upb_strtable_insert(&s->symtab, name, upb_value_ptr(def));
UPB_ASSERT_VAR(success, success == true);
}
- free(add_defs);
+ free(add_objs);
return true;
oom_err:
@@ -4033,11 +4275,40 @@ err: {
}
}
upb_strtable_uninit(&addtab);
- free(add_defs);
+ free(add_objs);
assert(!upb_ok(status));
return false;
}
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_status *status) {
+ return symtab_add(s, defs, n, ref_donor, NULL, status);
+}
+
+bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status *status) {
+ size_t n;
+ size_t i;
+ upb_def **defs;
+ bool ret;
+
+ n = upb_filedef_defcount(file);
+ defs = malloc(sizeof(*defs) * n);
+
+ if (defs == NULL) {
+ upb_status_seterrmsg(status, "Out of memory");
+ return false;
+ }
+
+ for (i = 0; i < n; i++) {
+ defs[i] = upb_filedef_mutabledef(file, i);
+ }
+
+ ret = symtab_add(s, defs, n, NULL, upb_filedef_upcast_mutable(file), status);
+
+ free(defs);
+ return ret;
+}
+
/* Iteration. */
static void advance_to_matching(upb_symtab_iter *iter) {
@@ -5037,16 +5308,18 @@ void upb_status_copy(upb_status *to, const upb_status *from) {
* Do not edit -- your changes will be discarded when the file is
* regenerated. */
+#include <assert.h>
+
static const upb_msgdef msgs[22];
static const upb_fielddef fields[105];
static const upb_enumdef enums[5];
-static const upb_tabent strentries[268];
+static const upb_tabent strentries[236];
static const upb_tabent intentries[18];
static const upb_tabval arrays[184];
#ifdef UPB_DEBUG_REFS
-static upb_inttable reftables[266];
+static upb_inttable reftables[264];
#endif
static const upb_msgdef msgs[22] = {
@@ -5084,18 +5357,18 @@ static const upb_fielddef fields[105] = {
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "ctype", 1, &msgs[8], (const upb_def*)(&enums[2]), 6, 1, {0},&reftables[56], &reftables[57]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "default_value", 7, &msgs[7], NULL, 16, 7, {0},&reftables[58], &reftables[59]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_STRING, 0, false, false, false, false, "dependency", 3, &msgs[9], NULL, 30, 8, {0},&reftables[60], &reftables[61]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 6, 1, {0},&reftables[62], &reftables[63]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 7, 2, {0},&reftables[64], &reftables[65]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 6, 1, {0},&reftables[66], &reftables[67]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 8, 3, {0},&reftables[68], &reftables[69]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 6, 1, {0},&reftables[70], &reftables[71]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 8, 3, {0},&reftables[72], &reftables[73]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 21, 10, {0},&reftables[74], &reftables[75]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[12], NULL, 8, 3, {0},&reftables[62], &reftables[63]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[8], NULL, 8, 3, {0},&reftables[64], &reftables[65]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[14], NULL, 6, 1, {0},&reftables[66], &reftables[67]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 23, &msgs[11], NULL, 21, 10, {0},&reftables[68], &reftables[69]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 3, &msgs[4], NULL, 7, 2, {0},&reftables[70], &reftables[71]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 33, &msgs[17], NULL, 6, 1, {0},&reftables[72], &reftables[73]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "deprecated", 1, &msgs[6], NULL, 6, 1, {0},&reftables[74], &reftables[75]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_DOUBLE, 0, false, false, false, false, "double_value", 6, &msgs[20], NULL, 11, 4, {0},&reftables[76], &reftables[77]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[2], NULL, 3, 1, {0},&reftables[78], &reftables[79]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "end", 2, &msgs[1], NULL, 3, 1, {0},&reftables[80], &reftables[81]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 13, 1, {0},&reftables[82], &reftables[83]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 18, 2, {0},&reftables[84], &reftables[85]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 4, &msgs[0], (const upb_def*)(&msgs[3]), 18, 2, {0},&reftables[82], &reftables[83]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "enum_type", 5, &msgs[9], (const upb_def*)(&msgs[3]), 13, 1, {0},&reftables[84], &reftables[85]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "extendee", 2, &msgs[7], NULL, 7, 2, {0},&reftables[86], &reftables[87]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 6, &msgs[0], (const upb_def*)(&msgs[7]), 24, 4, {0},&reftables[88], &reftables[89]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "extension", 7, &msgs[9], (const upb_def*)(&msgs[7]), 19, 3, {0},&reftables[90], &reftables[91]),
@@ -5124,32 +5397,32 @@ static const upb_fielddef fields[105] = {
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "message_set_wire_format", 1, &msgs[12], NULL, 6, 1, {0},&reftables[136], &reftables[137]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "message_type", 4, &msgs[9], (const upb_def*)(&msgs[0]), 10, 0, {0},&reftables[138], &reftables[139]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "method", 2, &msgs[16], (const upb_def*)(&msgs[13]), 6, 0, {0},&reftables[140], &reftables[141]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[142], &reftables[143]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[144], &reftables[145]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[146], &reftables[147]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[142], &reftables[143]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[144], &reftables[145]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[146], &reftables[147]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[0], NULL, 32, 8, {0},&reftables[148], &reftables[149]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[3], NULL, 8, 2, {0},&reftables[150], &reftables[151]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[15], NULL, 2, 0, {0},&reftables[152], &reftables[153]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[154], &reftables[155]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[156], &reftables[157]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "name", 2, &msgs[20], (const upb_def*)(&msgs[21]), 5, 0, {0},&reftables[158], &reftables[159]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[5], NULL, 4, 1, {0},&reftables[150], &reftables[151]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[9], NULL, 22, 6, {0},&reftables[152], &reftables[153]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[7], NULL, 4, 1, {0},&reftables[154], &reftables[155]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[13], NULL, 4, 1, {0},&reftables[156], &reftables[157]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "name", 1, &msgs[16], NULL, 8, 2, {0},&reftables[158], &reftables[159]),
UPB_FIELDDEF_INIT(UPB_LABEL_REQUIRED, UPB_TYPE_STRING, 0, false, false, false, false, "name_part", 1, &msgs[21], NULL, 2, 0, {0},&reftables[160], &reftables[161]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT64, UPB_INTFMT_VARIABLE, false, false, false, false, "negative_int_value", 5, &msgs[20], NULL, 10, 3, {0},&reftables[162], &reftables[163]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "nested_type", 3, &msgs[0], (const upb_def*)(&msgs[0]), 15, 1, {0},&reftables[164], &reftables[165]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "no_standard_descriptor_accessor", 2, &msgs[12], NULL, 7, 2, {0},&reftables[166], &reftables[167]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[168], &reftables[169]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[170], &reftables[171]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 2, &msgs[5], NULL, 7, 2, {0},&reftables[168], &reftables[169]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "number", 3, &msgs[7], NULL, 10, 3, {0},&reftables[170], &reftables[171]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "objc_class_prefix", 36, &msgs[11], NULL, 24, 13, {0},&reftables[172], &reftables[173]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "oneof_decl", 8, &msgs[0], (const upb_def*)(&msgs[15]), 28, 6, {0},&reftables[174], &reftables[175]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "oneof_index", 9, &msgs[7], NULL, 19, 8, {0},&reftables[176], &reftables[177]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "optimize_for", 9, &msgs[11], (const upb_def*)(&enums[4]), 12, 3, {0},&reftables[178], &reftables[179]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[180], &reftables[181]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[182], &reftables[183]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[184], &reftables[185]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[186], &reftables[187]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[188], &reftables[189]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[190], &reftables[191]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[192], &reftables[193]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 7, &msgs[0], (const upb_def*)(&msgs[12]), 25, 5, {0},&reftables[180], &reftables[181]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[9], (const upb_def*)(&msgs[11]), 20, 4, {0},&reftables[182], &reftables[183]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 4, &msgs[13], (const upb_def*)(&msgs[14]), 3, 0, {0},&reftables[184], &reftables[185]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 8, &msgs[7], (const upb_def*)(&msgs[8]), 3, 0, {0},&reftables[186], &reftables[187]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[16], (const upb_def*)(&msgs[17]), 7, 1, {0},&reftables[188], &reftables[189]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[5], (const upb_def*)(&msgs[6]), 3, 0, {0},&reftables[190], &reftables[191]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "options", 3, &msgs[3], (const upb_def*)(&msgs[4]), 7, 1, {0},&reftables[192], &reftables[193]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "output_type", 3, &msgs[13], NULL, 10, 3, {0},&reftables[194], &reftables[195]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "package", 2, &msgs[9], NULL, 25, 7, {0},&reftables[196], &reftables[197]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "packed", 2, &msgs[8], NULL, 7, 2, {0},&reftables[198], &reftables[199]),
@@ -5163,20 +5436,20 @@ static const upb_fielddef fields[105] = {
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "service", 6, &msgs[9], (const upb_def*)(&msgs[16]), 16, 2, {0},&reftables[214], &reftables[215]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_MESSAGE, 0, false, false, false, false, "source_code_info", 9, &msgs[9], (const upb_def*)(&msgs[18]), 21, 5, {0},&reftables[216], &reftables[217]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, true, "span", 2, &msgs[19], NULL, 7, 1, {0},&reftables[218], &reftables[219]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[220], &reftables[221]),
- UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[222], &reftables[223]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[2], NULL, 2, 0, {0},&reftables[220], &reftables[221]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "start", 1, &msgs[1], NULL, 2, 0, {0},&reftables[222], &reftables[223]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BYTES, 0, false, false, false, false, "string_value", 7, &msgs[20], NULL, 12, 5, {0},&reftables[224], &reftables[225]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "syntax", 12, &msgs[9], NULL, 39, 11, {0},&reftables[226], &reftables[227]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "trailing_comments", 4, &msgs[19], NULL, 11, 3, {0},&reftables[228], &reftables[229]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_ENUM, 0, false, false, false, false, "type", 5, &msgs[7], (const upb_def*)(&enums[1]), 12, 5, {0},&reftables[230], &reftables[231]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_STRING, 0, false, false, false, false, "type_name", 6, &msgs[7], NULL, 13, 6, {0},&reftables[232], &reftables[233]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[234], &reftables[235]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[234], &reftables[235]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[12], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[236], &reftables[237]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[11], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]),
- UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[6], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[238], &reftables[239]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[4], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[240], &reftables[241]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[8], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[242], &reftables[243]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[14], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[244], &reftables[245]),
+ UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "uninterpreted_option", 999, &msgs[17], (const upb_def*)(&msgs[20]), 5, 0, {0},&reftables[246], &reftables[247]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_MESSAGE, 0, false, false, false, false, "value", 2, &msgs[3], (const upb_def*)(&msgs[5]), 6, 0, {0},&reftables[248], &reftables[249]),
UPB_FIELDDEF_INIT(UPB_LABEL_OPTIONAL, UPB_TYPE_BOOL, 0, false, false, false, false, "weak", 10, &msgs[8], NULL, 11, 6, {0},&reftables[250], &reftables[251]),
UPB_FIELDDEF_INIT(UPB_LABEL_REPEATED, UPB_TYPE_INT32, UPB_INTFMT_VARIABLE, false, false, false, false, "weak_dependency", 11, &msgs[9], NULL, 38, 10, {0},&reftables[252], &reftables[253]),
@@ -5190,7 +5463,7 @@ static const upb_enumdef enums[5] = {
UPB_ENUMDEF_INIT("google.protobuf.FileOptions.OptimizeMode", UPB_STRTABLE_INIT(3, 3, UPB_CTYPE_INT32, 2, &strentries[232]), UPB_INTTABLE_INIT(0, 0, UPB_CTYPE_CSTR, 0, NULL, &arrays[180], 4, 3), 0, &reftables[262], &reftables[263]),
};
-static const upb_tabent strentries[268] = {
+static const upb_tabent strentries[236] = {
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[22]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "reserved_name"), UPB_TABVALUE_PTR_INIT(&fields[82]), NULL},
@@ -5204,50 +5477,50 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_TABVALUE_PTR_INIT(&fields[60]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\016", "\000", "\000", "\000", "reserved_range"), UPB_TABVALUE_PTR_INIT(&fields[83]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "oneof_decl"), UPB_TABVALUE_PTR_INIT(&fields[65]), NULL},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), &strentries[13]},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL},
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), &strentries[13]},
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[89]), NULL},
{UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[18]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[89]), NULL},
+ {UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_TABVALUE_PTR_INIT(&fields[88]), NULL},
{UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_TABVALUE_PTR_INIT(&fields[17]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_TABVALUE_PTR_INIT(&fields[102]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[26]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[49]), &strentries[26]},
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_TABVALUE_PTR_INIT(&fields[1]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), NULL},
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), &strentries[34]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[9]), NULL},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[53]), &strentries[34]},
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[15]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "oneof_index"), UPB_TABVALUE_PTR_INIT(&fields[66]), NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "label"), UPB_TABVALUE_PTR_INIT(&fields[40]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[62]), &strentries[53]},
+ {UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_TABVALUE_PTR_INIT(&fields[63]), &strentries[53]},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_TABVALUE_PTR_INIT(&fields[21]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_TABVALUE_PTR_INIT(&fields[94]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "json_name"), UPB_TABVALUE_PTR_INIT(&fields[38]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_TABVALUE_PTR_INIT(&fields[93]), &strentries[50]},
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_TABVALUE_PTR_INIT(&fields[7]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[74]), NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[71]), NULL},
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_TABVALUE_PTR_INIT(&fields[103]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
@@ -5260,13 +5533,13 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "ctype"), UPB_TABVALUE_PTR_INIT(&fields[6]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "jstype"), UPB_TABVALUE_PTR_INIT(&fields[39]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[12]), NULL},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[10]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_TABVALUE_PTR_INIT(&fields[23]), NULL},
{UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_TABVALUE_PTR_INIT(&fields[104]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[49]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_TABVALUE_PTR_INIT(&fields[85]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_TABVALUE_PTR_INIT(&fields[86]), NULL},
@@ -5276,8 +5549,8 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_TABVALUE_PTR_INIT(&fields[8]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_TABVALUE_PTR_INIT(&fields[47]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_TABVALUE_PTR_INIT(&fields[76]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), &strentries[86]},
- {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[19]), NULL},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[69]), &strentries[86]},
+ {UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_TABVALUE_PTR_INIT(&fields[20]), NULL},
{UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_TABVALUE_PTR_INIT(&fields[80]), &strentries[85]},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_TABVALUE_PTR_INIT(&fields[26]), NULL},
@@ -5299,7 +5572,7 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_TABVALUE_PTR_INIT(&fields[34]), NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL},
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
@@ -5312,7 +5585,7 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_TABVALUE_PTR_INIT(&fields[81]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_TABVALUE_PTR_INIT(&fields[67]), NULL},
{UPB_TABKEY_STR("\026", "\000", "\000", "\000", "java_string_check_utf8"), UPB_TABVALUE_PTR_INIT(&fields[36]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[15]), &strentries[119]},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[12]), &strentries[119]},
{UPB_TABKEY_STR("\021", "\000", "\000", "\000", "objc_class_prefix"), UPB_TABVALUE_PTR_INIT(&fields[64]), NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "cc_enable_arenas"), UPB_TABVALUE_PTR_INIT(&fields[2]), NULL},
{UPB_TABKEY_STR("\027", "\000", "\000", "\000", "message_set_wire_format"), UPB_TABVALUE_PTR_INIT(&fields[46]), &strentries[128]},
@@ -5320,31 +5593,31 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[9]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "map_entry"), UPB_TABVALUE_PTR_INIT(&fields[45]), NULL},
{UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_TABVALUE_PTR_INIT(&fields[61]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "client_streaming"), UPB_TABVALUE_PTR_INIT(&fields[4]), NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "server_streaming"), UPB_TABVALUE_PTR_INIT(&fields[84]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[56]), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_TABVALUE_PTR_INIT(&fields[29]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_TABVALUE_PTR_INIT(&fields[75]), NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[68]), NULL},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[70]), NULL},
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[54]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[50]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[73]), &strentries[150]},
+ {UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_TABVALUE_PTR_INIT(&fields[72]), &strentries[150]},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_TABVALUE_PTR_INIT(&fields[48]), NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[55]), &strentries[149]},
- {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL},
- {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), &strentries[149]},
+ {UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL},
+ {UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
@@ -5362,7 +5635,7 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_TABVALUE_PTR_INIT(&fields[16]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[57]), NULL},
+ {UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_TABVALUE_PTR_INIT(&fields[51]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
@@ -5427,59 +5700,27 @@ static const upb_tabent strentries[268] = {
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "SPEED"), UPB_TABVALUE_INT_INIT(1), &strentries[235]},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "LITE_RUNTIME"), UPB_TABVALUE_INT_INIT(3), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\047", "\000", "\000", "\000", "google.protobuf.SourceCodeInfo.Location"), UPB_TABVALUE_PTR_INIT(&msgs[19]), NULL},
- {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.UninterpretedOption"), UPB_TABVALUE_PTR_INIT(&msgs[20]), NULL},
- {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.FileDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[9]), NULL},
- {UPB_TABKEY_STR("\045", "\000", "\000", "\000", "google.protobuf.MethodDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[13]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\040", "\000", "\000", "\000", "google.protobuf.EnumValueOptions"), UPB_TABVALUE_PTR_INIT(&msgs[6]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_STR("\055", "\000", "\000", "\000", "google.protobuf.DescriptorProto.ReservedRange"), UPB_TABVALUE_PTR_INIT(&msgs[2]), NULL},
- {UPB_TABKEY_STR("\037", "\000", "\000", "\000", "google.protobuf.DescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[0]), &strentries[248]},
- {UPB_TABKEY_STR("\041", "\000", "\000", "\000", "google.protobuf.FileDescriptorSet"), UPB_TABVALUE_PTR_INIT(&msgs[10]), &strentries[267]},
- {UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.SourceCodeInfo"), UPB_TABVALUE_PTR_INIT(&msgs[18]), NULL},
- {UPB_TABKEY_STR("\051", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto.Type"), UPB_TABVALUE_PTR_INIT(&enums[1]), NULL},
- {UPB_TABKEY_STR("\056", "\000", "\000", "\000", "google.protobuf.DescriptorProto.ExtensionRange"), UPB_TABVALUE_PTR_INIT(&msgs[1]), NULL},
- {UPB_TABKEY_STR("\044", "\000", "\000", "\000", "google.protobuf.OneofDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[15]), NULL},
- {UPB_TABKEY_STR("\046", "\000", "\000", "\000", "google.protobuf.ServiceDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[16]), NULL},
- {UPB_TABKEY_STR("\034", "\000", "\000", "\000", "google.protobuf.FieldOptions"), UPB_TABVALUE_PTR_INIT(&msgs[8]), NULL},
- {UPB_TABKEY_STR("\033", "\000", "\000", "\000", "google.protobuf.FileOptions"), UPB_TABVALUE_PTR_INIT(&msgs[11]), NULL},
- {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.EnumDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[3]), &strentries[265]},
- {UPB_TABKEY_STR("\052", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto.Label"), UPB_TABVALUE_PTR_INIT(&enums[0]), NULL},
- {UPB_TABKEY_STR("\050", "\000", "\000", "\000", "google.protobuf.FileOptions.OptimizeMode"), UPB_TABVALUE_PTR_INIT(&enums[4]), NULL},
- {UPB_TABKEY_STR("\042", "\000", "\000", "\000", "google.protobuf.FieldOptions.CType"), UPB_TABVALUE_PTR_INIT(&enums[2]), &strentries[261]},
- {UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.FieldOptions.JSType"), UPB_TABVALUE_PTR_INIT(&enums[3]), NULL},
- {UPB_TABKEY_STR("\033", "\000", "\000", "\000", "google.protobuf.EnumOptions"), UPB_TABVALUE_PTR_INIT(&msgs[4]), NULL},
- {UPB_TABKEY_STR("\044", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[7]), NULL},
- {UPB_TABKEY_STR("\050", "\000", "\000", "\000", "google.protobuf.EnumValueDescriptorProto"), UPB_TABVALUE_PTR_INIT(&msgs[5]), &strentries[258]},
- {UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.ServiceOptions"), UPB_TABVALUE_PTR_INIT(&msgs[17]), NULL},
- {UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.MessageOptions"), UPB_TABVALUE_PTR_INIT(&msgs[12]), NULL},
- {UPB_TABKEY_STR("\035", "\000", "\000", "\000", "google.protobuf.MethodOptions"), UPB_TABVALUE_PTR_INIT(&msgs[14]), &strentries[253]},
- {UPB_TABKEY_STR("\054", "\000", "\000", "\000", "google.protobuf.UninterpretedOption.NamePart"), UPB_TABVALUE_PTR_INIT(&msgs[21]), NULL},
};
static const upb_tabent intentries[18] = {
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL},
- {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL},
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[97]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[99]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL},
+ {UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
{UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[96]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[13]), NULL},
+ {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[98]), NULL},
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[100]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[11]), NULL},
+ {UPB_TABKEY_NUM(33), UPB_TABVALUE_PTR_INIT(&fields[14]), NULL},
{UPB_TABKEY_NONE, UPB_TABVALUE_EMPTY_INIT, NULL},
- {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[95]), NULL},
+ {UPB_TABKEY_NUM(999), UPB_TABVALUE_PTR_INIT(&fields[101]), NULL},
};
static const upb_tabval arrays[184] = {
@@ -5487,48 +5728,48 @@ static const upb_tabval arrays[184] = {
UPB_TABVALUE_PTR_INIT(&fields[52]),
UPB_TABVALUE_PTR_INIT(&fields[25]),
UPB_TABVALUE_PTR_INIT(&fields[60]),
- UPB_TABVALUE_PTR_INIT(&fields[20]),
+ UPB_TABVALUE_PTR_INIT(&fields[19]),
UPB_TABVALUE_PTR_INIT(&fields[24]),
UPB_TABVALUE_PTR_INIT(&fields[22]),
- UPB_TABVALUE_PTR_INIT(&fields[70]),
+ UPB_TABVALUE_PTR_INIT(&fields[68]),
UPB_TABVALUE_PTR_INIT(&fields[65]),
UPB_TABVALUE_PTR_INIT(&fields[83]),
UPB_TABVALUE_PTR_INIT(&fields[82]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[88]),
+ UPB_TABVALUE_PTR_INIT(&fields[89]),
UPB_TABVALUE_PTR_INIT(&fields[18]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[89]),
+ UPB_TABVALUE_PTR_INIT(&fields[88]),
UPB_TABVALUE_PTR_INIT(&fields[17]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[53]),
+ UPB_TABVALUE_PTR_INIT(&fields[49]),
UPB_TABVALUE_PTR_INIT(&fields[102]),
- UPB_TABVALUE_PTR_INIT(&fields[69]),
+ UPB_TABVALUE_PTR_INIT(&fields[74]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[1]),
- UPB_TABVALUE_PTR_INIT(&fields[10]),
+ UPB_TABVALUE_PTR_INIT(&fields[13]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[50]),
- UPB_TABVALUE_PTR_INIT(&fields[63]),
- UPB_TABVALUE_PTR_INIT(&fields[71]),
+ UPB_TABVALUE_PTR_INIT(&fields[53]),
+ UPB_TABVALUE_PTR_INIT(&fields[62]),
+ UPB_TABVALUE_PTR_INIT(&fields[73]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[9]),
+ UPB_TABVALUE_PTR_INIT(&fields[15]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[56]),
+ UPB_TABVALUE_PTR_INIT(&fields[55]),
UPB_TABVALUE_PTR_INIT(&fields[21]),
- UPB_TABVALUE_PTR_INIT(&fields[62]),
+ UPB_TABVALUE_PTR_INIT(&fields[63]),
UPB_TABVALUE_PTR_INIT(&fields[40]),
UPB_TABVALUE_PTR_INIT(&fields[93]),
UPB_TABVALUE_PTR_INIT(&fields[94]),
UPB_TABVALUE_PTR_INIT(&fields[7]),
- UPB_TABVALUE_PTR_INIT(&fields[74]),
+ UPB_TABVALUE_PTR_INIT(&fields[71]),
UPB_TABVALUE_PTR_INIT(&fields[66]),
UPB_TABVALUE_PTR_INIT(&fields[38]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[6]),
UPB_TABVALUE_PTR_INIT(&fields[77]),
- UPB_TABVALUE_PTR_INIT(&fields[12]),
+ UPB_TABVALUE_PTR_INIT(&fields[10]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[41]),
UPB_TABVALUE_PTR_INIT(&fields[39]),
@@ -5537,14 +5778,14 @@ static const upb_tabval arrays[184] = {
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[103]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[49]),
+ UPB_TABVALUE_PTR_INIT(&fields[54]),
UPB_TABVALUE_PTR_INIT(&fields[76]),
UPB_TABVALUE_PTR_INIT(&fields[8]),
UPB_TABVALUE_PTR_INIT(&fields[47]),
- UPB_TABVALUE_PTR_INIT(&fields[19]),
+ UPB_TABVALUE_PTR_INIT(&fields[20]),
UPB_TABVALUE_PTR_INIT(&fields[85]),
UPB_TABVALUE_PTR_INIT(&fields[23]),
- UPB_TABVALUE_PTR_INIT(&fields[72]),
+ UPB_TABVALUE_PTR_INIT(&fields[69]),
UPB_TABVALUE_PTR_INIT(&fields[86]),
UPB_TABVALUE_PTR_INIT(&fields[80]),
UPB_TABVALUE_PTR_INIT(&fields[104]),
@@ -5574,7 +5815,7 @@ static const upb_tabval arrays[184] = {
UPB_TABVALUE_PTR_INIT(&fields[31]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[15]),
+ UPB_TABVALUE_PTR_INIT(&fields[12]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
@@ -5593,25 +5834,25 @@ static const upb_tabval arrays[184] = {
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[46]),
UPB_TABVALUE_PTR_INIT(&fields[61]),
- UPB_TABVALUE_PTR_INIT(&fields[14]),
+ UPB_TABVALUE_PTR_INIT(&fields[9]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[45]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[51]),
+ UPB_TABVALUE_PTR_INIT(&fields[56]),
UPB_TABVALUE_PTR_INIT(&fields[29]),
UPB_TABVALUE_PTR_INIT(&fields[75]),
- UPB_TABVALUE_PTR_INIT(&fields[68]),
+ UPB_TABVALUE_PTR_INIT(&fields[70]),
UPB_TABVALUE_PTR_INIT(&fields[4]),
UPB_TABVALUE_PTR_INIT(&fields[84]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[54]),
+ UPB_TABVALUE_PTR_INIT(&fields[50]),
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[55]),
+ UPB_TABVALUE_PTR_INIT(&fields[57]),
UPB_TABVALUE_PTR_INIT(&fields[48]),
- UPB_TABVALUE_PTR_INIT(&fields[73]),
+ UPB_TABVALUE_PTR_INIT(&fields[72]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_PTR_INIT(&fields[44]),
@@ -5624,7 +5865,7 @@ static const upb_tabval arrays[184] = {
UPB_TABVALUE_PTR_INIT(&fields[43]),
UPB_TABVALUE_EMPTY_INIT,
UPB_TABVALUE_EMPTY_INIT,
- UPB_TABVALUE_PTR_INIT(&fields[57]),
+ UPB_TABVALUE_PTR_INIT(&fields[51]),
UPB_TABVALUE_PTR_INIT(&fields[28]),
UPB_TABVALUE_PTR_INIT(&fields[79]),
UPB_TABVALUE_PTR_INIT(&fields[59]),
@@ -5669,17 +5910,8 @@ static const upb_tabval arrays[184] = {
UPB_TABVALUE_PTR_INIT("LITE_RUNTIME"),
};
-static const upb_symtab symtab = UPB_SYMTAB_INIT(UPB_STRTABLE_INIT(27, 31, UPB_CTYPE_PTR, 5, &strentries[236]), &reftables[264], &reftables[265]);
-
-const upb_symtab *upbdefs_google_protobuf_descriptor(const void *owner) {
- upb_symtab_ref(&symtab, owner);
- return &symtab;
-}
-
#ifdef UPB_DEBUG_REFS
-static upb_inttable reftables[266] = {
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
- UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
+static upb_inttable reftables[264] = {
UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
UPB_EMPTY_INTTABLE_INIT(UPB_CTYPE_PTR),
@@ -5947,6 +6179,45 @@ static upb_inttable reftables[266] = {
};
#endif
+static const upb_msgdef *refm(const upb_msgdef *m, const void *owner) {
+ upb_msgdef_ref(m, owner);
+ return m;
+}
+
+static const upb_enumdef *refe(const upb_enumdef *e, const void *owner) {
+ upb_enumdef_ref(e, owner);
+ return e;
+}
+
+/* Public API. */
+const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner) { return refm(&msgs[0], owner); }
+const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(const void *owner) { return refm(&msgs[1], owner); }
+const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(const void *owner) { return refm(&msgs[2], owner); }
+const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *owner) { return refm(&msgs[3], owner); }
+const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner) { return refm(&msgs[4], owner); }
+const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const void *owner) { return refm(&msgs[5], owner); }
+const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner) { return refm(&msgs[6], owner); }
+const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *owner) { return refm(&msgs[7], owner); }
+const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner) { return refm(&msgs[8], owner); }
+const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *owner) { return refm(&msgs[9], owner); }
+const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owner) { return refm(&msgs[10], owner); }
+const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner) { return refm(&msgs[11], owner); }
+const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner) { return refm(&msgs[12], owner); }
+const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *owner) { return refm(&msgs[13], owner); }
+const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner) { return refm(&msgs[14], owner); }
+const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *owner) { return refm(&msgs[15], owner); }
+const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner) { return refm(&msgs[16], owner); }
+const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner) { return refm(&msgs[17], owner); }
+const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner) { return refm(&msgs[18], owner); }
+const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner) { return refm(&msgs[19], owner); }
+const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *owner) { return refm(&msgs[20], owner); }
+const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner) { return refm(&msgs[21], owner); }
+
+const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner) { return refe(&enums[0], owner); }
+const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const void *owner) { return refe(&enums[1], owner); }
+const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *owner) { return refe(&enums[2], owner); }
+const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *owner) { return refe(&enums[3], owner); }
+const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const void *owner) { return refe(&enums[4], owner); }
/*
** XXX: The routines in this file that consume a string do not currently
** support having the string span buffers. In the future, as upb_sink and
@@ -5965,15 +6236,6 @@ static bool upb_streq(const char *str, const char *buf, size_t n) {
return strlen(str) == n && memcmp(str, buf, n) == 0;
}
-/* upb_deflist is an internal-only dynamic array for storing a growing list of
- * upb_defs. */
-typedef struct {
- upb_def **defs;
- size_t len;
- size_t size;
- bool owned;
-} upb_deflist;
-
/* We keep a stack of all the messages scopes we are currently in, as well as
* the top-level file scope. This is necessary to correctly qualify the
* definitions that are contained inside. "name" tracks the name of the
@@ -5999,13 +6261,11 @@ typedef struct {
struct upb_descreader {
upb_sink sink;
- upb_deflist defs;
+ upb_inttable files;
+ upb_filedef *file; /* The last file in files. */
upb_descreader_frame stack[UPB_MAX_MESSAGE_NESTING];
int stack_len;
- bool primitives_have_presence;
- int file_start;
-
uint32_t number;
char *name;
bool saw_number;
@@ -6042,53 +6302,11 @@ static char *upb_join(const char *base, const char *name) {
}
}
-
-/* upb_deflist ****************************************************************/
-
-void upb_deflist_init(upb_deflist *l) {
- l->size = 0;
- l->defs = NULL;
- l->len = 0;
- l->owned = true;
-}
-
-void upb_deflist_uninit(upb_deflist *l) {
- size_t i;
- if (l->owned)
- for(i = 0; i < l->len; i++)
- upb_def_unref(l->defs[i], l);
- free(l->defs);
-}
-
-bool upb_deflist_push(upb_deflist *l, upb_def *d) {
- if(++l->len >= l->size) {
- size_t new_size = UPB_MAX(l->size, 4);
- new_size *= 2;
- l->defs = realloc(l->defs, new_size * sizeof(void *));
- if (!l->defs) return false;
- l->size = new_size;
- }
- l->defs[l->len - 1] = d;
- return true;
-}
-
-void upb_deflist_donaterefs(upb_deflist *l, void *owner) {
- size_t i;
- assert(l->owned);
- for (i = 0; i < l->len; i++)
- upb_def_donateref(l->defs[i], l, owner);
- l->owned = false;
-}
-
-static upb_def *upb_deflist_last(upb_deflist *l) {
- return l->defs[l->len-1];
-}
-
/* Qualify the defname for all defs starting with offset "start" with "str". */
-static void upb_deflist_qualify(upb_deflist *l, char *str, int32_t start) {
- uint32_t i;
- for (i = start; i < l->len; i++) {
- upb_def *def = l->defs[i];
+static void upb_descreader_qualify(upb_filedef *f, char *str, int32_t start) {
+ size_t i;
+ for (i = start; i < upb_filedef_defcount(f); i++) {
+ upb_def *def = upb_filedef_mutabledef(f, i);
char *name = upb_join(str, upb_def_fullname(def));
upb_def_setfullname(def, name, NULL);
free(name);
@@ -6103,24 +6321,24 @@ static upb_msgdef *upb_descreader_top(upb_descreader *r) {
assert(r->stack_len > 1);
index = r->stack[r->stack_len-1].start - 1;
assert(index >= 0);
- return upb_downcast_msgdef_mutable(r->defs.defs[index]);
+ return upb_downcast_msgdef_mutable(upb_filedef_mutabledef(r->file, index));
}
static upb_def *upb_descreader_last(upb_descreader *r) {
- return upb_deflist_last(&r->defs);
+ return upb_filedef_mutabledef(r->file, upb_filedef_defcount(r->file) - 1);
}
/* Start/end handlers for FileDescriptorProto and DescriptorProto (the two
* entities that have names and can contain sub-definitions. */
void upb_descreader_startcontainer(upb_descreader *r) {
upb_descreader_frame *f = &r->stack[r->stack_len++];
- f->start = r->defs.len;
+ f->start = upb_filedef_defcount(r->file);
f->name = NULL;
}
void upb_descreader_endcontainer(upb_descreader *r) {
upb_descreader_frame *f = &r->stack[--r->stack_len];
- upb_deflist_qualify(&r->defs, f->name, f->start);
+ upb_descreader_qualify(r->file, f->name, f->start);
free(f->name);
f->name = NULL;
}
@@ -6131,17 +6349,26 @@ void upb_descreader_setscopename(upb_descreader *r, char *str) {
f->name = str;
}
-/* Handlers for google.protobuf.FileDescriptorProto. */
-static bool file_startmsg(void *closure, const void *hd) {
+/** Handlers for google.protobuf.FileDescriptorSet. ***************************/
+
+static void *fileset_startfile(void *closure, const void *hd) {
+ upb_descreader *r = closure;
+ UPB_UNUSED(hd);
+ r->file = upb_filedef_new(&r->files);
+ upb_inttable_push(&r->files, upb_value_ptr(r->file));
+ return r;
+}
+
+/** Handlers for google.protobuf.FileDescriptorProto. *************************/
+
+static bool file_start(void *closure, const void *hd) {
upb_descreader *r = closure;
UPB_UNUSED(hd);
upb_descreader_startcontainer(r);
- r->primitives_have_presence = true;
- r->file_start = r->defs.len;
return true;
}
-static bool file_endmsg(void *closure, const void *hd, upb_status *status) {
+static bool file_end(void *closure, const void *hd, upb_status *status) {
upb_descreader *r = closure;
UPB_UNUSED(hd);
UPB_UNUSED(status);
@@ -6149,46 +6376,86 @@ static bool file_endmsg(void *closure, const void *hd, upb_status *status) {
return true;
}
+static size_t file_onname(void *closure, const void *hd, const char *buf,
+ size_t n, const upb_bufhandle *handle) {
+ upb_descreader *r = closure;
+ char *name;
+ bool ok;
+ UPB_UNUSED(hd);
+ UPB_UNUSED(handle);
+
+ name = upb_strndup(buf, n);
+ /* XXX: see comment at the top of the file. */
+ ok = upb_filedef_setname(r->file, name, NULL);
+ UPB_ASSERT_VAR(ok, ok);
+ return n;
+}
+
static size_t file_onpackage(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
+ char *package;
+ bool ok;
UPB_UNUSED(hd);
UPB_UNUSED(handle);
+
+ package = upb_strndup(buf, n);
/* XXX: see comment at the top of the file. */
- upb_descreader_setscopename(r, upb_strndup(buf, n));
+ upb_descreader_setscopename(r, package);
+ ok = upb_filedef_setpackage(r->file, package, NULL);
+ UPB_ASSERT_VAR(ok, ok);
return n;
}
static size_t file_onsyntax(void *closure, const void *hd, const char *buf,
size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
+ bool ok;
UPB_UNUSED(hd);
UPB_UNUSED(handle);
/* XXX: see comment at the top of the file. */
if (upb_streq("proto2", buf, n)) {
- /* Technically we could verify that proto3 hadn't previously been seen. */
+ ok = upb_filedef_setsyntax(r->file, UPB_SYNTAX_PROTO2, NULL);
} else if (upb_streq("proto3", buf, n)) {
- uint32_t i;
- /* Update messages created before the syntax was read. */
- for (i = r->file_start; i < r->defs.len; i++) {
- upb_msgdef *m = upb_dyncast_msgdef_mutable(r->defs.defs[i]);
- if (m) {
- upb_msgdef_setprimitiveshavepresence(m, false);
- }
- }
-
- /* Set a flag for any future messages that will be created. */
- r->primitives_have_presence = false;
+ ok = upb_filedef_setsyntax(r->file, UPB_SYNTAX_PROTO3, NULL);
} else {
- /* Error: neither proto3 nor proto3.
- * TODO(haberman): there should be a status object we can report this to. */
- return 0;
+ ok = false;
}
+ UPB_ASSERT_VAR(ok, ok);
return n;
}
-/* Handlers for google.protobuf.EnumValueDescriptorProto. */
+static void *file_startmsg(void *closure, const void *hd) {
+ upb_descreader *r = closure;
+ upb_msgdef *m = upb_msgdef_new(&m);
+ bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
+ UPB_UNUSED(hd);
+ UPB_ASSERT_VAR(ok, ok);
+ return r;
+}
+
+static void *file_startenum(void *closure, const void *hd) {
+ upb_descreader *r = closure;
+ upb_enumdef *e = upb_enumdef_new(&e);
+ bool ok = upb_filedef_addenum(r->file, e, &e, NULL);
+ UPB_UNUSED(hd);
+ UPB_ASSERT_VAR(ok, ok);
+ return r;
+}
+
+static void *file_startext(void *closure, const void *hd) {
+ upb_descreader *r = closure;
+ bool ok;
+ r->f = upb_fielddef_new(r);
+ ok = upb_filedef_addext(r->file, r->f, r, NULL);
+ UPB_UNUSED(hd);
+ UPB_ASSERT_VAR(ok, ok);
+ return r;
+}
+
+/** Handlers for google.protobuf.EnumValueDescriptorProto. *********************/
+
static bool enumval_startmsg(void *closure, const void *hd) {
upb_descreader *r = closure;
UPB_UNUSED(hd);
@@ -6233,15 +6500,7 @@ static bool enumval_endmsg(void *closure, const void *hd, upb_status *status) {
return true;
}
-
-/* Handlers for google.protobuf.EnumDescriptorProto. */
-static bool enum_startmsg(void *closure, const void *hd) {
- upb_descreader *r = closure;
- UPB_UNUSED(hd);
- upb_deflist_push(&r->defs,
- upb_enumdef_upcast_mutable(upb_enumdef_new(&r->defs)));
- return true;
-}
+/** Handlers for google.protobuf.EnumDescriptorProto. *************************/
static bool enum_endmsg(void *closure, const void *hd, upb_status *status) {
upb_descreader *r = closure;
@@ -6272,11 +6531,12 @@ static size_t enum_onname(void *closure, const void *hd, const char *buf,
return n;
}
-/* Handlers for google.protobuf.FieldDescriptorProto */
+/** Handlers for google.protobuf.FieldDescriptorProto *************************/
+
static bool field_startmsg(void *closure, const void *hd) {
upb_descreader *r = closure;
UPB_UNUSED(hd);
- r->f = upb_fielddef_new(&r->defs);
+ assert(r->f);
free(r->default_string);
r->default_string = NULL;
@@ -6419,9 +6679,10 @@ static bool field_onlabel(void *closure, const void *hd, int32_t val) {
static bool field_onnumber(void *closure, const void *hd, int32_t val) {
upb_descreader *r = closure;
- bool ok = upb_fielddef_setnumber(r->f, val, NULL);
+ bool ok;
UPB_UNUSED(hd);
+ ok = upb_fielddef_setnumber(r->f, val, NULL);
UPB_ASSERT_VAR(ok, ok);
return true;
}
@@ -6479,20 +6740,17 @@ static size_t field_ondefaultval(void *closure, const void *hd, const char *buf,
return n;
}
-/* Handlers for google.protobuf.DescriptorProto (representing a message). */
-static bool msg_startmsg(void *closure, const void *hd) {
+/** Handlers for google.protobuf.DescriptorProto ******************************/
+
+static bool msg_start(void *closure, const void *hd) {
upb_descreader *r = closure;
- upb_msgdef *m;
UPB_UNUSED(hd);
- m = upb_msgdef_new(&r->defs);
- upb_msgdef_setprimitiveshavepresence(m, r->primitives_have_presence);
- upb_deflist_push(&r->defs, upb_msgdef_upcast_mutable(m));
upb_descreader_startcontainer(r);
return true;
}
-static bool msg_endmsg(void *closure, const void *hd, upb_status *status) {
+static bool msg_end(void *closure, const void *hd, upb_status *status) {
upb_descreader *r = closure;
upb_msgdef *m = upb_descreader_top(r);
UPB_UNUSED(hd);
@@ -6505,8 +6763,8 @@ static bool msg_endmsg(void *closure, const void *hd, upb_status *status) {
return true;
}
-static size_t msg_onname(void *closure, const void *hd, const char *buf,
- size_t n, const upb_bufhandle *handle) {
+static size_t msg_name(void *closure, const void *hd, const char *buf,
+ size_t n, const upb_bufhandle *handle) {
upb_descreader *r = closure;
upb_msgdef *m = upb_descreader_top(r);
/* XXX: see comment at the top of the file. */
@@ -6519,89 +6777,130 @@ static size_t msg_onname(void *closure, const void *hd, const char *buf,
return n;
}
-static bool msg_onendfield(void *closure, const void *hd) {
+static void *msg_startmsg(void *closure, const void *hd) {
upb_descreader *r = closure;
- upb_msgdef *m = upb_descreader_top(r);
+ upb_msgdef *m = upb_msgdef_new(&m);
+ bool ok = upb_filedef_addmsg(r->file, m, &m, NULL);
UPB_UNUSED(hd);
+ UPB_ASSERT_VAR(ok, ok);
+ return r;
+}
- upb_msgdef_addfield(m, r->f, &r->defs, NULL);
- r->f = NULL;
- return true;
+static void *msg_startext(void *closure, const void *hd) {
+ upb_descreader *r = closure;
+ upb_fielddef *f = upb_fielddef_new(&f);
+ bool ok = upb_filedef_addext(r->file, f, &f, NULL);
+ UPB_UNUSED(hd);
+ UPB_ASSERT_VAR(ok, ok);
+ return r;
+}
+
+static void *msg_startfield(void *closure, const void *hd) {
+ upb_descreader *r = closure;
+ r->f = upb_fielddef_new(&r->f);
+ /* We can't add the new field to the message until its name/number are
+ * filled in. */
+ UPB_UNUSED(hd);
+ return r;
}
-static bool pushextension(void *closure, const void *hd) {
+static bool msg_endfield(void *closure, const void *hd) {
upb_descreader *r = closure;
+ upb_msgdef *m = upb_descreader_top(r);
UPB_UNUSED(hd);
- assert(upb_fielddef_containingtypename(r->f));
- upb_fielddef_setisextension(r->f, true);
- upb_deflist_push(&r->defs, upb_fielddef_upcast_mutable(r->f));
+ upb_msgdef_addfield(m, r->f, &r->f, NULL);
r->f = NULL;
return true;
}
-#define D(name) upbdefs_google_protobuf_ ## name(s)
+
+/** Code to register handlers *************************************************/
+
+#define F(msg, field) upbdefs_google_protobuf_ ## msg ## _f_ ## field(m)
static void reghandlers(const void *closure, upb_handlers *h) {
- const upb_symtab *s = closure;
const upb_msgdef *m = upb_handlers_msgdef(h);
+ UPB_UNUSED(closure);
- if (m == D(DescriptorProto)) {
- upb_handlers_setstartmsg(h, &msg_startmsg, NULL);
- upb_handlers_setendmsg(h, &msg_endmsg, NULL);
- upb_handlers_setstring(h, D(DescriptorProto_name), &msg_onname, NULL);
- upb_handlers_setendsubmsg(h, D(DescriptorProto_field), &msg_onendfield,
- NULL);
- upb_handlers_setendsubmsg(h, D(DescriptorProto_extension), &pushextension,
- NULL);
- } else if (m == D(FileDescriptorProto)) {
- upb_handlers_setstartmsg(h, &file_startmsg, NULL);
- upb_handlers_setendmsg(h, &file_endmsg, NULL);
- upb_handlers_setstring(h, D(FileDescriptorProto_package), &file_onpackage,
+ if (upbdefs_google_protobuf_FileDescriptorSet_is(m)) {
+ upb_handlers_setstartsubmsg(h, F(FileDescriptorSet, file),
+ &fileset_startfile, NULL);
+ } else if (upbdefs_google_protobuf_DescriptorProto_is(m)) {
+ upb_handlers_setstartmsg(h, &msg_start, NULL);
+ upb_handlers_setendmsg(h, &msg_end, NULL);
+ upb_handlers_setstring(h, F(DescriptorProto, name), &msg_name, NULL);
+ upb_handlers_setstartsubmsg(h, F(DescriptorProto, extension), &msg_startext,
+ NULL);
+ upb_handlers_setstartsubmsg(h, F(DescriptorProto, nested_type),
+ &msg_startmsg, NULL);
+ upb_handlers_setstartsubmsg(h, F(DescriptorProto, field),
+ &msg_startfield, NULL);
+ upb_handlers_setendsubmsg(h, F(DescriptorProto, field),
+ &msg_endfield, NULL);
+ upb_handlers_setstartsubmsg(h, F(DescriptorProto, enum_type),
+ &file_startenum, NULL);
+ } else if (upbdefs_google_protobuf_FileDescriptorProto_is(m)) {
+ upb_handlers_setstartmsg(h, &file_start, NULL);
+ upb_handlers_setendmsg(h, &file_end, NULL);
+ upb_handlers_setstring(h, F(FileDescriptorProto, name), &file_onname,
+ NULL);
+ upb_handlers_setstring(h, F(FileDescriptorProto, package), &file_onpackage,
NULL);
- upb_handlers_setstring(h, D(FileDescriptorProto_syntax), &file_onsyntax,
+ upb_handlers_setstring(h, F(FileDescriptorProto, syntax), &file_onsyntax,
NULL);
- upb_handlers_setendsubmsg(h, D(FileDescriptorProto_extension), &pushextension,
- NULL);
- } else if (m == D(EnumValueDescriptorProto)) {
+ upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, message_type),
+ &file_startmsg, NULL);
+ upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, enum_type),
+ &file_startenum, NULL);
+ upb_handlers_setstartsubmsg(h, F(FileDescriptorProto, extension),
+ &file_startext, NULL);
+ } else if (upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)) {
upb_handlers_setstartmsg(h, &enumval_startmsg, NULL);
upb_handlers_setendmsg(h, &enumval_endmsg, NULL);
- upb_handlers_setstring(h, D(EnumValueDescriptorProto_name), &enumval_onname, NULL);
- upb_handlers_setint32(h, D(EnumValueDescriptorProto_number), &enumval_onnumber,
+ upb_handlers_setstring(h, F(EnumValueDescriptorProto, name), &enumval_onname, NULL);
+ upb_handlers_setint32(h, F(EnumValueDescriptorProto, number), &enumval_onnumber,
NULL);
- } else if (m == D(EnumDescriptorProto)) {
- upb_handlers_setstartmsg(h, &enum_startmsg, NULL);
+ } else if (upbdefs_google_protobuf_EnumDescriptorProto_is(m)) {
upb_handlers_setendmsg(h, &enum_endmsg, NULL);
- upb_handlers_setstring(h, D(EnumDescriptorProto_name), &enum_onname, NULL);
- } else if (m == D(FieldDescriptorProto)) {
+ upb_handlers_setstring(h, F(EnumDescriptorProto, name), &enum_onname, NULL);
+ } else if (upbdefs_google_protobuf_FieldDescriptorProto_is(m)) {
upb_handlers_setstartmsg(h, &field_startmsg, NULL);
upb_handlers_setendmsg(h, &field_endmsg, NULL);
- upb_handlers_setint32(h, D(FieldDescriptorProto_type), &field_ontype,
+ upb_handlers_setint32(h, F(FieldDescriptorProto, type), &field_ontype,
NULL);
- upb_handlers_setint32(h, D(FieldDescriptorProto_label), &field_onlabel,
+ upb_handlers_setint32(h, F(FieldDescriptorProto, label), &field_onlabel,
NULL);
- upb_handlers_setint32(h, D(FieldDescriptorProto_number), &field_onnumber,
+ upb_handlers_setint32(h, F(FieldDescriptorProto, number), &field_onnumber,
NULL);
- upb_handlers_setstring(h, D(FieldDescriptorProto_name), &field_onname,
+ upb_handlers_setstring(h, F(FieldDescriptorProto, name), &field_onname,
NULL);
- upb_handlers_setstring(h, D(FieldDescriptorProto_type_name),
+ upb_handlers_setstring(h, F(FieldDescriptorProto, type_name),
&field_ontypename, NULL);
- upb_handlers_setstring(h, D(FieldDescriptorProto_extendee),
+ upb_handlers_setstring(h, F(FieldDescriptorProto, extendee),
&field_onextendee, NULL);
- upb_handlers_setstring(h, D(FieldDescriptorProto_default_value),
+ upb_handlers_setstring(h, F(FieldDescriptorProto, default_value),
&field_ondefaultval, NULL);
- } else if (m == D(FieldOptions)) {
- upb_handlers_setbool(h, D(FieldOptions_lazy), &field_onlazy, NULL);
- upb_handlers_setbool(h, D(FieldOptions_packed), &field_onpacked, NULL);
+ } else if (upbdefs_google_protobuf_FieldOptions_is(m)) {
+ upb_handlers_setbool(h, F(FieldOptions, lazy), &field_onlazy, NULL);
+ upb_handlers_setbool(h, F(FieldOptions, packed), &field_onpacked, NULL);
}
+
+ assert(upb_ok(upb_handlers_status(h)));
}
-#undef D
+#undef F
void descreader_cleanup(void *_r) {
upb_descreader *r = _r;
+ size_t i;
+
+ for (i = 0; i < upb_descreader_filecount(r); i++) {
+ upb_filedef_unref(upb_descreader_file(r, i), &r->files);
+ }
+
free(r->name);
- upb_deflist_uninit(&r->defs);
+ upb_inttable_uninit(&r->files);
free(r->default_string);
while (r->stack_len > 0) {
upb_descreader_frame *f = &r->stack[--r->stack_len];
@@ -6618,7 +6917,7 @@ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) {
return NULL;
}
- upb_deflist_init(&r->defs);
+ upb_inttable_init(&r->files, UPB_CTYPE_PTR);
upb_sink_reset(upb_descreader_input(r), h, r);
r->stack_len = 0;
r->name = NULL;
@@ -6627,10 +6926,17 @@ upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h) {
return r;
}
-upb_def **upb_descreader_getdefs(upb_descreader *r, void *owner, int *n) {
- *n = r->defs.len;
- upb_deflist_donaterefs(&r->defs, owner);
- return r->defs.defs;
+size_t upb_descreader_filecount(const upb_descreader *r) {
+ return upb_inttable_count(&r->files);
+}
+
+upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i) {
+ upb_value v;
+ if (upb_inttable_lookup(&r->files, i, &v)) {
+ return upb_value_getptr(v);
+ } else {
+ return NULL;
+ }
}
upb_sink *upb_descreader_input(upb_descreader *r) {
@@ -6638,10 +6944,9 @@ upb_sink *upb_descreader_input(upb_descreader *r) {
}
const upb_handlers *upb_descreader_newhandlers(const void *owner) {
- const upb_symtab *s = upbdefs_google_protobuf_descriptor(&s);
- const upb_handlers *h = upb_handlers_newfrozen(
- upbdefs_google_protobuf_FileDescriptorSet(s), owner, reghandlers, s);
- upb_symtab_unref(s, &s);
+ const upb_msgdef *m = upbdefs_google_protobuf_FileDescriptorSet_get(&m);
+ const upb_handlers *h = upb_handlers_newfrozen(m, owner, reghandlers, NULL);
+ upb_msgdef_unref(m, &m);
return h;
}
/*
@@ -9281,8 +9586,8 @@ upb_sink *upb_pb_encoder_input(upb_pb_encoder *e) { return &e->input_; }
#include <stdlib.h>
#include <string.h>
-upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n,
- void *owner, upb_status *status) {
+upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
+ upb_status *status) {
/* Create handlers. */
const upb_pbdecodermethod *decoder_m;
const upb_handlers *reader_h = upb_descreader_newhandlers(&reader_h);
@@ -9291,8 +9596,8 @@ upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n,
upb_pbdecoder *decoder;
upb_descreader *reader;
bool ok;
- upb_def **ret = NULL;
- upb_def **defs;
+ size_t i;
+ upb_filedef **ret = NULL;
upb_pbdecodermethodopts_init(&opts, reader_h);
decoder_m = upb_pbdecodermethod_new(&opts, &decoder_m);
@@ -9304,12 +9609,24 @@ upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n,
decoder = upb_pbdecoder_create(&env, decoder_m, upb_descreader_input(reader));
/* Push input data. */
- ok = upb_bufsrc_putbuf(str, len, upb_pbdecoder_input(decoder));
+ ok = upb_bufsrc_putbuf(buf, n, upb_pbdecoder_input(decoder));
- if (!ok) goto cleanup;
- defs = upb_descreader_getdefs(reader, owner, n);
- ret = malloc(sizeof(upb_def*) * (*n));
- memcpy(ret, defs, sizeof(upb_def*) * (*n));
+ if (!ok) {
+ goto cleanup;
+ }
+
+ ret = malloc(sizeof (*ret) * (upb_descreader_filecount(reader) + 1));
+
+ if (!ret) {
+ goto cleanup;
+ }
+
+ for (i = 0; i < upb_descreader_filecount(reader); i++) {
+ ret[i] = upb_descreader_file(reader, i);
+ upb_filedef_ref(ret[i], owner);
+ }
+
+ ret[i] = NULL;
cleanup:
upb_env_uninit(&env);
@@ -9317,51 +9634,6 @@ cleanup:
upb_pbdecodermethod_unref(decoder_m, &decoder_m);
return ret;
}
-
-bool upb_load_descriptor_into_symtab(upb_symtab *s, const char *str, size_t len,
- upb_status *status) {
- int n;
- bool success;
- upb_def **defs = upb_load_defs_from_descriptor(str, len, &n, &defs, status);
- if (!defs) return false;
- success = upb_symtab_add(s, defs, n, &defs, status);
- free(defs);
- return success;
-}
-
-char *upb_readfile(const char *filename, size_t *len) {
- long size;
- char *buf;
- FILE *f = fopen(filename, "rb");
- if(!f) return NULL;
- if(fseek(f, 0, SEEK_END) != 0) goto error;
- size = ftell(f);
- if(size < 0) goto error;
- if(fseek(f, 0, SEEK_SET) != 0) goto error;
- buf = malloc(size + 1);
- if(size && fread(buf, size, 1, f) != 1) goto error;
- fclose(f);
- if (len) *len = size;
- return buf;
-
-error:
- fclose(f);
- return NULL;
-}
-
-bool upb_load_descriptor_file_into_symtab(upb_symtab *symtab, const char *fname,
- upb_status *status) {
- size_t len;
- bool success;
- char *data = upb_readfile(fname, &len);
- if (!data) {
- if (status) upb_status_seterrf(status, "Couldn't read file: %s", fname);
- return false;
- }
- success = upb_load_descriptor_into_symtab(symtab, data, len, status);
- free(data);
- return success;
-}
/*
* upb::pb::TextPrinter
*
@@ -11352,7 +11624,7 @@ _again:
#line 1270 "upb/json/parser.rl"
if (p != pe) {
- upb_status_seterrf(&parser->status, "Parse error at %s\n", p);
+ upb_status_seterrf(&parser->status, "Parse error at '%.*s'\n", pe - p, p);
upb_env_reporterror(parser->env, &parser->status);
} else {
capture_suspend(parser, &p);
@@ -11452,14 +11724,25 @@ static void add_jsonname_table(upb_json_parsermethod *m, const upb_msgdef* md) {
!upb_msg_field_done(&i);
upb_msg_field_next(&i)) {
const upb_fielddef *f = upb_msg_iter_field(&i);
+
+ /* Add an entry for the JSON name. */
size_t field_len = upb_fielddef_getjsonname(f, buf, len);
if (field_len > len) {
+ size_t len2;
buf = realloc(buf, field_len);
len = field_len;
- upb_fielddef_getjsonname(f, buf, len);
+ len2 = upb_fielddef_getjsonname(f, buf, len);
+ UPB_ASSERT_VAR(len2, len == len2);
}
upb_strtable_insert(t, buf, upb_value_constptr(f));
+ if (strcmp(buf, upb_fielddef_name(f)) != 0) {
+ /* Since the JSON name is different from the regular field name, add an
+ * entry for the raw name (compliant proto3 JSON parsers must accept
+ * both). */
+ upb_strtable_insert(t, upb_fielddef_name(f), upb_value_constptr(f));
+ }
+
if (upb_fielddef_issubmsg(f)) {
add_jsonname_table(m, upb_fielddef_msgsubdef(f));
}
@@ -11571,15 +11854,21 @@ void freestrpc(void *ptr) {
}
/* Convert fielddef name to JSON name and return as a string piece. */
-strpc *newstrpc(upb_handlers *h, const upb_fielddef *f) {
+strpc *newstrpc(upb_handlers *h, const upb_fielddef *f,
+ bool preserve_fieldnames) {
/* TODO(haberman): handle malloc failure. */
strpc *ret = malloc(sizeof(*ret));
- size_t len;
- ret->len = upb_fielddef_getjsonname(f, NULL, 0);
- ret->ptr = malloc(ret->len);
- len = upb_fielddef_getjsonname(f, ret->ptr, ret->len);
- UPB_ASSERT_VAR(len, len == ret->len);
- ret->len--; /* NULL */
+ if (preserve_fieldnames) {
+ ret->ptr = upb_strdup(upb_fielddef_name(f));
+ ret->len = strlen(ret->ptr);
+ } else {
+ size_t len;
+ ret->len = upb_fielddef_getjsonname(f, NULL, 0);
+ ret->ptr = malloc(ret->len);
+ len = upb_fielddef_getjsonname(f, ret->ptr, ret->len);
+ UPB_ASSERT_VAR(len, len == ret->len);
+ ret->len--; /* NULL */
+ }
upb_handlers_addcleanup(h, ret, freestrpc);
return ret;
@@ -12085,10 +12374,11 @@ static size_t mapkey_bytes(void *closure, const void *handler_data,
static void set_enum_hd(upb_handlers *h,
const upb_fielddef *f,
+ bool preserve_fieldnames,
upb_handlerattr *attr) {
EnumHandlerData *hd = malloc(sizeof(EnumHandlerData));
hd->enumdef = (const upb_enumdef *)upb_fielddef_subdef(f);
- hd->keyname = newstrpc(h, f);
+ hd->keyname = newstrpc(h, f, preserve_fieldnames);
upb_handlers_addcleanup(h, hd, free);
upb_handlerattr_sethandlerdata(attr, hd);
}
@@ -12105,7 +12395,8 @@ static void set_enum_hd(upb_handlers *h,
* our sources that emit mapentry messages do so canonically (with one key
* field, and then one value field), so this is not a pressing concern at the
* moment. */
-void printer_sethandlers_mapentry(const void *closure, upb_handlers *h) {
+void printer_sethandlers_mapentry(const void *closure, bool preserve_fieldnames,
+ upb_handlers *h) {
const upb_msgdef *md = upb_handlers_msgdef(h);
/* A mapentry message is printed simply as '"key": value'. Rather than
@@ -12179,7 +12470,7 @@ void printer_sethandlers_mapentry(const void *closure, upb_handlers *h) {
break;
case UPB_TYPE_ENUM: {
upb_handlerattr enum_attr = UPB_HANDLERATTR_INITIALIZER;
- set_enum_hd(h, value_field, &enum_attr);
+ set_enum_hd(h, value_field, preserve_fieldnames, &enum_attr);
upb_handlers_setint32(h, value_field, mapvalue_enum, &enum_attr);
upb_handlerattr_uninit(&enum_attr);
break;
@@ -12198,13 +12489,13 @@ void printer_sethandlers(const void *closure, upb_handlers *h) {
bool is_mapentry = upb_msgdef_mapentry(md);
upb_handlerattr empty_attr = UPB_HANDLERATTR_INITIALIZER;
upb_msg_field_iter i;
-
- UPB_UNUSED(closure);
+ const bool *preserve_fieldnames_ptr = closure;
+ const bool preserve_fieldnames = *preserve_fieldnames_ptr;
if (is_mapentry) {
/* mapentry messages are sufficiently different that we handle them
* separately. */
- printer_sethandlers_mapentry(closure, h);
+ printer_sethandlers_mapentry(closure, preserve_fieldnames, h);
return;
}
@@ -12225,7 +12516,8 @@ void printer_sethandlers(const void *closure, upb_handlers *h) {
const upb_fielddef *f = upb_msg_iter_field(&i);
upb_handlerattr name_attr = UPB_HANDLERATTR_INITIALIZER;
- upb_handlerattr_sethandlerdata(&name_attr, newstrpc(h, f));
+ upb_handlerattr_sethandlerdata(&name_attr,
+ newstrpc(h, f, preserve_fieldnames));
if (upb_fielddef_ismap(f)) {
upb_handlers_setstartseq(h, f, startmap, &name_attr);
@@ -12248,7 +12540,7 @@ void printer_sethandlers(const void *closure, upb_handlers *h) {
* option later to control this behavior, but we will wait for a real
* need first. */
upb_handlerattr enum_attr = UPB_HANDLERATTR_INITIALIZER;
- set_enum_hd(h, f, &enum_attr);
+ set_enum_hd(h, f, preserve_fieldnames, &enum_attr);
if (upb_fielddef_isseq(f)) {
upb_handlers_setint32(h, f, repeated_enum, &enum_attr);
@@ -12325,6 +12617,8 @@ upb_sink *upb_json_printer_input(upb_json_printer *p) {
}
const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md,
+ bool preserve_fieldnames,
const void *owner) {
- return upb_handlers_newfrozen(md, owner, printer_sethandlers, NULL);
+ return upb_handlers_newfrozen(
+ md, owner, printer_sethandlers, &preserve_fieldnames);
}
diff --git a/ruby/ext/google/protobuf_c/upb.h b/ruby/ext/google/protobuf_c/upb.h
index 0be5b296..b0058161 100644
--- a/ruby/ext/google/protobuf_c/upb.h
+++ b/ruby/ext/google/protobuf_c/upb.h
@@ -5,6 +5,7 @@
**
** - upb::MessageDef (upb_msgdef): describes a "message" construct.
** - upb::FieldDef (upb_fielddef): describes a message field.
+** - upb::FileDef (upb_filedef): describes a .proto file and its defs.
** - upb::EnumDef (upb_enumdef): describes an enum.
** - upb::OneofDef (upb_oneofdef): describes a oneof.
** - upb::Def (upb_def): base class of all the others.
@@ -365,6 +366,11 @@ template <class T> class reffed_ptr {
if (ptr_) ptr_->Ref(this);
}
+ reffed_ptr(const reffed_ptr& other)
+ : ptr_(upb::upcast(other.get())) {
+ if (ptr_) ptr_->Ref(this);
+ }
+
~reffed_ptr() { if (ptr_) ptr_->Unref(this); }
template <class U>
@@ -1265,12 +1271,17 @@ namespace upb {
class Def;
class EnumDef;
class FieldDef;
+class FileDef;
class MessageDef;
class OneofDef;
}
#endif
UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted)
+UPB_DECLARE_DERIVED_TYPE(upb::OneofDef, upb::RefCounted, upb_oneofdef,
+ upb_refcounted)
+UPB_DECLARE_DERIVED_TYPE(upb::FileDef, upb::RefCounted, upb_filedef,
+ upb_refcounted)
/* The maximum message depth that the type graph can have. This is a resource
* limit for the C stack since we sometimes need to recursively traverse the
@@ -1282,15 +1293,16 @@ UPB_DECLARE_DERIVED_TYPE(upb::Def, upb::RefCounted, upb_def, upb_refcounted)
#define UPB_MAX_MESSAGE_DEPTH 64
-/* upb::Def: base class for defs *********************************************/
+/* upb::Def: base class for top-level defs ***********************************/
-/* All the different kind of defs we support. These correspond 1:1 with
- * declarations in a .proto file. */
+/* All the different kind of defs that can be defined at the top-level and put
+ * in a SymbolTable or appear in a FileDef::defs() list. This excludes some
+ * defs (like oneofs and files). It only includes fields because they can be
+ * defined as extensions. */
typedef enum {
UPB_DEF_MSG,
UPB_DEF_FIELD,
UPB_DEF_ENUM,
- UPB_DEF_ONEOF,
UPB_DEF_SERVICE, /* Not yet implemented. */
UPB_DEF_ANY = -1 /* Wildcard for upb_symtab_get*() */
} upb_deftype_t;
@@ -1313,6 +1325,9 @@ class upb::Def {
/* "fullname" is the def's fully-qualified name (eg. foo.bar.Message). */
const char *full_name() const;
+ /* The final part of a def's name (eg. Message). */
+ const char *name() const;
+
/* The def must be mutable. Caller retains ownership of fullname. Defs are
* not required to have a name; if a def has no name when it is frozen, it
* will remain an anonymous def. On failure, returns false and details in "s"
@@ -1320,6 +1335,11 @@ class upb::Def {
bool set_full_name(const char* fullname, upb::Status* s);
bool set_full_name(const std::string &fullname, upb::Status* s);
+ /* The file in which this def appears. It is not necessary to add a def to a
+ * file (and consequently the accessor may return NULL). Set this by calling
+ * file->Add(def). */
+ FileDef* file() const;
+
/* Freezes the given defs; this validates all constraints and marks the defs
* as frozen (read-only). "defs" may not contain any fielddefs, but fields
* of any msgdefs will be frozen.
@@ -1331,7 +1351,7 @@ class upb::Def {
*
* After this operation succeeds, the finalized defs must only be accessed
* through a const pointer! */
- static bool Freeze(Def* const* defs, int n, Status* status);
+ static bool Freeze(Def* const* defs, size_t n, Status* status);
static bool Freeze(const std::vector<Def*>& defs, Status* status);
private:
@@ -1350,8 +1370,13 @@ UPB_REFCOUNTED_CMETHODS(upb_def, upb_def_upcast)
upb_deftype_t upb_def_type(const upb_def *d);
const char *upb_def_fullname(const upb_def *d);
+const char *upb_def_name(const upb_def *d);
+const upb_filedef *upb_def_file(const upb_def *d);
bool upb_def_setfullname(upb_def *def, const char *fullname, upb_status *s);
-bool upb_def_freeze(upb_def *const *defs, int n, upb_status *s);
+bool upb_def_freeze(upb_def *const *defs, size_t n, upb_status *s);
+
+/* Temporary API: for internal use only. */
+bool _upb_def_validate(upb_def *const*defs, size_t n, upb_status *s);
UPB_END_EXTERN_C
@@ -1424,7 +1449,6 @@ UPB_END_EXTERN_C
UPB_DECLARE_DEF_TYPE(upb::FieldDef, fielddef, FIELD)
UPB_DECLARE_DEF_TYPE(upb::MessageDef, msgdef, MSG)
UPB_DECLARE_DEF_TYPE(upb::EnumDef, enumdef, ENUM)
-UPB_DECLARE_DEF_TYPE(upb::OneofDef, oneofdef, ONEOF)
#undef UPB_DECLARE_DEF_TYPE
#undef UPB_DEF_CASTS
@@ -1582,7 +1606,7 @@ class upb::FieldDef {
* whatever message this field belongs to. Guaranteed to be less than
* f->containing_type()->field_count(). May only be accessed once the def has
* been finalized. */
- int index() const;
+ uint32_t index() const;
/* The MessageDef to which this field belongs.
*
@@ -1893,6 +1917,7 @@ class upb::MessageDef {
/* Functionality from upb::Def. */
const char* full_name() const;
+ const char* name() const;
bool set_full_name(const char* fullname, Status* s);
bool set_full_name(const std::string& fullname, Status* s);
@@ -2126,6 +2151,7 @@ UPB_REFCOUNTED_CMETHODS(upb_msgdef, upb_msgdef_upcast2)
bool upb_msgdef_freeze(upb_msgdef *m, upb_status *status);
const char *upb_msgdef_fullname(const upb_msgdef *m);
+const char *upb_msgdef_name(const upb_msgdef *m);
bool upb_msgdef_setfullname(upb_msgdef *m, const char *fullname, upb_status *s);
upb_msgdef *upb_msgdef_dup(const upb_msgdef *m, const void *owner);
@@ -2133,7 +2159,6 @@ bool upb_msgdef_addfield(upb_msgdef *m, upb_fielddef *f, const void *ref_donor,
upb_status *s);
bool upb_msgdef_addoneof(upb_msgdef *m, upb_oneofdef *o, const void *ref_donor,
upb_status *s);
-void upb_msgdef_setprimitiveshavepresence(upb_msgdef *m, bool have_presence);
/* Field lookup in a couple of different variations:
* - itof = int to field
@@ -2232,6 +2257,7 @@ class upb::EnumDef {
/* Functionality from upb::Def. */
const char* full_name() const;
+ const char* name() const;
bool set_full_name(const char* fullname, Status* s);
bool set_full_name(const std::string& fullname, Status* s);
@@ -2306,6 +2332,7 @@ bool upb_enumdef_freeze(upb_enumdef *e, upb_status *status);
/* From upb_def. */
const char *upb_enumdef_fullname(const upb_enumdef *e);
+const char *upb_enumdef_name(const upb_enumdef *e);
bool upb_enumdef_setfullname(upb_enumdef *e, const char *fullname,
upb_status *s);
@@ -2347,8 +2374,7 @@ typedef upb_inttable_iter upb_oneof_iter;
#ifdef __cplusplus
-/* Class that represents a oneof. Its base class is upb::Def (convert with
- * upb::upcast()). */
+/* Class that represents a oneof. */
class upb::OneofDef {
public:
/* Returns NULL if memory allocation failed. */
@@ -2357,9 +2383,6 @@ class upb::OneofDef {
/* upb::RefCounted methods like Ref()/Unref(). */
UPB_REFCOUNTED_CPPMETHODS
- /* Functionality from upb::Def. */
- const char* full_name() const;
-
/* Returns the MessageDef that owns this OneofDef. */
const MessageDef* containing_type() const;
@@ -2367,6 +2390,7 @@ class upb::OneofDef {
* by name once added to a message def. */
const char* name() const;
bool set_name(const char* name, Status* s);
+ bool set_name(const std::string& name, Status* s);
/* Returns the number of fields currently defined in the oneof. */
int field_count() const;
@@ -2460,7 +2484,7 @@ upb_oneofdef *upb_oneofdef_new(const void *owner);
upb_oneofdef *upb_oneofdef_dup(const upb_oneofdef *o, const void *owner);
/* Include upb_refcounted methods like upb_oneofdef_ref(). */
-UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast2)
+UPB_REFCOUNTED_CMETHODS(upb_oneofdef, upb_oneofdef_upcast)
const char *upb_oneofdef_name(const upb_oneofdef *o);
bool upb_oneofdef_setname(upb_oneofdef *o, const char *name, upb_status *s);
@@ -2496,6 +2520,125 @@ void upb_oneof_iter_setdone(upb_oneof_iter *iter);
UPB_END_EXTERN_C
+
+/* upb::FileDef ***************************************************************/
+
+typedef enum {
+ UPB_SYNTAX_PROTO2 = 2,
+ UPB_SYNTAX_PROTO3 = 3
+} upb_syntax_t;
+
+#ifdef __cplusplus
+
+/* Class that represents a .proto file with some things defined in it.
+ *
+ * Many users won't care about FileDefs, but they are necessary if you want to
+ * read the values of file-level options. */
+class upb::FileDef {
+ public:
+ /* Returns NULL if memory allocation failed. */
+ static reffed_ptr<FileDef> New();
+
+ /* upb::RefCounted methods like Ref()/Unref(). */
+ UPB_REFCOUNTED_CPPMETHODS
+
+ /* Get/set name of the file (eg. "foo/bar.proto"). */
+ const char* name() const;
+ bool set_name(const char* name, Status* s);
+ bool set_name(const std::string& name, Status* s);
+
+ /* Package name for definitions inside the file (eg. "foo.bar"). */
+ const char* package() const;
+ bool set_package(const char* package, Status* s);
+
+ /* Syntax for the file. Defaults to proto2. */
+ upb_syntax_t syntax() const;
+ void set_syntax(upb_syntax_t syntax);
+
+ /* Get the list of defs from the file. These are returned in the order that
+ * they were added to the FileDef. */
+ int def_count() const;
+ const Def* def(int index) const;
+ Def* def(int index);
+
+ /* Get the list of dependencies from the file. These are returned in the
+ * order that they were added to the FileDef. */
+ int dependency_count() const;
+ const FileDef* dependency(int index) const;
+
+ /* Adds defs to this file. The def must not already belong to another
+ * file.
+ *
+ * Note: this does *not* ensure that this def's name is unique in this file!
+ * Use a SymbolTable if you want to check this property. Especially since
+ * properly checking uniqueness would require a check across *all* files
+ * (including dependencies). */
+ bool AddDef(Def* def, Status* s);
+ bool AddMessage(MessageDef* m, Status* s);
+ bool AddEnum(EnumDef* e, Status* s);
+ bool AddExtension(FieldDef* f, Status* s);
+
+ /* Adds a dependency of this file. */
+ bool AddDependency(const FileDef* file);
+
+ /* Freezes this FileDef and all messages/enums under it. All subdefs must be
+ * resolved and all messages/enums must validate. Returns true if this
+ * succeeded.
+ *
+ * TODO(haberman): should we care whether the file's dependencies are frozen
+ * already? */
+ bool Freeze(Status* s);
+
+ private:
+ UPB_DISALLOW_POD_OPS(FileDef, upb::FileDef)
+};
+
+#endif
+
+UPB_BEGIN_EXTERN_C
+
+upb_filedef *upb_filedef_new(const void *owner);
+
+/* Include upb_refcounted methods like upb_msgdef_ref(). */
+UPB_REFCOUNTED_CMETHODS(upb_filedef, upb_filedef_upcast)
+
+const char *upb_filedef_name(const upb_filedef *f);
+const char *upb_filedef_package(const upb_filedef *f);
+upb_syntax_t upb_filedef_syntax(const upb_filedef *f);
+size_t upb_filedef_defcount(const upb_filedef *f);
+size_t upb_filedef_depcount(const upb_filedef *f);
+const upb_def *upb_filedef_def(const upb_filedef *f, size_t i);
+const upb_filedef *upb_filedef_dep(const upb_filedef *f, size_t i);
+
+bool upb_filedef_freeze(upb_filedef *f, upb_status *s);
+bool upb_filedef_setname(upb_filedef *f, const char *name, upb_status *s);
+bool upb_filedef_setpackage(upb_filedef *f, const char *package, upb_status *s);
+bool upb_filedef_setsyntax(upb_filedef *f, upb_syntax_t syntax, upb_status *s);
+
+bool upb_filedef_adddef(upb_filedef *f, upb_def *def, const void *ref_donor,
+ upb_status *s);
+bool upb_filedef_adddep(upb_filedef *f, const upb_filedef *dep);
+
+UPB_INLINE bool upb_filedef_addmsg(upb_filedef *f, upb_msgdef *m,
+ const void *ref_donor, upb_status *s) {
+ return upb_filedef_adddef(f, upb_msgdef_upcast_mutable(m), ref_donor, s);
+}
+
+UPB_INLINE bool upb_filedef_addenum(upb_filedef *f, upb_enumdef *e,
+ const void *ref_donor, upb_status *s) {
+ return upb_filedef_adddef(f, upb_enumdef_upcast_mutable(e), ref_donor, s);
+}
+
+UPB_INLINE bool upb_filedef_addext(upb_filedef *file, upb_fielddef *f,
+ const void *ref_donor, upb_status *s) {
+ return upb_filedef_adddef(file, upb_fielddef_upcast_mutable(f), ref_donor, s);
+}
+UPB_INLINE upb_def *upb_filedef_mutabledef(upb_filedef *f, int i) {
+ return (upb_def*)upb_filedef_def(f, i);
+}
+
+UPB_END_EXTERN_C
+
#ifdef __cplusplus
UPB_INLINE const char* upb_safecstr(const std::string& str) {
@@ -2511,13 +2654,14 @@ inline Def* Def::Dup(const void* owner) const {
}
inline Def::Type Def::def_type() const { return upb_def_type(this); }
inline const char* Def::full_name() const { return upb_def_fullname(this); }
+inline const char* Def::name() const { return upb_def_name(this); }
inline bool Def::set_full_name(const char* fullname, Status* s) {
return upb_def_setfullname(this, fullname, s);
}
inline bool Def::set_full_name(const std::string& fullname, Status* s) {
return upb_def_setfullname(this, upb_safecstr(fullname), s);
}
-inline bool Def::Freeze(Def* const* defs, int n, Status* status) {
+inline bool Def::Freeze(Def* const* defs, size_t n, Status* status) {
return upb_def_freeze(defs, n, status);
}
inline bool Def::Freeze(const std::vector<Def*>& defs, Status* status) {
@@ -2596,6 +2740,9 @@ inline void FieldDef::set_lazy(bool lazy) {
inline bool FieldDef::packed() const {
return upb_fielddef_packed(this);
}
+inline uint32_t FieldDef::index() const {
+ return upb_fielddef_index(this);
+}
inline void FieldDef::set_packed(bool packed) {
upb_fielddef_setpacked(this, packed);
}
@@ -2740,6 +2887,9 @@ inline reffed_ptr<MessageDef> MessageDef::New() {
inline const char *MessageDef::full_name() const {
return upb_msgdef_fullname(this);
}
+inline const char *MessageDef::name() const {
+ return upb_msgdef_name(this);
+}
inline bool MessageDef::set_full_name(const char* fullname, Status* s) {
return upb_msgdef_setfullname(this, fullname, s);
}
@@ -2927,6 +3077,9 @@ inline reffed_ptr<EnumDef> EnumDef::New() {
inline const char* EnumDef::full_name() const {
return upb_enumdef_fullname(this);
}
+inline const char* EnumDef::name() const {
+ return upb_enumdef_name(this);
+}
inline bool EnumDef::set_full_name(const char* fullname, Status* s) {
return upb_enumdef_setfullname(this, fullname, s);
}
@@ -2976,9 +3129,6 @@ inline reffed_ptr<OneofDef> OneofDef::New() {
upb_oneofdef *o = upb_oneofdef_new(&o);
return reffed_ptr<OneofDef>(o, &o);
}
-inline const char* OneofDef::full_name() const {
- return upb_oneofdef_name(this);
-}
inline const MessageDef* OneofDef::containing_type() const {
return upb_oneofdef_containingtype(this);
@@ -2989,6 +3139,9 @@ inline const char* OneofDef::name() const {
inline bool OneofDef::set_name(const char* name, Status* s) {
return upb_oneofdef_setname(this, name, s);
}
+inline bool OneofDef::set_name(const std::string& name, Status* s) {
+ return upb_oneofdef_setname(this, upb_safecstr(name), s);
+}
inline int OneofDef::field_count() const {
return upb_oneofdef_numfields(this);
}
@@ -3057,6 +3210,57 @@ inline bool OneofDef::const_iterator::operator!=(
return !(*this == other);
}
+inline reffed_ptr<FileDef> FileDef::New() {
+ upb_filedef *f = upb_filedef_new(&f);
+ return reffed_ptr<FileDef>(f, &f);
+}
+
+inline const char* FileDef::name() const {
+ return upb_filedef_name(this);
+}
+inline bool FileDef::set_name(const char* name, Status* s) {
+ return upb_filedef_setname(this, name, s);
+}
+inline bool FileDef::set_name(const std::string& name, Status* s) {
+ return upb_filedef_setname(this, upb_safecstr(name), s);
+}
+inline const char* FileDef::package() const {
+ return upb_filedef_package(this);
+}
+inline bool FileDef::set_package(const char* package, Status* s) {
+ return upb_filedef_setpackage(this, package, s);
+}
+inline int FileDef::def_count() const {
+ return upb_filedef_defcount(this);
+}
+inline const Def* FileDef::def(int index) const {
+ return upb_filedef_def(this, index);
+}
+inline Def* FileDef::def(int index) {
+ return const_cast<Def*>(upb_filedef_def(this, index));
+}
+inline int FileDef::dependency_count() const {
+ return upb_filedef_depcount(this);
+}
+inline const FileDef* FileDef::dependency(int index) const {
+ return upb_filedef_dep(this, index);
+}
+inline bool FileDef::AddDef(Def* def, Status* s) {
+ return upb_filedef_adddef(this, def, NULL, s);
+}
+inline bool FileDef::AddMessage(MessageDef* m, Status* s) {
+ return upb_filedef_addmsg(this, m, NULL, s);
+}
+inline bool FileDef::AddEnum(EnumDef* e, Status* s) {
+ return upb_filedef_addenum(this, e, NULL, s);
+}
+inline bool FileDef::AddExtension(FieldDef* f, Status* s) {
+ return upb_filedef_addext(this, f, NULL, s);
+}
+inline bool FileDef::AddDependency(const FileDef* file) {
+ return upb_filedef_adddep(this, file);
+}
+
} /* namespace upb */
#endif
@@ -3095,6 +3299,7 @@ struct upb_def {
upb_refcounted base;
const char *fullname;
+ const upb_filedef* file;
char type; /* A upb_deftype_t (char to save space) */
/* Used as a flag during the def's mutable stage. Must be false unless
@@ -3105,7 +3310,7 @@ struct upb_def {
};
#define UPB_DEF_INIT(name, type, refs, ref2s) \
- { UPB_REFCOUNT_INIT(refs, ref2s), name, type, false }
+ { UPB_REFCOUNT_INIT(refs, ref2s), name, NULL, type, false }
/* upb_fielddef ***************************************************************/
@@ -3176,10 +3381,10 @@ struct upb_msgdef {
* descriptor.upb.c. */
bool map_entry;
- /* Do primitive values in this message have explicit presence or not?
+ /* Whether this message has proto2 or proto3 semantics.
* TODO: set this flag properly for static descriptors; regenerate
* descriptor.upb.c. */
- bool primitives_have_presence;
+ upb_syntax_t syntax;
/* TODO(haberman): proper extension ranges (there can be multiple). */
};
@@ -3212,15 +3417,16 @@ struct upb_enumdef {
/* upb_oneofdef ***************************************************************/
struct upb_oneofdef {
- upb_def base;
+ upb_refcounted base;
+ const char *name;
upb_strtable ntof;
upb_inttable itof;
const upb_msgdef *parent;
};
#define UPB_ONEOFDEF_INIT(name, ntof, itof, refs, ref2s) \
- { UPB_DEF_INIT(name, UPB_DEF_ENUM, refs, ref2s), ntof, itof }
+ { UPB_REFCOUNT_INIT(refs, ref2s), name, ntof, itof }
/* upb_symtab *****************************************************************/
@@ -3234,6 +3440,16 @@ struct upb_symtab {
#define UPB_SYMTAB_INIT(symtab, refs, ref2s) \
{ UPB_REFCOUNT_INIT(refs, ref2s), symtab }
+struct upb_filedef {
+ upb_refcounted base;
+
+ const char *name;
+ const char *package;
+ upb_syntax_t syntax;
+
+ upb_inttable defs;
+ upb_inttable deps;
+};
#endif /* UPB_STATICINIT_H_ */
/*
@@ -6140,12 +6356,17 @@ class upb::SymbolTable {
* only a few messages are changing. We may want to add a way of adding a
* tree of frozen defs to the symtab (perhaps an alternate constructor where
* you pass the root of the tree?) */
- bool Add(Def*const* defs, int n, void* ref_donor, upb_status* status);
+ bool Add(Def*const* defs, size_t n, void* ref_donor, Status* status);
bool Add(const std::vector<Def*>& defs, void *owner, Status* status) {
return Add((Def*const*)&defs[0], defs.size(), owner, status);
}
+ /* Resolves all subdefs for messages in this file and attempts to freeze the
+ * file. If this succeeds, adds all the symbols to this SymbolTable
+ * (replacing any existing ones with the same names). */
+ bool AddFile(FileDef* file, Status* s);
+
private:
UPB_DISALLOW_POD_OPS(SymbolTable, upb::SymbolTable)
};
@@ -6166,8 +6387,9 @@ const upb_def *upb_symtab_resolve(const upb_symtab *s, const char *base,
const upb_def *upb_symtab_lookup(const upb_symtab *s, const char *sym);
const upb_msgdef *upb_symtab_lookupmsg(const upb_symtab *s, const char *sym);
const upb_enumdef *upb_symtab_lookupenum(const upb_symtab *s, const char *sym);
-bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, int n, void *ref_donor,
- upb_status *status);
+bool upb_symtab_add(upb_symtab *s, upb_def *const*defs, size_t n,
+ void *ref_donor, upb_status *status);
+bool upb_symtab_addfile(upb_symtab *s, upb_filedef *file, upb_status* status);
/* upb_symtab_iter i;
* for(upb_symtab_begin(&i, s, type); !upb_symtab_done(&i);
@@ -6209,9 +6431,12 @@ inline const MessageDef *SymbolTable::LookupMessage(const char *sym) const {
return upb_symtab_lookupmsg(this, sym);
}
inline bool SymbolTable::Add(
- Def*const* defs, int n, void* ref_donor, upb_status* status) {
+ Def*const* defs, size_t n, void* ref_donor, Status* status) {
return upb_symtab_add(this, (upb_def*const*)defs, n, ref_donor, status);
}
+inline bool SymbolTable::AddFile(FileDef* file, Status* s) {
+ return upb_symtab_addfile(this, file, s);
+}
} /* namespace upb */
#endif
@@ -6255,14 +6480,9 @@ class upb::descriptor::Reader {
/* The reader's input; this is where descriptor.proto data should be sent. */
Sink* input();
- /* Returns an array of all defs that have been parsed, and transfers ownership
- * of them to "owner". The number of defs is stored in *n. Ownership of the
- * returned array is retained and is invalidated by any other call into
- * Reader.
- *
- * These defs are not frozen or resolved; they are ready to be added to a
- * symtab. */
- upb::Def** GetDefs(void* owner, int* n);
+ /* Use to get the FileDefs that have been parsed. */
+ size_t file_count() const;
+ FileDef* file(size_t i) const;
/* Builds and returns handlers for the reader, owned by "owner." */
static Handlers* NewHandlers(const void* owner);
@@ -6278,7 +6498,8 @@ UPB_BEGIN_EXTERN_C
/* C API. */
upb_descreader *upb_descreader_create(upb_env *e, const upb_handlers *h);
upb_sink *upb_descreader_input(upb_descreader *r);
-upb_def **upb_descreader_getdefs(upb_descreader *r, void *owner, int *n);
+size_t upb_descreader_filecount(const upb_descreader *r);
+upb_filedef *upb_descreader_file(const upb_descreader *r, size_t i);
const upb_handlers *upb_descreader_newhandlers(const void *owner);
UPB_END_EXTERN_C
@@ -6291,8 +6512,11 @@ inline Reader* Reader::Create(Environment* e, const Handlers *h) {
return upb_descreader_create(e, h);
}
inline Sink* Reader::input() { return upb_descreader_input(this); }
-inline upb::Def** Reader::GetDefs(void* owner, int* n) {
- return upb_descreader_getdefs(this, owner, n);
+inline size_t Reader::file_count() const {
+ return upb_descreader_filecount(this);
+}
+inline FileDef* Reader::file(size_t i) const {
+ return upb_descreader_file(this, i);
}
} /* namespace descriptor */
} /* namespace upb */
@@ -6309,610 +6533,282 @@ inline upb::Def** Reader::GetDefs(void* owner, int* n) {
* Do not edit -- your changes will be discarded when the file is
* regenerated. */
-#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_
-#define GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_
+#ifndef UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_
+#define UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_
-#ifdef __cplusplus
UPB_BEGIN_EXTERN_C
-#endif
/* Enums */
typedef enum {
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_OPTIONAL = 1,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REQUIRED = 2,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_REPEATED = 3
+ google_protobuf_FieldDescriptorProto_LABEL_OPTIONAL = 1,
+ google_protobuf_FieldDescriptorProto_LABEL_REQUIRED = 2,
+ google_protobuf_FieldDescriptorProto_LABEL_REPEATED = 3
} google_protobuf_FieldDescriptorProto_Label;
typedef enum {
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_DOUBLE = 1,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FLOAT = 2,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT64 = 3,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT64 = 4,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 = 5,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED64 = 6,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_FIXED32 = 7,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BOOL = 8,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_STRING = 9,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_GROUP = 10,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_MESSAGE = 11,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_BYTES = 12,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_UINT32 = 13,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_ENUM = 14,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED32 = 15,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SFIXED64 = 16,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT32 = 17,
- GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_SINT64 = 18
+ google_protobuf_FieldDescriptorProto_TYPE_DOUBLE = 1,
+ google_protobuf_FieldDescriptorProto_TYPE_FLOAT = 2,
+ google_protobuf_FieldDescriptorProto_TYPE_INT64 = 3,
+ google_protobuf_FieldDescriptorProto_TYPE_UINT64 = 4,
+ google_protobuf_FieldDescriptorProto_TYPE_INT32 = 5,
+ google_protobuf_FieldDescriptorProto_TYPE_FIXED64 = 6,
+ google_protobuf_FieldDescriptorProto_TYPE_FIXED32 = 7,
+ google_protobuf_FieldDescriptorProto_TYPE_BOOL = 8,
+ google_protobuf_FieldDescriptorProto_TYPE_STRING = 9,
+ google_protobuf_FieldDescriptorProto_TYPE_GROUP = 10,
+ google_protobuf_FieldDescriptorProto_TYPE_MESSAGE = 11,
+ google_protobuf_FieldDescriptorProto_TYPE_BYTES = 12,
+ google_protobuf_FieldDescriptorProto_TYPE_UINT32 = 13,
+ google_protobuf_FieldDescriptorProto_TYPE_ENUM = 14,
+ google_protobuf_FieldDescriptorProto_TYPE_SFIXED32 = 15,
+ google_protobuf_FieldDescriptorProto_TYPE_SFIXED64 = 16,
+ google_protobuf_FieldDescriptorProto_TYPE_SINT32 = 17,
+ google_protobuf_FieldDescriptorProto_TYPE_SINT64 = 18
} google_protobuf_FieldDescriptorProto_Type;
typedef enum {
- GOOGLE_PROTOBUF_FIELDOPTIONS_STRING = 0,
- GOOGLE_PROTOBUF_FIELDOPTIONS_CORD = 1,
- GOOGLE_PROTOBUF_FIELDOPTIONS_STRING_PIECE = 2
+ google_protobuf_FieldOptions_STRING = 0,
+ google_protobuf_FieldOptions_CORD = 1,
+ google_protobuf_FieldOptions_STRING_PIECE = 2
} google_protobuf_FieldOptions_CType;
typedef enum {
- GOOGLE_PROTOBUF_FIELDOPTIONS_JS_NORMAL = 0,
- GOOGLE_PROTOBUF_FIELDOPTIONS_JS_STRING = 1,
- GOOGLE_PROTOBUF_FIELDOPTIONS_JS_NUMBER = 2
+ google_protobuf_FieldOptions_JS_NORMAL = 0,
+ google_protobuf_FieldOptions_JS_STRING = 1,
+ google_protobuf_FieldOptions_JS_NUMBER = 2
} google_protobuf_FieldOptions_JSType;
typedef enum {
- GOOGLE_PROTOBUF_FILEOPTIONS_SPEED = 1,
- GOOGLE_PROTOBUF_FILEOPTIONS_CODE_SIZE = 2,
- GOOGLE_PROTOBUF_FILEOPTIONS_LITE_RUNTIME = 3
+ google_protobuf_FileOptions_SPEED = 1,
+ google_protobuf_FileOptions_CODE_SIZE = 2,
+ google_protobuf_FileOptions_LITE_RUNTIME = 3
} google_protobuf_FileOptions_OptimizeMode;
-/* Selectors */
-
-/* google.protobuf.DescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 4
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSUBMSG 6
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_STARTSUBMSG 7
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_STARTSUBMSG 8
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_STARTSUBMSG 9
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_STARTSEQ 10
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSEQ 11
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_FIELD_ENDSUBMSG 12
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_STARTSEQ 13
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSEQ 14
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NESTED_TYPE_ENDSUBMSG 15
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 16
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 17
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 18
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_STARTSEQ 19
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSEQ 20
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_RANGE_ENDSUBMSG 21
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_STARTSEQ 22
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSEQ 23
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSION_ENDSUBMSG 24
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_OPTIONS_ENDSUBMSG 25
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_STARTSEQ 26
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_ENDSEQ 27
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_ONEOF_DECL_ENDSUBMSG 28
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_STARTSEQ 29
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_ENDSEQ 30
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_RANGE_ENDSUBMSG 31
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STRING 32
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_STARTSTR 33
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_NAME_ENDSTR 34
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_STARTSEQ 35
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_ENDSEQ 36
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_STRING 37
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_STARTSTR 38
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVED_NAME_ENDSTR 39
-
-/* google.protobuf.DescriptorProto.ExtensionRange */
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_START_INT32 2
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_EXTENSIONRANGE_END_INT32 3
-
-/* google.protobuf.DescriptorProto.ReservedRange */
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVEDRANGE_START_INT32 2
-#define SEL_GOOGLE_PROTOBUF_DESCRIPTORPROTO_RESERVEDRANGE_END_INT32 3
-
-/* google.protobuf.EnumDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_STARTSEQ 4
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSEQ 5
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_VALUE_ENDSUBMSG 6
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STRING 8
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_STARTSTR 9
-#define SEL_GOOGLE_PROTOBUF_ENUMDESCRIPTORPROTO_NAME_ENDSTR 10
-
-/* google.protobuf.EnumOptions */
-#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_ALLOW_ALIAS_BOOL 6
-#define SEL_GOOGLE_PROTOBUF_ENUMOPTIONS_DEPRECATED_BOOL 7
-
-/* google.protobuf.EnumValueDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STRING 4
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_STARTSTR 5
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NAME_ENDSTR 6
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_INT32 7
-
-/* google.protobuf.EnumValueOptions */
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_ENUMVALUEOPTIONS_DEPRECATED_BOOL 6
-
-/* google.protobuf.FieldDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STRING 4
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_STARTSTR 5
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NAME_ENDSTR 6
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STRING 7
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_STARTSTR 8
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_EXTENDEE_ENDSTR 9
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_NUMBER_INT32 10
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_LABEL_INT32 11
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_INT32 12
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STRING 13
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_STARTSTR 14
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_TYPE_NAME_ENDSTR 15
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STRING 16
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_STARTSTR 17
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_DEFAULT_VALUE_ENDSTR 18
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_ONEOF_INDEX_INT32 19
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_JSON_NAME_STRING 20
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_JSON_NAME_STARTSTR 21
-#define SEL_GOOGLE_PROTOBUF_FIELDDESCRIPTORPROTO_JSON_NAME_ENDSTR 22
-
-/* google.protobuf.FieldOptions */
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_CTYPE_INT32 6
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_PACKED_BOOL 7
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_DEPRECATED_BOOL 8
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_LAZY_BOOL 9
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_JSTYPE_INT32 10
-#define SEL_GOOGLE_PROTOBUF_FIELDOPTIONS_WEAK_BOOL 11
-
-/* google.protobuf.FileDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSUBMSG 4
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 6
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_STARTSUBMSG 7
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_STARTSEQ 8
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSEQ 9
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_MESSAGE_TYPE_ENDSUBMSG 10
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_STARTSEQ 11
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSEQ 12
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_ENUM_TYPE_ENDSUBMSG 13
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_STARTSEQ 14
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSEQ 15
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SERVICE_ENDSUBMSG 16
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_STARTSEQ 17
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSEQ 18
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_EXTENSION_ENDSUBMSG 19
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 20
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SOURCE_CODE_INFO_ENDSUBMSG 21
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STRING 22
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_STARTSTR 23
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_NAME_ENDSTR 24
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STRING 25
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_STARTSTR 26
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PACKAGE_ENDSTR 27
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSEQ 28
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSEQ 29
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STRING 30
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_STARTSTR 31
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_DEPENDENCY_ENDSTR 32
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_STARTSEQ 33
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_ENDSEQ 34
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_PUBLIC_DEPENDENCY_INT32 35
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_STARTSEQ 36
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_ENDSEQ 37
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_WEAK_DEPENDENCY_INT32 38
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SYNTAX_STRING 39
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SYNTAX_STARTSTR 40
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORPROTO_SYNTAX_ENDSTR 41
-
-/* google.protobuf.FileDescriptorSet */
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_FILEDESCRIPTORSET_FILE_ENDSUBMSG 5
-
-/* google.protobuf.FileOptions */
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STRING 6
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_STARTSTR 7
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_PACKAGE_ENDSTR 8
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STRING 9
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_STARTSTR 10
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_OUTER_CLASSNAME_ENDSTR 11
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OPTIMIZE_FOR_INT32 12
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_MULTIPLE_FILES_BOOL 13
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STRING 14
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_STARTSTR 15
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_GO_PACKAGE_ENDSTR 16
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CC_GENERIC_SERVICES_BOOL 17
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERIC_SERVICES_BOOL 18
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_PY_GENERIC_SERVICES_BOOL 19
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_GENERATE_EQUALS_AND_HASH_BOOL 20
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_DEPRECATED_BOOL 21
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVA_STRING_CHECK_UTF8_BOOL 22
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CC_ENABLE_ARENAS_BOOL 23
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OBJC_CLASS_PREFIX_STRING 24
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OBJC_CLASS_PREFIX_STARTSTR 25
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_OBJC_CLASS_PREFIX_ENDSTR 26
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CSHARP_NAMESPACE_STRING 27
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CSHARP_NAMESPACE_STARTSTR 28
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_CSHARP_NAMESPACE_ENDSTR 29
-#define SEL_GOOGLE_PROTOBUF_FILEOPTIONS_JAVANANO_USE_DEPRECATED_PACKAGE_BOOL 30
-
-/* google.protobuf.MessageOptions */
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MESSAGE_SET_WIRE_FORMAT_BOOL 6
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_NO_STANDARD_DESCRIPTOR_ACCESSOR_BOOL 7
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_DEPRECATED_BOOL 8
-#define SEL_GOOGLE_PROTOBUF_MESSAGEOPTIONS_MAP_ENTRY_BOOL 9
-
-/* google.protobuf.MethodDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STRING 4
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_STARTSTR 5
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_NAME_ENDSTR 6
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STRING 7
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_STARTSTR 8
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_INPUT_TYPE_ENDSTR 9
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STRING 10
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_STARTSTR 11
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_OUTPUT_TYPE_ENDSTR 12
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_CLIENT_STREAMING_BOOL 13
-#define SEL_GOOGLE_PROTOBUF_METHODDESCRIPTORPROTO_SERVER_STREAMING_BOOL 14
-
-/* google.protobuf.MethodOptions */
-#define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_METHODOPTIONS_DEPRECATED_BOOL 6
-
-/* google.protobuf.OneofDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_ONEOFDESCRIPTORPROTO_NAME_STRING 2
-#define SEL_GOOGLE_PROTOBUF_ONEOFDESCRIPTORPROTO_NAME_STARTSTR 3
-#define SEL_GOOGLE_PROTOBUF_ONEOFDESCRIPTORPROTO_NAME_ENDSTR 4
-
-/* google.protobuf.ServiceDescriptorProto */
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_STARTSUBMSG 3
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_STARTSEQ 4
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSEQ 5
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_METHOD_ENDSUBMSG 6
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_OPTIONS_ENDSUBMSG 7
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STRING 8
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_STARTSTR 9
-#define SEL_GOOGLE_PROTOBUF_SERVICEDESCRIPTORPROTO_NAME_ENDSTR 10
-
-/* google.protobuf.ServiceOptions */
-#define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_UNINTERPRETED_OPTION_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_SERVICEOPTIONS_DEPRECATED_BOOL 6
-
-/* google.protobuf.SourceCodeInfo */
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_ENDSUBMSG 5
-
-/* google.protobuf.SourceCodeInfo.Location */
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_STARTSEQ 2
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_ENDSEQ 3
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_PATH_INT32 4
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_STARTSEQ 5
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_ENDSEQ 6
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_SPAN_INT32 7
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STRING 8
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_STARTSTR 9
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_COMMENTS_ENDSTR 10
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STRING 11
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_STARTSTR 12
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_TRAILING_COMMENTS_ENDSTR 13
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_STARTSEQ 14
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_ENDSEQ 15
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_STRING 16
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_STARTSTR 17
-#define SEL_GOOGLE_PROTOBUF_SOURCECODEINFO_LOCATION_LEADING_DETACHED_COMMENTS_ENDSTR 18
-
-/* google.protobuf.UninterpretedOption */
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSUBMSG 2
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_STARTSEQ 3
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSEQ 4
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAME_ENDSUBMSG 5
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STRING 6
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_STARTSTR 7
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_IDENTIFIER_VALUE_ENDSTR 8
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_POSITIVE_INT_VALUE_UINT64 9
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NEGATIVE_INT_VALUE_INT64 10
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_DOUBLE_VALUE_DOUBLE 11
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STRING 12
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_STARTSTR 13
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_STRING_VALUE_ENDSTR 14
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STRING 15
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_STARTSTR 16
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_AGGREGATE_VALUE_ENDSTR 17
-
-/* google.protobuf.UninterpretedOption.NamePart */
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STRING 2
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_STARTSTR 3
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_NAME_PART_ENDSTR 4
-#define SEL_GOOGLE_PROTOBUF_UNINTERPRETEDOPTION_NAMEPART_IS_EXTENSION_BOOL 5
-
-const upb_symtab *upbdefs_google_protobuf_descriptor(const void *owner);
-
-/* MessageDefs */
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ExtensionRange");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.DescriptorProto.ReservedRange");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumValueDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.EnumValueOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FieldDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FieldOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FieldOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileDescriptorSet");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_FileOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.FileOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MessageOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.MessageOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.MethodDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_MethodOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.MethodOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.OneofDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceDescriptorProto");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_ServiceOptions(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.ServiceOptions");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.SourceCodeInfo.Location");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption");
- assert(m);
- return m;
-}
-UPB_INLINE const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart(const upb_symtab *s) {
- const upb_msgdef *m = upb_symtab_lookupmsg(s, "google.protobuf.UninterpretedOption.NamePart");
- assert(m);
- return m;
-}
-
-
-/* EnumDefs */
-UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label(const upb_symtab *s) {
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldDescriptorProto.Label");
- assert(e);
- return e;
-}
-UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type(const upb_symtab *s) {
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldDescriptorProto.Type");
- assert(e);
- return e;
-}
-UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType(const upb_symtab *s) {
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldOptions.CType");
- assert(e);
- return e;
-}
-UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType(const upb_symtab *s) {
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FieldOptions.JSType");
- assert(e);
- return e;
-}
-UPB_INLINE const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode(const upb_symtab *s) {
- const upb_enumdef *e = upb_symtab_lookupenum(s, "google.protobuf.FileOptions.OptimizeMode");
- assert(e);
- return e;
-}
-
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ExtensionRange(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_end(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ReservedRange(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_start(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto_ReservedRange(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_enum_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_extension_range(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_field(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_nested_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_oneof_decl(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_reserved_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_reserved_range(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_DescriptorProto(s), 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumDescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_allow_alias(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueDescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueOptions(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_EnumValueOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_default_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_extendee(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_json_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_label(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_number(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_oneof_index(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_type_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldDescriptorProto(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_ctype(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_jstype(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_lazy(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_packed(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_weak(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FieldOptions(s), 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_enum_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_message_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_public_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_service(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_source_code_info(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_syntax(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 12); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_weak_dependency(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorProto(s), 11); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_file(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileDescriptorSet(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_enable_arenas(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 31); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_cc_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 16); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_csharp_namespace(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 37); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 23); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_go_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 11); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 20); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 17); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_multiple_files(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 10); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_outer_classname(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_java_string_check_utf8(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 27); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_javanano_use_deprecated_package(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 38); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_objc_class_prefix(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 36); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_optimize_for(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 9); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_py_generic_services(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 18); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_FileOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_map_entry(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 7); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_message_set_wire_format(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MessageOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_client_streaming(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_input_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_output_type(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_server_streaming(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodDescriptorProto(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodOptions(s), 33); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_MethodOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_OneofDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_method(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_options(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceDescriptorProto(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_deprecated(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceOptions(s), 33); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_uninterpreted_option(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_ServiceOptions(s), 999); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_leading_detached_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_path(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_span(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo_Location(s), 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_location(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_SourceCodeInfo(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_is_extension(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption_NamePart(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_name_part(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption_NamePart(s), 1); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_aggregate_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 8); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_double_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 6); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_identifier_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 3); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_name(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 2); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_negative_int_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 5); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_positive_int_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 4); }
-UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_string_value(const upb_symtab *s) { return upb_msgdef_itof(upbdefs_google_protobuf_UninterpretedOption(s), 7); }
+/* MessageDefs: call these functions to get a ref to a msgdef. */
+const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_EnumDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_EnumOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_EnumValueDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_EnumValueOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_FieldDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_FieldOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_FileDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_FileDescriptorSet_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_FileOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_MessageOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_MethodDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_MethodOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_OneofDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_ServiceDescriptorProto_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_ServiceOptions_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_SourceCodeInfo_Location_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_get(const void *owner);
+const upb_msgdef *upbdefs_google_protobuf_UninterpretedOption_NamePart_get(const void *owner);
+
+/* EnumDefs: call these functions to get a ref to an enumdef. */
+const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Label_get(const void *owner);
+const upb_enumdef *upbdefs_google_protobuf_FieldDescriptorProto_Type_get(const void *owner);
+const upb_enumdef *upbdefs_google_protobuf_FieldOptions_CType_get(const void *owner);
+const upb_enumdef *upbdefs_google_protobuf_FieldOptions_JSType_get(const void *owner);
+const upb_enumdef *upbdefs_google_protobuf_FileOptions_OptimizeMode_get(const void *owner);
+
+/* Functions to test whether this message is of a certain type. */
+UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.ExtensionRange") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.DescriptorProto.ReservedRange") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_EnumDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_EnumOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_EnumValueDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_EnumValueOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.EnumValueOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FieldOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FileDescriptorSet_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileDescriptorSet") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FileOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.FileOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_MessageOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.MessageOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_MethodDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_MethodOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.MethodOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_OneofDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.OneofDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_ServiceDescriptorProto_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceDescriptorProto") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_ServiceOptions_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.ServiceOptions") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_SourceCodeInfo_Location_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.SourceCodeInfo.Location") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_UninterpretedOption_NamePart_is(const upb_msgdef *m) {
+ return strcmp(upb_msgdef_fullname(m), "google.protobuf.UninterpretedOption.NamePart") == 0;
+}
+
+/* Functions to test whether this enum is of a certain type. */
+UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Label_is(const upb_enumdef *e) {
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.Label") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FieldDescriptorProto_Type_is(const upb_enumdef *e) {
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldDescriptorProto.Type") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_CType_is(const upb_enumdef *e) {
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.CType") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FieldOptions_JSType_is(const upb_enumdef *e) {
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FieldOptions.JSType") == 0;
+}
+UPB_INLINE bool upbdefs_google_protobuf_FileOptions_OptimizeMode_is(const upb_enumdef *e) {
+ return strcmp(upb_enumdef_fullname(e), "google.protobuf.FileOptions.OptimizeMode") == 0;
+}
+
+
+/* Functions to get a fielddef from a msgdef reference. */
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ExtensionRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_end(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_ReservedRange_f_start(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_extension_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_field(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_nested_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_oneof_decl(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_DescriptorProto_f_reserved_range(const upb_msgdef *m) { assert(upbdefs_google_protobuf_DescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumDescriptorProto_f_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_allow_alias(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_EnumValueOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_EnumValueOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_default_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_extendee(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_json_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_label(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_number(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_oneof_index(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldDescriptorProto_f_type_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_ctype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_jstype(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_lazy(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_packed(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FieldOptions_f_weak(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FieldOptions_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_enum_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_message_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_public_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_service(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_source_code_info(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_syntax(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 12); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorProto_f_weak_dependency(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorProto_is(m)); return upb_msgdef_itof(m, 11); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileDescriptorSet_f_file(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileDescriptorSet_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_enable_arenas(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 31); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_cc_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 16); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_csharp_namespace(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 37); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 23); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_go_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 11); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generate_equals_and_hash(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 20); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 17); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_multiple_files(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 10); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_outer_classname(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_java_string_check_utf8(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 27); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_javanano_use_deprecated_package(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 38); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_objc_class_prefix(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 36); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_optimize_for(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 9); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_py_generic_services(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 18); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_FileOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_FileOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_map_entry(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 7); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_message_set_wire_format(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_no_standard_descriptor_accessor(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MessageOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MessageOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_client_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_input_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_output_type(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodDescriptorProto_f_server_streaming(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 33); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_MethodOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_MethodOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_OneofDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_method(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceDescriptorProto_f_options(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_deprecated(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 33); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_ServiceOptions_f_uninterpreted_option(const upb_msgdef *m) { assert(upbdefs_google_protobuf_ServiceOptions_is(m)); return upb_msgdef_itof(m, 999); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_leading_detached_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_path(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_span(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_Location_f_trailing_comments(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_SourceCodeInfo_f_location(const upb_msgdef *m) { assert(upbdefs_google_protobuf_SourceCodeInfo_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_is_extension(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_NamePart_f_name_part(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m)); return upb_msgdef_itof(m, 1); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_aggregate_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 8); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_double_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 6); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_identifier_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 3); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_name(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 2); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_negative_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 5); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_positive_int_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 4); }
+UPB_INLINE const upb_fielddef *upbdefs_google_protobuf_UninterpretedOption_f_string_value(const upb_msgdef *m) { assert(upbdefs_google_protobuf_UninterpretedOption_is(m)); return upb_msgdef_itof(m, 7); }
UPB_END_EXTERN_C
@@ -6921,320 +6817,360 @@ UPB_END_EXTERN_C
namespace upbdefs {
namespace google {
namespace protobuf {
-namespace descriptor {
-inline upb::reffed_ptr<const upb::SymbolTable> SymbolTable() {
- const upb::SymbolTable* s = upbdefs_google_protobuf_descriptor(&s);
- return upb::reffed_ptr<const upb::SymbolTable>(s, &s);
-}
-} /* namespace descriptor */
-} /* namespace protobuf */
-} /* namespace google */
-#define RETURN_REFFED(type, func) \
- const type* obj = func(upbdefs::google::protobuf::descriptor::SymbolTable().get()); \
- return upb::reffed_ptr<const type>(obj);
+class DescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ DescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_DescriptorProto_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace DescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_DescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_enum_type) }
-inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_extension) }
-inline upb::reffed_ptr<const upb::FieldDef> extension_range() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_extension_range) }
-inline upb::reffed_ptr<const upb::FieldDef> field() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_field) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> nested_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_nested_type) }
-inline upb::reffed_ptr<const upb::FieldDef> oneof_decl() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_oneof_decl) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_options) }
-inline upb::reffed_ptr<const upb::FieldDef> reserved_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_reserved_name) }
-inline upb::reffed_ptr<const upb::FieldDef> reserved_range() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_reserved_range) }
-} /* namespace DescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+ static DescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_get(&m);
+ return DescriptorProto(m, &m);
+ }
-namespace google {
-namespace protobuf {
-namespace DescriptorProto {
-namespace ExtensionRange {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange) }
-inline upb::reffed_ptr<const upb::FieldDef> end() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_end) }
-inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ExtensionRange_start) }
-} /* namespace ExtensionRange */
-} /* namespace DescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+ class ExtensionRange : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ ExtensionRange(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_DescriptorProto_ExtensionRange_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace DescriptorProto {
-namespace ReservedRange {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_DescriptorProto_ReservedRange) }
-inline upb::reffed_ptr<const upb::FieldDef> end() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ReservedRange_end) }
-inline upb::reffed_ptr<const upb::FieldDef> start() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_DescriptorProto_ReservedRange_start) }
-} /* namespace ReservedRange */
-} /* namespace DescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+ static ExtensionRange get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_ExtensionRange_get(&m);
+ return ExtensionRange(m, &m);
+ }
+ };
-namespace google {
-namespace protobuf {
-namespace EnumDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumDescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumDescriptorProto_options) }
-inline upb::reffed_ptr<const upb::FieldDef> value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumDescriptorProto_value) }
-} /* namespace EnumDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+ class ReservedRange : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ ReservedRange(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_DescriptorProto_ReservedRange_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace EnumOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> allow_alias() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_allow_alias) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumOptions_uninterpreted_option) }
-} /* namespace EnumOptions */
-} /* namespace protobuf */
-} /* namespace google */
+ static ReservedRange get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_DescriptorProto_ReservedRange_get(&m);
+ return ReservedRange(m, &m);
+ }
+ };
+};
-namespace google {
-namespace protobuf {
-namespace EnumValueDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumValueDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueDescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueDescriptorProto_number) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueDescriptorProto_options) }
-} /* namespace EnumValueDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+class EnumDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ EnumDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_EnumDescriptorProto_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace EnumValueOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_EnumValueOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_EnumValueOptions_uninterpreted_option) }
-} /* namespace EnumValueOptions */
-} /* namespace protobuf */
-} /* namespace google */
+ static EnumDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_EnumDescriptorProto_get(&m);
+ return EnumDescriptorProto(m, &m);
+ }
+};
-namespace google {
-namespace protobuf {
-namespace FieldDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> default_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_default_value) }
-inline upb::reffed_ptr<const upb::FieldDef> extendee() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_extendee) }
-inline upb::reffed_ptr<const upb::FieldDef> json_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_json_name) }
-inline upb::reffed_ptr<const upb::FieldDef> label() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_label) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> number() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_number) }
-inline upb::reffed_ptr<const upb::FieldDef> oneof_index() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_oneof_index) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_options) }
-inline upb::reffed_ptr<const upb::FieldDef> type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type) }
-inline upb::reffed_ptr<const upb::FieldDef> type_name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldDescriptorProto_type_name) }
-inline upb::reffed_ptr<const upb::EnumDef> Label() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldDescriptorProto_Label) }
-inline upb::reffed_ptr<const upb::EnumDef> Type() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldDescriptorProto_Type) }
-} /* namespace FieldDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+class EnumOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ EnumOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_EnumOptions_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace FieldOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FieldOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> ctype() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_ctype) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> jstype() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_jstype) }
-inline upb::reffed_ptr<const upb::FieldDef> lazy() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_lazy) }
-inline upb::reffed_ptr<const upb::FieldDef> packed() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_packed) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_uninterpreted_option) }
-inline upb::reffed_ptr<const upb::FieldDef> weak() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FieldOptions_weak) }
-inline upb::reffed_ptr<const upb::EnumDef> CType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_CType) }
-inline upb::reffed_ptr<const upb::EnumDef> JSType() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FieldOptions_JSType) }
-} /* namespace FieldOptions */
-} /* namespace protobuf */
-} /* namespace google */
+ static EnumOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_EnumOptions_get(&m);
+ return EnumOptions(m, &m);
+ }
+};
-namespace google {
-namespace protobuf {
-namespace FileDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_dependency) }
-inline upb::reffed_ptr<const upb::FieldDef> enum_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_enum_type) }
-inline upb::reffed_ptr<const upb::FieldDef> extension() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_extension) }
-inline upb::reffed_ptr<const upb::FieldDef> message_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_message_type) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_options) }
-inline upb::reffed_ptr<const upb::FieldDef> package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_package) }
-inline upb::reffed_ptr<const upb::FieldDef> public_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_public_dependency) }
-inline upb::reffed_ptr<const upb::FieldDef> service() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_service) }
-inline upb::reffed_ptr<const upb::FieldDef> source_code_info() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_source_code_info) }
-inline upb::reffed_ptr<const upb::FieldDef> syntax() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_syntax) }
-inline upb::reffed_ptr<const upb::FieldDef> weak_dependency() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorProto_weak_dependency) }
-} /* namespace FileDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+class EnumValueDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ EnumValueDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_EnumValueDescriptorProto_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace FileDescriptorSet {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileDescriptorSet) }
-inline upb::reffed_ptr<const upb::FieldDef> file() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileDescriptorSet_file) }
-} /* namespace FileDescriptorSet */
-} /* namespace protobuf */
-} /* namespace google */
+ static EnumValueDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_EnumValueDescriptorProto_get(&m);
+ return EnumValueDescriptorProto(m, &m);
+ }
+};
-namespace google {
-namespace protobuf {
-namespace FileOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_FileOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> cc_enable_arenas() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_enable_arenas) }
-inline upb::reffed_ptr<const upb::FieldDef> cc_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_cc_generic_services) }
-inline upb::reffed_ptr<const upb::FieldDef> csharp_namespace() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_csharp_namespace) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> go_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_go_package) }
-inline upb::reffed_ptr<const upb::FieldDef> java_generate_equals_and_hash() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generate_equals_and_hash) }
-inline upb::reffed_ptr<const upb::FieldDef> java_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_generic_services) }
-inline upb::reffed_ptr<const upb::FieldDef> java_multiple_files() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_multiple_files) }
-inline upb::reffed_ptr<const upb::FieldDef> java_outer_classname() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_outer_classname) }
-inline upb::reffed_ptr<const upb::FieldDef> java_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_package) }
-inline upb::reffed_ptr<const upb::FieldDef> java_string_check_utf8() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_java_string_check_utf8) }
-inline upb::reffed_ptr<const upb::FieldDef> javanano_use_deprecated_package() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_javanano_use_deprecated_package) }
-inline upb::reffed_ptr<const upb::FieldDef> objc_class_prefix() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_objc_class_prefix) }
-inline upb::reffed_ptr<const upb::FieldDef> optimize_for() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_optimize_for) }
-inline upb::reffed_ptr<const upb::FieldDef> py_generic_services() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_py_generic_services) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_FileOptions_uninterpreted_option) }
-inline upb::reffed_ptr<const upb::EnumDef> OptimizeMode() { RETURN_REFFED(upb::EnumDef, upbdefs_google_protobuf_FileOptions_OptimizeMode) }
-} /* namespace FileOptions */
-} /* namespace protobuf */
-} /* namespace google */
+class EnumValueOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ EnumValueOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_EnumValueOptions_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace MessageOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MessageOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> map_entry() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_map_entry) }
-inline upb::reffed_ptr<const upb::FieldDef> message_set_wire_format() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_message_set_wire_format) }
-inline upb::reffed_ptr<const upb::FieldDef> no_standard_descriptor_accessor() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_no_standard_descriptor_accessor) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MessageOptions_uninterpreted_option) }
-} /* namespace MessageOptions */
-} /* namespace protobuf */
-} /* namespace google */
+ static EnumValueOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_EnumValueOptions_get(&m);
+ return EnumValueOptions(m, &m);
+ }
+};
-namespace google {
-namespace protobuf {
-namespace MethodDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> client_streaming() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_client_streaming) }
-inline upb::reffed_ptr<const upb::FieldDef> input_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_input_type) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_options) }
-inline upb::reffed_ptr<const upb::FieldDef> output_type() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_output_type) }
-inline upb::reffed_ptr<const upb::FieldDef> server_streaming() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodDescriptorProto_server_streaming) }
-} /* namespace MethodDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+class FieldDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ FieldDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_FieldDescriptorProto_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace MethodOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_MethodOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_MethodOptions_uninterpreted_option) }
-} /* namespace MethodOptions */
-} /* namespace protobuf */
-} /* namespace google */
+ static FieldDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_FieldDescriptorProto_get(&m);
+ return FieldDescriptorProto(m, &m);
+ }
-namespace google {
-namespace protobuf {
-namespace OneofDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_OneofDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_OneofDescriptorProto_name) }
-} /* namespace OneofDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+ class Label : public upb::reffed_ptr<const upb::EnumDef> {
+ public:
+ Label(const upb::EnumDef* e, const void *ref_donor = NULL)
+ : reffed_ptr(e, ref_donor) {
+ assert(upbdefs_google_protobuf_FieldDescriptorProto_Label_is(e));
+ }
+ static Label get() {
+ const upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Label_get(&e);
+ return Label(e, &e);
+ }
+ };
-namespace google {
-namespace protobuf {
-namespace ServiceDescriptorProto {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_ServiceDescriptorProto) }
-inline upb::reffed_ptr<const upb::FieldDef> method() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceDescriptorProto_method) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceDescriptorProto_name) }
-inline upb::reffed_ptr<const upb::FieldDef> options() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceDescriptorProto_options) }
-} /* namespace ServiceDescriptorProto */
-} /* namespace protobuf */
-} /* namespace google */
+ class Type : public upb::reffed_ptr<const upb::EnumDef> {
+ public:
+ Type(const upb::EnumDef* e, const void *ref_donor = NULL)
+ : reffed_ptr(e, ref_donor) {
+ assert(upbdefs_google_protobuf_FieldDescriptorProto_Type_is(e));
+ }
+ static Type get() {
+ const upb::EnumDef* e = upbdefs_google_protobuf_FieldDescriptorProto_Type_get(&e);
+ return Type(e, &e);
+ }
+ };
+};
-namespace google {
-namespace protobuf {
-namespace ServiceOptions {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_ServiceOptions) }
-inline upb::reffed_ptr<const upb::FieldDef> deprecated() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_deprecated) }
-inline upb::reffed_ptr<const upb::FieldDef> uninterpreted_option() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_ServiceOptions_uninterpreted_option) }
-} /* namespace ServiceOptions */
-} /* namespace protobuf */
-} /* namespace google */
+class FieldOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ FieldOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_FieldOptions_is(m));
+ }
-namespace google {
-namespace protobuf {
-namespace SourceCodeInfo {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_SourceCodeInfo) }
-inline upb::reffed_ptr<const upb::FieldDef> location() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_location) }
-} /* namespace SourceCodeInfo */
-} /* namespace protobuf */
-} /* namespace google */
+ static FieldOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_FieldOptions_get(&m);
+ return FieldOptions(m, &m);
+ }
-namespace google {
-namespace protobuf {
-namespace SourceCodeInfo {
-namespace Location {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_SourceCodeInfo_Location) }
-inline upb::reffed_ptr<const upb::FieldDef> leading_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_comments) }
-inline upb::reffed_ptr<const upb::FieldDef> leading_detached_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_leading_detached_comments) }
-inline upb::reffed_ptr<const upb::FieldDef> path() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_path) }
-inline upb::reffed_ptr<const upb::FieldDef> span() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_span) }
-inline upb::reffed_ptr<const upb::FieldDef> trailing_comments() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_SourceCodeInfo_Location_trailing_comments) }
-} /* namespace Location */
-} /* namespace SourceCodeInfo */
-} /* namespace protobuf */
-} /* namespace google */
+ class CType : public upb::reffed_ptr<const upb::EnumDef> {
+ public:
+ CType(const upb::EnumDef* e, const void *ref_donor = NULL)
+ : reffed_ptr(e, ref_donor) {
+ assert(upbdefs_google_protobuf_FieldOptions_CType_is(e));
+ }
+ static CType get() {
+ const upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_CType_get(&e);
+ return CType(e, &e);
+ }
+ };
-namespace google {
-namespace protobuf {
-namespace UninterpretedOption {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_UninterpretedOption) }
-inline upb::reffed_ptr<const upb::FieldDef> aggregate_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_aggregate_value) }
-inline upb::reffed_ptr<const upb::FieldDef> double_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_double_value) }
-inline upb::reffed_ptr<const upb::FieldDef> identifier_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_identifier_value) }
-inline upb::reffed_ptr<const upb::FieldDef> name() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_name) }
-inline upb::reffed_ptr<const upb::FieldDef> negative_int_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_negative_int_value) }
-inline upb::reffed_ptr<const upb::FieldDef> positive_int_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_positive_int_value) }
-inline upb::reffed_ptr<const upb::FieldDef> string_value() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_string_value) }
-} /* namespace UninterpretedOption */
-} /* namespace protobuf */
-} /* namespace google */
+ class JSType : public upb::reffed_ptr<const upb::EnumDef> {
+ public:
+ JSType(const upb::EnumDef* e, const void *ref_donor = NULL)
+ : reffed_ptr(e, ref_donor) {
+ assert(upbdefs_google_protobuf_FieldOptions_JSType_is(e));
+ }
+ static JSType get() {
+ const upb::EnumDef* e = upbdefs_google_protobuf_FieldOptions_JSType_get(&e);
+ return JSType(e, &e);
+ }
+ };
+};
+
+class FileDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ FileDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_FileDescriptorProto_is(m));
+ }
+
+ static FileDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorProto_get(&m);
+ return FileDescriptorProto(m, &m);
+ }
+};
+
+class FileDescriptorSet : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ FileDescriptorSet(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_FileDescriptorSet_is(m));
+ }
+
+ static FileDescriptorSet get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_FileDescriptorSet_get(&m);
+ return FileDescriptorSet(m, &m);
+ }
+};
+
+class FileOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ FileOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_FileOptions_is(m));
+ }
+
+ static FileOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_FileOptions_get(&m);
+ return FileOptions(m, &m);
+ }
+
+ class OptimizeMode : public upb::reffed_ptr<const upb::EnumDef> {
+ public:
+ OptimizeMode(const upb::EnumDef* e, const void *ref_donor = NULL)
+ : reffed_ptr(e, ref_donor) {
+ assert(upbdefs_google_protobuf_FileOptions_OptimizeMode_is(e));
+ }
+ static OptimizeMode get() {
+ const upb::EnumDef* e = upbdefs_google_protobuf_FileOptions_OptimizeMode_get(&e);
+ return OptimizeMode(e, &e);
+ }
+ };
+};
+
+class MessageOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ MessageOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_MessageOptions_is(m));
+ }
+
+ static MessageOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_MessageOptions_get(&m);
+ return MessageOptions(m, &m);
+ }
+};
+
+class MethodDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ MethodDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_MethodDescriptorProto_is(m));
+ }
+
+ static MethodDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_MethodDescriptorProto_get(&m);
+ return MethodDescriptorProto(m, &m);
+ }
+};
+
+class MethodOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ MethodOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_MethodOptions_is(m));
+ }
+
+ static MethodOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_MethodOptions_get(&m);
+ return MethodOptions(m, &m);
+ }
+};
+
+class OneofDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ OneofDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_OneofDescriptorProto_is(m));
+ }
+
+ static OneofDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_OneofDescriptorProto_get(&m);
+ return OneofDescriptorProto(m, &m);
+ }
+};
+
+class ServiceDescriptorProto : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ ServiceDescriptorProto(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_ServiceDescriptorProto_is(m));
+ }
+
+ static ServiceDescriptorProto get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_ServiceDescriptorProto_get(&m);
+ return ServiceDescriptorProto(m, &m);
+ }
+};
+
+class ServiceOptions : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ ServiceOptions(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_ServiceOptions_is(m));
+ }
+
+ static ServiceOptions get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_ServiceOptions_get(&m);
+ return ServiceOptions(m, &m);
+ }
+};
+
+class SourceCodeInfo : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ SourceCodeInfo(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_SourceCodeInfo_is(m));
+ }
+
+ static SourceCodeInfo get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_get(&m);
+ return SourceCodeInfo(m, &m);
+ }
+
+ class Location : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ Location(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_SourceCodeInfo_Location_is(m));
+ }
+
+ static Location get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_SourceCodeInfo_Location_get(&m);
+ return Location(m, &m);
+ }
+ };
+};
+
+class UninterpretedOption : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ UninterpretedOption(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_UninterpretedOption_is(m));
+ }
+
+ static UninterpretedOption get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_get(&m);
+ return UninterpretedOption(m, &m);
+ }
+
+ class NamePart : public upb::reffed_ptr<const upb::MessageDef> {
+ public:
+ NamePart(const upb::MessageDef* m, const void *ref_donor = NULL)
+ : reffed_ptr(m, ref_donor) {
+ assert(upbdefs_google_protobuf_UninterpretedOption_NamePart_is(m));
+ }
+
+ static NamePart get() {
+ const upb::MessageDef* m = upbdefs_google_protobuf_UninterpretedOption_NamePart_get(&m);
+ return NamePart(m, &m);
+ }
+ };
+};
-namespace google {
-namespace protobuf {
-namespace UninterpretedOption {
-namespace NamePart {
-inline upb::reffed_ptr<const upb::MessageDef> MessageDef() { RETURN_REFFED(upb::MessageDef, upbdefs_google_protobuf_UninterpretedOption_NamePart) }
-inline upb::reffed_ptr<const upb::FieldDef> is_extension() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_is_extension) }
-inline upb::reffed_ptr<const upb::FieldDef> name_part() { RETURN_REFFED(upb::FieldDef, upbdefs_google_protobuf_UninterpretedOption_NamePart_name_part) }
-} /* namespace NamePart */
-} /* namespace UninterpretedOption */
} /* namespace protobuf */
} /* namespace google */
-
} /* namespace upbdefs */
+#endif /* __cplusplus */
-#undef RETURN_REFFED
-#endif /* __cplusplus */
-
-#endif /* GOOGLE_PROTOBUF_DESCRIPTOR_UPB_H_ */
+#endif /* UPB_DESCRIPTOR_DESCRIPTOR_PROTO_UPB_H_ */
/*
** Internal-only definitions for the decoder.
*/
@@ -8155,49 +8091,43 @@ inline reffed_ptr<const Handlers> Encoder::NewHandlers(
#include <stdbool.h>
#ifdef __cplusplus
+#include <vector>
+
extern "C" {
#endif
-/* Loads all defs from the given protobuf binary descriptor, setting default
- * accessors and a default layout on all messages. The caller owns the
- * returned array of defs, which will be of length *n. On error NULL is
- * returned and status is set (if non-NULL). */
-upb_def **upb_load_defs_from_descriptor(const char *str, size_t len, int *n,
- void *owner, upb_status *status);
-
-/* Like the previous but also adds the loaded defs to the given symtab. */
-bool upb_load_descriptor_into_symtab(upb_symtab *symtab, const char *str,
- size_t len, upb_status *status);
-
-/* Like the previous but also reads the descriptor from the given filename. */
-bool upb_load_descriptor_file_into_symtab(upb_symtab *symtab, const char *fname,
- upb_status *status);
-
-/* Reads the given filename into a character string, returning NULL if there
- * was an error. */
-char *upb_readfile(const char *filename, size_t *len);
+/* Loads a binary descriptor and returns a NULL-terminated array of unfrozen
+ * filedefs. The caller owns the returned array. */
+upb_filedef **upb_loaddescriptor(const char *buf, size_t n, const void *owner,
+ upb_status *status);
#ifdef __cplusplus
} /* extern "C" */
namespace upb {
-/* All routines that load descriptors expect the descriptor to be a
- * FileDescriptorSet. */
-inline bool LoadDescriptorFileIntoSymtab(SymbolTable* s, const char *fname,
- Status* status) {
- return upb_load_descriptor_file_into_symtab(s, fname, status);
-}
+inline bool LoadDescriptor(const char* buf, size_t n, Status* status,
+ std::vector<reffed_ptr<FileDef> >* files) {
+ FileDef** parsed_files = upb_loaddescriptor(buf, n, &parsed_files, status);
-inline bool LoadDescriptorIntoSymtab(SymbolTable* s, const char* str,
- size_t len, Status* status) {
- return upb_load_descriptor_into_symtab(s, str, len, status);
+ if (parsed_files) {
+ FileDef** p = parsed_files;
+ while (*p) {
+ files->push_back(reffed_ptr<FileDef>(*p, &parsed_files));
+ ++p;
+ }
+ free(parsed_files);
+ return true;
+ } else {
+ return false;
+ }
}
/* Templated so it can accept both string and std::string. */
template <typename T>
-bool LoadDescriptorIntoSymtab(SymbolTable* s, const T& desc, Status* status) {
- return upb_load_descriptor_into_symtab(s, desc.c_str(), desc.size(), status);
+bool LoadDescriptor(const T& desc, Status* status,
+ std::vector<reffed_ptr<FileDef> >* files) {
+ return LoadDescriptor(desc.c_str(), desc.size(), status, files);
}
} /* namespace upb */
@@ -8440,8 +8370,12 @@ class upb::json::Printer {
/* The input to the printer. */
Sink* input();
- /* Returns handlers for printing according to the specified schema. */
- static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md);
+ /* Returns handlers for printing according to the specified schema.
+ * If preserve_proto_fieldnames is true, the output JSON will use the
+ * original .proto field names (ie. {"my_field":3}) instead of using
+ * camelCased names, which is the default: (eg. {"myField":3}). */
+ static reffed_ptr<const Handlers> NewHandlers(const upb::MessageDef* md,
+ bool preserve_proto_fieldnames);
static const size_t kSize = UPB_JSON_PRINTER_SIZE;
@@ -8458,6 +8392,7 @@ upb_json_printer *upb_json_printer_create(upb_env *e, const upb_handlers *h,
upb_bytessink *output);
upb_sink *upb_json_printer_input(upb_json_printer *p);
const upb_handlers *upb_json_printer_newhandlers(const upb_msgdef *md,
+ bool preserve_fieldnames,
const void *owner);
UPB_END_EXTERN_C
@@ -8472,8 +8407,9 @@ inline Printer* Printer::Create(Environment* env, const upb::Handlers* handlers,
}
inline Sink* Printer::input() { return upb_json_printer_input(this); }
inline reffed_ptr<const Handlers> Printer::NewHandlers(
- const upb::MessageDef *md) {
- const Handlers* h = upb_json_printer_newhandlers(md, &h);
+ const upb::MessageDef *md, bool preserve_proto_fieldnames) {
+ const Handlers* h = upb_json_printer_newhandlers(
+ md, preserve_proto_fieldnames, &h);
return reffed_ptr<const Handlers>(h, &h);
}
} /* namespace json */
diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb
index 86c74c2a..77c186ef 100644
--- a/ruby/tests/basic.rb
+++ b/ruby/tests/basic.rb
@@ -1161,7 +1161,12 @@ module BasicTest
return if RUBY_PLATFORM == "java"
m = MapMessage.new(:map_string_int32 => {"a" => 1})
expected = '{"mapStringInt32":{"a":1},"mapStringMsg":{}}'
+ expected_preserve = '{"map_string_int32":{"a":1},"map_string_msg":{}}'
assert MapMessage.encode_json(m) == expected
+
+ json = MapMessage.encode_json(m, :preserve_proto_fieldnames => true)
+ assert json == expected_preserve
+
m2 = MapMessage.decode_json(MapMessage.encode_json(m))
assert m == m2
end
diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc
index 9616f172..bdfcc2be 100644
--- a/src/google/protobuf/compiler/csharp/csharp_enum.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc
@@ -41,6 +41,7 @@
#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>
#include <google/protobuf/compiler/csharp/csharp_enum.h>
#include <google/protobuf/compiler/csharp/csharp_helpers.h>
+#include <google/protobuf/compiler/csharp/csharp_options.h>
using google::protobuf::internal::scoped_ptr;
@@ -64,11 +65,24 @@ void EnumGenerator::Generate(io::Printer* printer) {
"access_level", class_access_level(),
"name", descriptor_->name());
printer->Indent();
+ std::set<string> used_names;
for (int i = 0; i < descriptor_->value_count(); i++) {
WriteEnumValueDocComment(printer, descriptor_->value(i));
- printer->Print("$name$ = $number$,\n",
- "name", descriptor_->value(i)->name(),
- "number", SimpleItoa(descriptor_->value(i)->number()));
+ string original_name = descriptor_->value(i)->name();
+ string name = options()->legacy_enum_values
+ ? descriptor_->value(i)->name()
+ : GetEnumValueName(descriptor_->name(), descriptor_->value(i)->name());
+ // Make sure we don't get any duplicate names due to prefix removal.
+ while (!used_names.insert(name).second) {
+ // It's possible we'll end up giving this warning multiple times, but that's better than not at all.
+ GOOGLE_LOG(WARNING) << "Duplicate enum value " << name << " (originally " << original_name
+ << ") in " << descriptor_->name() << "; adding underscore to distinguish";
+ name += "_";
+ }
+ printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n",
+ "original_name", original_name,
+ "name", name,
+ "number", SimpleItoa(descriptor_->value(i)->number()));
}
printer->Outdent();
printer->Print("}\n");
diff --git a/src/google/protobuf/compiler/csharp/csharp_field_base.cc b/src/google/protobuf/compiler/csharp/csharp_field_base.cc
index 3b88954c..e3c34040 100644
--- a/src/google/protobuf/compiler/csharp/csharp_field_base.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_field_base.cc
@@ -306,7 +306,9 @@ std::string FieldGeneratorBase::default_value() {
std::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) {
switch (descriptor->type()) {
case FieldDescriptor::TYPE_ENUM:
- return type_name() + "." + descriptor->default_value_enum()->name();
+ // All proto3 enums have a default value of 0, and there's an implicit conversion from the constant 0 to
+ // any C# enum. This means we don't need to work out what we actually mapped the enum value name to.
+ return "0";
case FieldDescriptor::TYPE_MESSAGE:
case FieldDescriptor::TYPE_GROUP:
if (IsWrapperType(descriptor)) {
diff --git a/src/google/protobuf/compiler/csharp/csharp_generator.cc b/src/google/protobuf/compiler/csharp/csharp_generator.cc
index c13ed65b..d74e8c88 100644
--- a/src/google/protobuf/compiler/csharp/csharp_generator.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_generator.cc
@@ -83,6 +83,9 @@ bool Generator::Generate(
cli_options.base_namespace_specified = true;
} else if (options[i].first == "internal_access") {
cli_options.internal_access = true;
+ } else if (options[i].first == "legacy_enum_values") {
+ // TODO: Remove this before final release
+ cli_options.legacy_enum_values = true;
} else {
*error = "Unknown generator option: " + options[i].first;
return false;
diff --git a/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc b/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
index 7ef7df42..5755fee0 100644
--- a/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
@@ -30,8 +30,8 @@
#include <memory>
-#include <google/protobuf/compiler/ruby/ruby_generator.h>
#include <google/protobuf/compiler/command_line_interface.h>
+#include <google/protobuf/compiler/csharp/csharp_helpers.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/printer.h>
@@ -45,7 +45,23 @@ namespace compiler {
namespace csharp {
namespace {
-// TODO(jtattermusch): add some tests.
+TEST(CSharpEnumValue, PascalCasedPrefixStripping) {
+ EXPECT_EQ("Bar", GetEnumValueName("Foo", "BAR"));
+ EXPECT_EQ("BarBaz", GetEnumValueName("Foo", "BAR_BAZ"));
+ EXPECT_EQ("Bar", GetEnumValueName("Foo", "FOO_BAR"));
+ EXPECT_EQ("Bar", GetEnumValueName("Foo", "FOO__BAR"));
+ EXPECT_EQ("BarBaz", GetEnumValueName("Foo", "FOO_BAR_BAZ"));
+ EXPECT_EQ("BarBaz", GetEnumValueName("Foo", "Foo_BarBaz"));
+ EXPECT_EQ("Bar", GetEnumValueName("FO_O", "FOO_BAR"));
+ EXPECT_EQ("Bar", GetEnumValueName("FOO", "F_O_O_BAR"));
+ EXPECT_EQ("Bar", GetEnumValueName("Foo", "BAR"));
+ EXPECT_EQ("BarBaz", GetEnumValueName("Foo", "BAR_BAZ"));
+ EXPECT_EQ("Foo", GetEnumValueName("Foo", "FOO"));
+ EXPECT_EQ("Foo", GetEnumValueName("Foo", "FOO___"));
+ // Identifiers can't start with digits
+ EXPECT_EQ("_2Bar", GetEnumValueName("Foo", "FOO_2_BAR"));
+ EXPECT_EQ("_2", GetEnumValueName("Foo", "FOO___2"));
+}
} // namespace
} // namespace csharp
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.cc b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
index 41265f9a..6c154c5a 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.cc
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.cc
@@ -178,6 +178,104 @@ std::string UnderscoresToPascalCase(const std::string& input) {
return UnderscoresToCamelCase(input, true);
}
+// Convert a string which is expected to be SHOUTY_CASE (but may not be *precisely* shouty)
+// into a PascalCase string. Precise rules implemented:
+
+// Previous input character Current character Case
+// Any Non-alphanumeric Skipped
+// None - first char of input Alphanumeric Upper
+// Non-letter (e.g. _ or 1) Alphanumeric Upper
+// Numeric Alphanumeric Upper
+// Lower letter Alphanumeric Same as current
+// Upper letter Alphanumeric Lower
+std::string ShoutyToPascalCase(const std::string& input) {
+ string result;
+ // Simple way of implementing "always start with upper"
+ char previous = '_';
+ for (int i = 0; i < input.size(); i++) {
+ char current = input[i];
+ if (!ascii_isalnum(current)) {
+ previous = current;
+ continue;
+ }
+ if (!ascii_isalnum(previous)) {
+ result += ascii_toupper(current);
+ } else if (ascii_isdigit(previous)) {
+ result += ascii_toupper(current);
+ } else if (ascii_islower(previous)) {
+ result += current;
+ } else {
+ result += ascii_tolower(current);
+ }
+ previous = current;
+ }
+ return result;
+}
+
+// Attempt to remove a prefix from a value, ignoring casing and skipping underscores.
+// (foo, foo_bar) => bar - underscore after prefix is skipped
+// (FOO, foo_bar) => bar - casing is ignored
+// (foo_bar, foobarbaz) => baz - underscore in prefix is ignored
+// (foobar, foo_barbaz) => baz - underscore in value is ignored
+// (foo, bar) => bar - prefix isn't matched; return original value
+std::string TryRemovePrefix(const std::string& prefix, const std::string& value) {
+ // First normalize to a lower-case no-underscores prefix to match against
+ std::string prefix_to_match = "";
+ for (size_t i = 0; i < prefix.size(); i++) {
+ if (prefix[i] != '_') {
+ prefix_to_match += ascii_tolower(prefix[i]);
+ }
+ }
+
+ // This keeps track of how much of value we've consumed
+ size_t prefix_index, value_index;
+ for (prefix_index = 0, value_index = 0;
+ prefix_index < prefix_to_match.size() && value_index < value.size();
+ value_index++) {
+ // Skip over underscores in the value
+ if (value[value_index] == '_') {
+ continue;
+ }
+ if (ascii_tolower(value[value_index]) != prefix_to_match[prefix_index++]) {
+ // Failed to match the prefix - bail out early.
+ return value;
+ }
+ }
+
+ // If we didn't finish looking through the prefix, we can't strip it.
+ if (prefix_index < prefix_to_match.size()) {
+ return value;
+ }
+
+ // Step over any underscores after the prefix
+ while (value_index < value.size() && value[value_index] == '_') {
+ value_index++;
+ }
+
+ // If there's nothing left (e.g. it was a prefix with only underscores afterwards), don't strip.
+ if (value_index == value.size()) {
+ return value;
+ }
+
+ return value.substr(value_index);
+}
+
+// Format the enum value name in a pleasant way for C#:
+// - Strip the enum name as a prefix if possible
+// - Convert to PascalCase.
+// For example, an enum called Color with a value of COLOR_BLUE should
+// result in an enum value in C# called just Blue
+std::string GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name) {
+ std::string stripped = TryRemovePrefix(enum_name, enum_value_name);
+ std::string result = ShoutyToPascalCase(stripped);
+ // Just in case we have an enum name of FOO and a value of FOO_2... make sure the returned
+ // string is a valid identifier.
+ if (ascii_isdigit(result[0])) {
+ result = "_" + result;
+ }
+ return result;
+}
+
std::string ToCSharpName(const std::string& name, const FileDescriptor* file) {
std::string result = GetFileNamespace(file);
if (result != "") {
diff --git a/src/google/protobuf/compiler/csharp/csharp_helpers.h b/src/google/protobuf/compiler/csharp/csharp_helpers.h
index eaf85014..1563ca7e 100644
--- a/src/google/protobuf/compiler/csharp/csharp_helpers.h
+++ b/src/google/protobuf/compiler/csharp/csharp_helpers.h
@@ -36,6 +36,7 @@
#define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__
#include <string>
+#include <google/protobuf/stubs/port.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/compiler/code_generator.h>
@@ -93,6 +94,10 @@ inline std::string UnderscoresToCamelCase(const std::string& input, bool cap_nex
std::string UnderscoresToPascalCase(const std::string& input);
+// Note that we wouldn't normally want to export this (we're not expecting
+// it to be used outside libprotoc itself) but this exposes it for testing.
+std::string LIBPROTOBUF_EXPORT GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name);
+
// TODO(jtattermusch): perhaps we could move this to strutil
std::string StringToBase64(const std::string& input);
diff --git a/src/google/protobuf/compiler/csharp/csharp_options.h b/src/google/protobuf/compiler/csharp/csharp_options.h
index 426fb3b5..4079bf7f 100644
--- a/src/google/protobuf/compiler/csharp/csharp_options.h
+++ b/src/google/protobuf/compiler/csharp/csharp_options.h
@@ -45,7 +45,8 @@ struct Options {
file_extension(".cs"),
base_namespace(""),
base_namespace_specified(false),
- internal_access(false) {
+ internal_access(false),
+ legacy_enum_values(false) {
}
// Extension of the generated file. Defaults to ".cs"
string file_extension;
@@ -68,6 +69,12 @@ struct Options {
// Whether the generated classes should have accessibility level of "internal".
// Defaults to false that generates "public" classes.
bool internal_access;
+ // By default, C# codegen now uses PascalCased enum values names, after
+ // removing the enum type name as a prefix (if it *is* a prefix of the value).
+ // Setting this option reverts to the previous behavior of just copying the
+ // value name specified in the .proto file, allowing gradual migration.
+ // This option will be removed before final release.
+ bool legacy_enum_values;
};
} // namespace csharp
diff --git a/src/google/protobuf/stubs/stringprintf.cc b/src/google/protobuf/stubs/stringprintf.cc
index 3272d8e3..83fdfe45 100644
--- a/src/google/protobuf/stubs/stringprintf.cc
+++ b/src/google/protobuf/stubs/stringprintf.cc
@@ -37,7 +37,6 @@
#include <stdio.h> // MSVC requires this for _vsnprintf
#include <vector>
#include <google/protobuf/stubs/common.h>
-#include <google/protobuf/testing/googletest.h>
namespace google {
namespace protobuf {
diff --git a/src/google/protobuf/util/field_mask_util_test.cc b/src/google/protobuf/util/field_mask_util_test.cc
index b3787857..9b7fb62a 100644
--- a/src/google/protobuf/util/field_mask_util_test.cc
+++ b/src/google/protobuf/util/field_mask_util_test.cc
@@ -30,6 +30,8 @@
#include <google/protobuf/util/field_mask_util.h>
+#include <algorithm>
+
#include <google/protobuf/stubs/logging.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/field_mask.pb.h>