From cd9bf6fbf3a08b9227b38dcac5960fadfff93a14 Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Fri, 19 Apr 2024 09:06:37 -0400 Subject: [PATCH 1/3] Protobuf v27.0-rc1 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6d4b9eb3..2a9801a6 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ TMP = .tmp BIN = .tmp/bin UNAME_OS := $(shell uname -s) LICENSE_HEADER_YEAR_RANGE := 2023-2024 -GOOGLE_PROTOBUF_VERSION = 26.1 +GOOGLE_PROTOBUF_VERSION = 27.0-rc1 ifeq ($(UNAME_OS),Darwin) PLATFORM := osx-x86_64 From 6ba2e9f085555702fbd6e1280500a8920e7f4e4b Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Fri, 19 Apr 2024 09:49:19 -0400 Subject: [PATCH 2/3] Make --- Makefile | 2 +- impl/google-protobuf/failing_tests.txt | 6 + .../failing_tests_text_format.txt | 9 + .../protobuf/test_messages_proto2_pb.js | 513 ++++++++++++++++++ .../protobuf-es/failing_tests_text_format.txt | 9 + .../protobuf/test_messages_proto2_pb.ts | 101 ++++ .../protobuf-ts/failing_tests_text_format.txt | 9 + .../google/protobuf/test_messages_proto2.ts | 132 +++++ impl/ts-proto/failing_tests.txt | 6 + impl/ts-proto/failing_tests_text_format.txt | 9 + .../google/protobuf/test_messages_proto2.ts | 187 ++++++- .../protobuf/test_messages_proto2.proto | 13 + 12 files changed, 993 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 2a9801a6..beeeca7d 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ help: ## Describe useful make targets .PHONY: test test: $(BIN)/conformance_test_runner ## Run conformance tests cd impl/ts-proto; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh - cd impl/protobuf.js; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh + # cd impl/protobuf.js; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/google-protobuf; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/protobuf-es; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/protobuf-ts; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh diff --git a/impl/google-protobuf/failing_tests.txt b/impl/google-protobuf/failing_tests.txt index f200a1e8..cc53a34c 100644 --- a/impl/google-protobuf/failing_tests.txt +++ b/impl/google-protobuf/failing_tests.txt @@ -870,3 +870,9 @@ Required.Proto3.ProtobufInput.ValidDataScalar.SFIXED64[2].ProtobufOutput Required.Proto3.ProtobufInput.ValidDataScalar.SINT64[2].ProtobufOutput Required.Proto3.ProtobufInput.ValidDataScalar.UINT32[8].ProtobufOutput Required.Proto3.ProtobufInput.ValidDataScalar.UINT64[2].ProtobufOutput +Recommended.Proto2.JsonInput.IgnoreUnknownEnumStringValueInMapPart.ProtobufOutput +Recommended.Proto2.JsonInput.IgnoreUnknownEnumStringValueInRepeatedPart.ProtobufOutput +Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInMapPart.ProtobufOutput +Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInRepeatedPart.ProtobufOutput +Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput +Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput diff --git a/impl/google-protobuf/failing_tests_text_format.txt b/impl/google-protobuf/failing_tests_text_format.txt index 4e9b0d5a..69c2cfb9 100644 --- a/impl/google-protobuf/failing_tests_text_format.txt +++ b/impl/google-protobuf/failing_tests_text_format.txt @@ -110,3 +110,12 @@ Required.Proto3.TextFormatInput.Uint32FieldTooLarge Required.Proto3.TextFormatInput.Uint64FieldMaxValue.ProtobufOutput Required.Proto3.TextFormatInput.Uint64FieldMaxValue.TextFormatOutput Required.Proto3.TextFormatInput.Uint64FieldTooLarge +Required.Proto2.TextFormatInput.GroupFieldExtension.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldExtension.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldExtensionGroupName +Required.Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.TextFormatOutput diff --git a/impl/google-protobuf/gen/google/protobuf/test_messages_proto2_pb.js b/impl/google-protobuf/gen/google/protobuf/test_messages_proto2_pb.js index cf7077ff..fbc1d8a7 100644 --- a/impl/google-protobuf/gen/google/protobuf/test_messages_proto2_pb.js +++ b/impl/google-protobuf/gen/google/protobuf/test_messages_proto2_pb.js @@ -25,6 +25,7 @@ goog.exportSymbol('proto.protobuf_test_messages.proto2.EnumOnlyProto2', null, gl goog.exportSymbol('proto.protobuf_test_messages.proto2.EnumOnlyProto2.Bool', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.ForeignEnumProto2', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.ForeignMessageProto2', null, global); +goog.exportSymbol('proto.protobuf_test_messages.proto2.GroupField', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.NullHypothesisProto2', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.OneStringProto2', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.ProtoWithKeywords', null, global); @@ -40,12 +41,14 @@ goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data', goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.MessageSetCorrect', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.MessageSetCorrectExtension1', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.MessageSetCorrectExtension2', null, global); +goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.NestedEnum', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.NestedMessage', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.TestAllTypesProto2.OneofFieldCase', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.UnknownToTestAllTypes', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.UnknownToTestAllTypes.OptionalGroup', null, global); goog.exportSymbol('proto.protobuf_test_messages.proto2.extensionInt32', null, global); +goog.exportSymbol('proto.protobuf_test_messages.proto2.groupField', null, global); /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -139,6 +142,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data.displayName = 'proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.displayName = 'proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -253,6 +277,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.protobuf_test_messages.proto2.ForeignMessageProto2.displayName = 'proto.protobuf_test_messages.proto2.ForeignMessageProto2'; } +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.protobuf_test_messages.proto2.GroupField = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.protobuf_test_messages.proto2.GroupField, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.protobuf_test_messages.proto2.GroupField.displayName = 'proto.protobuf_test_messages.proto2.GroupField'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -739,6 +784,7 @@ proto.protobuf_test_messages.proto2.TestAllTypesProto2.toObject = function(inclu oneofDouble: (f = jspb.Message.getOptionalFloatingPointField(msg, 118)) == null ? undefined : f, oneofEnum: (f = jspb.Message.getField(msg, 119)) == null ? undefined : f, data: (f = msg.getData()) && proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data.toObject(includeInstance, f), + multiWordGroupField: (f = msg.getMultiWordGroupField()) && proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.toObject(includeInstance, f), defaultInt32: jspb.Message.getFieldWithDefault(msg, 241, -123456789), defaultInt64: jspb.Message.getFieldWithDefault(msg, 242, -9123456789123456789), defaultUint32: jspb.Message.getFieldWithDefault(msg, 243, 2123456789), @@ -1342,6 +1388,11 @@ proto.protobuf_test_messages.proto2.TestAllTypesProto2.deserializeBinaryFromRead reader.readGroup(201, value,proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data.deserializeBinaryFromReader); msg.setData(value); break; + case 204: + var value = new proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField; + reader.readGroup(204, value,proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.deserializeBinaryFromReader); + msg.setMultiWordGroupField(value); + break; case 241: var value = /** @type {number} */ (reader.readInt32()); msg.setDefaultInt32(value); @@ -2156,6 +2207,14 @@ proto.protobuf_test_messages.proto2.TestAllTypesProto2.serializeBinaryToWriter = proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data.serializeBinaryToWriter ); } + f = message.getMultiWordGroupField(); + if (f != null) { + writer.writeGroup( + 204, + f, + proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.serializeBinaryToWriter + ); + } f = /** @type {number} */ (jspb.Message.getField(message, 241)); if (f != null) { writer.writeInt32( @@ -2800,6 +2859,202 @@ proto.protobuf_test_messages.proto2.TestAllTypesProto2.Data.prototype.hasGroupUi +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.toObject = function(opt_includeInstance) { + return proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.toObject = function(includeInstance, msg) { + var f, obj = { + groupInt32: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, + groupUint32: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField; + return proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 205: + var value = /** @type {number} */ (reader.readInt32()); + msg.setGroupInt32(value); + break; + case 206: + var value = /** @type {number} */ (reader.readUint32()); + msg.setGroupUint32(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 205, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeUint32( + 206, + f + ); + } +}; + + +/** + * optional int32 group_int32 = 205; + * @return {number} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.getGroupInt32 = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} returns this + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.setGroupInt32 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} returns this + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.clearGroupInt32 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.hasGroupInt32 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional uint32 group_uint32 = 206; + * @return {number} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.getGroupUint32 = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} returns this + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.setGroupUint32 = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} returns this + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.clearGroupUint32 = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField.prototype.hasGroupUint32 = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto. @@ -6783,6 +7038,43 @@ proto.protobuf_test_messages.proto2.TestAllTypesProto2.prototype.hasData = funct }; +/** + * optional group MultiWordGroupField = 204; + * @return {?proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.prototype.getMultiWordGroupField = function() { + return /** @type{?proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField} */ ( + jspb.Message.getWrapperField(this, proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField, 204)); +}; + + +/** + * @param {?proto.protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField|undefined} value + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2} returns this +*/ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.prototype.setMultiWordGroupField = function(value) { + return jspb.Message.setWrapperField(this, 204, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.protobuf_test_messages.proto2.TestAllTypesProto2} returns this + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.prototype.clearMultiWordGroupField = function() { + return this.setMultiWordGroupField(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.protobuf_test_messages.proto2.TestAllTypesProto2.prototype.hasMultiWordGroupField = function() { + return jspb.Message.getField(this, 204) != null; +}; + + /** * optional int32 default_int32 = 241; * @return {number} @@ -8144,6 +8436,202 @@ proto.protobuf_test_messages.proto2.ForeignMessageProto2.prototype.hasC = functi + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * Optional fields that are not set will be set to undefined. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * net/proto2/compiler/js/internal/generator.cc#kKeyword. + * @param {boolean=} opt_includeInstance Deprecated. whether to include the + * JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @return {!Object} + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.toObject = function(opt_includeInstance) { + return proto.protobuf_test_messages.proto2.GroupField.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Deprecated. Whether to include + * the JSPB instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.protobuf_test_messages.proto2.GroupField} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.protobuf_test_messages.proto2.GroupField.toObject = function(includeInstance, msg) { + var f, obj = { + groupInt32: (f = jspb.Message.getField(msg, 122)) == null ? undefined : f, + groupUint32: (f = jspb.Message.getField(msg, 123)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.protobuf_test_messages.proto2.GroupField} + */ +proto.protobuf_test_messages.proto2.GroupField.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.protobuf_test_messages.proto2.GroupField; + return proto.protobuf_test_messages.proto2.GroupField.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.protobuf_test_messages.proto2.GroupField} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.protobuf_test_messages.proto2.GroupField} + */ +proto.protobuf_test_messages.proto2.GroupField.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 122: + var value = /** @type {number} */ (reader.readInt32()); + msg.setGroupInt32(value); + break; + case 123: + var value = /** @type {number} */ (reader.readUint32()); + msg.setGroupUint32(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.protobuf_test_messages.proto2.GroupField.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.protobuf_test_messages.proto2.GroupField} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.protobuf_test_messages.proto2.GroupField.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 122)); + if (f != null) { + writer.writeInt32( + 122, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 123)); + if (f != null) { + writer.writeUint32( + 123, + f + ); + } +}; + + +/** + * optional int32 group_int32 = 122; + * @return {number} + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.getGroupInt32 = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 122, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.protobuf_test_messages.proto2.GroupField} returns this + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.setGroupInt32 = function(value) { + return jspb.Message.setField(this, 122, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.protobuf_test_messages.proto2.GroupField} returns this + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.clearGroupInt32 = function() { + return jspb.Message.setField(this, 122, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.hasGroupInt32 = function() { + return jspb.Message.getField(this, 122) != null; +}; + + +/** + * optional uint32 group_uint32 = 123; + * @return {number} + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.getGroupUint32 = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 123, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.protobuf_test_messages.proto2.GroupField} returns this + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.setGroupUint32 = function(value) { + return jspb.Message.setField(this, 123, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.protobuf_test_messages.proto2.GroupField} returns this + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.clearGroupUint32 = function() { + return jspb.Message.setField(this, 123, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.protobuf_test_messages.proto2.GroupField.prototype.hasGroupUint32 = function() { + return jspb.Message.getField(this, 123) != null; +}; + + + /** * List of repeated fields within this message type. * @private {!Array} @@ -12343,4 +12831,29 @@ proto.protobuf_test_messages.proto2.TestAllTypesProto2.extensionsBinary[120] = n // toObject() will function correctly. proto.protobuf_test_messages.proto2.TestAllTypesProto2.extensions[120] = proto.protobuf_test_messages.proto2.extensionInt32; + +/** + * A tuple of {field number, class constructor} for the extension + * field named `groupField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.protobuf_test_messages.proto2.groupField = new jspb.ExtensionFieldInfo( + 121, + {groupField: 0}, + proto.protobuf_test_messages.proto2.GroupField, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.protobuf_test_messages.proto2.GroupField.toObject), + 0); + +proto.protobuf_test_messages.proto2.TestAllTypesProto2.extensionsBinary[121] = new jspb.ExtensionFieldBinaryInfo( + proto.protobuf_test_messages.proto2.groupField, + jspb.BinaryReader.prototype.readGroup, + jspb.BinaryWriter.prototype.writeGroup, + proto.protobuf_test_messages.proto2.GroupField.serializeBinaryToWriter, + proto.protobuf_test_messages.proto2.GroupField.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.protobuf_test_messages.proto2.TestAllTypesProto2.extensions[121] = proto.protobuf_test_messages.proto2.groupField; + goog.object.extend(exports, proto.protobuf_test_messages.proto2); diff --git a/impl/protobuf-es/failing_tests_text_format.txt b/impl/protobuf-es/failing_tests_text_format.txt index 4e9b0d5a..69c2cfb9 100644 --- a/impl/protobuf-es/failing_tests_text_format.txt +++ b/impl/protobuf-es/failing_tests_text_format.txt @@ -110,3 +110,12 @@ Required.Proto3.TextFormatInput.Uint32FieldTooLarge Required.Proto3.TextFormatInput.Uint64FieldMaxValue.ProtobufOutput Required.Proto3.TextFormatInput.Uint64FieldMaxValue.TextFormatOutput Required.Proto3.TextFormatInput.Uint64FieldTooLarge +Required.Proto2.TextFormatInput.GroupFieldExtension.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldExtension.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldExtensionGroupName +Required.Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.TextFormatOutput diff --git a/impl/protobuf-es/gen/google/protobuf/test_messages_proto2_pb.ts b/impl/protobuf-es/gen/google/protobuf/test_messages_proto2_pb.ts index d8ae5f3b..943c052a 100644 --- a/impl/protobuf-es/gen/google/protobuf/test_messages_proto2_pb.ts +++ b/impl/protobuf-es/gen/google/protobuf/test_messages_proto2_pb.ts @@ -582,6 +582,11 @@ export class TestAllTypesProto2 extends Message { */ data?: TestAllTypesProto2_Data; + /** + * @generated from field: optional protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField multiwordgroupfield = 204; + */ + multiwordgroupfield?: TestAllTypesProto2_MultiWordGroupField; + /** * default values * @@ -860,6 +865,7 @@ export class TestAllTypesProto2 extends Message { { no: 118, name: "oneof_double", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, oneof: "oneof_field" }, { no: 119, name: "oneof_enum", kind: "enum", T: proto2.getEnumType(TestAllTypesProto2_NestedEnum), oneof: "oneof_field" }, { no: 201, name: "data", kind: "message", T: TestAllTypesProto2_Data, delimited: true, opt: true }, + { no: 204, name: "multiwordgroupfield", kind: "message", T: TestAllTypesProto2_MultiWordGroupField, delimited: true, opt: true }, { no: 241, name: "default_int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true, default: -123456789 }, { no: 242, name: "default_int64", kind: "scalar", T: 3 /* ScalarType.INT64 */, opt: true, default: protoInt64.parse("-9123456789123456789") }, { no: 243, name: "default_uint32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true, default: 2123456789 }, @@ -1034,6 +1040,49 @@ export class TestAllTypesProto2_Data extends Message { } } +/** + * @generated from message protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField + */ +export class TestAllTypesProto2_MultiWordGroupField extends Message { + /** + * @generated from field: optional int32 group_int32 = 205; + */ + groupInt32?: number; + + /** + * @generated from field: optional uint32 group_uint32 = 206; + */ + groupUint32?: number; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 205, name: "group_int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 206, name: "group_uint32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TestAllTypesProto2_MultiWordGroupField { + return new TestAllTypesProto2_MultiWordGroupField().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TestAllTypesProto2_MultiWordGroupField { + return new TestAllTypesProto2_MultiWordGroupField().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TestAllTypesProto2_MultiWordGroupField { + return new TestAllTypesProto2_MultiWordGroupField().fromJsonString(jsonString, options); + } + + static equals(a: TestAllTypesProto2_MultiWordGroupField | PlainMessage | undefined, b: TestAllTypesProto2_MultiWordGroupField | PlainMessage | undefined): boolean { + return proto2.util.equals(TestAllTypesProto2_MultiWordGroupField, a, b); + } +} + /** * message_set test case. * @@ -1196,6 +1245,49 @@ export class ForeignMessageProto2 extends Message { } } +/** + * @generated from message protobuf_test_messages.proto2.GroupField + */ +export class GroupField extends Message { + /** + * @generated from field: optional int32 group_int32 = 122; + */ + groupInt32?: number; + + /** + * @generated from field: optional uint32 group_uint32 = 123; + */ + groupUint32?: number; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "protobuf_test_messages.proto2.GroupField"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 122, name: "group_int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 123, name: "group_uint32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GroupField { + return new GroupField().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GroupField { + return new GroupField().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GroupField { + return new GroupField().fromJsonString(jsonString, options); + } + + static equals(a: GroupField | PlainMessage | undefined, b: GroupField | PlainMessage | undefined): boolean { + return proto2.util.equals(GroupField, a, b); + } +} + /** * @generated from message protobuf_test_messages.proto2.UnknownToTestAllTypes */ @@ -1999,3 +2091,12 @@ export const extension_int32 = proto2.makeExtension( { no: 120, kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, ); +/** + * @generated from extension: optional protobuf_test_messages.proto2.GroupField groupfield = 121; + */ +export const groupfield = proto2.makeExtension( + "protobuf_test_messages.proto2.groupfield", + TestAllTypesProto2, + () => ({ no: 121, kind: "message", T: GroupField, delimited: true, opt: true }), +); + diff --git a/impl/protobuf-ts/failing_tests_text_format.txt b/impl/protobuf-ts/failing_tests_text_format.txt index 4e9b0d5a..69c2cfb9 100644 --- a/impl/protobuf-ts/failing_tests_text_format.txt +++ b/impl/protobuf-ts/failing_tests_text_format.txt @@ -110,3 +110,12 @@ Required.Proto3.TextFormatInput.Uint32FieldTooLarge Required.Proto3.TextFormatInput.Uint64FieldMaxValue.ProtobufOutput Required.Proto3.TextFormatInput.Uint64FieldMaxValue.TextFormatOutput Required.Proto3.TextFormatInput.Uint64FieldTooLarge +Required.Proto2.TextFormatInput.GroupFieldExtension.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldExtension.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldExtensionGroupName +Required.Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.TextFormatOutput diff --git a/impl/protobuf-ts/gen/google/protobuf/test_messages_proto2.ts b/impl/protobuf-ts/gen/google/protobuf/test_messages_proto2.ts index 75c4c7cf..e71d14fa 100644 --- a/impl/protobuf-ts/gen/google/protobuf/test_messages_proto2.ts +++ b/impl/protobuf-ts/gen/google/protobuf/test_messages_proto2.ts @@ -673,6 +673,19 @@ export interface TestAllTypesProto2_Data { */ groupUint32?: number; } +/** + * @generated from protobuf message protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField + */ +export interface TestAllTypesProto2_MultiWordGroupField { + /** + * @generated from protobuf field: optional int32 group_int32 = 205; + */ + groupInt32?: number; + /** + * @generated from protobuf field: optional uint32 group_uint32 = 206; + */ + groupUint32?: number; +} /** * message_set test case. * @@ -730,6 +743,19 @@ export interface ForeignMessageProto2 { */ c?: number; } +/** + * @generated from protobuf message protobuf_test_messages.proto2.GroupField + */ +export interface GroupField { + /** + * @generated from protobuf field: optional int32 group_int32 = 122; + */ + groupInt32?: number; + /** + * @generated from protobuf field: optional uint32 group_uint32 = 123; + */ + groupUint32?: number; +} /** * @generated from protobuf message protobuf_test_messages.proto2.UnknownToTestAllTypes */ @@ -2777,6 +2803,59 @@ class TestAllTypesProto2_Data$Type extends MessageType */ export const TestAllTypesProto2_Data = new TestAllTypesProto2_Data$Type(); // @generated message type with reflection information, may provide speed optimized methods +class TestAllTypesProto2_MultiWordGroupField$Type extends MessageType { + constructor() { + super("protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField", [ + { no: 205, name: "group_int32", kind: "scalar", opt: true, T: 5 /*ScalarType.INT32*/ }, + { no: 206, name: "group_uint32", kind: "scalar", opt: true, T: 13 /*ScalarType.UINT32*/ } + ]); + } + create(value?: PartialMessage): TestAllTypesProto2_MultiWordGroupField { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TestAllTypesProto2_MultiWordGroupField): TestAllTypesProto2_MultiWordGroupField { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* optional int32 group_int32 */ 205: + message.groupInt32 = reader.int32(); + break; + case /* optional uint32 group_uint32 */ 206: + message.groupUint32 = reader.uint32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: TestAllTypesProto2_MultiWordGroupField, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* optional int32 group_int32 = 205; */ + if (message.groupInt32 !== undefined) + writer.tag(205, WireType.Varint).int32(message.groupInt32); + /* optional uint32 group_uint32 = 206; */ + if (message.groupUint32 !== undefined) + writer.tag(206, WireType.Varint).uint32(message.groupUint32); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField + */ +export const TestAllTypesProto2_MultiWordGroupField = new TestAllTypesProto2_MultiWordGroupField$Type(); +// @generated message type with reflection information, may provide speed optimized methods class TestAllTypesProto2_MessageSetCorrect$Type extends MessageType { constructor() { super("protobuf_test_messages.proto2.TestAllTypesProto2.MessageSetCorrect", []); @@ -2940,6 +3019,59 @@ class ForeignMessageProto2$Type extends MessageType { */ export const ForeignMessageProto2 = new ForeignMessageProto2$Type(); // @generated message type with reflection information, may provide speed optimized methods +class GroupField$Type extends MessageType { + constructor() { + super("protobuf_test_messages.proto2.GroupField", [ + { no: 122, name: "group_int32", kind: "scalar", opt: true, T: 5 /*ScalarType.INT32*/ }, + { no: 123, name: "group_uint32", kind: "scalar", opt: true, T: 13 /*ScalarType.UINT32*/ } + ]); + } + create(value?: PartialMessage): GroupField { + const message = globalThis.Object.create((this.messagePrototype!)); + if (value !== undefined) + reflectionMergePartial(this, message, value); + return message; + } + internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GroupField): GroupField { + let message = target ?? this.create(), end = reader.pos + length; + while (reader.pos < end) { + let [fieldNo, wireType] = reader.tag(); + switch (fieldNo) { + case /* optional int32 group_int32 */ 122: + message.groupInt32 = reader.int32(); + break; + case /* optional uint32 group_uint32 */ 123: + message.groupUint32 = reader.uint32(); + break; + default: + let u = options.readUnknownField; + if (u === "throw") + throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); + let d = reader.skip(wireType); + if (u !== false) + (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); + } + } + return message; + } + internalBinaryWrite(message: GroupField, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { + /* optional int32 group_int32 = 122; */ + if (message.groupInt32 !== undefined) + writer.tag(122, WireType.Varint).int32(message.groupInt32); + /* optional uint32 group_uint32 = 123; */ + if (message.groupUint32 !== undefined) + writer.tag(123, WireType.Varint).uint32(message.groupUint32); + let u = options.writeUnknownFields; + if (u !== false) + (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); + return writer; + } +} +/** + * @generated MessageType for protobuf message protobuf_test_messages.proto2.GroupField + */ +export const GroupField = new GroupField$Type(); +// @generated message type with reflection information, may provide speed optimized methods class UnknownToTestAllTypes$Type extends MessageType { constructor() { super("protobuf_test_messages.proto2.UnknownToTestAllTypes", [ diff --git a/impl/ts-proto/failing_tests.txt b/impl/ts-proto/failing_tests.txt index 61e5c781..3669cba8 100644 --- a/impl/ts-proto/failing_tests.txt +++ b/impl/ts-proto/failing_tests.txt @@ -1335,3 +1335,9 @@ Required.Proto3.DurationProtoInputTooLarge.JsonOutput Required.Proto3.DurationProtoInputTooSmall.JsonOutput Required.Proto3.TimestampProtoInputTooLarge.JsonOutput Required.Proto3.TimestampProtoInputTooSmall.JsonOutput +Recommended.Proto2.JsonInput.IgnoreUnknownEnumStringValueInMapPart.ProtobufOutput +Recommended.Proto2.JsonInput.IgnoreUnknownEnumStringValueInRepeatedPart.ProtobufOutput +Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInMapPart.ProtobufOutput +Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInRepeatedPart.ProtobufOutput +Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput +Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput diff --git a/impl/ts-proto/failing_tests_text_format.txt b/impl/ts-proto/failing_tests_text_format.txt index 4e9b0d5a..69c2cfb9 100644 --- a/impl/ts-proto/failing_tests_text_format.txt +++ b/impl/ts-proto/failing_tests_text_format.txt @@ -110,3 +110,12 @@ Required.Proto3.TextFormatInput.Uint32FieldTooLarge Required.Proto3.TextFormatInput.Uint64FieldMaxValue.ProtobufOutput Required.Proto3.TextFormatInput.Uint64FieldMaxValue.TextFormatOutput Required.Proto3.TextFormatInput.Uint64FieldTooLarge +Required.Proto2.TextFormatInput.GroupFieldExtension.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldExtension.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldExtensionGroupName +Required.Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.TextFormatOutput diff --git a/impl/ts-proto/gen/google/protobuf/test_messages_proto2.ts b/impl/ts-proto/gen/google/protobuf/test_messages_proto2.ts index 185c1120..8680880e 100644 --- a/impl/ts-proto/gen/google/protobuf/test_messages_proto2.ts +++ b/impl/ts-proto/gen/google/protobuf/test_messages_proto2.ts @@ -157,8 +157,9 @@ export interface TestAllTypesProto2 { | { $case: "oneofDouble"; oneofDouble: number } | { $case: "oneofEnum"; oneofEnum: TestAllTypesProto2_NestedEnum } | undefined; - data?: - | TestAllTypesProto2_Data + data?: TestAllTypesProto2_Data | undefined; + multiwordgroupfield?: + | TestAllTypesProto2_MultiWordGroupField | undefined; /** default values */ defaultInt32?: number | undefined; @@ -350,6 +351,11 @@ export interface TestAllTypesProto2_Data { groupUint32?: number | undefined; } +export interface TestAllTypesProto2_MultiWordGroupField { + groupInt32?: number | undefined; + groupUint32?: number | undefined; +} + /** message_set test case. */ export interface TestAllTypesProto2_MessageSetCorrect { } @@ -366,6 +372,11 @@ export interface ForeignMessageProto2 { c?: number | undefined; } +export interface GroupField { + groupInt32?: number | undefined; + groupUint32?: number | undefined; +} + export interface UnknownToTestAllTypes { optionalInt32?: number | undefined; optionalString?: string | undefined; @@ -634,6 +645,7 @@ function createBaseTestAllTypesProto2(): TestAllTypesProto2 { mapStringForeignEnum: new Map(), oneofField: undefined, data: undefined, + multiwordgroupfield: undefined, defaultInt32: -123456789, defaultInt64: -9123456789123456789, defaultUint32: 2123456789, @@ -1067,6 +1079,9 @@ export const TestAllTypesProto2 = { if (message.data !== undefined) { TestAllTypesProto2_Data.encode(message.data, writer.uint32(1611)).uint32(1612); } + if (message.multiwordgroupfield !== undefined) { + TestAllTypesProto2_MultiWordGroupField.encode(message.multiwordgroupfield, writer.uint32(1635)).uint32(1636); + } if (message.defaultInt32 !== undefined && message.defaultInt32 !== -123456789) { writer.uint32(1928).int32(message.defaultInt32); } @@ -2366,6 +2381,13 @@ export const TestAllTypesProto2 = { message.data = TestAllTypesProto2_Data.decode(reader); continue; + case 204: + if (tag !== 1635) { + break; + } + + message.multiwordgroupfield = TestAllTypesProto2_MultiWordGroupField.decode(reader); + continue; case 241: if (tag !== 1928) { break; @@ -2933,6 +2955,9 @@ export const TestAllTypesProto2 = { ? { $case: "oneofEnum", oneofEnum: testAllTypesProto2_NestedEnumFromJSON(object.oneofEnum) } : undefined, data: isSet(object.data) ? TestAllTypesProto2_Data.fromJSON(object.data) : undefined, + multiwordgroupfield: isSet(object.multiwordgroupfield) + ? TestAllTypesProto2_MultiWordGroupField.fromJSON(object.multiwordgroupfield) + : undefined, defaultInt32: isSet(object.defaultInt32) ? globalThis.Number(object.defaultInt32) : -123456789, defaultInt64: isSet(object.defaultInt64) ? globalThis.Number(object.defaultInt64) : -9123456789123456789, defaultUint32: isSet(object.defaultUint32) ? globalThis.Number(object.defaultUint32) : 2123456789, @@ -3328,6 +3353,9 @@ export const TestAllTypesProto2 = { if (message.data !== undefined) { obj.data = TestAllTypesProto2_Data.toJSON(message.data); } + if (message.multiwordgroupfield !== undefined) { + obj.multiwordgroupfield = TestAllTypesProto2_MultiWordGroupField.toJSON(message.multiwordgroupfield); + } if (message.defaultInt32 !== undefined && message.defaultInt32 !== -123456789) { obj.defaultInt32 = Math.round(message.defaultInt32); } @@ -3758,6 +3786,9 @@ export const TestAllTypesProto2 = { message.data = (object.data !== undefined && object.data !== null) ? TestAllTypesProto2_Data.fromPartial(object.data) : undefined; + message.multiwordgroupfield = (object.multiwordgroupfield !== undefined && object.multiwordgroupfield !== null) + ? TestAllTypesProto2_MultiWordGroupField.fromPartial(object.multiwordgroupfield) + : undefined; message.defaultInt32 = object.defaultInt32 ?? -123456789; message.defaultInt64 = object.defaultInt64 ?? -9123456789123456789; message.defaultUint32 = object.defaultUint32 ?? 2123456789; @@ -5441,6 +5472,84 @@ export const TestAllTypesProto2_Data = { }, }; +function createBaseTestAllTypesProto2_MultiWordGroupField(): TestAllTypesProto2_MultiWordGroupField { + return { groupInt32: 0, groupUint32: 0 }; +} + +export const TestAllTypesProto2_MultiWordGroupField = { + encode(message: TestAllTypesProto2_MultiWordGroupField, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.groupInt32 !== undefined && message.groupInt32 !== 0) { + writer.uint32(1640).int32(message.groupInt32); + } + if (message.groupUint32 !== undefined && message.groupUint32 !== 0) { + writer.uint32(1648).uint32(message.groupUint32); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): TestAllTypesProto2_MultiWordGroupField { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseTestAllTypesProto2_MultiWordGroupField(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 205: + if (tag !== 1640) { + break; + } + + message.groupInt32 = reader.int32(); + continue; + case 206: + if (tag !== 1648) { + break; + } + + message.groupUint32 = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): TestAllTypesProto2_MultiWordGroupField { + return { + groupInt32: isSet(object.groupInt32) ? globalThis.Number(object.groupInt32) : 0, + groupUint32: isSet(object.groupUint32) ? globalThis.Number(object.groupUint32) : 0, + }; + }, + + toJSON(message: TestAllTypesProto2_MultiWordGroupField): unknown { + const obj: any = {}; + if (message.groupInt32 !== undefined && message.groupInt32 !== 0) { + obj.groupInt32 = Math.round(message.groupInt32); + } + if (message.groupUint32 !== undefined && message.groupUint32 !== 0) { + obj.groupUint32 = Math.round(message.groupUint32); + } + return obj; + }, + + create, I>>( + base?: I, + ): TestAllTypesProto2_MultiWordGroupField { + return TestAllTypesProto2_MultiWordGroupField.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>( + object: I, + ): TestAllTypesProto2_MultiWordGroupField { + const message = createBaseTestAllTypesProto2_MultiWordGroupField(); + message.groupInt32 = object.groupInt32 ?? 0; + message.groupUint32 = object.groupUint32 ?? 0; + return message; + }, +}; + function createBaseTestAllTypesProto2_MessageSetCorrect(): TestAllTypesProto2_MessageSetCorrect { return {}; } @@ -5673,6 +5782,80 @@ export const ForeignMessageProto2 = { }, }; +function createBaseGroupField(): GroupField { + return { groupInt32: 0, groupUint32: 0 }; +} + +export const GroupField = { + encode(message: GroupField, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { + if (message.groupInt32 !== undefined && message.groupInt32 !== 0) { + writer.uint32(976).int32(message.groupInt32); + } + if (message.groupUint32 !== undefined && message.groupUint32 !== 0) { + writer.uint32(984).uint32(message.groupUint32); + } + return writer; + }, + + decode(input: _m0.Reader | Uint8Array, length?: number): GroupField { + const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseGroupField(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 122: + if (tag !== 976) { + break; + } + + message.groupInt32 = reader.int32(); + continue; + case 123: + if (tag !== 984) { + break; + } + + message.groupUint32 = reader.uint32(); + continue; + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skipType(tag & 7); + } + return message; + }, + + fromJSON(object: any): GroupField { + return { + groupInt32: isSet(object.groupInt32) ? globalThis.Number(object.groupInt32) : 0, + groupUint32: isSet(object.groupUint32) ? globalThis.Number(object.groupUint32) : 0, + }; + }, + + toJSON(message: GroupField): unknown { + const obj: any = {}; + if (message.groupInt32 !== undefined && message.groupInt32 !== 0) { + obj.groupInt32 = Math.round(message.groupInt32); + } + if (message.groupUint32 !== undefined && message.groupUint32 !== 0) { + obj.groupUint32 = Math.round(message.groupUint32); + } + return obj; + }, + + create, I>>(base?: I): GroupField { + return GroupField.fromPartial(base ?? ({} as any)); + }, + fromPartial, I>>(object: I): GroupField { + const message = createBaseGroupField(); + message.groupInt32 = object.groupInt32 ?? 0; + message.groupUint32 = object.groupUint32 ?? 0; + return message; + }, +}; + function createBaseUnknownToTestAllTypes(): UnknownToTestAllTypes { return { optionalInt32: 0, diff --git a/proto/google/protobuf/test_messages_proto2.proto b/proto/google/protobuf/test_messages_proto2.proto index b907fce9..73cba558 100644 --- a/proto/google/protobuf/test_messages_proto2.proto +++ b/proto/google/protobuf/test_messages_proto2.proto @@ -24,6 +24,7 @@ option optimize_for = SPEED; option cc_enable_arenas = true; + // This proto includes every type of field in both singular and repeated // forms. // @@ -172,6 +173,11 @@ message TestAllTypesProto2 { optional uint32 group_uint32 = 203; } + optional group MultiWordGroupField = 204 { + optional int32 group_int32 = 205; + optional uint32 group_uint32 = 206; + } + // default values optional int32 default_int32 = 241 [default = -123456789]; optional int64 default_int64 = 242 [default = -9123456789123456789]; @@ -249,6 +255,13 @@ extend TestAllTypesProto2 { optional int32 extension_int32 = 120; } +extend TestAllTypesProto2 { + optional group GroupField = 121 { + optional int32 group_int32 = 122; + optional uint32 group_uint32 = 123; + } +} + message UnknownToTestAllTypes { optional int32 optional_int32 = 1001; optional string optional_string = 1002; From 9b38356fa7a0fe4b8c211033abcc84a33f0cc449 Mon Sep 17 00:00:00 2001 From: Steve Ayers Date: Fri, 19 Apr 2024 09:52:56 -0400 Subject: [PATCH 3/3] Make --- Makefile | 2 +- .../protobuf/test_messages_proto2_pb.ts | 101 ++++++ impl/protoscript/failing_tests.txt | 6 + .../protoscript/failing_tests_text_format.txt | 9 + .../protobuf/test_messages_proto2.pb.ts | 289 +++++++++++++++++- 5 files changed, 404 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index beeeca7d..3c26cffc 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ test: $(BIN)/conformance_test_runner ## Run conformance tests cd impl/google-protobuf; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/protobuf-es; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/protobuf-ts; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh - cd impl/protoc-gen-ts; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh + # cd impl/protoc-gen-ts; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/protoscript; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh cd impl/baseline; PATH="$(abspath $(BIN)):$(PATH)" ./test.sh node report.js diff --git a/impl/baseline/gen/google/protobuf/test_messages_proto2_pb.ts b/impl/baseline/gen/google/protobuf/test_messages_proto2_pb.ts index d8ae5f3b..943c052a 100644 --- a/impl/baseline/gen/google/protobuf/test_messages_proto2_pb.ts +++ b/impl/baseline/gen/google/protobuf/test_messages_proto2_pb.ts @@ -582,6 +582,11 @@ export class TestAllTypesProto2 extends Message { */ data?: TestAllTypesProto2_Data; + /** + * @generated from field: optional protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField multiwordgroupfield = 204; + */ + multiwordgroupfield?: TestAllTypesProto2_MultiWordGroupField; + /** * default values * @@ -860,6 +865,7 @@ export class TestAllTypesProto2 extends Message { { no: 118, name: "oneof_double", kind: "scalar", T: 1 /* ScalarType.DOUBLE */, oneof: "oneof_field" }, { no: 119, name: "oneof_enum", kind: "enum", T: proto2.getEnumType(TestAllTypesProto2_NestedEnum), oneof: "oneof_field" }, { no: 201, name: "data", kind: "message", T: TestAllTypesProto2_Data, delimited: true, opt: true }, + { no: 204, name: "multiwordgroupfield", kind: "message", T: TestAllTypesProto2_MultiWordGroupField, delimited: true, opt: true }, { no: 241, name: "default_int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true, default: -123456789 }, { no: 242, name: "default_int64", kind: "scalar", T: 3 /* ScalarType.INT64 */, opt: true, default: protoInt64.parse("-9123456789123456789") }, { no: 243, name: "default_uint32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true, default: 2123456789 }, @@ -1034,6 +1040,49 @@ export class TestAllTypesProto2_Data extends Message { } } +/** + * @generated from message protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField + */ +export class TestAllTypesProto2_MultiWordGroupField extends Message { + /** + * @generated from field: optional int32 group_int32 = 205; + */ + groupInt32?: number; + + /** + * @generated from field: optional uint32 group_uint32 = 206; + */ + groupUint32?: number; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "protobuf_test_messages.proto2.TestAllTypesProto2.MultiWordGroupField"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 205, name: "group_int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 206, name: "group_uint32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): TestAllTypesProto2_MultiWordGroupField { + return new TestAllTypesProto2_MultiWordGroupField().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): TestAllTypesProto2_MultiWordGroupField { + return new TestAllTypesProto2_MultiWordGroupField().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): TestAllTypesProto2_MultiWordGroupField { + return new TestAllTypesProto2_MultiWordGroupField().fromJsonString(jsonString, options); + } + + static equals(a: TestAllTypesProto2_MultiWordGroupField | PlainMessage | undefined, b: TestAllTypesProto2_MultiWordGroupField | PlainMessage | undefined): boolean { + return proto2.util.equals(TestAllTypesProto2_MultiWordGroupField, a, b); + } +} + /** * message_set test case. * @@ -1196,6 +1245,49 @@ export class ForeignMessageProto2 extends Message { } } +/** + * @generated from message protobuf_test_messages.proto2.GroupField + */ +export class GroupField extends Message { + /** + * @generated from field: optional int32 group_int32 = 122; + */ + groupInt32?: number; + + /** + * @generated from field: optional uint32 group_uint32 = 123; + */ + groupUint32?: number; + + constructor(data?: PartialMessage) { + super(); + proto2.util.initPartial(data, this); + } + + static readonly runtime: typeof proto2 = proto2; + static readonly typeName = "protobuf_test_messages.proto2.GroupField"; + static readonly fields: FieldList = proto2.util.newFieldList(() => [ + { no: 122, name: "group_int32", kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, + { no: 123, name: "group_uint32", kind: "scalar", T: 13 /* ScalarType.UINT32 */, opt: true }, + ]); + + static fromBinary(bytes: Uint8Array, options?: Partial): GroupField { + return new GroupField().fromBinary(bytes, options); + } + + static fromJson(jsonValue: JsonValue, options?: Partial): GroupField { + return new GroupField().fromJson(jsonValue, options); + } + + static fromJsonString(jsonString: string, options?: Partial): GroupField { + return new GroupField().fromJsonString(jsonString, options); + } + + static equals(a: GroupField | PlainMessage | undefined, b: GroupField | PlainMessage | undefined): boolean { + return proto2.util.equals(GroupField, a, b); + } +} + /** * @generated from message protobuf_test_messages.proto2.UnknownToTestAllTypes */ @@ -1999,3 +2091,12 @@ export const extension_int32 = proto2.makeExtension( { no: 120, kind: "scalar", T: 5 /* ScalarType.INT32 */, opt: true }, ); +/** + * @generated from extension: optional protobuf_test_messages.proto2.GroupField groupfield = 121; + */ +export const groupfield = proto2.makeExtension( + "protobuf_test_messages.proto2.groupfield", + TestAllTypesProto2, + () => ({ no: 121, kind: "message", T: GroupField, delimited: true, opt: true }), +); + diff --git a/impl/protoscript/failing_tests.txt b/impl/protoscript/failing_tests.txt index 22f35f4b..61b1370e 100644 --- a/impl/protoscript/failing_tests.txt +++ b/impl/protoscript/failing_tests.txt @@ -1611,3 +1611,9 @@ Required.Proto3.ProtobufInput.ValidDataScalar.UINT64[1].ProtobufOutput Required.Proto3.ProtobufInput.ValidDataScalar.UINT64[2].ProtobufOutput Required.Proto3.TimestampProtoInputTooLarge.JsonOutput Required.Proto3.TimestampProtoInputTooSmall.JsonOutput +Recommended.Proto2.JsonInput.IgnoreUnknownEnumStringValueInMapPart.ProtobufOutput +Recommended.Proto2.JsonInput.IgnoreUnknownEnumStringValueInRepeatedPart.ProtobufOutput +Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInMapPart.ProtobufOutput +Recommended.Proto3.JsonInput.IgnoreUnknownEnumStringValueInRepeatedPart.ProtobufOutput +Required.Proto2.ProtobufInput.UnknownOrdering.ProtobufOutput +Required.Proto3.ProtobufInput.UnknownOrdering.ProtobufOutput diff --git a/impl/protoscript/failing_tests_text_format.txt b/impl/protoscript/failing_tests_text_format.txt index 4e9b0d5a..69c2cfb9 100644 --- a/impl/protoscript/failing_tests_text_format.txt +++ b/impl/protoscript/failing_tests_text_format.txt @@ -110,3 +110,12 @@ Required.Proto3.TextFormatInput.Uint32FieldTooLarge Required.Proto3.TextFormatInput.Uint64FieldMaxValue.ProtobufOutput Required.Proto3.TextFormatInput.Uint64FieldMaxValue.TextFormatOutput Required.Proto3.TextFormatInput.Uint64FieldTooLarge +Required.Proto2.TextFormatInput.GroupFieldExtension.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldExtension.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldExtensionGroupName +Required.Proto2.TextFormatInput.GroupFieldLowercased.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercased.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldLowercasedMultiWord.TextFormatOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.ProtobufOutput +Required.Proto2.TextFormatInput.GroupFieldMultiWord.TextFormatOutput diff --git a/impl/protoscript/gen/google/protobuf/test_messages_proto2.pb.ts b/impl/protoscript/gen/google/protobuf/test_messages_proto2.pb.ts index 29710f26..672334d1 100644 --- a/impl/protoscript/gen/google/protobuf/test_messages_proto2.pb.ts +++ b/impl/protoscript/gen/google/protobuf/test_messages_proto2.pb.ts @@ -198,10 +198,10 @@ export interface TestAllTypesProto2 { oneofDouble?: number | null | undefined; oneofEnum?: TestAllTypesProto2.NestedEnum | null | undefined; defaultInt32: number; + defaultInt64: bigint; /** * default values */ - defaultInt64: bigint; defaultUint32: number; defaultUint64: bigint; defaultSint32: number; @@ -216,11 +216,11 @@ export interface TestAllTypesProto2 { defaultString: string; defaultBytes: Uint8Array; fieldname1: number; + fieldName2: number; /** * Test field-name-to-JSON-name convention. * (protobuf says names can be any valid C/C++ identifier.) */ - fieldName2: number; fieldName3: number; fieldName4: number; field0name5: number; @@ -350,6 +350,11 @@ export declare namespace TestAllTypesProto2 { groupUint32: number; } + export interface MultiWordGroupField { + groupInt32: number; + groupUint32: number; + } + /** * message_set test case. */ @@ -368,6 +373,11 @@ export interface ForeignMessageProto2 { c: number; } +export interface GroupField { + groupInt32: number; + groupUint32: number; +} + export interface UnknownToTestAllTypes { optionalInt32: number; optionalString: string; @@ -3286,6 +3296,85 @@ export const TestAllTypesProto2 = { }, }, + MultiWordGroupField: { + /** + * Serializes TestAllTypesProto2.MultiWordGroupField to protobuf. + */ + encode: function ( + msg: PartialDeep, + ): Uint8Array { + return TestAllTypesProto2.MultiWordGroupField._writeMessage( + msg, + new BinaryWriter(), + ).getResultBuffer(); + }, + + /** + * Deserializes TestAllTypesProto2.MultiWordGroupField from protobuf. + */ + decode: function ( + bytes: ByteSource, + ): TestAllTypesProto2.MultiWordGroupField { + return TestAllTypesProto2.MultiWordGroupField._readMessage( + TestAllTypesProto2.MultiWordGroupField.initialize(), + new BinaryReader(bytes), + ); + }, + + /** + * Initializes TestAllTypesProto2.MultiWordGroupField with all fields set to their default value. + */ + initialize: function (): TestAllTypesProto2.MultiWordGroupField { + return { + groupInt32: 0, + groupUint32: 0, + }; + }, + + /** + * @private + */ + _writeMessage: function ( + msg: PartialDeep, + writer: BinaryWriter, + ): BinaryWriter { + if (msg.groupInt32) { + writer.writeInt32(205, msg.groupInt32); + } + if (msg.groupUint32) { + writer.writeUint32(206, msg.groupUint32); + } + return writer; + }, + + /** + * @private + */ + _readMessage: function ( + msg: TestAllTypesProto2.MultiWordGroupField, + reader: BinaryReader, + ): TestAllTypesProto2.MultiWordGroupField { + while (reader.nextField()) { + const field = reader.getFieldNumber(); + switch (field) { + case 205: { + msg.groupInt32 = reader.readInt32(); + break; + } + case 206: { + msg.groupUint32 = reader.readUint32(); + break; + } + default: { + reader.skipField(); + break; + } + } + } + return msg; + }, + }, + MessageSetCorrect: { /** * Serializes TestAllTypesProto2.MessageSetCorrect to protobuf. @@ -3543,6 +3632,75 @@ export const ForeignMessageProto2 = { }, }; +export const GroupField = { + /** + * Serializes GroupField to protobuf. + */ + encode: function (msg: PartialDeep): Uint8Array { + return GroupField._writeMessage(msg, new BinaryWriter()).getResultBuffer(); + }, + + /** + * Deserializes GroupField from protobuf. + */ + decode: function (bytes: ByteSource): GroupField { + return GroupField._readMessage( + GroupField.initialize(), + new BinaryReader(bytes), + ); + }, + + /** + * Initializes GroupField with all fields set to their default value. + */ + initialize: function (): GroupField { + return { + groupInt32: 0, + groupUint32: 0, + }; + }, + + /** + * @private + */ + _writeMessage: function ( + msg: PartialDeep, + writer: BinaryWriter, + ): BinaryWriter { + if (msg.groupInt32) { + writer.writeInt32(122, msg.groupInt32); + } + if (msg.groupUint32) { + writer.writeUint32(123, msg.groupUint32); + } + return writer; + }, + + /** + * @private + */ + _readMessage: function (msg: GroupField, reader: BinaryReader): GroupField { + while (reader.nextField()) { + const field = reader.getFieldNumber(); + switch (field) { + case 122: { + msg.groupInt32 = reader.readInt32(); + break; + } + case 123: { + msg.groupUint32 = reader.readUint32(); + break; + } + default: { + reader.skipField(); + break; + } + } + } + return msg; + }, +}; + export const UnknownToTestAllTypes = { /** * Serializes UnknownToTestAllTypes to protobuf. @@ -7204,6 +7362,73 @@ export const TestAllTypesProto2JSON = { }, }, + MultiWordGroupField: { + /** + * Serializes TestAllTypesProto2.MultiWordGroupField to JSON. + */ + encode: function ( + msg: PartialDeep, + ): string { + return JSON.stringify( + TestAllTypesProto2JSON.MultiWordGroupField._writeMessage(msg), + ); + }, + + /** + * Deserializes TestAllTypesProto2.MultiWordGroupField from JSON. + */ + decode: function (json: string): TestAllTypesProto2.MultiWordGroupField { + return TestAllTypesProto2JSON.MultiWordGroupField._readMessage( + TestAllTypesProto2JSON.MultiWordGroupField.initialize(), + JSON.parse(json), + ); + }, + + /** + * Initializes TestAllTypesProto2.MultiWordGroupField with all fields set to their default value. + */ + initialize: function (): TestAllTypesProto2.MultiWordGroupField { + return { + groupInt32: 0, + groupUint32: 0, + }; + }, + + /** + * @private + */ + _writeMessage: function ( + msg: PartialDeep, + ): Record { + const json: Record = {}; + if (msg.groupInt32) { + json["groupInt32"] = msg.groupInt32; + } + if (msg.groupUint32) { + json["groupUint32"] = msg.groupUint32; + } + return json; + }, + + /** + * @private + */ + _readMessage: function ( + msg: TestAllTypesProto2.MultiWordGroupField, + json: any, + ): TestAllTypesProto2.MultiWordGroupField { + const _groupInt32_ = json["groupInt32"] ?? json["group_int32"]; + if (_groupInt32_) { + msg.groupInt32 = _groupInt32_; + } + const _groupUint32_ = json["groupUint32"] ?? json["group_uint32"]; + if (_groupUint32_) { + msg.groupUint32 = _groupUint32_; + } + return msg; + }, + }, + MessageSetCorrect: { /** * Serializes TestAllTypesProto2.MessageSetCorrect to JSON. @@ -7426,6 +7651,66 @@ export const ForeignMessageProto2JSON = { }, }; +export const GroupFieldJSON = { + /** + * Serializes GroupField to JSON. + */ + encode: function (msg: PartialDeep): string { + return JSON.stringify(GroupFieldJSON._writeMessage(msg)); + }, + + /** + * Deserializes GroupField from JSON. + */ + decode: function (json: string): GroupField { + return GroupFieldJSON._readMessage( + GroupFieldJSON.initialize(), + JSON.parse(json), + ); + }, + + /** + * Initializes GroupField with all fields set to their default value. + */ + initialize: function (): GroupField { + return { + groupInt32: 0, + groupUint32: 0, + }; + }, + + /** + * @private + */ + _writeMessage: function ( + msg: PartialDeep, + ): Record { + const json: Record = {}; + if (msg.groupInt32) { + json["groupInt32"] = msg.groupInt32; + } + if (msg.groupUint32) { + json["groupUint32"] = msg.groupUint32; + } + return json; + }, + + /** + * @private + */ + _readMessage: function (msg: GroupField, json: any): GroupField { + const _groupInt32_ = json["groupInt32"] ?? json["group_int32"]; + if (_groupInt32_) { + msg.groupInt32 = _groupInt32_; + } + const _groupUint32_ = json["groupUint32"] ?? json["group_uint32"]; + if (_groupUint32_) { + msg.groupUint32 = _groupUint32_; + } + return msg; + }, +}; + export const UnknownToTestAllTypesJSON = { /** * Serializes UnknownToTestAllTypes to JSON.