diff --git a/.bazelversion b/.bazelversion index 468c41f..b26a34e 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.2.1 \ No newline at end of file +7.2.1 diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..0e34ce3 --- /dev/null +++ b/example/README.md @@ -0,0 +1,41 @@ +# Generation + +To build example output: + +``` +bazel build generator:protoc-gen-js +protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test,import_style=es6,generate_dts,binary:. protos/test.proto +protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test2,import_style=es6,generate_dts,binary:. protos/test2.proto +``` + +Generates all of: +* `example/test.js` +* `example/test2.js` +* `example/test.d.ts` +* `example/test2.d.ts` + +The `*.js` files are generated with ES6-style imports/exports. The `*.d.ts` files have TypeScript definitions for their respective `.js` files. The `test2.*` files demonstrate dependency between generated files. + +To regression test Closure output: + +``` +git checkout origin/main +bazel build generator:protoc-gen-js +protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test,import_style=closure,binary:. protos/test.proto +mv example/test.js example-test.js +protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test2,import_style=closure,binary:. protos/test2.proto +mv example/test2.js example-test2.js +rmdir example + +git checkout lukfugl/es6 +bazel build generator:protoc-gen-js +mv example-test.js example/test.closure-old.js +mv example-test2.js example/test2.closure-old.js +protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test,import_style=closure,binary:. protos/test.proto +mv example/test.js example/test.closure-new.js +protoc --plugin=protoc-gen-js=bazel-bin/generator/protoc-gen-js --proto_path=. --js_out=output_dir=example,library=test2,import_style=closure,binary:. protos/test2.proto +mv example/test2.js example/test2.closure-new.js + +diff example/test.closure-* > example/test.closure.diff # empty +diff example/test2.closure-* > example/test2.closure.diff # empty +``` \ No newline at end of file diff --git a/example/test.closure-new.js b/example/test.closure-new.js new file mode 100644 index 0000000..7610c51 --- /dev/null +++ b/example/test.closure-new.js @@ -0,0 +1,9724 @@ +// source: protos/test.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + + +goog.provide('proto.jspb.test.BooleanFields'); +goog.provide('proto.jspb.test.CloneExtension'); +goog.provide('proto.jspb.test.Complex'); +goog.provide('proto.jspb.test.Complex.Nested'); +goog.provide('proto.jspb.test.Deeply'); +goog.provide('proto.jspb.test.Deeply.Nested'); +goog.provide('proto.jspb.test.Deeply.Nested.Message'); +goog.provide('proto.jspb.test.DefaultValues'); +goog.provide('proto.jspb.test.DefaultValues.Enum'); +goog.provide('proto.jspb.test.Empty'); +goog.provide('proto.jspb.test.EnumContainer'); +goog.provide('proto.jspb.test.FloatingPointFields'); +goog.provide('proto.jspb.test.HasExtensions'); +goog.provide('proto.jspb.test.IndirectExtension'); +goog.provide('proto.jspb.test.Int64Types'); +goog.provide('proto.jspb.test.IsExtension'); +goog.provide('proto.jspb.test.MapValueEnumNoBinary'); +goog.provide('proto.jspb.test.MapValueMessageNoBinary'); +goog.provide('proto.jspb.test.MineField'); +goog.provide('proto.jspb.test.OptionalFields'); +goog.provide('proto.jspb.test.OptionalFields.Nested'); +goog.provide('proto.jspb.test.OuterEnum'); +goog.provide('proto.jspb.test.OuterMessage'); +goog.provide('proto.jspb.test.OuterMessage.Complex'); +goog.provide('proto.jspb.test.Simple1'); +goog.provide('proto.jspb.test.Simple2'); +goog.provide('proto.jspb.test.SpecialCases'); +goog.provide('proto.jspb.test.TestAllowAliasEnum'); +goog.provide('proto.jspb.test.TestClone'); +goog.provide('proto.jspb.test.TestCloneExtension'); +goog.provide('proto.jspb.test.TestEndsWithBytes'); +goog.provide('proto.jspb.test.TestGroup'); +goog.provide('proto.jspb.test.TestGroup.OptionalGroup'); +goog.provide('proto.jspb.test.TestGroup.RepeatedGroup'); +goog.provide('proto.jspb.test.TestGroup.RequiredGroup'); +goog.provide('proto.jspb.test.TestGroup1'); +goog.provide('proto.jspb.test.TestLastFieldBeforePivot'); +goog.provide('proto.jspb.test.TestMapFieldsNoBinary'); +goog.provide('proto.jspb.test.TestMessageWithOneof'); +goog.provide('proto.jspb.test.TestMessageWithOneof.DefaultOneofACase'); +goog.provide('proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase'); +goog.provide('proto.jspb.test.TestMessageWithOneof.PartialOneofCase'); +goog.provide('proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase'); +goog.provide('proto.jspb.test.TestReservedNames'); +goog.provide('proto.jspb.test.TestReservedNamesExtension'); +goog.provide('proto.jspb.test.extendTestLastFieldBeforePivotField'); +goog.provide('proto.jspb.test.simple1'); + +goog.require('jspb.BinaryReader'); +goog.require('jspb.BinaryWriter'); +goog.require('jspb.ExtensionFieldBinaryInfo'); +goog.require('jspb.ExtensionFieldInfo'); +goog.require('jspb.Map'); +goog.require('jspb.Message'); + +/** + * 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.jspb.test.Empty = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Empty, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Empty.displayName = 'proto.jspb.test.Empty'; +} +/** + * 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.jspb.test.EnumContainer = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.EnumContainer, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.EnumContainer.displayName = 'proto.jspb.test.EnumContainer'; +} +/** + * 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.jspb.test.Simple1 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.Simple1.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.Simple1, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Simple1.displayName = 'proto.jspb.test.Simple1'; +} +/** + * 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.jspb.test.Simple2 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.Simple2.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.Simple2, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Simple2.displayName = 'proto.jspb.test.Simple2'; +} +/** + * 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.jspb.test.SpecialCases = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.SpecialCases, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.SpecialCases.displayName = 'proto.jspb.test.SpecialCases'; +} +/** + * 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.jspb.test.OptionalFields = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.OptionalFields.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.OptionalFields, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OptionalFields.displayName = 'proto.jspb.test.OptionalFields'; +} +/** + * 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.jspb.test.OptionalFields.Nested = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.OptionalFields.Nested, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OptionalFields.Nested.displayName = 'proto.jspb.test.OptionalFields.Nested'; +} +/** + * 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.jspb.test.HasExtensions = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 4, null, null); +}; +goog.inherits(proto.jspb.test.HasExtensions, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.HasExtensions.displayName = 'proto.jspb.test.HasExtensions'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.HasExtensions.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.HasExtensions.extensionsBinary = {}; + +/** + * 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.jspb.test.Complex = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.Complex.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.Complex, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Complex.displayName = 'proto.jspb.test.Complex'; +} +/** + * 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.jspb.test.Complex.Nested = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Complex.Nested, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Complex.Nested.displayName = 'proto.jspb.test.Complex.Nested'; +} +/** + * 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.jspb.test.OuterMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.OuterMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OuterMessage.displayName = 'proto.jspb.test.OuterMessage'; +} +/** + * 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.jspb.test.OuterMessage.Complex = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.OuterMessage.Complex, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OuterMessage.Complex.displayName = 'proto.jspb.test.OuterMessage.Complex'; +} +/** + * 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.jspb.test.MineField = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.MineField, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.MineField.displayName = 'proto.jspb.test.MineField'; +} +/** + * 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.jspb.test.IsExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.IsExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.IsExtension.displayName = 'proto.jspb.test.IsExtension'; +} +/** + * 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.jspb.test.IndirectExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.IndirectExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.IndirectExtension.displayName = 'proto.jspb.test.IndirectExtension'; +} +/** + * 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.jspb.test.DefaultValues = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.DefaultValues, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.DefaultValues.displayName = 'proto.jspb.test.DefaultValues'; +} +/** + * 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.jspb.test.FloatingPointFields = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.FloatingPointFields.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.FloatingPointFields, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.FloatingPointFields.displayName = 'proto.jspb.test.FloatingPointFields'; +} +/** + * 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.jspb.test.BooleanFields = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.BooleanFields.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.BooleanFields, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.BooleanFields.displayName = 'proto.jspb.test.BooleanFields'; +} +/** + * 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.jspb.test.TestClone = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 8, proto.jspb.test.TestClone.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.TestClone, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestClone.displayName = 'proto.jspb.test.TestClone'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestClone.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestClone.extensionsBinary = {}; + +/** + * 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.jspb.test.TestCloneExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestCloneExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestCloneExtension.displayName = 'proto.jspb.test.TestCloneExtension'; +} +/** + * 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.jspb.test.CloneExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.CloneExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.CloneExtension.displayName = 'proto.jspb.test.CloneExtension'; +} +/** + * 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.jspb.test.TestGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.TestGroup.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.TestGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.displayName = 'proto.jspb.test.TestGroup'; +} +/** + * 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.jspb.test.TestGroup.RepeatedGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.TestGroup.RepeatedGroup.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.TestGroup.RepeatedGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.RepeatedGroup.displayName = 'proto.jspb.test.TestGroup.RepeatedGroup'; +} +/** + * 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.jspb.test.TestGroup.RequiredGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestGroup.RequiredGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.RequiredGroup.displayName = 'proto.jspb.test.TestGroup.RequiredGroup'; +} +/** + * 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.jspb.test.TestGroup.OptionalGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestGroup.OptionalGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.OptionalGroup.displayName = 'proto.jspb.test.TestGroup.OptionalGroup'; +} +/** + * 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.jspb.test.TestGroup1 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestGroup1, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup1.displayName = 'proto.jspb.test.TestGroup1'; +} +/** + * 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.jspb.test.TestReservedNames = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); +}; +goog.inherits(proto.jspb.test.TestReservedNames, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestReservedNames.displayName = 'proto.jspb.test.TestReservedNames'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestReservedNames.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestReservedNames.extensionsBinary = {}; + +/** + * 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.jspb.test.TestReservedNamesExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestReservedNamesExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestReservedNamesExtension.displayName = 'proto.jspb.test.TestReservedNamesExtension'; +} +/** + * 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.jspb.test.TestMessageWithOneof = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.TestMessageWithOneof.repeatedFields_, proto.jspb.test.TestMessageWithOneof.oneofGroups_); +}; +goog.inherits(proto.jspb.test.TestMessageWithOneof, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestMessageWithOneof.displayName = 'proto.jspb.test.TestMessageWithOneof'; +} +/** + * 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.jspb.test.TestEndsWithBytes = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestEndsWithBytes, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestEndsWithBytes.displayName = 'proto.jspb.test.TestEndsWithBytes'; +} +/** + * 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.jspb.test.TestLastFieldBeforePivot = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); +}; +goog.inherits(proto.jspb.test.TestLastFieldBeforePivot, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestLastFieldBeforePivot.displayName = 'proto.jspb.test.TestLastFieldBeforePivot'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestLastFieldBeforePivot.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary = {}; + +/** + * 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.jspb.test.Int64Types = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Int64Types, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Int64Types.displayName = 'proto.jspb.test.Int64Types'; +} +/** + * 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.jspb.test.TestMapFieldsNoBinary = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestMapFieldsNoBinary, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestMapFieldsNoBinary.displayName = 'proto.jspb.test.TestMapFieldsNoBinary'; +} +/** + * 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.jspb.test.MapValueMessageNoBinary = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.MapValueMessageNoBinary, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.MapValueMessageNoBinary.displayName = 'proto.jspb.test.MapValueMessageNoBinary'; +} +/** + * 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.jspb.test.Deeply = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Deeply, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Deeply.displayName = 'proto.jspb.test.Deeply'; +} +/** + * 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.jspb.test.Deeply.Nested = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Deeply.Nested, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Deeply.Nested.displayName = 'proto.jspb.test.Deeply.Nested'; +} +/** + * 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.jspb.test.Deeply.Nested.Message = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Deeply.Nested.Message, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Deeply.Nested.Message.displayName = 'proto.jspb.test.Deeply.Nested.Message'; +} + + + +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.jspb.test.Empty.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Empty.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.jspb.test.Empty} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Empty.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Empty} + */ +proto.jspb.test.Empty.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Empty; + return proto.jspb.test.Empty.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Empty} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Empty} + */ +proto.jspb.test.Empty.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Empty.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Empty.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Empty} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Empty.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.EnumContainer.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.EnumContainer.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.jspb.test.EnumContainer} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.EnumContainer.toObject = function(includeInstance, msg) { + var f, obj = { +outerEnum: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.EnumContainer} + */ +proto.jspb.test.EnumContainer.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.EnumContainer; + return proto.jspb.test.EnumContainer.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.EnumContainer} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.EnumContainer} + */ +proto.jspb.test.EnumContainer.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.jspb.test.OuterEnum} */ (reader.readEnum()); + msg.setOuterEnum(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.EnumContainer.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.EnumContainer.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.EnumContainer} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.EnumContainer.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {!proto.jspb.test.OuterEnum} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeEnum( + 1, + f + ); + } +}; + + +/** + * optional OuterEnum outer_enum = 1; + * @return {!proto.jspb.test.OuterEnum} + */ +proto.jspb.test.EnumContainer.prototype.getOuterEnum = function() { + return /** @type {!proto.jspb.test.OuterEnum} */ (jspb.Message.getFieldWithDefault(this, 1, 1)); +}; + + +/** + * @param {!proto.jspb.test.OuterEnum} value + * @return {!proto.jspb.test.EnumContainer} returns this + */ +proto.jspb.test.EnumContainer.prototype.setOuterEnum = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.EnumContainer} returns this + */ +proto.jspb.test.EnumContainer.prototype.clearOuterEnum = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.EnumContainer.prototype.hasOuterEnum = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.Simple1.repeatedFields_ = [2]; + + + +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.jspb.test.Simple1.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Simple1.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.jspb.test.Simple1} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple1.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f, +aBoolean: (f = jspb.Message.getBooleanField(msg, 3)) == 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.jspb.test.Simple1} + */ +proto.jspb.test.Simple1.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Simple1; + return proto.jspb.test.Simple1.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Simple1} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Simple1} + */ +proto.jspb.test.Simple1.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + case 3: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setABoolean(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Simple1.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Simple1.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Simple1} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple1.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeBool( + 3, + f + ); + } +}; + + +/** + * required string a_string = 1; + * @return {string} + */ +proto.jspb.test.Simple1.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Simple1.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * repeated string a_repeated_string = 2; + * @return {!Array} + */ +proto.jspb.test.Simple1.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + +/** + * optional bool a_boolean = 3; + * @return {boolean} + */ +proto.jspb.test.Simple1.prototype.getABoolean = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.setABoolean = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.clearABoolean = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Simple1.prototype.hasABoolean = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.Simple2.repeatedFields_ = [2]; + + + +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.jspb.test.Simple2.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Simple2.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.jspb.test.Simple2} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple2.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aRepeatedStringList: (f = jspb.Message.getRepeatedField(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.jspb.test.Simple2} + */ +proto.jspb.test.Simple2.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Simple2; + return proto.jspb.test.Simple2.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Simple2} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Simple2} + */ +proto.jspb.test.Simple2.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Simple2.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Simple2.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Simple2} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple2.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } +}; + + +/** + * required string a_string = 1; + * @return {string} + */ +proto.jspb.test.Simple2.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Simple2.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * repeated string a_repeated_string = 2; + * @return {!Array} + */ +proto.jspb.test.Simple2.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + + + + +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.jspb.test.SpecialCases.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.SpecialCases.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.jspb.test.SpecialCases} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.SpecialCases.toObject = function(includeInstance, msg) { + var f, obj = { +normal: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +pb_default: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +pb_function: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f, +pb_var: (f = jspb.Message.getField(msg, 4)) == 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.jspb.test.SpecialCases} + */ +proto.jspb.test.SpecialCases.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.SpecialCases; + return proto.jspb.test.SpecialCases.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.SpecialCases} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.SpecialCases} + */ +proto.jspb.test.SpecialCases.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setNormal(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDefault(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setFunction(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setVar(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.SpecialCases.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.SpecialCases.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.SpecialCases} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.SpecialCases.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } +}; + + +/** + * required string normal = 1; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getNormal = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setNormal = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearNormal = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasNormal = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required string default = 2; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getDefault = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setDefault = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearDefault = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasDefault = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * required string function = 3; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getFunction = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setFunction = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearFunction = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasFunction = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * required string var = 4; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getVar = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setVar = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearVar = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasVar = function() { + return jspb.Message.getField(this, 4) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.OptionalFields.repeatedFields_ = [4,5]; + + + +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.jspb.test.OptionalFields.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OptionalFields.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.jspb.test.OptionalFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aBool: (f = jspb.Message.getBooleanField(msg, 2)) == null ? undefined : f, +aNestedMessage: (f = msg.getANestedMessage()) && proto.jspb.test.OptionalFields.Nested.toObject(includeInstance, f), +aRepeatedMessageList: jspb.Message.toObjectList(msg.getARepeatedMessageList(), + proto.jspb.test.OptionalFields.Nested.toObject, includeInstance), +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 5)) == 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.jspb.test.OptionalFields} + */ +proto.jspb.test.OptionalFields.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OptionalFields; + return proto.jspb.test.OptionalFields.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OptionalFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OptionalFields} + */ +proto.jspb.test.OptionalFields.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setABool(value); + break; + case 3: + var value = new proto.jspb.test.OptionalFields.Nested; + reader.readMessage(value,proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader); + msg.setANestedMessage(value); + break; + case 4: + var value = new proto.jspb.test.OptionalFields.Nested; + reader.readMessage(value,proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader); + msg.addARepeatedMessage(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OptionalFields.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OptionalFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OptionalFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = message.getANestedMessage(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedMessageList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 4, + f, + proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 5, + f + ); + } +}; + + + + + +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.jspb.test.OptionalFields.Nested.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OptionalFields.Nested.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.jspb.test.OptionalFields.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.Nested.toObject = function(includeInstance, msg) { + var f, obj = { +anInt: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.Nested.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OptionalFields.Nested; + return proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OptionalFields.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAnInt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OptionalFields.Nested.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OptionalFields.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 an_int = 1; + * @return {number} + */ +proto.jspb.test.OptionalFields.Nested.prototype.getAnInt = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.OptionalFields.Nested} returns this + */ +proto.jspb.test.OptionalFields.Nested.prototype.setAnInt = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields.Nested} returns this + */ +proto.jspb.test.OptionalFields.Nested.prototype.clearAnInt = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.Nested.prototype.hasAnInt = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string a_string = 1; + * @return {string} + */ +proto.jspb.test.OptionalFields.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required bool a_bool = 2; + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.getABool = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.setABool = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearABool = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.hasABool = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional Nested a_nested_message = 3; + * @return {?proto.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.prototype.getANestedMessage = function() { + return /** @type{?proto.jspb.test.OptionalFields.Nested} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.OptionalFields.Nested, 3)); +}; + + +/** + * @param {?proto.jspb.test.OptionalFields.Nested|undefined} value + * @return {!proto.jspb.test.OptionalFields} returns this +*/ +proto.jspb.test.OptionalFields.prototype.setANestedMessage = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearANestedMessage = function() { + return this.setANestedMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.hasANestedMessage = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * repeated Nested a_repeated_message = 4; + * @return {!Array} + */ +proto.jspb.test.OptionalFields.prototype.getARepeatedMessageList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.OptionalFields.Nested, 4)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.OptionalFields} returns this +*/ +proto.jspb.test.OptionalFields.prototype.setARepeatedMessageList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 4, value); +}; + + +/** + * @param {!proto.jspb.test.OptionalFields.Nested=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.prototype.addARepeatedMessage = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 4, opt_value, proto.jspb.test.OptionalFields.Nested, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearARepeatedMessageList = function() { + return this.setARepeatedMessageList([]); +}; + + +/** + * repeated string a_repeated_string = 5; + * @return {!Array} + */ +proto.jspb.test.OptionalFields.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 5, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 5, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + + + + +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.jspb.test.HasExtensions.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.HasExtensions.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.jspb.test.HasExtensions} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.HasExtensions.toObject = function(includeInstance, msg) { + var f, obj = { +str1: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +str2: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +str3: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.HasExtensions.extensions, proto.jspb.test.HasExtensions.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.HasExtensions} + */ +proto.jspb.test.HasExtensions.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.HasExtensions; + return proto.jspb.test.HasExtensions.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.HasExtensions} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.HasExtensions} + */ +proto.jspb.test.HasExtensions.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStr1(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setStr2(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setStr3(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.HasExtensions.extensionsBinary, + proto.jspb.test.HasExtensions.prototype.getExtension, + proto.jspb.test.HasExtensions.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.HasExtensions.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.HasExtensions.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.HasExtensions} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.HasExtensions.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.HasExtensions.extensionsBinary, proto.jspb.test.HasExtensions.prototype.getExtension); +}; + + +/** + * optional string str1 = 1; + * @return {string} + */ +proto.jspb.test.HasExtensions.prototype.getStr1 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.setStr1 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.clearStr1 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.HasExtensions.prototype.hasStr1 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string str2 = 2; + * @return {string} + */ +proto.jspb.test.HasExtensions.prototype.getStr2 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.setStr2 = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.clearStr2 = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.HasExtensions.prototype.hasStr2 = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string str3 = 3; + * @return {string} + */ +proto.jspb.test.HasExtensions.prototype.getStr3 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.setStr3 = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.clearStr3 = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.HasExtensions.prototype.hasStr3 = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.Complex.repeatedFields_ = [5,7]; + + + +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.jspb.test.Complex.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Complex.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.jspb.test.Complex} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +anOutOfOrderBool: (f = jspb.Message.getBooleanField(msg, 9)) == null ? undefined : f, +aNestedMessage: (f = msg.getANestedMessage()) && proto.jspb.test.Complex.Nested.toObject(includeInstance, f), +aRepeatedMessageList: jspb.Message.toObjectList(msg.getARepeatedMessageList(), + proto.jspb.test.Complex.Nested.toObject, includeInstance), +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 7)) == null ? undefined : f, +aFloatingPointField: (f = jspb.Message.getOptionalFloatingPointField(msg, 10)) == 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.jspb.test.Complex} + */ +proto.jspb.test.Complex.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Complex; + return proto.jspb.test.Complex.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Complex} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Complex} + */ +proto.jspb.test.Complex.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 9: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAnOutOfOrderBool(value); + break; + case 4: + var value = new proto.jspb.test.Complex.Nested; + reader.readMessage(value,proto.jspb.test.Complex.Nested.deserializeBinaryFromReader); + msg.setANestedMessage(value); + break; + case 5: + var value = new proto.jspb.test.Complex.Nested; + reader.readMessage(value,proto.jspb.test.Complex.Nested.deserializeBinaryFromReader); + msg.addARepeatedMessage(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + case 10: + var value = /** @type {number} */ (reader.readDouble()); + msg.setAFloatingPointField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Complex.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Complex.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Complex} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 9)); + if (f != null) { + writer.writeBool( + 9, + f + ); + } + f = message.getANestedMessage(); + if (f != null) { + writer.writeMessage( + 4, + f, + proto.jspb.test.Complex.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedMessageList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + proto.jspb.test.Complex.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 7, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 10)); + if (f != null) { + writer.writeDouble( + 10, + f + ); + } +}; + + + + + +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.jspb.test.Complex.Nested.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Complex.Nested.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.jspb.test.Complex.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.Nested.toObject = function(includeInstance, msg) { + var f, obj = { +anInt: (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.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.Nested.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Complex.Nested; + return proto.jspb.test.Complex.Nested.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Complex.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.Nested.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAnInt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Complex.Nested.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Complex.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Complex.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.Nested.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeInt32( + 2, + f + ); + } +}; + + +/** + * required int32 an_int = 2; + * @return {number} + */ +proto.jspb.test.Complex.Nested.prototype.getAnInt = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Complex.Nested} returns this + */ +proto.jspb.test.Complex.Nested.prototype.setAnInt = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex.Nested} returns this + */ +proto.jspb.test.Complex.Nested.prototype.clearAnInt = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.Nested.prototype.hasAnInt = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * required string a_string = 1; + * @return {string} + */ +proto.jspb.test.Complex.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bool an_out_of_order_bool = 9; + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.getAnOutOfOrderBool = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 9, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setAnOutOfOrderBool = function(value) { + return jspb.Message.setField(this, 9, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearAnOutOfOrderBool = function() { + return jspb.Message.setField(this, 9, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasAnOutOfOrderBool = function() { + return jspb.Message.getField(this, 9) != null; +}; + + +/** + * optional Nested a_nested_message = 4; + * @return {?proto.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.prototype.getANestedMessage = function() { + return /** @type{?proto.jspb.test.Complex.Nested} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Complex.Nested, 4)); +}; + + +/** + * @param {?proto.jspb.test.Complex.Nested|undefined} value + * @return {!proto.jspb.test.Complex} returns this +*/ +proto.jspb.test.Complex.prototype.setANestedMessage = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearANestedMessage = function() { + return this.setANestedMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasANestedMessage = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * repeated Nested a_repeated_message = 5; + * @return {!Array} + */ +proto.jspb.test.Complex.prototype.getARepeatedMessageList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.Complex.Nested, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Complex} returns this +*/ +proto.jspb.test.Complex.prototype.setARepeatedMessageList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); +}; + + +/** + * @param {!proto.jspb.test.Complex.Nested=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.prototype.addARepeatedMessage = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.jspb.test.Complex.Nested, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearARepeatedMessageList = function() { + return this.setARepeatedMessageList([]); +}; + + +/** + * repeated string a_repeated_string = 7; + * @return {!Array} + */ +proto.jspb.test.Complex.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 7)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 7, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 7, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + +/** + * optional double a_floating_point_field = 10; + * @return {number} + */ +proto.jspb.test.Complex.prototype.getAFloatingPointField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 10, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setAFloatingPointField = function(value) { + return jspb.Message.setField(this, 10, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearAFloatingPointField = function() { + return jspb.Message.setField(this, 10, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasAFloatingPointField = function() { + return jspb.Message.getField(this, 10) != null; +}; + + + + + +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.jspb.test.OuterMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OuterMessage.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.jspb.test.OuterMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.OuterMessage} + */ +proto.jspb.test.OuterMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OuterMessage; + return proto.jspb.test.OuterMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OuterMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OuterMessage} + */ +proto.jspb.test.OuterMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OuterMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OuterMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OuterMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.OuterMessage.Complex.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OuterMessage.Complex.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.jspb.test.OuterMessage.Complex} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.Complex.toObject = function(includeInstance, msg) { + var f, obj = { +innerComplexField: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.OuterMessage.Complex} + */ +proto.jspb.test.OuterMessage.Complex.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OuterMessage.Complex; + return proto.jspb.test.OuterMessage.Complex.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OuterMessage.Complex} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OuterMessage.Complex} + */ +proto.jspb.test.OuterMessage.Complex.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setInnerComplexField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OuterMessage.Complex.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OuterMessage.Complex.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OuterMessage.Complex} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.Complex.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 inner_complex_field = 1; + * @return {number} + */ +proto.jspb.test.OuterMessage.Complex.prototype.getInnerComplexField = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.OuterMessage.Complex} returns this + */ +proto.jspb.test.OuterMessage.Complex.prototype.setInnerComplexField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OuterMessage.Complex} returns this + */ +proto.jspb.test.OuterMessage.Complex.prototype.clearInnerComplexField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OuterMessage.Complex.prototype.hasInnerComplexField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.MineField.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.MineField.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.jspb.test.MineField} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MineField.toObject = function(includeInstance, msg) { + var f, obj = { +cookie: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.MineField} + */ +proto.jspb.test.MineField.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.MineField; + return proto.jspb.test.MineField.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.MineField} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.MineField} + */ +proto.jspb.test.MineField.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setCookie(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.MineField.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.MineField.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.MineField} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MineField.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string cookie = 1; + * @return {string} + */ +proto.jspb.test.MineField.prototype.getCookie = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.MineField} returns this + */ +proto.jspb.test.MineField.prototype.setCookie = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.MineField} returns this + */ +proto.jspb.test.MineField.prototype.clearCookie = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.MineField.prototype.hasCookie = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.IsExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.IsExtension.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.jspb.test.IsExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IsExtension.toObject = function(includeInstance, msg) { + var f, obj = { +ext1: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.IsExtension} + */ +proto.jspb.test.IsExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.IsExtension; + return proto.jspb.test.IsExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.IsExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.IsExtension} + */ +proto.jspb.test.IsExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setExt1(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.IsExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.IsExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.IsExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IsExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.IsExtension.extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + proto.jspb.test.IsExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.IsExtension.toObject), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IsExtension.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.IsExtension.serializeBinaryToWriter, + proto.jspb.test.IsExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[100] = proto.jspb.test.IsExtension.extField; + +/** + * optional string ext1 = 1; + * @return {string} + */ +proto.jspb.test.IsExtension.prototype.getExt1 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.IsExtension} returns this + */ +proto.jspb.test.IsExtension.prototype.setExt1 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.IsExtension} returns this + */ +proto.jspb.test.IsExtension.prototype.clearExt1 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.IsExtension.prototype.hasExt1 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.IndirectExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.IndirectExtension.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.jspb.test.IndirectExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IndirectExtension.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.IndirectExtension} + */ +proto.jspb.test.IndirectExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.IndirectExtension; + return proto.jspb.test.IndirectExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.IndirectExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.IndirectExtension} + */ +proto.jspb.test.IndirectExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.IndirectExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.IndirectExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.IndirectExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IndirectExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `simple`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.IndirectExtension.simple = new jspb.ExtensionFieldInfo( + 101, + {simple: 0}, + proto.jspb.test.Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.Simple1.toObject), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.simple, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.Simple1.serializeBinaryToWriter, + proto.jspb.test.Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[101] = proto.jspb.test.IndirectExtension.simple; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `str`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.IndirectExtension.str = new jspb.ExtensionFieldInfo( + 102, + {str: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[102] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.str, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[102] = proto.jspb.test.IndirectExtension.str; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `repeatedStrList`. + * @type {!jspb.ExtensionFieldInfo>} + */ +proto.jspb.test.IndirectExtension.repeatedStrList = new jspb.ExtensionFieldInfo( + 103, + {repeatedStrList: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 1); + +proto.jspb.test.HasExtensions.extensionsBinary[103] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.repeatedStrList, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeRepeatedString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[103] = proto.jspb.test.IndirectExtension.repeatedStrList; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `repeatedSimpleList`. + * @type {!jspb.ExtensionFieldInfo>} + */ +proto.jspb.test.IndirectExtension.repeatedSimpleList = new jspb.ExtensionFieldInfo( + 104, + {repeatedSimpleList: 0}, + proto.jspb.test.Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.Simple1.toObject), + 1); + +proto.jspb.test.HasExtensions.extensionsBinary[104] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.repeatedSimpleList, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeRepeatedMessage, + proto.jspb.test.Simple1.serializeBinaryToWriter, + proto.jspb.test.Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[104] = proto.jspb.test.IndirectExtension.repeatedSimpleList; + + + + +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.jspb.test.DefaultValues.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.DefaultValues.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.jspb.test.DefaultValues} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.DefaultValues.toObject = function(includeInstance, msg) { + var f, obj = { +stringField: jspb.Message.getFieldWithDefault(msg, 1, "default\x3c\x3e\x27\x22abc"), +boolField: jspb.Message.getBooleanFieldWithDefault(msg, 2, true), +intField: jspb.Message.getFieldWithDefault(msg, 3, 11), +enumField: jspb.Message.getFieldWithDefault(msg, 4, 13), +emptyField: jspb.Message.getFieldWithDefault(msg, 6, ""), +bytesField: msg.getBytesField_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.DefaultValues} + */ +proto.jspb.test.DefaultValues.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.DefaultValues; + return proto.jspb.test.DefaultValues.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.DefaultValues} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.DefaultValues} + */ +proto.jspb.test.DefaultValues.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStringField(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setBoolField(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt64()); + msg.setIntField(value); + break; + case 4: + var value = /** @type {!proto.jspb.test.DefaultValues.Enum} */ (reader.readEnum()); + msg.setEnumField(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setEmptyField(value); + break; + case 8: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBytesField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.DefaultValues.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.DefaultValues.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.DefaultValues} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.DefaultValues.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeInt64( + 3, + f + ); + } + f = /** @type {!proto.jspb.test.DefaultValues.Enum} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeEnum( + 4, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeString( + 6, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeBytes( + 8, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.jspb.test.DefaultValues.Enum = { + E1: 13, + E2: 77 +}; + +/** + * optional string string_field = 1; + * @return {string} + */ +proto.jspb.test.DefaultValues.prototype.getStringField = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "default\x3c\x3e\x27\x22abc")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setStringField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearStringField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasStringField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bool bool_field = 2; + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.getBoolField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, true)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setBoolField = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearBoolField = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasBoolField = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional int64 int_field = 3; + * @return {number} + */ +proto.jspb.test.DefaultValues.prototype.getIntField = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 11)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setIntField = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearIntField = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasIntField = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional Enum enum_field = 4; + * @return {!proto.jspb.test.DefaultValues.Enum} + */ +proto.jspb.test.DefaultValues.prototype.getEnumField = function() { + return /** @type {!proto.jspb.test.DefaultValues.Enum} */ (jspb.Message.getFieldWithDefault(this, 4, 13)); +}; + + +/** + * @param {!proto.jspb.test.DefaultValues.Enum} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setEnumField = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearEnumField = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasEnumField = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional string empty_field = 6; + * @return {string} + */ +proto.jspb.test.DefaultValues.prototype.getEmptyField = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setEmptyField = function(value) { + return jspb.Message.setField(this, 6, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearEmptyField = function() { + return jspb.Message.setField(this, 6, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasEmptyField = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional bytes bytes_field = 8; + * @return {!(string|Uint8Array)} + */ +proto.jspb.test.DefaultValues.prototype.getBytesField = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 8, "bW9v")); +}; + + +/** + * optional bytes bytes_field = 8; + * This is a type-conversion wrapper around `getBytesField()` + * @return {string} + */ +proto.jspb.test.DefaultValues.prototype.getBytesField_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBytesField())); +}; + + +/** + * optional bytes bytes_field = 8; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBytesField()` + * @return {!Uint8Array} + */ +proto.jspb.test.DefaultValues.prototype.getBytesField_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBytesField())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setBytesField = function(value) { + return jspb.Message.setField(this, 8, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearBytesField = function() { + return jspb.Message.setField(this, 8, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasBytesField = function() { + return jspb.Message.getField(this, 8) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.FloatingPointFields.repeatedFields_ = [3,7]; + + + +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.jspb.test.FloatingPointFields.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.FloatingPointFields.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.jspb.test.FloatingPointFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.FloatingPointFields.toObject = function(includeInstance, msg) { + var f, obj = { +optionalFloatField: (f = jspb.Message.getOptionalFloatingPointField(msg, 1)) == null ? undefined : f, +requiredFloatField: (f = jspb.Message.getOptionalFloatingPointField(msg, 2)) == null ? undefined : f, +repeatedFloatFieldList: (f = jspb.Message.getRepeatedFloatingPointField(msg, 3)) == null ? undefined : f, +defaultFloatField: jspb.Message.getFloatingPointFieldWithDefault(msg, 4, 2.0), +optionalDoubleField: (f = jspb.Message.getOptionalFloatingPointField(msg, 5)) == null ? undefined : f, +requiredDoubleField: (f = jspb.Message.getOptionalFloatingPointField(msg, 6)) == null ? undefined : f, +repeatedDoubleFieldList: (f = jspb.Message.getRepeatedFloatingPointField(msg, 7)) == null ? undefined : f, +defaultDoubleField: jspb.Message.getFloatingPointFieldWithDefault(msg, 8, 2.0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.FloatingPointFields} + */ +proto.jspb.test.FloatingPointFields.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.FloatingPointFields; + return proto.jspb.test.FloatingPointFields.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.FloatingPointFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.FloatingPointFields} + */ +proto.jspb.test.FloatingPointFields.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readFloat()); + msg.setOptionalFloatField(value); + break; + case 2: + var value = /** @type {number} */ (reader.readFloat()); + msg.setRequiredFloatField(value); + break; + case 3: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readFloat() : [reader.readFloat()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedFloatField(values[i]); + } + break; + case 4: + var value = /** @type {number} */ (reader.readFloat()); + msg.setDefaultFloatField(value); + break; + case 5: + var value = /** @type {number} */ (reader.readDouble()); + msg.setOptionalDoubleField(value); + break; + case 6: + var value = /** @type {number} */ (reader.readDouble()); + msg.setRequiredDoubleField(value); + break; + case 7: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readDouble() : [reader.readDouble()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedDoubleField(values[i]); + } + break; + case 8: + var value = /** @type {number} */ (reader.readDouble()); + msg.setDefaultDoubleField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.FloatingPointFields.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.FloatingPointFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.FloatingPointFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.FloatingPointFields.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeFloat( + 1, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeFloat( + 2, + f + ); + } + f = message.getRepeatedFloatFieldList(); + if (f.length > 0) { + writer.writeRepeatedFloat( + 3, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeFloat( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeDouble( + 5, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeDouble( + 6, + f + ); + } + f = message.getRepeatedDoubleFieldList(); + if (f.length > 0) { + writer.writeRepeatedDouble( + 7, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeDouble( + 8, + f + ); + } +}; + + +/** + * optional float optional_float_field = 1; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getOptionalFloatField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 1, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setOptionalFloatField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearOptionalFloatField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasOptionalFloatField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required float required_float_field = 2; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getRequiredFloatField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 2, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRequiredFloatField = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRequiredFloatField = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasRequiredFloatField = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * repeated float repeated_float_field = 3; + * @return {!Array} + */ +proto.jspb.test.FloatingPointFields.prototype.getRepeatedFloatFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedFloatingPointField(this, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRepeatedFloatFieldList = function(value) { + return jspb.Message.setField(this, 3, value || []); +}; + + +/** + * @param {number} value + * @param {number=} opt_index + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.addRepeatedFloatField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRepeatedFloatFieldList = function() { + return this.setRepeatedFloatFieldList([]); +}; + + +/** + * optional float default_float_field = 4; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getDefaultFloatField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 4, 2.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setDefaultFloatField = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearDefaultFloatField = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasDefaultFloatField = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional double optional_double_field = 5; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getOptionalDoubleField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setOptionalDoubleField = function(value) { + return jspb.Message.setField(this, 5, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearOptionalDoubleField = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasOptionalDoubleField = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * required double required_double_field = 6; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getRequiredDoubleField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 6, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRequiredDoubleField = function(value) { + return jspb.Message.setField(this, 6, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRequiredDoubleField = function() { + return jspb.Message.setField(this, 6, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasRequiredDoubleField = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * repeated double repeated_double_field = 7; + * @return {!Array} + */ +proto.jspb.test.FloatingPointFields.prototype.getRepeatedDoubleFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedFloatingPointField(this, 7)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRepeatedDoubleFieldList = function(value) { + return jspb.Message.setField(this, 7, value || []); +}; + + +/** + * @param {number} value + * @param {number=} opt_index + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.addRepeatedDoubleField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 7, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRepeatedDoubleFieldList = function() { + return this.setRepeatedDoubleFieldList([]); +}; + + +/** + * optional double default_double_field = 8; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getDefaultDoubleField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 8, 2.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setDefaultDoubleField = function(value) { + return jspb.Message.setField(this, 8, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearDefaultDoubleField = function() { + return jspb.Message.setField(this, 8, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasDefaultDoubleField = function() { + return jspb.Message.getField(this, 8) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.BooleanFields.repeatedFields_ = [3]; + + + +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.jspb.test.BooleanFields.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.BooleanFields.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.jspb.test.BooleanFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.BooleanFields.toObject = function(includeInstance, msg) { + var f, obj = { +optionalBooleanField: (f = jspb.Message.getBooleanField(msg, 1)) == null ? undefined : f, +requiredBooleanField: (f = jspb.Message.getBooleanField(msg, 2)) == null ? undefined : f, +repeatedBooleanFieldList: (f = jspb.Message.getRepeatedBooleanField(msg, 3)) == null ? undefined : f, +defaultBooleanField: jspb.Message.getBooleanFieldWithDefault(msg, 4, true) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.BooleanFields} + */ +proto.jspb.test.BooleanFields.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.BooleanFields; + return proto.jspb.test.BooleanFields.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.BooleanFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.BooleanFields} + */ +proto.jspb.test.BooleanFields.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setOptionalBooleanField(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setRequiredBooleanField(value); + break; + case 3: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readBool() : [reader.readBool()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedBooleanField(values[i]); + } + break; + case 4: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDefaultBooleanField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.BooleanFields.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.BooleanFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.BooleanFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.BooleanFields.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {boolean} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeBool( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = message.getRepeatedBooleanFieldList(); + if (f.length > 0) { + writer.writeRepeatedBool( + 3, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBool( + 4, + f + ); + } +}; + + +/** + * optional bool optional_boolean_field = 1; + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.getOptionalBooleanField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setOptionalBooleanField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearOptionalBooleanField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.hasOptionalBooleanField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required bool required_boolean_field = 2; + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.getRequiredBooleanField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setRequiredBooleanField = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearRequiredBooleanField = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.hasRequiredBooleanField = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * repeated bool repeated_boolean_field = 3; + * @return {!Array} + */ +proto.jspb.test.BooleanFields.prototype.getRepeatedBooleanFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedBooleanField(this, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setRepeatedBooleanFieldList = function(value) { + return jspb.Message.setField(this, 3, value || []); +}; + + +/** + * @param {boolean} value + * @param {number=} opt_index + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.addRepeatedBooleanField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearRepeatedBooleanFieldList = function() { + return this.setRepeatedBooleanFieldList([]); +}; + + +/** + * optional bool default_boolean_field = 4; + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.getDefaultBooleanField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, true)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setDefaultBooleanField = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearDefaultBooleanField = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.hasDefaultBooleanField = function() { + return jspb.Message.getField(this, 4) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestClone.repeatedFields_ = [5]; + + + +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.jspb.test.TestClone.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestClone.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.jspb.test.TestClone} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestClone.toObject = function(includeInstance, msg) { + var f, obj = { +str: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +simple1: (f = msg.getSimple1()) && proto.jspb.test.Simple1.toObject(includeInstance, f), +simple2List: jspb.Message.toObjectList(msg.getSimple2List(), + proto.jspb.test.Simple1.toObject, includeInstance), +bytesField: msg.getBytesField_asB64(), +unused: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestClone.extensions, proto.jspb.test.TestClone.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestClone} + */ +proto.jspb.test.TestClone.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestClone; + return proto.jspb.test.TestClone.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestClone} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestClone} + */ +proto.jspb.test.TestClone.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStr(value); + break; + case 3: + var value = new proto.jspb.test.Simple1; + reader.readMessage(value,proto.jspb.test.Simple1.deserializeBinaryFromReader); + msg.setSimple1(value); + break; + case 5: + var value = new proto.jspb.test.Simple1; + reader.readMessage(value,proto.jspb.test.Simple1.deserializeBinaryFromReader); + msg.addSimple2(value); + break; + case 6: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBytesField(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setUnused(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestClone.extensionsBinary, + proto.jspb.test.TestClone.prototype.getExtension, + proto.jspb.test.TestClone.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestClone.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestClone.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestClone} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestClone.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getSimple1(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.jspb.test.Simple1.serializeBinaryToWriter + ); + } + f = message.getSimple2List(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + proto.jspb.test.Simple1.serializeBinaryToWriter + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBytes( + 6, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeString( + 7, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestClone.extensionsBinary, proto.jspb.test.TestClone.prototype.getExtension); +}; + + +/** + * optional string str = 1; + * @return {string} + */ +proto.jspb.test.TestClone.prototype.getStr = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.setStr = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearStr = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasStr = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Simple1 simple1 = 3; + * @return {?proto.jspb.test.Simple1} + */ +proto.jspb.test.TestClone.prototype.getSimple1 = function() { + return /** @type{?proto.jspb.test.Simple1} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Simple1, 3)); +}; + + +/** + * @param {?proto.jspb.test.Simple1|undefined} value + * @return {!proto.jspb.test.TestClone} returns this +*/ +proto.jspb.test.TestClone.prototype.setSimple1 = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearSimple1 = function() { + return this.setSimple1(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasSimple1 = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * repeated Simple1 simple2 = 5; + * @return {!Array} + */ +proto.jspb.test.TestClone.prototype.getSimple2List = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.Simple1, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestClone} returns this +*/ +proto.jspb.test.TestClone.prototype.setSimple2List = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); +}; + + +/** + * @param {!proto.jspb.test.Simple1=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple1} + */ +proto.jspb.test.TestClone.prototype.addSimple2 = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.jspb.test.Simple1, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearSimple2List = function() { + return this.setSimple2List([]); +}; + + +/** + * optional bytes bytes_field = 6; + * @return {!(string|Uint8Array)} + */ +proto.jspb.test.TestClone.prototype.getBytesField = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * optional bytes bytes_field = 6; + * This is a type-conversion wrapper around `getBytesField()` + * @return {string} + */ +proto.jspb.test.TestClone.prototype.getBytesField_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBytesField())); +}; + + +/** + * optional bytes bytes_field = 6; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBytesField()` + * @return {!Uint8Array} + */ +proto.jspb.test.TestClone.prototype.getBytesField_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBytesField())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.setBytesField = function(value) { + return jspb.Message.setField(this, 6, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearBytesField = function() { + return jspb.Message.setField(this, 6, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasBytesField = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional string unused = 7; + * @return {string} + */ +proto.jspb.test.TestClone.prototype.getUnused = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.setUnused = function(value) { + return jspb.Message.setField(this, 7, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearUnused = function() { + return jspb.Message.setField(this, 7, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasUnused = function() { + return jspb.Message.getField(this, 7) != null; +}; + + + + + +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.jspb.test.TestCloneExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestCloneExtension.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.jspb.test.TestCloneExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestCloneExtension.toObject = function(includeInstance, msg) { + var f, obj = { +f: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.TestCloneExtension} + */ +proto.jspb.test.TestCloneExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestCloneExtension; + return proto.jspb.test.TestCloneExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestCloneExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestCloneExtension} + */ +proto.jspb.test.TestCloneExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setF(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestCloneExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestCloneExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestCloneExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestCloneExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `lowExt`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.TestCloneExtension.lowExt = new jspb.ExtensionFieldInfo( + 11, + {lowExt: 0}, + proto.jspb.test.TestCloneExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.TestCloneExtension.toObject), + 0); + +proto.jspb.test.TestClone.extensionsBinary[11] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.TestCloneExtension.lowExt, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.TestCloneExtension.serializeBinaryToWriter, + proto.jspb.test.TestCloneExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestClone.extensions[11] = proto.jspb.test.TestCloneExtension.lowExt; + +/** + * optional int32 f = 1; + * @return {number} + */ +proto.jspb.test.TestCloneExtension.prototype.getF = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestCloneExtension} returns this + */ +proto.jspb.test.TestCloneExtension.prototype.setF = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestCloneExtension} returns this + */ +proto.jspb.test.TestCloneExtension.prototype.clearF = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestCloneExtension.prototype.hasF = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.CloneExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.CloneExtension.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.jspb.test.CloneExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.CloneExtension.toObject = function(includeInstance, msg) { + var f, obj = { +ext: (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.jspb.test.CloneExtension} + */ +proto.jspb.test.CloneExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.CloneExtension; + return proto.jspb.test.CloneExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.CloneExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.CloneExtension} + */ +proto.jspb.test.CloneExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setExt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.CloneExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.CloneExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.CloneExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.CloneExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.CloneExtension.extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + proto.jspb.test.CloneExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.CloneExtension.toObject), + 0); + +proto.jspb.test.TestClone.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.CloneExtension.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.CloneExtension.serializeBinaryToWriter, + proto.jspb.test.CloneExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestClone.extensions[100] = proto.jspb.test.CloneExtension.extField; + +/** + * optional string ext = 2; + * @return {string} + */ +proto.jspb.test.CloneExtension.prototype.getExt = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.CloneExtension} returns this + */ +proto.jspb.test.CloneExtension.prototype.setExt = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.CloneExtension} returns this + */ +proto.jspb.test.CloneExtension.prototype.clearExt = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.CloneExtension.prototype.hasExt = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestGroup.repeatedFields_ = [1]; + + + +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.jspb.test.TestGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.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.jspb.test.TestGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.toObject = function(includeInstance, msg) { + var f, obj = { +repeatedGroupList: jspb.Message.toObjectList(msg.getRepeatedGroupList(), + proto.jspb.test.TestGroup.RepeatedGroup.toObject, includeInstance), +requiredGroup: (f = msg.getRequiredGroup()) && proto.jspb.test.TestGroup.RequiredGroup.toObject(includeInstance, f), +optionalGroup: (f = msg.getOptionalGroup()) && proto.jspb.test.TestGroup.OptionalGroup.toObject(includeInstance, f), +id: (f = jspb.Message.getField(msg, 4)) == null ? undefined : f, +requiredSimple: (f = msg.getRequiredSimple()) && proto.jspb.test.Simple2.toObject(includeInstance, f), +optionalSimple: (f = msg.getOptionalSimple()) && proto.jspb.test.Simple2.toObject(includeInstance, 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.jspb.test.TestGroup} + */ +proto.jspb.test.TestGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup; + return proto.jspb.test.TestGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup} + */ +proto.jspb.test.TestGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.jspb.test.TestGroup.RepeatedGroup; + reader.readGroup(1, value,proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader); + msg.addRepeatedGroup(value); + break; + case 2: + var value = new proto.jspb.test.TestGroup.RequiredGroup; + reader.readGroup(2, value,proto.jspb.test.TestGroup.RequiredGroup.deserializeBinaryFromReader); + msg.setRequiredGroup(value); + break; + case 3: + var value = new proto.jspb.test.TestGroup.OptionalGroup; + reader.readGroup(3, value,proto.jspb.test.TestGroup.OptionalGroup.deserializeBinaryFromReader); + msg.setOptionalGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 5: + var value = new proto.jspb.test.Simple2; + reader.readMessage(value,proto.jspb.test.Simple2.deserializeBinaryFromReader); + msg.setRequiredSimple(value); + break; + case 6: + var value = new proto.jspb.test.Simple2; + reader.readMessage(value,proto.jspb.test.Simple2.deserializeBinaryFromReader); + msg.setOptionalSimple(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRepeatedGroupList(); + if (f.length > 0) { + writer.writeRepeatedGroup( + 1, + f, + proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter + ); + } + f = message.getRequiredGroup(); + if (f != null) { + writer.writeGroup( + 2, + f, + proto.jspb.test.TestGroup.RequiredGroup.serializeBinaryToWriter + ); + } + f = message.getOptionalGroup(); + if (f != null) { + writer.writeGroup( + 3, + f, + proto.jspb.test.TestGroup.OptionalGroup.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } + f = message.getRequiredSimple(); + if (f != null) { + writer.writeMessage( + 5, + f, + proto.jspb.test.Simple2.serializeBinaryToWriter + ); + } + f = message.getOptionalSimple(); + if (f != null) { + writer.writeMessage( + 6, + f, + proto.jspb.test.Simple2.serializeBinaryToWriter + ); + } +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestGroup.RepeatedGroup.repeatedFields_ = [1]; + + + +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.jspb.test.TestGroup.RepeatedGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.RepeatedGroup.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.jspb.test.TestGroup.RepeatedGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RepeatedGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, 0)) == null ? undefined : f, +someBoolList: (f = jspb.Message.getRepeatedBooleanField(msg, 1)) == 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.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup.RepeatedGroup; + return proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.RepeatedGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 2: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readBool() : [reader.readBool()]); + for (var i = 0; i < values.length; i++) { + msg.addSomeBool(values[i]); + } + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.RepeatedGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 0)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getSomeBoolList(); + if (f.length > 0) { + writer.writeRepeatedBool( + 2, + f + ); + } +}; + + +/** + * required string id = 1; + * @return {string} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 0, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, 0, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.clearId = function() { + return jspb.Message.setField(this, 0, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.hasId = function() { + return jspb.Message.getField(this, 0) != null; +}; + + +/** + * repeated bool some_bool = 2; + * @return {!Array} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.getSomeBoolList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedBooleanField(this, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.setSomeBoolList = function(value) { + return jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {boolean} value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.addSomeBool = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.clearSomeBoolList = function() { + return this.setSomeBoolList([]); +}; + + + + + +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.jspb.test.TestGroup.RequiredGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.RequiredGroup.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.jspb.test.TestGroup.RequiredGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RequiredGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, -1)) == 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.jspb.test.TestGroup.RequiredGroup} + */ +proto.jspb.test.TestGroup.RequiredGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup.RequiredGroup; + return proto.jspb.test.TestGroup.RequiredGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.RequiredGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ +proto.jspb.test.TestGroup.RequiredGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.RequiredGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.RequiredGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RequiredGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, -1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * required string id = 1; + * @return {string} + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, -1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.RequiredGroup} returns this + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, -1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} returns this + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.clearId = function() { + return jspb.Message.setField(this, -1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.hasId = function() { + return jspb.Message.getField(this, -1) != null; +}; + + + + + +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.jspb.test.TestGroup.OptionalGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.OptionalGroup.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.jspb.test.TestGroup.OptionalGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.OptionalGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (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.jspb.test.TestGroup.OptionalGroup} + */ +proto.jspb.test.TestGroup.OptionalGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup.OptionalGroup; + return proto.jspb.test.TestGroup.OptionalGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.OptionalGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} + */ +proto.jspb.test.TestGroup.OptionalGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.OptionalGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.OptionalGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.OptionalGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, -2)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * required string id = 1; + * @return {string} + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, -2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.OptionalGroup} returns this + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, -2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} returns this + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.clearId = function() { + return jspb.Message.setField(this, -2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.hasId = function() { + return jspb.Message.getField(this, -2) != null; +}; + + +/** + * repeated group RepeatedGroup = 1; + * @return {!Array} + */ +proto.jspb.test.TestGroup.prototype.getRepeatedGroupList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.TestGroup.RepeatedGroup, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setRepeatedGroupList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.jspb.test.TestGroup.RepeatedGroup=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup.prototype.addRepeatedGroup = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.jspb.test.TestGroup.RepeatedGroup, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearRepeatedGroupList = function() { + return this.setRepeatedGroupList([]); +}; + + +/** + * required group RequiredGroup = 2; + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ +proto.jspb.test.TestGroup.prototype.getRequiredGroup = function() { + return /** @type{!proto.jspb.test.TestGroup.RequiredGroup} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestGroup.RequiredGroup, 2, 1)); +}; + + +/** + * @param {!proto.jspb.test.TestGroup.RequiredGroup} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setRequiredGroup = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearRequiredGroup = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasRequiredGroup = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional group OptionalGroup = 3; + * @return {?proto.jspb.test.TestGroup.OptionalGroup} + */ +proto.jspb.test.TestGroup.prototype.getOptionalGroup = function() { + return /** @type{?proto.jspb.test.TestGroup.OptionalGroup} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestGroup.OptionalGroup, 3)); +}; + + +/** + * @param {?proto.jspb.test.TestGroup.OptionalGroup|undefined} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setOptionalGroup = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearOptionalGroup = function() { + return this.setOptionalGroup(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasOptionalGroup = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional string id = 4; + * @return {string} + */ +proto.jspb.test.TestGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearId = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasId = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * required Simple2 required_simple = 5; + * @return {!proto.jspb.test.Simple2} + */ +proto.jspb.test.TestGroup.prototype.getRequiredSimple = function() { + return /** @type{!proto.jspb.test.Simple2} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Simple2, 5, 1)); +}; + + +/** + * @param {!proto.jspb.test.Simple2} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setRequiredSimple = function(value) { + return jspb.Message.setWrapperField(this, 5, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearRequiredSimple = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasRequiredSimple = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional Simple2 optional_simple = 6; + * @return {?proto.jspb.test.Simple2} + */ +proto.jspb.test.TestGroup.prototype.getOptionalSimple = function() { + return /** @type{?proto.jspb.test.Simple2} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Simple2, 6)); +}; + + +/** + * @param {?proto.jspb.test.Simple2|undefined} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setOptionalSimple = function(value) { + return jspb.Message.setWrapperField(this, 6, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearOptionalSimple = function() { + return this.setOptionalSimple(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasOptionalSimple = function() { + return jspb.Message.getField(this, 6) != null; +}; + + + + + +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.jspb.test.TestGroup1.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup1.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.jspb.test.TestGroup1} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup1.toObject = function(includeInstance, msg) { + var f, obj = { +group: (f = msg.getGroup()) && proto.jspb.test.TestGroup.RepeatedGroup.toObject(includeInstance, 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.jspb.test.TestGroup1} + */ +proto.jspb.test.TestGroup1.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup1; + return proto.jspb.test.TestGroup1.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup1} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup1} + */ +proto.jspb.test.TestGroup1.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.jspb.test.TestGroup.RepeatedGroup; + reader.readMessage(value,proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader); + msg.setGroup(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup1.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup1.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup1} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup1.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getGroup(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter + ); + } +}; + + +/** + * optional TestGroup.RepeatedGroup group = 1; + * @return {?proto.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup1.prototype.getGroup = function() { + return /** @type{?proto.jspb.test.TestGroup.RepeatedGroup} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestGroup.RepeatedGroup, 1)); +}; + + +/** + * @param {?proto.jspb.test.TestGroup.RepeatedGroup|undefined} value + * @return {!proto.jspb.test.TestGroup1} returns this +*/ +proto.jspb.test.TestGroup1.prototype.setGroup = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup1} returns this + */ +proto.jspb.test.TestGroup1.prototype.clearGroup = function() { + return this.setGroup(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup1.prototype.hasGroup = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.TestReservedNames.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestReservedNames.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.jspb.test.TestReservedNames} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNames.toObject = function(includeInstance, msg) { + var f, obj = { +extension: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestReservedNames.extensions, proto.jspb.test.TestReservedNames.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestReservedNames} + */ +proto.jspb.test.TestReservedNames.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestReservedNames; + return proto.jspb.test.TestReservedNames.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestReservedNames} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestReservedNames} + */ +proto.jspb.test.TestReservedNames.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setExtension$(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestReservedNames.extensionsBinary, + proto.jspb.test.TestReservedNames.prototype.getExtension, + proto.jspb.test.TestReservedNames.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestReservedNames.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestReservedNames.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestReservedNames} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNames.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestReservedNames.extensionsBinary, proto.jspb.test.TestReservedNames.prototype.getExtension); +}; + + +/** + * optional int32 extension = 1; + * @return {number} + */ +proto.jspb.test.TestReservedNames.prototype.getExtension$ = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestReservedNames} returns this + */ +proto.jspb.test.TestReservedNames.prototype.setExtension$ = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestReservedNames} returns this + */ +proto.jspb.test.TestReservedNames.prototype.clearExtension$ = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestReservedNames.prototype.hasExtension$ = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.TestReservedNamesExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestReservedNamesExtension.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.jspb.test.TestReservedNamesExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNamesExtension.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestReservedNamesExtension} + */ +proto.jspb.test.TestReservedNamesExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestReservedNamesExtension; + return proto.jspb.test.TestReservedNamesExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestReservedNamesExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestReservedNamesExtension} + */ +proto.jspb.test.TestReservedNamesExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestReservedNamesExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestReservedNamesExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestReservedNamesExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNamesExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `foo`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.TestReservedNamesExtension.foo = new jspb.ExtensionFieldInfo( + 10, + {foo: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.TestReservedNames.extensionsBinary[10] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.TestReservedNamesExtension.foo, + jspb.BinaryReader.prototype.readInt32, + jspb.BinaryWriter.prototype.writeInt32, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestReservedNames.extensions[10] = proto.jspb.test.TestReservedNamesExtension.foo; + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestMessageWithOneof.repeatedFields_ = [9]; + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.jspb.test.TestMessageWithOneof.oneofGroups_ = [[3,5],[6,7],[10,11],[12,13]]; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.PartialOneofCase = { + PARTIAL_ONEOF_NOT_SET: 0, + PONE: 3, + PTHREE: 5 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.PartialOneofCase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getPartialOneofCase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.PartialOneofCase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0])); +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase = { + RECURSIVE_ONEOF_NOT_SET: 0, + RONE: 6, + RTWO: 7 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRecursiveOneofCase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1])); +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.DefaultOneofACase = { + DEFAULT_ONEOF_A_NOT_SET: 0, + AONE: 10, + ATWO: 11 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.DefaultOneofACase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getDefaultOneofACase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.DefaultOneofACase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2])); +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase = { + DEFAULT_ONEOF_B_NOT_SET: 0, + BONE: 12, + BTWO: 13 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getDefaultOneofBCase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3])); +}; + + + +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.jspb.test.TestMessageWithOneof.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestMessageWithOneof.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.jspb.test.TestMessageWithOneof} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMessageWithOneof.toObject = function(includeInstance, msg) { + var f, obj = { +pone: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f, +pthree: (f = jspb.Message.getField(msg, 5)) == null ? undefined : f, +rone: (f = msg.getRone()) && proto.jspb.test.TestMessageWithOneof.toObject(includeInstance, f), +rtwo: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f, +normalField: (f = jspb.Message.getBooleanField(msg, 8)) == null ? undefined : f, +repeatedFieldList: (f = jspb.Message.getRepeatedField(msg, 9)) == null ? undefined : f, +aone: jspb.Message.getFieldWithDefault(msg, 10, 1234), +atwo: (f = jspb.Message.getField(msg, 11)) == null ? undefined : f, +bone: (f = jspb.Message.getField(msg, 12)) == null ? undefined : f, +btwo: jspb.Message.getFieldWithDefault(msg, 13, 1234) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestMessageWithOneof} + */ +proto.jspb.test.TestMessageWithOneof.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestMessageWithOneof; + return proto.jspb.test.TestMessageWithOneof.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestMessageWithOneof} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestMessageWithOneof} + */ +proto.jspb.test.TestMessageWithOneof.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setPone(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setPthree(value); + break; + case 6: + var value = new proto.jspb.test.TestMessageWithOneof; + reader.readMessage(value,proto.jspb.test.TestMessageWithOneof.deserializeBinaryFromReader); + msg.setRone(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setRtwo(value); + break; + case 8: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setNormalField(value); + break; + case 9: + var value = /** @type {string} */ (reader.readString()); + msg.addRepeatedField(value); + break; + case 10: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAone(value); + break; + case 11: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAtwo(value); + break; + case 12: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBone(value); + break; + case 13: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBtwo(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestMessageWithOneof.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestMessageWithOneof.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestMessageWithOneof} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMessageWithOneof.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeString( + 5, + f + ); + } + f = message.getRone(); + if (f != null) { + writer.writeMessage( + 6, + f, + proto.jspb.test.TestMessageWithOneof.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeString( + 7, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeBool( + 8, + f + ); + } + f = message.getRepeatedFieldList(); + if (f.length > 0) { + writer.writeRepeatedString( + 9, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 10)); + if (f != null) { + writer.writeInt32( + 10, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 11)); + if (f != null) { + writer.writeInt32( + 11, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 12)); + if (f != null) { + writer.writeInt32( + 12, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 13)); + if (f != null) { + writer.writeInt32( + 13, + f + ); + } +}; + + +/** + * optional string pone = 3; + * @return {string} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getPone = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setPone = function(value) { + return jspb.Message.setOneofField(this, 3, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearPone = function() { + return jspb.Message.setOneofField(this, 3, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasPone = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional string pthree = 5; + * @return {string} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getPthree = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setPthree = function(value) { + return jspb.Message.setOneofField(this, 5, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearPthree = function() { + return jspb.Message.setOneofField(this, 5, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasPthree = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional TestMessageWithOneof rone = 6; + * @return {?proto.jspb.test.TestMessageWithOneof} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRone = function() { + return /** @type{?proto.jspb.test.TestMessageWithOneof} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestMessageWithOneof, 6)); +}; + + +/** + * @param {?proto.jspb.test.TestMessageWithOneof|undefined} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this +*/ +proto.jspb.test.TestMessageWithOneof.prototype.setRone = function(value) { + return jspb.Message.setOneofWrapperField(this, 6, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearRone = function() { + return this.setRone(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasRone = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional string rtwo = 7; + * @return {string} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRtwo = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setRtwo = function(value) { + return jspb.Message.setOneofField(this, 7, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearRtwo = function() { + return jspb.Message.setOneofField(this, 7, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasRtwo = function() { + return jspb.Message.getField(this, 7) != null; +}; + + +/** + * optional bool normal_field = 8; + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getNormalField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setNormalField = function(value) { + return jspb.Message.setField(this, 8, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearNormalField = function() { + return jspb.Message.setField(this, 8, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasNormalField = function() { + return jspb.Message.getField(this, 8) != null; +}; + + +/** + * repeated string repeated_field = 9; + * @return {!Array} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRepeatedFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 9)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setRepeatedFieldList = function(value) { + return jspb.Message.setField(this, 9, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.addRepeatedField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 9, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearRepeatedFieldList = function() { + return this.setRepeatedFieldList([]); +}; + + +/** + * optional int32 aone = 10; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getAone = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 10, 1234)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setAone = function(value) { + return jspb.Message.setOneofField(this, 10, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearAone = function() { + return jspb.Message.setOneofField(this, 10, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasAone = function() { + return jspb.Message.getField(this, 10) != null; +}; + + +/** + * optional int32 atwo = 11; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getAtwo = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 11, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setAtwo = function(value) { + return jspb.Message.setOneofField(this, 11, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearAtwo = function() { + return jspb.Message.setOneofField(this, 11, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasAtwo = function() { + return jspb.Message.getField(this, 11) != null; +}; + + +/** + * optional int32 bone = 12; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getBone = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 12, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setBone = function(value) { + return jspb.Message.setOneofField(this, 12, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearBone = function() { + return jspb.Message.setOneofField(this, 12, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasBone = function() { + return jspb.Message.getField(this, 12) != null; +}; + + +/** + * optional int32 btwo = 13; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getBtwo = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 13, 1234)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setBtwo = function(value) { + return jspb.Message.setOneofField(this, 13, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearBtwo = function() { + return jspb.Message.setOneofField(this, 13, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasBtwo = function() { + return jspb.Message.getField(this, 13) != null; +}; + + + + + +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.jspb.test.TestEndsWithBytes.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestEndsWithBytes.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.jspb.test.TestEndsWithBytes} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestEndsWithBytes.toObject = function(includeInstance, msg) { + var f, obj = { +value: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestEndsWithBytes} + */ +proto.jspb.test.TestEndsWithBytes.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestEndsWithBytes; + return proto.jspb.test.TestEndsWithBytes.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestEndsWithBytes} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestEndsWithBytes} + */ +proto.jspb.test.TestEndsWithBytes.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setValue(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestEndsWithBytes.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestEndsWithBytes.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestEndsWithBytes} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestEndsWithBytes.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBytes( + 2, + f + ); + } +}; + + +/** + * optional int32 value = 1; + * @return {number} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getValue = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.setValue = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.clearValue = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestEndsWithBytes.prototype.hasValue = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bytes data = 2; + * @return {!(string|Uint8Array)} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes data = 2; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.setData = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.clearData = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestEndsWithBytes.prototype.hasData = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +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.jspb.test.TestLastFieldBeforePivot.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestLastFieldBeforePivot.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.jspb.test.TestLastFieldBeforePivot} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestLastFieldBeforePivot.toObject = function(includeInstance, msg) { + var f, obj = { +lastFieldBeforePivot: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestLastFieldBeforePivot.extensions, proto.jspb.test.TestLastFieldBeforePivot.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} + */ +proto.jspb.test.TestLastFieldBeforePivot.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestLastFieldBeforePivot; + return proto.jspb.test.TestLastFieldBeforePivot.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestLastFieldBeforePivot} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} + */ +proto.jspb.test.TestLastFieldBeforePivot.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setLastFieldBeforePivot(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary, + proto.jspb.test.TestLastFieldBeforePivot.prototype.getExtension, + proto.jspb.test.TestLastFieldBeforePivot.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestLastFieldBeforePivot.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestLastFieldBeforePivot} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestLastFieldBeforePivot.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary, proto.jspb.test.TestLastFieldBeforePivot.prototype.getExtension); +}; + + +/** + * optional int32 last_field_before_pivot = 1; + * @return {number} + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.getLastFieldBeforePivot = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestLastFieldBeforePivot} returns this + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.setLastFieldBeforePivot = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} returns this + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.clearLastFieldBeforePivot = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.hasLastFieldBeforePivot = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.Int64Types.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Int64Types.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.jspb.test.Int64Types} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Int64Types.toObject = function(includeInstance, msg) { + var f, obj = { +int64Normal: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +int64String: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +int64Number: (f = jspb.Message.getField(msg, 3)) == 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.jspb.test.Int64Types} + */ +proto.jspb.test.Int64Types.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Int64Types; + return proto.jspb.test.Int64Types.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Int64Types} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Int64Types} + */ +proto.jspb.test.Int64Types.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setInt64Normal(value); + break; + case 2: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setInt64String(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint64()); + msg.setInt64Number(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Int64Types.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Int64Types.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Int64Types} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Int64Types.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt64( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeSint64String( + 2, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeUint64( + 3, + f + ); + } +}; + + +/** + * optional int64 int64_normal = 1; + * @return {number} + */ +proto.jspb.test.Int64Types.prototype.getInt64Normal = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.setInt64Normal = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.clearInt64Normal = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Int64Types.prototype.hasInt64Normal = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional sint64 int64_string = 2; + * @return {string} + */ +proto.jspb.test.Int64Types.prototype.getInt64String = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.setInt64String = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.clearInt64String = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Int64Types.prototype.hasInt64String = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional uint64 int64_number = 3; + * @return {number} + */ +proto.jspb.test.Int64Types.prototype.getInt64Number = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.setInt64Number = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.clearInt64Number = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Int64Types.prototype.hasInt64Number = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +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.jspb.test.TestMapFieldsNoBinary.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestMapFieldsNoBinary.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.jspb.test.TestMapFieldsNoBinary} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMapFieldsNoBinary.toObject = function(includeInstance, msg) { + var f, obj = { +mapStringStringMap: (f = msg.getMapStringStringMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringInt32Map: (f = msg.getMapStringInt32Map()) ? f.toObject(includeInstance, undefined) : [], +mapStringInt64Map: (f = msg.getMapStringInt64Map()) ? f.toObject(includeInstance, undefined) : [], +mapStringBoolMap: (f = msg.getMapStringBoolMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringDoubleMap: (f = msg.getMapStringDoubleMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringEnumMap: (f = msg.getMapStringEnumMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringMsgMap: (f = msg.getMapStringMsgMap()) ? f.toObject(includeInstance, proto.jspb.test.MapValueMessageNoBinary.toObject) : [], +mapInt32StringMap: (f = msg.getMapInt32StringMap()) ? f.toObject(includeInstance, undefined) : [], +mapInt64StringMap: (f = msg.getMapInt64StringMap()) ? f.toObject(includeInstance, undefined) : [], +mapBoolStringMap: (f = msg.getMapBoolStringMap()) ? f.toObject(includeInstance, undefined) : [], +testMapFields: (f = msg.getTestMapFields()) && proto.jspb.test.TestMapFieldsNoBinary.toObject(includeInstance, f), +mapStringTestmapfieldsMap: (f = msg.getMapStringTestmapfieldsMap()) ? f.toObject(includeInstance, proto.jspb.test.TestMapFieldsNoBinary.toObject) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} + */ +proto.jspb.test.TestMapFieldsNoBinary.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestMapFieldsNoBinary; + return proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestMapFieldsNoBinary} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} + */ +proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = msg.getMapStringStringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 2: + var value = msg.getMapStringInt32Map(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readInt32, null, "", 0); + }); + break; + case 3: + var value = msg.getMapStringInt64Map(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readInt64, null, "", 0); + }); + break; + case 4: + var value = msg.getMapStringBoolMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readBool, null, "", false); + }); + break; + case 5: + var value = msg.getMapStringDoubleMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readDouble, null, "", 0.0); + }); + break; + case 6: + var value = msg.getMapStringEnumMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readEnum, null, "", 0); + }); + break; + case 7: + var value = msg.getMapStringMsgMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.jspb.test.MapValueMessageNoBinary.deserializeBinaryFromReader, "", new proto.jspb.test.MapValueMessageNoBinary()); + }); + break; + case 8: + var value = msg.getMapInt32StringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt32, jspb.BinaryReader.prototype.readString, null, 0, ""); + }); + break; + case 9: + var value = msg.getMapInt64StringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt64, jspb.BinaryReader.prototype.readString, null, 0, ""); + }); + break; + case 10: + var value = msg.getMapBoolStringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readBool, jspb.BinaryReader.prototype.readString, null, false, ""); + }); + break; + case 11: + var value = new proto.jspb.test.TestMapFieldsNoBinary; + reader.readMessage(value,proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader); + msg.setTestMapFields(value); + break; + case 12: + var value = msg.getMapStringTestmapfieldsMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader, "", new proto.jspb.test.TestMapFieldsNoBinary()); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestMapFieldsNoBinary} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMapStringStringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapStringInt32Map(true); + if (f && f.getLength() > 0) { + f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeInt32); + } + f = message.getMapStringInt64Map(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeInt64); + } + f = message.getMapStringBoolMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeBool); + } + f = message.getMapStringDoubleMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeDouble); + } + f = message.getMapStringEnumMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeEnum); + } + f = message.getMapStringMsgMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(7, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.jspb.test.MapValueMessageNoBinary.serializeBinaryToWriter); + } + f = message.getMapInt32StringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(8, writer, jspb.BinaryWriter.prototype.writeInt32, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapInt64StringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(9, writer, jspb.BinaryWriter.prototype.writeInt64, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapBoolStringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(10, writer, jspb.BinaryWriter.prototype.writeBool, jspb.BinaryWriter.prototype.writeString); + } + f = message.getTestMapFields(); + if (f != null) { + writer.writeMessage( + 11, + f, + proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter + ); + } + f = message.getMapStringTestmapfieldsMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(12, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter); + } +}; + + +/** + * map map_string_string = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringStringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringStringMap = function() { + this.getMapStringStringMap().clear(); + return this; +}; + + +/** + * map map_string_int32 = 2; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringInt32Map = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 2, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringInt32Map = function() { + this.getMapStringInt32Map().clear(); + return this; +}; + + +/** + * map map_string_int64 = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringInt64Map = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringInt64Map = function() { + this.getMapStringInt64Map().clear(); + return this; +}; + + +/** + * map map_string_bool = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringBoolMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringBoolMap = function() { + this.getMapStringBoolMap().clear(); + return this; +}; + + +/** + * map map_string_double = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringDoubleMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringDoubleMap = function() { + this.getMapStringDoubleMap().clear(); + return this; +}; + + +/** + * map map_string_enum = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringEnumMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringEnumMap = function() { + this.getMapStringEnumMap().clear(); + return this; +}; + + +/** + * map map_string_msg = 7; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringMsgMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 7, opt_noLazyCreate, + proto.jspb.test.MapValueMessageNoBinary)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringMsgMap = function() { + this.getMapStringMsgMap().clear(); + return this; +}; + + +/** + * map map_int32_string = 8; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapInt32StringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 8, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapInt32StringMap = function() { + this.getMapInt32StringMap().clear(); + return this; +}; + + +/** + * map map_int64_string = 9; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapInt64StringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 9, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapInt64StringMap = function() { + this.getMapInt64StringMap().clear(); + return this; +}; + + +/** + * map map_bool_string = 10; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapBoolStringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 10, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapBoolStringMap = function() { + this.getMapBoolStringMap().clear(); + return this; +}; + + +/** + * optional TestMapFieldsNoBinary test_map_fields = 11; + * @return {?proto.jspb.test.TestMapFieldsNoBinary} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getTestMapFields = function() { + return /** @type{?proto.jspb.test.TestMapFieldsNoBinary} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestMapFieldsNoBinary, 11)); +}; + + +/** + * @param {?proto.jspb.test.TestMapFieldsNoBinary|undefined} value + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this +*/ +proto.jspb.test.TestMapFieldsNoBinary.prototype.setTestMapFields = function(value) { + return jspb.Message.setWrapperField(this, 11, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearTestMapFields = function() { + return this.setTestMapFields(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.hasTestMapFields = function() { + return jspb.Message.getField(this, 11) != null; +}; + + +/** + * map map_string_testmapfields = 12; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringTestmapfieldsMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 12, opt_noLazyCreate, + proto.jspb.test.TestMapFieldsNoBinary)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringTestmapfieldsMap = function() { + this.getMapStringTestmapfieldsMap().clear(); + return this; +}; + + + + + +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.jspb.test.MapValueMessageNoBinary.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.MapValueMessageNoBinary.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.jspb.test.MapValueMessageNoBinary} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MapValueMessageNoBinary.toObject = function(includeInstance, msg) { + var f, obj = { +foo: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.MapValueMessageNoBinary} + */ +proto.jspb.test.MapValueMessageNoBinary.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.MapValueMessageNoBinary; + return proto.jspb.test.MapValueMessageNoBinary.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.MapValueMessageNoBinary} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.MapValueMessageNoBinary} + */ +proto.jspb.test.MapValueMessageNoBinary.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setFoo(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.MapValueMessageNoBinary.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.MapValueMessageNoBinary} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MapValueMessageNoBinary.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 foo = 1; + * @return {number} + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.getFoo = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.MapValueMessageNoBinary} returns this + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.setFoo = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.MapValueMessageNoBinary} returns this + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.clearFoo = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.hasFoo = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.Deeply.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Deeply.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.jspb.test.Deeply} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply} + */ +proto.jspb.test.Deeply.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Deeply; + return proto.jspb.test.Deeply.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply} + */ +proto.jspb.test.Deeply.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Deeply.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Deeply.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.Deeply.Nested.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Deeply.Nested.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.jspb.test.Deeply.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply.Nested} + */ +proto.jspb.test.Deeply.Nested.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Deeply.Nested; + return proto.jspb.test.Deeply.Nested.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply.Nested} + */ +proto.jspb.test.Deeply.Nested.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Deeply.Nested.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Deeply.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.Deeply.Nested.Message.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Deeply.Nested.Message.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.jspb.test.Deeply.Nested.Message} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.Message.toObject = function(includeInstance, msg) { + var f, obj = { +count: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.Deeply.Nested.Message} + */ +proto.jspb.test.Deeply.Nested.Message.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Deeply.Nested.Message; + return proto.jspb.test.Deeply.Nested.Message.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply.Nested.Message} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply.Nested.Message} + */ +proto.jspb.test.Deeply.Nested.Message.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Deeply.Nested.Message.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Deeply.Nested.Message.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply.Nested.Message} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.Message.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 count = 1; + * @return {number} + */ +proto.jspb.test.Deeply.Nested.Message.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Deeply.Nested.Message} returns this + */ +proto.jspb.test.Deeply.Nested.Message.prototype.setCount = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Deeply.Nested.Message} returns this + */ +proto.jspb.test.Deeply.Nested.Message.prototype.clearCount = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Deeply.Nested.Message.prototype.hasCount = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * @enum {number} + */ +proto.jspb.test.OuterEnum = { + FOO: 1, + BAR: 2 +}; + +/** + * @enum {number} + */ +proto.jspb.test.MapValueEnumNoBinary = { + MAP_VALUE_FOO_NOBINARY: 0, + MAP_VALUE_BAR_NOBINARY: 1, + MAP_VALUE_BAZ_NOBINARY: 2 +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestAllowAliasEnum = { + TEST_ALLOW_ALIAS_DEFAULT: 0, + VALUE1: 1 +}; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `simple1`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.simple1 = new jspb.ExtensionFieldInfo( + 105, + {simple1: 0}, + proto.jspb.test.Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.Simple1.toObject), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[105] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.simple1, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.Simple1.serializeBinaryToWriter, + proto.jspb.test.Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[105] = proto.jspb.test.simple1; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extendTestLastFieldBeforePivotField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.extendTestLastFieldBeforePivotField = new jspb.ExtensionFieldInfo( + 101, + {extendTestLastFieldBeforePivotField: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.extendTestLastFieldBeforePivotField, + jspb.BinaryReader.prototype.readInt32, + jspb.BinaryWriter.prototype.writeInt32, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestLastFieldBeforePivot.extensions[101] = proto.jspb.test.extendTestLastFieldBeforePivotField; + diff --git a/example/test.closure-old.js b/example/test.closure-old.js new file mode 100644 index 0000000..7610c51 --- /dev/null +++ b/example/test.closure-old.js @@ -0,0 +1,9724 @@ +// source: protos/test.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + + +goog.provide('proto.jspb.test.BooleanFields'); +goog.provide('proto.jspb.test.CloneExtension'); +goog.provide('proto.jspb.test.Complex'); +goog.provide('proto.jspb.test.Complex.Nested'); +goog.provide('proto.jspb.test.Deeply'); +goog.provide('proto.jspb.test.Deeply.Nested'); +goog.provide('proto.jspb.test.Deeply.Nested.Message'); +goog.provide('proto.jspb.test.DefaultValues'); +goog.provide('proto.jspb.test.DefaultValues.Enum'); +goog.provide('proto.jspb.test.Empty'); +goog.provide('proto.jspb.test.EnumContainer'); +goog.provide('proto.jspb.test.FloatingPointFields'); +goog.provide('proto.jspb.test.HasExtensions'); +goog.provide('proto.jspb.test.IndirectExtension'); +goog.provide('proto.jspb.test.Int64Types'); +goog.provide('proto.jspb.test.IsExtension'); +goog.provide('proto.jspb.test.MapValueEnumNoBinary'); +goog.provide('proto.jspb.test.MapValueMessageNoBinary'); +goog.provide('proto.jspb.test.MineField'); +goog.provide('proto.jspb.test.OptionalFields'); +goog.provide('proto.jspb.test.OptionalFields.Nested'); +goog.provide('proto.jspb.test.OuterEnum'); +goog.provide('proto.jspb.test.OuterMessage'); +goog.provide('proto.jspb.test.OuterMessage.Complex'); +goog.provide('proto.jspb.test.Simple1'); +goog.provide('proto.jspb.test.Simple2'); +goog.provide('proto.jspb.test.SpecialCases'); +goog.provide('proto.jspb.test.TestAllowAliasEnum'); +goog.provide('proto.jspb.test.TestClone'); +goog.provide('proto.jspb.test.TestCloneExtension'); +goog.provide('proto.jspb.test.TestEndsWithBytes'); +goog.provide('proto.jspb.test.TestGroup'); +goog.provide('proto.jspb.test.TestGroup.OptionalGroup'); +goog.provide('proto.jspb.test.TestGroup.RepeatedGroup'); +goog.provide('proto.jspb.test.TestGroup.RequiredGroup'); +goog.provide('proto.jspb.test.TestGroup1'); +goog.provide('proto.jspb.test.TestLastFieldBeforePivot'); +goog.provide('proto.jspb.test.TestMapFieldsNoBinary'); +goog.provide('proto.jspb.test.TestMessageWithOneof'); +goog.provide('proto.jspb.test.TestMessageWithOneof.DefaultOneofACase'); +goog.provide('proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase'); +goog.provide('proto.jspb.test.TestMessageWithOneof.PartialOneofCase'); +goog.provide('proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase'); +goog.provide('proto.jspb.test.TestReservedNames'); +goog.provide('proto.jspb.test.TestReservedNamesExtension'); +goog.provide('proto.jspb.test.extendTestLastFieldBeforePivotField'); +goog.provide('proto.jspb.test.simple1'); + +goog.require('jspb.BinaryReader'); +goog.require('jspb.BinaryWriter'); +goog.require('jspb.ExtensionFieldBinaryInfo'); +goog.require('jspb.ExtensionFieldInfo'); +goog.require('jspb.Map'); +goog.require('jspb.Message'); + +/** + * 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.jspb.test.Empty = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Empty, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Empty.displayName = 'proto.jspb.test.Empty'; +} +/** + * 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.jspb.test.EnumContainer = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.EnumContainer, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.EnumContainer.displayName = 'proto.jspb.test.EnumContainer'; +} +/** + * 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.jspb.test.Simple1 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.Simple1.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.Simple1, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Simple1.displayName = 'proto.jspb.test.Simple1'; +} +/** + * 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.jspb.test.Simple2 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.Simple2.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.Simple2, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Simple2.displayName = 'proto.jspb.test.Simple2'; +} +/** + * 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.jspb.test.SpecialCases = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.SpecialCases, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.SpecialCases.displayName = 'proto.jspb.test.SpecialCases'; +} +/** + * 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.jspb.test.OptionalFields = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.OptionalFields.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.OptionalFields, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OptionalFields.displayName = 'proto.jspb.test.OptionalFields'; +} +/** + * 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.jspb.test.OptionalFields.Nested = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.OptionalFields.Nested, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OptionalFields.Nested.displayName = 'proto.jspb.test.OptionalFields.Nested'; +} +/** + * 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.jspb.test.HasExtensions = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 4, null, null); +}; +goog.inherits(proto.jspb.test.HasExtensions, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.HasExtensions.displayName = 'proto.jspb.test.HasExtensions'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.HasExtensions.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.HasExtensions.extensionsBinary = {}; + +/** + * 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.jspb.test.Complex = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.Complex.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.Complex, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Complex.displayName = 'proto.jspb.test.Complex'; +} +/** + * 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.jspb.test.Complex.Nested = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Complex.Nested, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Complex.Nested.displayName = 'proto.jspb.test.Complex.Nested'; +} +/** + * 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.jspb.test.OuterMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.OuterMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OuterMessage.displayName = 'proto.jspb.test.OuterMessage'; +} +/** + * 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.jspb.test.OuterMessage.Complex = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.OuterMessage.Complex, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.OuterMessage.Complex.displayName = 'proto.jspb.test.OuterMessage.Complex'; +} +/** + * 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.jspb.test.MineField = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.MineField, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.MineField.displayName = 'proto.jspb.test.MineField'; +} +/** + * 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.jspb.test.IsExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.IsExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.IsExtension.displayName = 'proto.jspb.test.IsExtension'; +} +/** + * 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.jspb.test.IndirectExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.IndirectExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.IndirectExtension.displayName = 'proto.jspb.test.IndirectExtension'; +} +/** + * 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.jspb.test.DefaultValues = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.DefaultValues, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.DefaultValues.displayName = 'proto.jspb.test.DefaultValues'; +} +/** + * 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.jspb.test.FloatingPointFields = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.FloatingPointFields.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.FloatingPointFields, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.FloatingPointFields.displayName = 'proto.jspb.test.FloatingPointFields'; +} +/** + * 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.jspb.test.BooleanFields = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.BooleanFields.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.BooleanFields, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.BooleanFields.displayName = 'proto.jspb.test.BooleanFields'; +} +/** + * 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.jspb.test.TestClone = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 8, proto.jspb.test.TestClone.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.TestClone, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestClone.displayName = 'proto.jspb.test.TestClone'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestClone.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestClone.extensionsBinary = {}; + +/** + * 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.jspb.test.TestCloneExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestCloneExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestCloneExtension.displayName = 'proto.jspb.test.TestCloneExtension'; +} +/** + * 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.jspb.test.CloneExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.CloneExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.CloneExtension.displayName = 'proto.jspb.test.CloneExtension'; +} +/** + * 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.jspb.test.TestGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.TestGroup.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.TestGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.displayName = 'proto.jspb.test.TestGroup'; +} +/** + * 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.jspb.test.TestGroup.RepeatedGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.TestGroup.RepeatedGroup.repeatedFields_, null); +}; +goog.inherits(proto.jspb.test.TestGroup.RepeatedGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.RepeatedGroup.displayName = 'proto.jspb.test.TestGroup.RepeatedGroup'; +} +/** + * 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.jspb.test.TestGroup.RequiredGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestGroup.RequiredGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.RequiredGroup.displayName = 'proto.jspb.test.TestGroup.RequiredGroup'; +} +/** + * 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.jspb.test.TestGroup.OptionalGroup = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestGroup.OptionalGroup, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup.OptionalGroup.displayName = 'proto.jspb.test.TestGroup.OptionalGroup'; +} +/** + * 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.jspb.test.TestGroup1 = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestGroup1, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestGroup1.displayName = 'proto.jspb.test.TestGroup1'; +} +/** + * 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.jspb.test.TestReservedNames = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); +}; +goog.inherits(proto.jspb.test.TestReservedNames, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestReservedNames.displayName = 'proto.jspb.test.TestReservedNames'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestReservedNames.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestReservedNames.extensionsBinary = {}; + +/** + * 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.jspb.test.TestReservedNamesExtension = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestReservedNamesExtension, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestReservedNamesExtension.displayName = 'proto.jspb.test.TestReservedNamesExtension'; +} +/** + * 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.jspb.test.TestMessageWithOneof = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, proto.jspb.test.TestMessageWithOneof.repeatedFields_, proto.jspb.test.TestMessageWithOneof.oneofGroups_); +}; +goog.inherits(proto.jspb.test.TestMessageWithOneof, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestMessageWithOneof.displayName = 'proto.jspb.test.TestMessageWithOneof'; +} +/** + * 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.jspb.test.TestEndsWithBytes = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestEndsWithBytes, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestEndsWithBytes.displayName = 'proto.jspb.test.TestEndsWithBytes'; +} +/** + * 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.jspb.test.TestLastFieldBeforePivot = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); +}; +goog.inherits(proto.jspb.test.TestLastFieldBeforePivot, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestLastFieldBeforePivot.displayName = 'proto.jspb.test.TestLastFieldBeforePivot'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestLastFieldBeforePivot.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary = {}; + +/** + * 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.jspb.test.Int64Types = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Int64Types, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Int64Types.displayName = 'proto.jspb.test.Int64Types'; +} +/** + * 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.jspb.test.TestMapFieldsNoBinary = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.TestMapFieldsNoBinary, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestMapFieldsNoBinary.displayName = 'proto.jspb.test.TestMapFieldsNoBinary'; +} +/** + * 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.jspb.test.MapValueMessageNoBinary = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.MapValueMessageNoBinary, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.MapValueMessageNoBinary.displayName = 'proto.jspb.test.MapValueMessageNoBinary'; +} +/** + * 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.jspb.test.Deeply = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Deeply, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Deeply.displayName = 'proto.jspb.test.Deeply'; +} +/** + * 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.jspb.test.Deeply.Nested = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Deeply.Nested, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Deeply.Nested.displayName = 'proto.jspb.test.Deeply.Nested'; +} +/** + * 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.jspb.test.Deeply.Nested.Message = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.Deeply.Nested.Message, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.Deeply.Nested.Message.displayName = 'proto.jspb.test.Deeply.Nested.Message'; +} + + + +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.jspb.test.Empty.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Empty.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.jspb.test.Empty} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Empty.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Empty} + */ +proto.jspb.test.Empty.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Empty; + return proto.jspb.test.Empty.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Empty} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Empty} + */ +proto.jspb.test.Empty.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Empty.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Empty.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Empty} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Empty.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.EnumContainer.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.EnumContainer.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.jspb.test.EnumContainer} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.EnumContainer.toObject = function(includeInstance, msg) { + var f, obj = { +outerEnum: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.EnumContainer} + */ +proto.jspb.test.EnumContainer.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.EnumContainer; + return proto.jspb.test.EnumContainer.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.EnumContainer} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.EnumContainer} + */ +proto.jspb.test.EnumContainer.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.jspb.test.OuterEnum} */ (reader.readEnum()); + msg.setOuterEnum(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.EnumContainer.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.EnumContainer.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.EnumContainer} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.EnumContainer.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {!proto.jspb.test.OuterEnum} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeEnum( + 1, + f + ); + } +}; + + +/** + * optional OuterEnum outer_enum = 1; + * @return {!proto.jspb.test.OuterEnum} + */ +proto.jspb.test.EnumContainer.prototype.getOuterEnum = function() { + return /** @type {!proto.jspb.test.OuterEnum} */ (jspb.Message.getFieldWithDefault(this, 1, 1)); +}; + + +/** + * @param {!proto.jspb.test.OuterEnum} value + * @return {!proto.jspb.test.EnumContainer} returns this + */ +proto.jspb.test.EnumContainer.prototype.setOuterEnum = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.EnumContainer} returns this + */ +proto.jspb.test.EnumContainer.prototype.clearOuterEnum = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.EnumContainer.prototype.hasOuterEnum = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.Simple1.repeatedFields_ = [2]; + + + +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.jspb.test.Simple1.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Simple1.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.jspb.test.Simple1} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple1.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f, +aBoolean: (f = jspb.Message.getBooleanField(msg, 3)) == 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.jspb.test.Simple1} + */ +proto.jspb.test.Simple1.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Simple1; + return proto.jspb.test.Simple1.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Simple1} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Simple1} + */ +proto.jspb.test.Simple1.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + case 3: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setABoolean(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Simple1.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Simple1.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Simple1} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple1.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeBool( + 3, + f + ); + } +}; + + +/** + * required string a_string = 1; + * @return {string} + */ +proto.jspb.test.Simple1.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Simple1.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * repeated string a_repeated_string = 2; + * @return {!Array} + */ +proto.jspb.test.Simple1.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + +/** + * optional bool a_boolean = 3; + * @return {boolean} + */ +proto.jspb.test.Simple1.prototype.getABoolean = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.setABoolean = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple1} returns this + */ +proto.jspb.test.Simple1.prototype.clearABoolean = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Simple1.prototype.hasABoolean = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.Simple2.repeatedFields_ = [2]; + + + +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.jspb.test.Simple2.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Simple2.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.jspb.test.Simple2} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple2.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aRepeatedStringList: (f = jspb.Message.getRepeatedField(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.jspb.test.Simple2} + */ +proto.jspb.test.Simple2.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Simple2; + return proto.jspb.test.Simple2.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Simple2} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Simple2} + */ +proto.jspb.test.Simple2.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Simple2.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Simple2.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Simple2} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Simple2.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } +}; + + +/** + * required string a_string = 1; + * @return {string} + */ +proto.jspb.test.Simple2.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Simple2.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * repeated string a_repeated_string = 2; + * @return {!Array} + */ +proto.jspb.test.Simple2.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 2, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Simple2} returns this + */ +proto.jspb.test.Simple2.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + + + + +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.jspb.test.SpecialCases.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.SpecialCases.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.jspb.test.SpecialCases} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.SpecialCases.toObject = function(includeInstance, msg) { + var f, obj = { +normal: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +pb_default: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +pb_function: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f, +pb_var: (f = jspb.Message.getField(msg, 4)) == 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.jspb.test.SpecialCases} + */ +proto.jspb.test.SpecialCases.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.SpecialCases; + return proto.jspb.test.SpecialCases.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.SpecialCases} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.SpecialCases} + */ +proto.jspb.test.SpecialCases.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setNormal(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDefault(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setFunction(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setVar(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.SpecialCases.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.SpecialCases.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.SpecialCases} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.SpecialCases.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } +}; + + +/** + * required string normal = 1; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getNormal = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setNormal = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearNormal = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasNormal = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required string default = 2; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getDefault = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setDefault = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearDefault = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasDefault = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * required string function = 3; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getFunction = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setFunction = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearFunction = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasFunction = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * required string var = 4; + * @return {string} + */ +proto.jspb.test.SpecialCases.prototype.getVar = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.setVar = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ +proto.jspb.test.SpecialCases.prototype.clearVar = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.SpecialCases.prototype.hasVar = function() { + return jspb.Message.getField(this, 4) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.OptionalFields.repeatedFields_ = [4,5]; + + + +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.jspb.test.OptionalFields.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OptionalFields.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.jspb.test.OptionalFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aBool: (f = jspb.Message.getBooleanField(msg, 2)) == null ? undefined : f, +aNestedMessage: (f = msg.getANestedMessage()) && proto.jspb.test.OptionalFields.Nested.toObject(includeInstance, f), +aRepeatedMessageList: jspb.Message.toObjectList(msg.getARepeatedMessageList(), + proto.jspb.test.OptionalFields.Nested.toObject, includeInstance), +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 5)) == 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.jspb.test.OptionalFields} + */ +proto.jspb.test.OptionalFields.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OptionalFields; + return proto.jspb.test.OptionalFields.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OptionalFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OptionalFields} + */ +proto.jspb.test.OptionalFields.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setABool(value); + break; + case 3: + var value = new proto.jspb.test.OptionalFields.Nested; + reader.readMessage(value,proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader); + msg.setANestedMessage(value); + break; + case 4: + var value = new proto.jspb.test.OptionalFields.Nested; + reader.readMessage(value,proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader); + msg.addARepeatedMessage(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OptionalFields.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OptionalFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OptionalFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = message.getANestedMessage(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedMessageList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 4, + f, + proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 5, + f + ); + } +}; + + + + + +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.jspb.test.OptionalFields.Nested.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OptionalFields.Nested.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.jspb.test.OptionalFields.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.Nested.toObject = function(includeInstance, msg) { + var f, obj = { +anInt: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.Nested.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OptionalFields.Nested; + return proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OptionalFields.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.Nested.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAnInt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OptionalFields.Nested.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OptionalFields.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OptionalFields.Nested.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 an_int = 1; + * @return {number} + */ +proto.jspb.test.OptionalFields.Nested.prototype.getAnInt = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.OptionalFields.Nested} returns this + */ +proto.jspb.test.OptionalFields.Nested.prototype.setAnInt = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields.Nested} returns this + */ +proto.jspb.test.OptionalFields.Nested.prototype.clearAnInt = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.Nested.prototype.hasAnInt = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string a_string = 1; + * @return {string} + */ +proto.jspb.test.OptionalFields.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required bool a_bool = 2; + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.getABool = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.setABool = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearABool = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.hasABool = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional Nested a_nested_message = 3; + * @return {?proto.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.prototype.getANestedMessage = function() { + return /** @type{?proto.jspb.test.OptionalFields.Nested} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.OptionalFields.Nested, 3)); +}; + + +/** + * @param {?proto.jspb.test.OptionalFields.Nested|undefined} value + * @return {!proto.jspb.test.OptionalFields} returns this +*/ +proto.jspb.test.OptionalFields.prototype.setANestedMessage = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearANestedMessage = function() { + return this.setANestedMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OptionalFields.prototype.hasANestedMessage = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * repeated Nested a_repeated_message = 4; + * @return {!Array} + */ +proto.jspb.test.OptionalFields.prototype.getARepeatedMessageList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.OptionalFields.Nested, 4)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.OptionalFields} returns this +*/ +proto.jspb.test.OptionalFields.prototype.setARepeatedMessageList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 4, value); +}; + + +/** + * @param {!proto.jspb.test.OptionalFields.Nested=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.OptionalFields.Nested} + */ +proto.jspb.test.OptionalFields.prototype.addARepeatedMessage = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 4, opt_value, proto.jspb.test.OptionalFields.Nested, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearARepeatedMessageList = function() { + return this.setARepeatedMessageList([]); +}; + + +/** + * repeated string a_repeated_string = 5; + * @return {!Array} + */ +proto.jspb.test.OptionalFields.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 5, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 5, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.OptionalFields} returns this + */ +proto.jspb.test.OptionalFields.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + + + + +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.jspb.test.HasExtensions.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.HasExtensions.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.jspb.test.HasExtensions} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.HasExtensions.toObject = function(includeInstance, msg) { + var f, obj = { +str1: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +str2: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +str3: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.HasExtensions.extensions, proto.jspb.test.HasExtensions.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.HasExtensions} + */ +proto.jspb.test.HasExtensions.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.HasExtensions; + return proto.jspb.test.HasExtensions.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.HasExtensions} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.HasExtensions} + */ +proto.jspb.test.HasExtensions.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStr1(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setStr2(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setStr3(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.HasExtensions.extensionsBinary, + proto.jspb.test.HasExtensions.prototype.getExtension, + proto.jspb.test.HasExtensions.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.HasExtensions.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.HasExtensions.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.HasExtensions} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.HasExtensions.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.HasExtensions.extensionsBinary, proto.jspb.test.HasExtensions.prototype.getExtension); +}; + + +/** + * optional string str1 = 1; + * @return {string} + */ +proto.jspb.test.HasExtensions.prototype.getStr1 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.setStr1 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.clearStr1 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.HasExtensions.prototype.hasStr1 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional string str2 = 2; + * @return {string} + */ +proto.jspb.test.HasExtensions.prototype.getStr2 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.setStr2 = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.clearStr2 = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.HasExtensions.prototype.hasStr2 = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional string str3 = 3; + * @return {string} + */ +proto.jspb.test.HasExtensions.prototype.getStr3 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.setStr3 = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ +proto.jspb.test.HasExtensions.prototype.clearStr3 = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.HasExtensions.prototype.hasStr3 = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.Complex.repeatedFields_ = [5,7]; + + + +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.jspb.test.Complex.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Complex.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.jspb.test.Complex} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +anOutOfOrderBool: (f = jspb.Message.getBooleanField(msg, 9)) == null ? undefined : f, +aNestedMessage: (f = msg.getANestedMessage()) && proto.jspb.test.Complex.Nested.toObject(includeInstance, f), +aRepeatedMessageList: jspb.Message.toObjectList(msg.getARepeatedMessageList(), + proto.jspb.test.Complex.Nested.toObject, includeInstance), +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 7)) == null ? undefined : f, +aFloatingPointField: (f = jspb.Message.getOptionalFloatingPointField(msg, 10)) == 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.jspb.test.Complex} + */ +proto.jspb.test.Complex.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Complex; + return proto.jspb.test.Complex.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Complex} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Complex} + */ +proto.jspb.test.Complex.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 9: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAnOutOfOrderBool(value); + break; + case 4: + var value = new proto.jspb.test.Complex.Nested; + reader.readMessage(value,proto.jspb.test.Complex.Nested.deserializeBinaryFromReader); + msg.setANestedMessage(value); + break; + case 5: + var value = new proto.jspb.test.Complex.Nested; + reader.readMessage(value,proto.jspb.test.Complex.Nested.deserializeBinaryFromReader); + msg.addARepeatedMessage(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + case 10: + var value = /** @type {number} */ (reader.readDouble()); + msg.setAFloatingPointField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Complex.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Complex.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Complex} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 9)); + if (f != null) { + writer.writeBool( + 9, + f + ); + } + f = message.getANestedMessage(); + if (f != null) { + writer.writeMessage( + 4, + f, + proto.jspb.test.Complex.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedMessageList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + proto.jspb.test.Complex.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 7, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 10)); + if (f != null) { + writer.writeDouble( + 10, + f + ); + } +}; + + + + + +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.jspb.test.Complex.Nested.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Complex.Nested.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.jspb.test.Complex.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.Nested.toObject = function(includeInstance, msg) { + var f, obj = { +anInt: (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.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.Nested.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Complex.Nested; + return proto.jspb.test.Complex.Nested.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Complex.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.Nested.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAnInt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Complex.Nested.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Complex.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Complex.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Complex.Nested.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeInt32( + 2, + f + ); + } +}; + + +/** + * required int32 an_int = 2; + * @return {number} + */ +proto.jspb.test.Complex.Nested.prototype.getAnInt = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Complex.Nested} returns this + */ +proto.jspb.test.Complex.Nested.prototype.setAnInt = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex.Nested} returns this + */ +proto.jspb.test.Complex.Nested.prototype.clearAnInt = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.Nested.prototype.hasAnInt = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * required string a_string = 1; + * @return {string} + */ +proto.jspb.test.Complex.prototype.getAString = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setAString = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearAString = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasAString = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bool an_out_of_order_bool = 9; + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.getAnOutOfOrderBool = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 9, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setAnOutOfOrderBool = function(value) { + return jspb.Message.setField(this, 9, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearAnOutOfOrderBool = function() { + return jspb.Message.setField(this, 9, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasAnOutOfOrderBool = function() { + return jspb.Message.getField(this, 9) != null; +}; + + +/** + * optional Nested a_nested_message = 4; + * @return {?proto.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.prototype.getANestedMessage = function() { + return /** @type{?proto.jspb.test.Complex.Nested} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Complex.Nested, 4)); +}; + + +/** + * @param {?proto.jspb.test.Complex.Nested|undefined} value + * @return {!proto.jspb.test.Complex} returns this +*/ +proto.jspb.test.Complex.prototype.setANestedMessage = function(value) { + return jspb.Message.setWrapperField(this, 4, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearANestedMessage = function() { + return this.setANestedMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasANestedMessage = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * repeated Nested a_repeated_message = 5; + * @return {!Array} + */ +proto.jspb.test.Complex.prototype.getARepeatedMessageList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.Complex.Nested, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Complex} returns this +*/ +proto.jspb.test.Complex.prototype.setARepeatedMessageList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); +}; + + +/** + * @param {!proto.jspb.test.Complex.Nested=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.Complex.Nested} + */ +proto.jspb.test.Complex.prototype.addARepeatedMessage = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.jspb.test.Complex.Nested, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearARepeatedMessageList = function() { + return this.setARepeatedMessageList([]); +}; + + +/** + * repeated string a_repeated_string = 7; + * @return {!Array} + */ +proto.jspb.test.Complex.prototype.getARepeatedStringList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 7)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setARepeatedStringList = function(value) { + return jspb.Message.setField(this, 7, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.addARepeatedString = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 7, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearARepeatedStringList = function() { + return this.setARepeatedStringList([]); +}; + + +/** + * optional double a_floating_point_field = 10; + * @return {number} + */ +proto.jspb.test.Complex.prototype.getAFloatingPointField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 10, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.setAFloatingPointField = function(value) { + return jspb.Message.setField(this, 10, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ +proto.jspb.test.Complex.prototype.clearAFloatingPointField = function() { + return jspb.Message.setField(this, 10, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Complex.prototype.hasAFloatingPointField = function() { + return jspb.Message.getField(this, 10) != null; +}; + + + + + +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.jspb.test.OuterMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OuterMessage.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.jspb.test.OuterMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.OuterMessage} + */ +proto.jspb.test.OuterMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OuterMessage; + return proto.jspb.test.OuterMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OuterMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OuterMessage} + */ +proto.jspb.test.OuterMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OuterMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OuterMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OuterMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.OuterMessage.Complex.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.OuterMessage.Complex.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.jspb.test.OuterMessage.Complex} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.Complex.toObject = function(includeInstance, msg) { + var f, obj = { +innerComplexField: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.OuterMessage.Complex} + */ +proto.jspb.test.OuterMessage.Complex.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.OuterMessage.Complex; + return proto.jspb.test.OuterMessage.Complex.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OuterMessage.Complex} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OuterMessage.Complex} + */ +proto.jspb.test.OuterMessage.Complex.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setInnerComplexField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.OuterMessage.Complex.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.OuterMessage.Complex.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OuterMessage.Complex} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.OuterMessage.Complex.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 inner_complex_field = 1; + * @return {number} + */ +proto.jspb.test.OuterMessage.Complex.prototype.getInnerComplexField = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.OuterMessage.Complex} returns this + */ +proto.jspb.test.OuterMessage.Complex.prototype.setInnerComplexField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OuterMessage.Complex} returns this + */ +proto.jspb.test.OuterMessage.Complex.prototype.clearInnerComplexField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.OuterMessage.Complex.prototype.hasInnerComplexField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.MineField.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.MineField.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.jspb.test.MineField} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MineField.toObject = function(includeInstance, msg) { + var f, obj = { +cookie: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.MineField} + */ +proto.jspb.test.MineField.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.MineField; + return proto.jspb.test.MineField.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.MineField} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.MineField} + */ +proto.jspb.test.MineField.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setCookie(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.MineField.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.MineField.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.MineField} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MineField.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * optional string cookie = 1; + * @return {string} + */ +proto.jspb.test.MineField.prototype.getCookie = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.MineField} returns this + */ +proto.jspb.test.MineField.prototype.setCookie = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.MineField} returns this + */ +proto.jspb.test.MineField.prototype.clearCookie = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.MineField.prototype.hasCookie = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.IsExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.IsExtension.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.jspb.test.IsExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IsExtension.toObject = function(includeInstance, msg) { + var f, obj = { +ext1: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.IsExtension} + */ +proto.jspb.test.IsExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.IsExtension; + return proto.jspb.test.IsExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.IsExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.IsExtension} + */ +proto.jspb.test.IsExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setExt1(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.IsExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.IsExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.IsExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IsExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.IsExtension.extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + proto.jspb.test.IsExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.IsExtension.toObject), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IsExtension.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.IsExtension.serializeBinaryToWriter, + proto.jspb.test.IsExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[100] = proto.jspb.test.IsExtension.extField; + +/** + * optional string ext1 = 1; + * @return {string} + */ +proto.jspb.test.IsExtension.prototype.getExt1 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.IsExtension} returns this + */ +proto.jspb.test.IsExtension.prototype.setExt1 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.IsExtension} returns this + */ +proto.jspb.test.IsExtension.prototype.clearExt1 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.IsExtension.prototype.hasExt1 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.IndirectExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.IndirectExtension.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.jspb.test.IndirectExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IndirectExtension.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.IndirectExtension} + */ +proto.jspb.test.IndirectExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.IndirectExtension; + return proto.jspb.test.IndirectExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.IndirectExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.IndirectExtension} + */ +proto.jspb.test.IndirectExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.IndirectExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.IndirectExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.IndirectExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.IndirectExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `simple`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.IndirectExtension.simple = new jspb.ExtensionFieldInfo( + 101, + {simple: 0}, + proto.jspb.test.Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.Simple1.toObject), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.simple, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.Simple1.serializeBinaryToWriter, + proto.jspb.test.Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[101] = proto.jspb.test.IndirectExtension.simple; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `str`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.IndirectExtension.str = new jspb.ExtensionFieldInfo( + 102, + {str: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[102] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.str, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[102] = proto.jspb.test.IndirectExtension.str; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `repeatedStrList`. + * @type {!jspb.ExtensionFieldInfo>} + */ +proto.jspb.test.IndirectExtension.repeatedStrList = new jspb.ExtensionFieldInfo( + 103, + {repeatedStrList: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 1); + +proto.jspb.test.HasExtensions.extensionsBinary[103] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.repeatedStrList, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeRepeatedString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[103] = proto.jspb.test.IndirectExtension.repeatedStrList; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `repeatedSimpleList`. + * @type {!jspb.ExtensionFieldInfo>} + */ +proto.jspb.test.IndirectExtension.repeatedSimpleList = new jspb.ExtensionFieldInfo( + 104, + {repeatedSimpleList: 0}, + proto.jspb.test.Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.Simple1.toObject), + 1); + +proto.jspb.test.HasExtensions.extensionsBinary[104] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.IndirectExtension.repeatedSimpleList, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeRepeatedMessage, + proto.jspb.test.Simple1.serializeBinaryToWriter, + proto.jspb.test.Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[104] = proto.jspb.test.IndirectExtension.repeatedSimpleList; + + + + +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.jspb.test.DefaultValues.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.DefaultValues.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.jspb.test.DefaultValues} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.DefaultValues.toObject = function(includeInstance, msg) { + var f, obj = { +stringField: jspb.Message.getFieldWithDefault(msg, 1, "default\x3c\x3e\x27\x22abc"), +boolField: jspb.Message.getBooleanFieldWithDefault(msg, 2, true), +intField: jspb.Message.getFieldWithDefault(msg, 3, 11), +enumField: jspb.Message.getFieldWithDefault(msg, 4, 13), +emptyField: jspb.Message.getFieldWithDefault(msg, 6, ""), +bytesField: msg.getBytesField_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.DefaultValues} + */ +proto.jspb.test.DefaultValues.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.DefaultValues; + return proto.jspb.test.DefaultValues.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.DefaultValues} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.DefaultValues} + */ +proto.jspb.test.DefaultValues.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStringField(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setBoolField(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt64()); + msg.setIntField(value); + break; + case 4: + var value = /** @type {!proto.jspb.test.DefaultValues.Enum} */ (reader.readEnum()); + msg.setEnumField(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setEmptyField(value); + break; + case 8: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBytesField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.DefaultValues.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.DefaultValues.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.DefaultValues} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.DefaultValues.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeInt64( + 3, + f + ); + } + f = /** @type {!proto.jspb.test.DefaultValues.Enum} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeEnum( + 4, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeString( + 6, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeBytes( + 8, + f + ); + } +}; + + +/** + * @enum {number} + */ +proto.jspb.test.DefaultValues.Enum = { + E1: 13, + E2: 77 +}; + +/** + * optional string string_field = 1; + * @return {string} + */ +proto.jspb.test.DefaultValues.prototype.getStringField = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "default\x3c\x3e\x27\x22abc")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setStringField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearStringField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasStringField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bool bool_field = 2; + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.getBoolField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, true)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setBoolField = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearBoolField = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasBoolField = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional int64 int_field = 3; + * @return {number} + */ +proto.jspb.test.DefaultValues.prototype.getIntField = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 11)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setIntField = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearIntField = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasIntField = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional Enum enum_field = 4; + * @return {!proto.jspb.test.DefaultValues.Enum} + */ +proto.jspb.test.DefaultValues.prototype.getEnumField = function() { + return /** @type {!proto.jspb.test.DefaultValues.Enum} */ (jspb.Message.getFieldWithDefault(this, 4, 13)); +}; + + +/** + * @param {!proto.jspb.test.DefaultValues.Enum} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setEnumField = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearEnumField = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasEnumField = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional string empty_field = 6; + * @return {string} + */ +proto.jspb.test.DefaultValues.prototype.getEmptyField = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setEmptyField = function(value) { + return jspb.Message.setField(this, 6, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearEmptyField = function() { + return jspb.Message.setField(this, 6, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasEmptyField = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional bytes bytes_field = 8; + * @return {!(string|Uint8Array)} + */ +proto.jspb.test.DefaultValues.prototype.getBytesField = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 8, "bW9v")); +}; + + +/** + * optional bytes bytes_field = 8; + * This is a type-conversion wrapper around `getBytesField()` + * @return {string} + */ +proto.jspb.test.DefaultValues.prototype.getBytesField_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBytesField())); +}; + + +/** + * optional bytes bytes_field = 8; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBytesField()` + * @return {!Uint8Array} + */ +proto.jspb.test.DefaultValues.prototype.getBytesField_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBytesField())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.setBytesField = function(value) { + return jspb.Message.setField(this, 8, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ +proto.jspb.test.DefaultValues.prototype.clearBytesField = function() { + return jspb.Message.setField(this, 8, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.DefaultValues.prototype.hasBytesField = function() { + return jspb.Message.getField(this, 8) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.FloatingPointFields.repeatedFields_ = [3,7]; + + + +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.jspb.test.FloatingPointFields.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.FloatingPointFields.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.jspb.test.FloatingPointFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.FloatingPointFields.toObject = function(includeInstance, msg) { + var f, obj = { +optionalFloatField: (f = jspb.Message.getOptionalFloatingPointField(msg, 1)) == null ? undefined : f, +requiredFloatField: (f = jspb.Message.getOptionalFloatingPointField(msg, 2)) == null ? undefined : f, +repeatedFloatFieldList: (f = jspb.Message.getRepeatedFloatingPointField(msg, 3)) == null ? undefined : f, +defaultFloatField: jspb.Message.getFloatingPointFieldWithDefault(msg, 4, 2.0), +optionalDoubleField: (f = jspb.Message.getOptionalFloatingPointField(msg, 5)) == null ? undefined : f, +requiredDoubleField: (f = jspb.Message.getOptionalFloatingPointField(msg, 6)) == null ? undefined : f, +repeatedDoubleFieldList: (f = jspb.Message.getRepeatedFloatingPointField(msg, 7)) == null ? undefined : f, +defaultDoubleField: jspb.Message.getFloatingPointFieldWithDefault(msg, 8, 2.0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.FloatingPointFields} + */ +proto.jspb.test.FloatingPointFields.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.FloatingPointFields; + return proto.jspb.test.FloatingPointFields.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.FloatingPointFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.FloatingPointFields} + */ +proto.jspb.test.FloatingPointFields.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readFloat()); + msg.setOptionalFloatField(value); + break; + case 2: + var value = /** @type {number} */ (reader.readFloat()); + msg.setRequiredFloatField(value); + break; + case 3: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readFloat() : [reader.readFloat()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedFloatField(values[i]); + } + break; + case 4: + var value = /** @type {number} */ (reader.readFloat()); + msg.setDefaultFloatField(value); + break; + case 5: + var value = /** @type {number} */ (reader.readDouble()); + msg.setOptionalDoubleField(value); + break; + case 6: + var value = /** @type {number} */ (reader.readDouble()); + msg.setRequiredDoubleField(value); + break; + case 7: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readDouble() : [reader.readDouble()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedDoubleField(values[i]); + } + break; + case 8: + var value = /** @type {number} */ (reader.readDouble()); + msg.setDefaultDoubleField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.FloatingPointFields.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.FloatingPointFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.FloatingPointFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.FloatingPointFields.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeFloat( + 1, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeFloat( + 2, + f + ); + } + f = message.getRepeatedFloatFieldList(); + if (f.length > 0) { + writer.writeRepeatedFloat( + 3, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeFloat( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeDouble( + 5, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeDouble( + 6, + f + ); + } + f = message.getRepeatedDoubleFieldList(); + if (f.length > 0) { + writer.writeRepeatedDouble( + 7, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeDouble( + 8, + f + ); + } +}; + + +/** + * optional float optional_float_field = 1; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getOptionalFloatField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 1, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setOptionalFloatField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearOptionalFloatField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasOptionalFloatField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required float required_float_field = 2; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getRequiredFloatField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 2, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRequiredFloatField = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRequiredFloatField = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasRequiredFloatField = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * repeated float repeated_float_field = 3; + * @return {!Array} + */ +proto.jspb.test.FloatingPointFields.prototype.getRepeatedFloatFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedFloatingPointField(this, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRepeatedFloatFieldList = function(value) { + return jspb.Message.setField(this, 3, value || []); +}; + + +/** + * @param {number} value + * @param {number=} opt_index + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.addRepeatedFloatField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRepeatedFloatFieldList = function() { + return this.setRepeatedFloatFieldList([]); +}; + + +/** + * optional float default_float_field = 4; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getDefaultFloatField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 4, 2.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setDefaultFloatField = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearDefaultFloatField = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasDefaultFloatField = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * optional double optional_double_field = 5; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getOptionalDoubleField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setOptionalDoubleField = function(value) { + return jspb.Message.setField(this, 5, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearOptionalDoubleField = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasOptionalDoubleField = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * required double required_double_field = 6; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getRequiredDoubleField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 6, 0.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRequiredDoubleField = function(value) { + return jspb.Message.setField(this, 6, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRequiredDoubleField = function() { + return jspb.Message.setField(this, 6, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasRequiredDoubleField = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * repeated double repeated_double_field = 7; + * @return {!Array} + */ +proto.jspb.test.FloatingPointFields.prototype.getRepeatedDoubleFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedFloatingPointField(this, 7)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setRepeatedDoubleFieldList = function(value) { + return jspb.Message.setField(this, 7, value || []); +}; + + +/** + * @param {number} value + * @param {number=} opt_index + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.addRepeatedDoubleField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 7, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearRepeatedDoubleFieldList = function() { + return this.setRepeatedDoubleFieldList([]); +}; + + +/** + * optional double default_double_field = 8; + * @return {number} + */ +proto.jspb.test.FloatingPointFields.prototype.getDefaultDoubleField = function() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 8, 2.0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.setDefaultDoubleField = function(value) { + return jspb.Message.setField(this, 8, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ +proto.jspb.test.FloatingPointFields.prototype.clearDefaultDoubleField = function() { + return jspb.Message.setField(this, 8, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.FloatingPointFields.prototype.hasDefaultDoubleField = function() { + return jspb.Message.getField(this, 8) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.BooleanFields.repeatedFields_ = [3]; + + + +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.jspb.test.BooleanFields.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.BooleanFields.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.jspb.test.BooleanFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.BooleanFields.toObject = function(includeInstance, msg) { + var f, obj = { +optionalBooleanField: (f = jspb.Message.getBooleanField(msg, 1)) == null ? undefined : f, +requiredBooleanField: (f = jspb.Message.getBooleanField(msg, 2)) == null ? undefined : f, +repeatedBooleanFieldList: (f = jspb.Message.getRepeatedBooleanField(msg, 3)) == null ? undefined : f, +defaultBooleanField: jspb.Message.getBooleanFieldWithDefault(msg, 4, true) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.BooleanFields} + */ +proto.jspb.test.BooleanFields.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.BooleanFields; + return proto.jspb.test.BooleanFields.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.BooleanFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.BooleanFields} + */ +proto.jspb.test.BooleanFields.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setOptionalBooleanField(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setRequiredBooleanField(value); + break; + case 3: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readBool() : [reader.readBool()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedBooleanField(values[i]); + } + break; + case 4: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDefaultBooleanField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.BooleanFields.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.BooleanFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.BooleanFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.BooleanFields.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {boolean} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeBool( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = message.getRepeatedBooleanFieldList(); + if (f.length > 0) { + writer.writeRepeatedBool( + 3, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBool( + 4, + f + ); + } +}; + + +/** + * optional bool optional_boolean_field = 1; + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.getOptionalBooleanField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setOptionalBooleanField = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearOptionalBooleanField = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.hasOptionalBooleanField = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * required bool required_boolean_field = 2; + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.getRequiredBooleanField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setRequiredBooleanField = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearRequiredBooleanField = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.hasRequiredBooleanField = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * repeated bool repeated_boolean_field = 3; + * @return {!Array} + */ +proto.jspb.test.BooleanFields.prototype.getRepeatedBooleanFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedBooleanField(this, 3)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setRepeatedBooleanFieldList = function(value) { + return jspb.Message.setField(this, 3, value || []); +}; + + +/** + * @param {boolean} value + * @param {number=} opt_index + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.addRepeatedBooleanField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearRepeatedBooleanFieldList = function() { + return this.setRepeatedBooleanFieldList([]); +}; + + +/** + * optional bool default_boolean_field = 4; + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.getDefaultBooleanField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, true)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.setDefaultBooleanField = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ +proto.jspb.test.BooleanFields.prototype.clearDefaultBooleanField = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.BooleanFields.prototype.hasDefaultBooleanField = function() { + return jspb.Message.getField(this, 4) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestClone.repeatedFields_ = [5]; + + + +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.jspb.test.TestClone.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestClone.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.jspb.test.TestClone} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestClone.toObject = function(includeInstance, msg) { + var f, obj = { +str: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +simple1: (f = msg.getSimple1()) && proto.jspb.test.Simple1.toObject(includeInstance, f), +simple2List: jspb.Message.toObjectList(msg.getSimple2List(), + proto.jspb.test.Simple1.toObject, includeInstance), +bytesField: msg.getBytesField_asB64(), +unused: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestClone.extensions, proto.jspb.test.TestClone.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestClone} + */ +proto.jspb.test.TestClone.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestClone; + return proto.jspb.test.TestClone.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestClone} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestClone} + */ +proto.jspb.test.TestClone.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStr(value); + break; + case 3: + var value = new proto.jspb.test.Simple1; + reader.readMessage(value,proto.jspb.test.Simple1.deserializeBinaryFromReader); + msg.setSimple1(value); + break; + case 5: + var value = new proto.jspb.test.Simple1; + reader.readMessage(value,proto.jspb.test.Simple1.deserializeBinaryFromReader); + msg.addSimple2(value); + break; + case 6: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBytesField(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setUnused(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestClone.extensionsBinary, + proto.jspb.test.TestClone.prototype.getExtension, + proto.jspb.test.TestClone.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestClone.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestClone.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestClone} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestClone.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getSimple1(); + if (f != null) { + writer.writeMessage( + 3, + f, + proto.jspb.test.Simple1.serializeBinaryToWriter + ); + } + f = message.getSimple2List(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + proto.jspb.test.Simple1.serializeBinaryToWriter + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBytes( + 6, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeString( + 7, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestClone.extensionsBinary, proto.jspb.test.TestClone.prototype.getExtension); +}; + + +/** + * optional string str = 1; + * @return {string} + */ +proto.jspb.test.TestClone.prototype.getStr = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.setStr = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearStr = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasStr = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional Simple1 simple1 = 3; + * @return {?proto.jspb.test.Simple1} + */ +proto.jspb.test.TestClone.prototype.getSimple1 = function() { + return /** @type{?proto.jspb.test.Simple1} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Simple1, 3)); +}; + + +/** + * @param {?proto.jspb.test.Simple1|undefined} value + * @return {!proto.jspb.test.TestClone} returns this +*/ +proto.jspb.test.TestClone.prototype.setSimple1 = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearSimple1 = function() { + return this.setSimple1(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasSimple1 = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * repeated Simple1 simple2 = 5; + * @return {!Array} + */ +proto.jspb.test.TestClone.prototype.getSimple2List = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.Simple1, 5)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestClone} returns this +*/ +proto.jspb.test.TestClone.prototype.setSimple2List = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); +}; + + +/** + * @param {!proto.jspb.test.Simple1=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple1} + */ +proto.jspb.test.TestClone.prototype.addSimple2 = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, proto.jspb.test.Simple1, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearSimple2List = function() { + return this.setSimple2List([]); +}; + + +/** + * optional bytes bytes_field = 6; + * @return {!(string|Uint8Array)} + */ +proto.jspb.test.TestClone.prototype.getBytesField = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** + * optional bytes bytes_field = 6; + * This is a type-conversion wrapper around `getBytesField()` + * @return {string} + */ +proto.jspb.test.TestClone.prototype.getBytesField_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBytesField())); +}; + + +/** + * optional bytes bytes_field = 6; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBytesField()` + * @return {!Uint8Array} + */ +proto.jspb.test.TestClone.prototype.getBytesField_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBytesField())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.setBytesField = function(value) { + return jspb.Message.setField(this, 6, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearBytesField = function() { + return jspb.Message.setField(this, 6, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasBytesField = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional string unused = 7; + * @return {string} + */ +proto.jspb.test.TestClone.prototype.getUnused = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.setUnused = function(value) { + return jspb.Message.setField(this, 7, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ +proto.jspb.test.TestClone.prototype.clearUnused = function() { + return jspb.Message.setField(this, 7, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestClone.prototype.hasUnused = function() { + return jspb.Message.getField(this, 7) != null; +}; + + + + + +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.jspb.test.TestCloneExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestCloneExtension.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.jspb.test.TestCloneExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestCloneExtension.toObject = function(includeInstance, msg) { + var f, obj = { +f: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.TestCloneExtension} + */ +proto.jspb.test.TestCloneExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestCloneExtension; + return proto.jspb.test.TestCloneExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestCloneExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestCloneExtension} + */ +proto.jspb.test.TestCloneExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setF(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestCloneExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestCloneExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestCloneExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestCloneExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `lowExt`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.TestCloneExtension.lowExt = new jspb.ExtensionFieldInfo( + 11, + {lowExt: 0}, + proto.jspb.test.TestCloneExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.TestCloneExtension.toObject), + 0); + +proto.jspb.test.TestClone.extensionsBinary[11] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.TestCloneExtension.lowExt, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.TestCloneExtension.serializeBinaryToWriter, + proto.jspb.test.TestCloneExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestClone.extensions[11] = proto.jspb.test.TestCloneExtension.lowExt; + +/** + * optional int32 f = 1; + * @return {number} + */ +proto.jspb.test.TestCloneExtension.prototype.getF = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestCloneExtension} returns this + */ +proto.jspb.test.TestCloneExtension.prototype.setF = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestCloneExtension} returns this + */ +proto.jspb.test.TestCloneExtension.prototype.clearF = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestCloneExtension.prototype.hasF = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.CloneExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.CloneExtension.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.jspb.test.CloneExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.CloneExtension.toObject = function(includeInstance, msg) { + var f, obj = { +ext: (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.jspb.test.CloneExtension} + */ +proto.jspb.test.CloneExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.CloneExtension; + return proto.jspb.test.CloneExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.CloneExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.CloneExtension} + */ +proto.jspb.test.CloneExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setExt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.CloneExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.CloneExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.CloneExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.CloneExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.CloneExtension.extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + proto.jspb.test.CloneExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.CloneExtension.toObject), + 0); + +proto.jspb.test.TestClone.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.CloneExtension.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.CloneExtension.serializeBinaryToWriter, + proto.jspb.test.CloneExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestClone.extensions[100] = proto.jspb.test.CloneExtension.extField; + +/** + * optional string ext = 2; + * @return {string} + */ +proto.jspb.test.CloneExtension.prototype.getExt = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.CloneExtension} returns this + */ +proto.jspb.test.CloneExtension.prototype.setExt = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.CloneExtension} returns this + */ +proto.jspb.test.CloneExtension.prototype.clearExt = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.CloneExtension.prototype.hasExt = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestGroup.repeatedFields_ = [1]; + + + +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.jspb.test.TestGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.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.jspb.test.TestGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.toObject = function(includeInstance, msg) { + var f, obj = { +repeatedGroupList: jspb.Message.toObjectList(msg.getRepeatedGroupList(), + proto.jspb.test.TestGroup.RepeatedGroup.toObject, includeInstance), +requiredGroup: (f = msg.getRequiredGroup()) && proto.jspb.test.TestGroup.RequiredGroup.toObject(includeInstance, f), +optionalGroup: (f = msg.getOptionalGroup()) && proto.jspb.test.TestGroup.OptionalGroup.toObject(includeInstance, f), +id: (f = jspb.Message.getField(msg, 4)) == null ? undefined : f, +requiredSimple: (f = msg.getRequiredSimple()) && proto.jspb.test.Simple2.toObject(includeInstance, f), +optionalSimple: (f = msg.getOptionalSimple()) && proto.jspb.test.Simple2.toObject(includeInstance, 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.jspb.test.TestGroup} + */ +proto.jspb.test.TestGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup; + return proto.jspb.test.TestGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup} + */ +proto.jspb.test.TestGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.jspb.test.TestGroup.RepeatedGroup; + reader.readGroup(1, value,proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader); + msg.addRepeatedGroup(value); + break; + case 2: + var value = new proto.jspb.test.TestGroup.RequiredGroup; + reader.readGroup(2, value,proto.jspb.test.TestGroup.RequiredGroup.deserializeBinaryFromReader); + msg.setRequiredGroup(value); + break; + case 3: + var value = new proto.jspb.test.TestGroup.OptionalGroup; + reader.readGroup(3, value,proto.jspb.test.TestGroup.OptionalGroup.deserializeBinaryFromReader); + msg.setOptionalGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 5: + var value = new proto.jspb.test.Simple2; + reader.readMessage(value,proto.jspb.test.Simple2.deserializeBinaryFromReader); + msg.setRequiredSimple(value); + break; + case 6: + var value = new proto.jspb.test.Simple2; + reader.readMessage(value,proto.jspb.test.Simple2.deserializeBinaryFromReader); + msg.setOptionalSimple(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getRepeatedGroupList(); + if (f.length > 0) { + writer.writeRepeatedGroup( + 1, + f, + proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter + ); + } + f = message.getRequiredGroup(); + if (f != null) { + writer.writeGroup( + 2, + f, + proto.jspb.test.TestGroup.RequiredGroup.serializeBinaryToWriter + ); + } + f = message.getOptionalGroup(); + if (f != null) { + writer.writeGroup( + 3, + f, + proto.jspb.test.TestGroup.OptionalGroup.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } + f = message.getRequiredSimple(); + if (f != null) { + writer.writeMessage( + 5, + f, + proto.jspb.test.Simple2.serializeBinaryToWriter + ); + } + f = message.getOptionalSimple(); + if (f != null) { + writer.writeMessage( + 6, + f, + proto.jspb.test.Simple2.serializeBinaryToWriter + ); + } +}; + + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestGroup.RepeatedGroup.repeatedFields_ = [1]; + + + +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.jspb.test.TestGroup.RepeatedGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.RepeatedGroup.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.jspb.test.TestGroup.RepeatedGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RepeatedGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, 0)) == null ? undefined : f, +someBoolList: (f = jspb.Message.getRepeatedBooleanField(msg, 1)) == 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.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup.RepeatedGroup; + return proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.RepeatedGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 2: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readBool() : [reader.readBool()]); + for (var i = 0; i < values.length; i++) { + msg.addSomeBool(values[i]); + } + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.RepeatedGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 0)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getSomeBoolList(); + if (f.length > 0) { + writer.writeRepeatedBool( + 2, + f + ); + } +}; + + +/** + * required string id = 1; + * @return {string} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 0, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, 0, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.clearId = function() { + return jspb.Message.setField(this, 0, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.hasId = function() { + return jspb.Message.getField(this, 0) != null; +}; + + +/** + * repeated bool some_bool = 2; + * @return {!Array} + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.getSomeBoolList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedBooleanField(this, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.setSomeBoolList = function(value) { + return jspb.Message.setField(this, 1, value || []); +}; + + +/** + * @param {boolean} value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.addSomeBool = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ +proto.jspb.test.TestGroup.RepeatedGroup.prototype.clearSomeBoolList = function() { + return this.setSomeBoolList([]); +}; + + + + + +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.jspb.test.TestGroup.RequiredGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.RequiredGroup.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.jspb.test.TestGroup.RequiredGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RequiredGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, -1)) == 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.jspb.test.TestGroup.RequiredGroup} + */ +proto.jspb.test.TestGroup.RequiredGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup.RequiredGroup; + return proto.jspb.test.TestGroup.RequiredGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.RequiredGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ +proto.jspb.test.TestGroup.RequiredGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.RequiredGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.RequiredGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.RequiredGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, -1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * required string id = 1; + * @return {string} + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, -1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.RequiredGroup} returns this + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, -1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} returns this + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.clearId = function() { + return jspb.Message.setField(this, -1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.RequiredGroup.prototype.hasId = function() { + return jspb.Message.getField(this, -1) != null; +}; + + + + + +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.jspb.test.TestGroup.OptionalGroup.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup.OptionalGroup.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.jspb.test.TestGroup.OptionalGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.OptionalGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (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.jspb.test.TestGroup.OptionalGroup} + */ +proto.jspb.test.TestGroup.OptionalGroup.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup.OptionalGroup; + return proto.jspb.test.TestGroup.OptionalGroup.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.OptionalGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} + */ +proto.jspb.test.TestGroup.OptionalGroup.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup.OptionalGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.OptionalGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup.OptionalGroup.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, -2)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + +/** + * required string id = 1; + * @return {string} + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, -2, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.OptionalGroup} returns this + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, -2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} returns this + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.clearId = function() { + return jspb.Message.setField(this, -2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.OptionalGroup.prototype.hasId = function() { + return jspb.Message.getField(this, -2) != null; +}; + + +/** + * repeated group RepeatedGroup = 1; + * @return {!Array} + */ +proto.jspb.test.TestGroup.prototype.getRepeatedGroupList = function() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, proto.jspb.test.TestGroup.RepeatedGroup, 1)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setRepeatedGroupList = function(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); +}; + + +/** + * @param {!proto.jspb.test.TestGroup.RepeatedGroup=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup.prototype.addRepeatedGroup = function(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, proto.jspb.test.TestGroup.RepeatedGroup, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearRepeatedGroupList = function() { + return this.setRepeatedGroupList([]); +}; + + +/** + * required group RequiredGroup = 2; + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ +proto.jspb.test.TestGroup.prototype.getRequiredGroup = function() { + return /** @type{!proto.jspb.test.TestGroup.RequiredGroup} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestGroup.RequiredGroup, 2, 1)); +}; + + +/** + * @param {!proto.jspb.test.TestGroup.RequiredGroup} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setRequiredGroup = function(value) { + return jspb.Message.setWrapperField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearRequiredGroup = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasRequiredGroup = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional group OptionalGroup = 3; + * @return {?proto.jspb.test.TestGroup.OptionalGroup} + */ +proto.jspb.test.TestGroup.prototype.getOptionalGroup = function() { + return /** @type{?proto.jspb.test.TestGroup.OptionalGroup} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestGroup.OptionalGroup, 3)); +}; + + +/** + * @param {?proto.jspb.test.TestGroup.OptionalGroup|undefined} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setOptionalGroup = function(value) { + return jspb.Message.setWrapperField(this, 3, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearOptionalGroup = function() { + return this.setOptionalGroup(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasOptionalGroup = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional string id = 4; + * @return {string} + */ +proto.jspb.test.TestGroup.prototype.getId = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.setId = function(value) { + return jspb.Message.setField(this, 4, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearId = function() { + return jspb.Message.setField(this, 4, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasId = function() { + return jspb.Message.getField(this, 4) != null; +}; + + +/** + * required Simple2 required_simple = 5; + * @return {!proto.jspb.test.Simple2} + */ +proto.jspb.test.TestGroup.prototype.getRequiredSimple = function() { + return /** @type{!proto.jspb.test.Simple2} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Simple2, 5, 1)); +}; + + +/** + * @param {!proto.jspb.test.Simple2} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setRequiredSimple = function(value) { + return jspb.Message.setWrapperField(this, 5, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearRequiredSimple = function() { + return jspb.Message.setField(this, 5, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasRequiredSimple = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional Simple2 optional_simple = 6; + * @return {?proto.jspb.test.Simple2} + */ +proto.jspb.test.TestGroup.prototype.getOptionalSimple = function() { + return /** @type{?proto.jspb.test.Simple2} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Simple2, 6)); +}; + + +/** + * @param {?proto.jspb.test.Simple2|undefined} value + * @return {!proto.jspb.test.TestGroup} returns this +*/ +proto.jspb.test.TestGroup.prototype.setOptionalSimple = function(value) { + return jspb.Message.setWrapperField(this, 6, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ +proto.jspb.test.TestGroup.prototype.clearOptionalSimple = function() { + return this.setOptionalSimple(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup.prototype.hasOptionalSimple = function() { + return jspb.Message.getField(this, 6) != null; +}; + + + + + +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.jspb.test.TestGroup1.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestGroup1.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.jspb.test.TestGroup1} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup1.toObject = function(includeInstance, msg) { + var f, obj = { +group: (f = msg.getGroup()) && proto.jspb.test.TestGroup.RepeatedGroup.toObject(includeInstance, 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.jspb.test.TestGroup1} + */ +proto.jspb.test.TestGroup1.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestGroup1; + return proto.jspb.test.TestGroup1.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup1} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup1} + */ +proto.jspb.test.TestGroup1.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.jspb.test.TestGroup.RepeatedGroup; + reader.readMessage(value,proto.jspb.test.TestGroup.RepeatedGroup.deserializeBinaryFromReader); + msg.setGroup(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestGroup1.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestGroup1.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup1} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestGroup1.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getGroup(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.jspb.test.TestGroup.RepeatedGroup.serializeBinaryToWriter + ); + } +}; + + +/** + * optional TestGroup.RepeatedGroup group = 1; + * @return {?proto.jspb.test.TestGroup.RepeatedGroup} + */ +proto.jspb.test.TestGroup1.prototype.getGroup = function() { + return /** @type{?proto.jspb.test.TestGroup.RepeatedGroup} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestGroup.RepeatedGroup, 1)); +}; + + +/** + * @param {?proto.jspb.test.TestGroup.RepeatedGroup|undefined} value + * @return {!proto.jspb.test.TestGroup1} returns this +*/ +proto.jspb.test.TestGroup1.prototype.setGroup = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup1} returns this + */ +proto.jspb.test.TestGroup1.prototype.clearGroup = function() { + return this.setGroup(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestGroup1.prototype.hasGroup = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.TestReservedNames.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestReservedNames.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.jspb.test.TestReservedNames} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNames.toObject = function(includeInstance, msg) { + var f, obj = { +extension: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestReservedNames.extensions, proto.jspb.test.TestReservedNames.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestReservedNames} + */ +proto.jspb.test.TestReservedNames.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestReservedNames; + return proto.jspb.test.TestReservedNames.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestReservedNames} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestReservedNames} + */ +proto.jspb.test.TestReservedNames.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setExtension$(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestReservedNames.extensionsBinary, + proto.jspb.test.TestReservedNames.prototype.getExtension, + proto.jspb.test.TestReservedNames.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestReservedNames.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestReservedNames.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestReservedNames} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNames.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestReservedNames.extensionsBinary, proto.jspb.test.TestReservedNames.prototype.getExtension); +}; + + +/** + * optional int32 extension = 1; + * @return {number} + */ +proto.jspb.test.TestReservedNames.prototype.getExtension$ = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestReservedNames} returns this + */ +proto.jspb.test.TestReservedNames.prototype.setExtension$ = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestReservedNames} returns this + */ +proto.jspb.test.TestReservedNames.prototype.clearExtension$ = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestReservedNames.prototype.hasExtension$ = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.TestReservedNamesExtension.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestReservedNamesExtension.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.jspb.test.TestReservedNamesExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNamesExtension.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestReservedNamesExtension} + */ +proto.jspb.test.TestReservedNamesExtension.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestReservedNamesExtension; + return proto.jspb.test.TestReservedNamesExtension.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestReservedNamesExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestReservedNamesExtension} + */ +proto.jspb.test.TestReservedNamesExtension.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestReservedNamesExtension.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestReservedNamesExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestReservedNamesExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestReservedNamesExtension.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `foo`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.TestReservedNamesExtension.foo = new jspb.ExtensionFieldInfo( + 10, + {foo: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.TestReservedNames.extensionsBinary[10] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.TestReservedNamesExtension.foo, + jspb.BinaryReader.prototype.readInt32, + jspb.BinaryWriter.prototype.writeInt32, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestReservedNames.extensions[10] = proto.jspb.test.TestReservedNamesExtension.foo; + + +/** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ +proto.jspb.test.TestMessageWithOneof.repeatedFields_ = [9]; + +/** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ +proto.jspb.test.TestMessageWithOneof.oneofGroups_ = [[3,5],[6,7],[10,11],[12,13]]; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.PartialOneofCase = { + PARTIAL_ONEOF_NOT_SET: 0, + PONE: 3, + PTHREE: 5 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.PartialOneofCase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getPartialOneofCase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.PartialOneofCase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0])); +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase = { + RECURSIVE_ONEOF_NOT_SET: 0, + RONE: 6, + RTWO: 7 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRecursiveOneofCase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1])); +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.DefaultOneofACase = { + DEFAULT_ONEOF_A_NOT_SET: 0, + AONE: 10, + ATWO: 11 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.DefaultOneofACase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getDefaultOneofACase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.DefaultOneofACase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2])); +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase = { + DEFAULT_ONEOF_B_NOT_SET: 0, + BONE: 12, + BTWO: 13 +}; + +/** + * @return {proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getDefaultOneofBCase = function() { + return /** @type {proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase} */(jspb.Message.computeOneofCase(this, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3])); +}; + + + +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.jspb.test.TestMessageWithOneof.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestMessageWithOneof.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.jspb.test.TestMessageWithOneof} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMessageWithOneof.toObject = function(includeInstance, msg) { + var f, obj = { +pone: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f, +pthree: (f = jspb.Message.getField(msg, 5)) == null ? undefined : f, +rone: (f = msg.getRone()) && proto.jspb.test.TestMessageWithOneof.toObject(includeInstance, f), +rtwo: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f, +normalField: (f = jspb.Message.getBooleanField(msg, 8)) == null ? undefined : f, +repeatedFieldList: (f = jspb.Message.getRepeatedField(msg, 9)) == null ? undefined : f, +aone: jspb.Message.getFieldWithDefault(msg, 10, 1234), +atwo: (f = jspb.Message.getField(msg, 11)) == null ? undefined : f, +bone: (f = jspb.Message.getField(msg, 12)) == null ? undefined : f, +btwo: jspb.Message.getFieldWithDefault(msg, 13, 1234) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestMessageWithOneof} + */ +proto.jspb.test.TestMessageWithOneof.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestMessageWithOneof; + return proto.jspb.test.TestMessageWithOneof.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestMessageWithOneof} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestMessageWithOneof} + */ +proto.jspb.test.TestMessageWithOneof.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setPone(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setPthree(value); + break; + case 6: + var value = new proto.jspb.test.TestMessageWithOneof; + reader.readMessage(value,proto.jspb.test.TestMessageWithOneof.deserializeBinaryFromReader); + msg.setRone(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setRtwo(value); + break; + case 8: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setNormalField(value); + break; + case 9: + var value = /** @type {string} */ (reader.readString()); + msg.addRepeatedField(value); + break; + case 10: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAone(value); + break; + case 11: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAtwo(value); + break; + case 12: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBone(value); + break; + case 13: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBtwo(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestMessageWithOneof.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestMessageWithOneof.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestMessageWithOneof} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMessageWithOneof.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeString( + 5, + f + ); + } + f = message.getRone(); + if (f != null) { + writer.writeMessage( + 6, + f, + proto.jspb.test.TestMessageWithOneof.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeString( + 7, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeBool( + 8, + f + ); + } + f = message.getRepeatedFieldList(); + if (f.length > 0) { + writer.writeRepeatedString( + 9, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 10)); + if (f != null) { + writer.writeInt32( + 10, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 11)); + if (f != null) { + writer.writeInt32( + 11, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 12)); + if (f != null) { + writer.writeInt32( + 12, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 13)); + if (f != null) { + writer.writeInt32( + 13, + f + ); + } +}; + + +/** + * optional string pone = 3; + * @return {string} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getPone = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setPone = function(value) { + return jspb.Message.setOneofField(this, 3, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearPone = function() { + return jspb.Message.setOneofField(this, 3, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasPone = function() { + return jspb.Message.getField(this, 3) != null; +}; + + +/** + * optional string pthree = 5; + * @return {string} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getPthree = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setPthree = function(value) { + return jspb.Message.setOneofField(this, 5, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearPthree = function() { + return jspb.Message.setOneofField(this, 5, proto.jspb.test.TestMessageWithOneof.oneofGroups_[0], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasPthree = function() { + return jspb.Message.getField(this, 5) != null; +}; + + +/** + * optional TestMessageWithOneof rone = 6; + * @return {?proto.jspb.test.TestMessageWithOneof} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRone = function() { + return /** @type{?proto.jspb.test.TestMessageWithOneof} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestMessageWithOneof, 6)); +}; + + +/** + * @param {?proto.jspb.test.TestMessageWithOneof|undefined} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this +*/ +proto.jspb.test.TestMessageWithOneof.prototype.setRone = function(value) { + return jspb.Message.setOneofWrapperField(this, 6, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1], value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearRone = function() { + return this.setRone(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasRone = function() { + return jspb.Message.getField(this, 6) != null; +}; + + +/** + * optional string rtwo = 7; + * @return {string} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRtwo = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setRtwo = function(value) { + return jspb.Message.setOneofField(this, 7, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearRtwo = function() { + return jspb.Message.setOneofField(this, 7, proto.jspb.test.TestMessageWithOneof.oneofGroups_[1], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasRtwo = function() { + return jspb.Message.getField(this, 7) != null; +}; + + +/** + * optional bool normal_field = 8; + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getNormalField = function() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); +}; + + +/** + * @param {boolean} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setNormalField = function(value) { + return jspb.Message.setField(this, 8, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearNormalField = function() { + return jspb.Message.setField(this, 8, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasNormalField = function() { + return jspb.Message.getField(this, 8) != null; +}; + + +/** + * repeated string repeated_field = 9; + * @return {!Array} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getRepeatedFieldList = function() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 9)); +}; + + +/** + * @param {!Array} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setRepeatedFieldList = function(value) { + return jspb.Message.setField(this, 9, value || []); +}; + + +/** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.addRepeatedField = function(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 9, value, opt_index); +}; + + +/** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearRepeatedFieldList = function() { + return this.setRepeatedFieldList([]); +}; + + +/** + * optional int32 aone = 10; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getAone = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 10, 1234)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setAone = function(value) { + return jspb.Message.setOneofField(this, 10, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearAone = function() { + return jspb.Message.setOneofField(this, 10, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasAone = function() { + return jspb.Message.getField(this, 10) != null; +}; + + +/** + * optional int32 atwo = 11; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getAtwo = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 11, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setAtwo = function(value) { + return jspb.Message.setOneofField(this, 11, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearAtwo = function() { + return jspb.Message.setOneofField(this, 11, proto.jspb.test.TestMessageWithOneof.oneofGroups_[2], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasAtwo = function() { + return jspb.Message.getField(this, 11) != null; +}; + + +/** + * optional int32 bone = 12; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getBone = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 12, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setBone = function(value) { + return jspb.Message.setOneofField(this, 12, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearBone = function() { + return jspb.Message.setOneofField(this, 12, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasBone = function() { + return jspb.Message.getField(this, 12) != null; +}; + + +/** + * optional int32 btwo = 13; + * @return {number} + */ +proto.jspb.test.TestMessageWithOneof.prototype.getBtwo = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 13, 1234)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.setBtwo = function(value) { + return jspb.Message.setOneofField(this, 13, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ +proto.jspb.test.TestMessageWithOneof.prototype.clearBtwo = function() { + return jspb.Message.setOneofField(this, 13, proto.jspb.test.TestMessageWithOneof.oneofGroups_[3], undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMessageWithOneof.prototype.hasBtwo = function() { + return jspb.Message.getField(this, 13) != null; +}; + + + + + +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.jspb.test.TestEndsWithBytes.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestEndsWithBytes.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.jspb.test.TestEndsWithBytes} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestEndsWithBytes.toObject = function(includeInstance, msg) { + var f, obj = { +value: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestEndsWithBytes} + */ +proto.jspb.test.TestEndsWithBytes.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestEndsWithBytes; + return proto.jspb.test.TestEndsWithBytes.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestEndsWithBytes} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestEndsWithBytes} + */ +proto.jspb.test.TestEndsWithBytes.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setValue(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestEndsWithBytes.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestEndsWithBytes.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestEndsWithBytes} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestEndsWithBytes.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBytes( + 2, + f + ); + } +}; + + +/** + * optional int32 value = 1; + * @return {number} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getValue = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.setValue = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.clearValue = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestEndsWithBytes.prototype.hasValue = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional bytes data = 2; + * @return {!(string|Uint8Array)} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getData = function() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** + * optional bytes data = 2; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getData_asB64 = function() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); +}; + + +/** + * optional bytes data = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ +proto.jspb.test.TestEndsWithBytes.prototype.getData_asU8 = function() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); +}; + + +/** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.setData = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ +proto.jspb.test.TestEndsWithBytes.prototype.clearData = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestEndsWithBytes.prototype.hasData = function() { + return jspb.Message.getField(this, 2) != null; +}; + + + + + +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.jspb.test.TestLastFieldBeforePivot.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestLastFieldBeforePivot.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.jspb.test.TestLastFieldBeforePivot} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestLastFieldBeforePivot.toObject = function(includeInstance, msg) { + var f, obj = { +lastFieldBeforePivot: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestLastFieldBeforePivot.extensions, proto.jspb.test.TestLastFieldBeforePivot.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} + */ +proto.jspb.test.TestLastFieldBeforePivot.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestLastFieldBeforePivot; + return proto.jspb.test.TestLastFieldBeforePivot.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestLastFieldBeforePivot} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} + */ +proto.jspb.test.TestLastFieldBeforePivot.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setLastFieldBeforePivot(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary, + proto.jspb.test.TestLastFieldBeforePivot.prototype.getExtension, + proto.jspb.test.TestLastFieldBeforePivot.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestLastFieldBeforePivot.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestLastFieldBeforePivot} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestLastFieldBeforePivot.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary, proto.jspb.test.TestLastFieldBeforePivot.prototype.getExtension); +}; + + +/** + * optional int32 last_field_before_pivot = 1; + * @return {number} + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.getLastFieldBeforePivot = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestLastFieldBeforePivot} returns this + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.setLastFieldBeforePivot = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} returns this + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.clearLastFieldBeforePivot = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestLastFieldBeforePivot.prototype.hasLastFieldBeforePivot = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.Int64Types.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Int64Types.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.jspb.test.Int64Types} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Int64Types.toObject = function(includeInstance, msg) { + var f, obj = { +int64Normal: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +int64String: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +int64Number: (f = jspb.Message.getField(msg, 3)) == 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.jspb.test.Int64Types} + */ +proto.jspb.test.Int64Types.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Int64Types; + return proto.jspb.test.Int64Types.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Int64Types} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Int64Types} + */ +proto.jspb.test.Int64Types.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setInt64Normal(value); + break; + case 2: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setInt64String(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint64()); + msg.setInt64Number(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Int64Types.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Int64Types.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Int64Types} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Int64Types.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt64( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeSint64String( + 2, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeUint64( + 3, + f + ); + } +}; + + +/** + * optional int64 int64_normal = 1; + * @return {number} + */ +proto.jspb.test.Int64Types.prototype.getInt64Normal = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.setInt64Normal = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.clearInt64Normal = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Int64Types.prototype.hasInt64Normal = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * optional sint64 int64_string = 2; + * @return {string} + */ +proto.jspb.test.Int64Types.prototype.getInt64String = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.setInt64String = function(value) { + return jspb.Message.setField(this, 2, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.clearInt64String = function() { + return jspb.Message.setField(this, 2, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Int64Types.prototype.hasInt64String = function() { + return jspb.Message.getField(this, 2) != null; +}; + + +/** + * optional uint64 int64_number = 3; + * @return {number} + */ +proto.jspb.test.Int64Types.prototype.getInt64Number = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.setInt64Number = function(value) { + return jspb.Message.setField(this, 3, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ +proto.jspb.test.Int64Types.prototype.clearInt64Number = function() { + return jspb.Message.setField(this, 3, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Int64Types.prototype.hasInt64Number = function() { + return jspb.Message.getField(this, 3) != null; +}; + + + + + +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.jspb.test.TestMapFieldsNoBinary.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestMapFieldsNoBinary.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.jspb.test.TestMapFieldsNoBinary} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMapFieldsNoBinary.toObject = function(includeInstance, msg) { + var f, obj = { +mapStringStringMap: (f = msg.getMapStringStringMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringInt32Map: (f = msg.getMapStringInt32Map()) ? f.toObject(includeInstance, undefined) : [], +mapStringInt64Map: (f = msg.getMapStringInt64Map()) ? f.toObject(includeInstance, undefined) : [], +mapStringBoolMap: (f = msg.getMapStringBoolMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringDoubleMap: (f = msg.getMapStringDoubleMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringEnumMap: (f = msg.getMapStringEnumMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringMsgMap: (f = msg.getMapStringMsgMap()) ? f.toObject(includeInstance, proto.jspb.test.MapValueMessageNoBinary.toObject) : [], +mapInt32StringMap: (f = msg.getMapInt32StringMap()) ? f.toObject(includeInstance, undefined) : [], +mapInt64StringMap: (f = msg.getMapInt64StringMap()) ? f.toObject(includeInstance, undefined) : [], +mapBoolStringMap: (f = msg.getMapBoolStringMap()) ? f.toObject(includeInstance, undefined) : [], +testMapFields: (f = msg.getTestMapFields()) && proto.jspb.test.TestMapFieldsNoBinary.toObject(includeInstance, f), +mapStringTestmapfieldsMap: (f = msg.getMapStringTestmapfieldsMap()) ? f.toObject(includeInstance, proto.jspb.test.TestMapFieldsNoBinary.toObject) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} + */ +proto.jspb.test.TestMapFieldsNoBinary.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestMapFieldsNoBinary; + return proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestMapFieldsNoBinary} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} + */ +proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = msg.getMapStringStringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 2: + var value = msg.getMapStringInt32Map(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readInt32, null, "", 0); + }); + break; + case 3: + var value = msg.getMapStringInt64Map(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readInt64, null, "", 0); + }); + break; + case 4: + var value = msg.getMapStringBoolMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readBool, null, "", false); + }); + break; + case 5: + var value = msg.getMapStringDoubleMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readDouble, null, "", 0.0); + }); + break; + case 6: + var value = msg.getMapStringEnumMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readEnum, null, "", 0); + }); + break; + case 7: + var value = msg.getMapStringMsgMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.jspb.test.MapValueMessageNoBinary.deserializeBinaryFromReader, "", new proto.jspb.test.MapValueMessageNoBinary()); + }); + break; + case 8: + var value = msg.getMapInt32StringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt32, jspb.BinaryReader.prototype.readString, null, 0, ""); + }); + break; + case 9: + var value = msg.getMapInt64StringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt64, jspb.BinaryReader.prototype.readString, null, 0, ""); + }); + break; + case 10: + var value = msg.getMapBoolStringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readBool, jspb.BinaryReader.prototype.readString, null, false, ""); + }); + break; + case 11: + var value = new proto.jspb.test.TestMapFieldsNoBinary; + reader.readMessage(value,proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader); + msg.setTestMapFields(value); + break; + case 12: + var value = msg.getMapStringTestmapfieldsMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, proto.jspb.test.TestMapFieldsNoBinary.deserializeBinaryFromReader, "", new proto.jspb.test.TestMapFieldsNoBinary()); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestMapFieldsNoBinary} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getMapStringStringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapStringInt32Map(true); + if (f && f.getLength() > 0) { + f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeInt32); + } + f = message.getMapStringInt64Map(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeInt64); + } + f = message.getMapStringBoolMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeBool); + } + f = message.getMapStringDoubleMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeDouble); + } + f = message.getMapStringEnumMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeEnum); + } + f = message.getMapStringMsgMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(7, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.jspb.test.MapValueMessageNoBinary.serializeBinaryToWriter); + } + f = message.getMapInt32StringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(8, writer, jspb.BinaryWriter.prototype.writeInt32, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapInt64StringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(9, writer, jspb.BinaryWriter.prototype.writeInt64, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapBoolStringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(10, writer, jspb.BinaryWriter.prototype.writeBool, jspb.BinaryWriter.prototype.writeString); + } + f = message.getTestMapFields(); + if (f != null) { + writer.writeMessage( + 11, + f, + proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter + ); + } + f = message.getMapStringTestmapfieldsMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(12, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.jspb.test.TestMapFieldsNoBinary.serializeBinaryToWriter); + } +}; + + +/** + * map map_string_string = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringStringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringStringMap = function() { + this.getMapStringStringMap().clear(); + return this; +}; + + +/** + * map map_string_int32 = 2; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringInt32Map = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 2, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringInt32Map = function() { + this.getMapStringInt32Map().clear(); + return this; +}; + + +/** + * map map_string_int64 = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringInt64Map = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringInt64Map = function() { + this.getMapStringInt64Map().clear(); + return this; +}; + + +/** + * map map_string_bool = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringBoolMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringBoolMap = function() { + this.getMapStringBoolMap().clear(); + return this; +}; + + +/** + * map map_string_double = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringDoubleMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringDoubleMap = function() { + this.getMapStringDoubleMap().clear(); + return this; +}; + + +/** + * map map_string_enum = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringEnumMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringEnumMap = function() { + this.getMapStringEnumMap().clear(); + return this; +}; + + +/** + * map map_string_msg = 7; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringMsgMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 7, opt_noLazyCreate, + proto.jspb.test.MapValueMessageNoBinary)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringMsgMap = function() { + this.getMapStringMsgMap().clear(); + return this; +}; + + +/** + * map map_int32_string = 8; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapInt32StringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 8, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapInt32StringMap = function() { + this.getMapInt32StringMap().clear(); + return this; +}; + + +/** + * map map_int64_string = 9; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapInt64StringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 9, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapInt64StringMap = function() { + this.getMapInt64StringMap().clear(); + return this; +}; + + +/** + * map map_bool_string = 10; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapBoolStringMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 10, opt_noLazyCreate, + null)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapBoolStringMap = function() { + this.getMapBoolStringMap().clear(); + return this; +}; + + +/** + * optional TestMapFieldsNoBinary test_map_fields = 11; + * @return {?proto.jspb.test.TestMapFieldsNoBinary} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getTestMapFields = function() { + return /** @type{?proto.jspb.test.TestMapFieldsNoBinary} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.TestMapFieldsNoBinary, 11)); +}; + + +/** + * @param {?proto.jspb.test.TestMapFieldsNoBinary|undefined} value + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this +*/ +proto.jspb.test.TestMapFieldsNoBinary.prototype.setTestMapFields = function(value) { + return jspb.Message.setWrapperField(this, 11, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearTestMapFields = function() { + return this.setTestMapFields(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.hasTestMapFields = function() { + return jspb.Message.getField(this, 11) != null; +}; + + +/** + * map map_string_testmapfields = 12; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.getMapStringTestmapfieldsMap = function(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 12, opt_noLazyCreate, + proto.jspb.test.TestMapFieldsNoBinary)); +}; + + +/** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ +proto.jspb.test.TestMapFieldsNoBinary.prototype.clearMapStringTestmapfieldsMap = function() { + this.getMapStringTestmapfieldsMap().clear(); + return this; +}; + + + + + +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.jspb.test.MapValueMessageNoBinary.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.MapValueMessageNoBinary.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.jspb.test.MapValueMessageNoBinary} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MapValueMessageNoBinary.toObject = function(includeInstance, msg) { + var f, obj = { +foo: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.MapValueMessageNoBinary} + */ +proto.jspb.test.MapValueMessageNoBinary.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.MapValueMessageNoBinary; + return proto.jspb.test.MapValueMessageNoBinary.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.MapValueMessageNoBinary} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.MapValueMessageNoBinary} + */ +proto.jspb.test.MapValueMessageNoBinary.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setFoo(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.MapValueMessageNoBinary.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.MapValueMessageNoBinary} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.MapValueMessageNoBinary.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 foo = 1; + * @return {number} + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.getFoo = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.MapValueMessageNoBinary} returns this + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.setFoo = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.MapValueMessageNoBinary} returns this + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.clearFoo = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.MapValueMessageNoBinary.prototype.hasFoo = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.Deeply.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Deeply.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.jspb.test.Deeply} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply} + */ +proto.jspb.test.Deeply.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Deeply; + return proto.jspb.test.Deeply.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply} + */ +proto.jspb.test.Deeply.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Deeply.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Deeply.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.Deeply.Nested.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Deeply.Nested.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.jspb.test.Deeply.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply.Nested} + */ +proto.jspb.test.Deeply.Nested.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Deeply.Nested; + return proto.jspb.test.Deeply.Nested.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply.Nested} + */ +proto.jspb.test.Deeply.Nested.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Deeply.Nested.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Deeply.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + +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.jspb.test.Deeply.Nested.Message.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.Deeply.Nested.Message.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.jspb.test.Deeply.Nested.Message} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.Message.toObject = function(includeInstance, msg) { + var f, obj = { +count: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.Deeply.Nested.Message} + */ +proto.jspb.test.Deeply.Nested.Message.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.Deeply.Nested.Message; + return proto.jspb.test.Deeply.Nested.Message.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply.Nested.Message} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply.Nested.Message} + */ +proto.jspb.test.Deeply.Nested.Message.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.Deeply.Nested.Message.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.Deeply.Nested.Message.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply.Nested.Message} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.Deeply.Nested.Message.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } +}; + + +/** + * optional int32 count = 1; + * @return {number} + */ +proto.jspb.test.Deeply.Nested.Message.prototype.getCount = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.Deeply.Nested.Message} returns this + */ +proto.jspb.test.Deeply.Nested.Message.prototype.setCount = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Deeply.Nested.Message} returns this + */ +proto.jspb.test.Deeply.Nested.Message.prototype.clearCount = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.Deeply.Nested.Message.prototype.hasCount = function() { + return jspb.Message.getField(this, 1) != null; +}; + + +/** + * @enum {number} + */ +proto.jspb.test.OuterEnum = { + FOO: 1, + BAR: 2 +}; + +/** + * @enum {number} + */ +proto.jspb.test.MapValueEnumNoBinary = { + MAP_VALUE_FOO_NOBINARY: 0, + MAP_VALUE_BAR_NOBINARY: 1, + MAP_VALUE_BAZ_NOBINARY: 2 +}; + +/** + * @enum {number} + */ +proto.jspb.test.TestAllowAliasEnum = { + TEST_ALLOW_ALIAS_DEFAULT: 0, + VALUE1: 1 +}; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `simple1`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.simple1 = new jspb.ExtensionFieldInfo( + 105, + {simple1: 0}, + proto.jspb.test.Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.Simple1.toObject), + 0); + +proto.jspb.test.HasExtensions.extensionsBinary[105] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.simple1, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.Simple1.serializeBinaryToWriter, + proto.jspb.test.Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.HasExtensions.extensions[105] = proto.jspb.test.simple1; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extendTestLastFieldBeforePivotField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.extendTestLastFieldBeforePivotField = new jspb.ExtensionFieldInfo( + 101, + {extendTestLastFieldBeforePivotField: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.TestLastFieldBeforePivot.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.extendTestLastFieldBeforePivotField, + jspb.BinaryReader.prototype.readInt32, + jspb.BinaryWriter.prototype.writeInt32, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestLastFieldBeforePivot.extensions[101] = proto.jspb.test.extendTestLastFieldBeforePivotField; + diff --git a/example/test.closure.diff b/example/test.closure.diff new file mode 100644 index 0000000..e69de29 diff --git a/example/test.d.ts b/example/test.d.ts new file mode 100644 index 0000000..036bc3d --- /dev/null +++ b/example/test.d.ts @@ -0,0 +1,810 @@ +import * as jspb from 'google-protobuf'; +import * as google_protobuf_descriptor_pb from 'google-protobuf/google/protobuf/descriptor.js'; + +export class Empty extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Empty): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Empty; + static deserializeBinaryFromReader(msg: Empty, reader: jspb.BinaryReader): Empty; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Empty, writer: jspb.BinaryWriter): void; +} + +export class EnumContainer extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: EnumContainer): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): EnumContainer; + static deserializeBinaryFromReader(msg: EnumContainer, reader: jspb.BinaryReader): EnumContainer; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: EnumContainer, writer: jspb.BinaryWriter): void; + getOuterEnum(): OuterEnum; + setOuterEnum(value: OuterEnum): EnumContainer; + clearOuterEnum(): EnumContainer; + hasOuterEnum(): boolean; +} + +export class Simple1 extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Simple1): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Simple1; + static deserializeBinaryFromReader(msg: Simple1, reader: jspb.BinaryReader): Simple1; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Simple1, writer: jspb.BinaryWriter): void; + getAString(): string; + setAString(value: string): Simple1; + clearAString(): Simple1; + hasAString(): boolean; + getARepeatedStringList(): string[]; + setARepeatedStringList(value: string[]): Simple1; + addARepeatedString(value: string, index?: number): Simple1; + clearARepeatedStringList(): Simple1; + getABoolean(): boolean; + setABoolean(value: boolean): Simple1; + clearABoolean(): Simple1; + hasABoolean(): boolean; +} + +export class Simple2 extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Simple2): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Simple2; + static deserializeBinaryFromReader(msg: Simple2, reader: jspb.BinaryReader): Simple2; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Simple2, writer: jspb.BinaryWriter): void; + getAString(): string; + setAString(value: string): Simple2; + clearAString(): Simple2; + hasAString(): boolean; + getARepeatedStringList(): string[]; + setARepeatedStringList(value: string[]): Simple2; + addARepeatedString(value: string, index?: number): Simple2; + clearARepeatedStringList(): Simple2; +} + +export class SpecialCases extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: SpecialCases): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): SpecialCases; + static deserializeBinaryFromReader(msg: SpecialCases, reader: jspb.BinaryReader): SpecialCases; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: SpecialCases, writer: jspb.BinaryWriter): void; + getNormal(): string; + setNormal(value: string): SpecialCases; + clearNormal(): SpecialCases; + hasNormal(): boolean; + getDefault(): string; + setDefault(value: string): SpecialCases; + clearDefault(): SpecialCases; + hasDefault(): boolean; + getFunction(): string; + setFunction(value: string): SpecialCases; + clearFunction(): SpecialCases; + hasFunction(): boolean; + getVar(): string; + setVar(value: string): SpecialCases; + clearVar(): SpecialCases; + hasVar(): boolean; +} + +export class OptionalFields extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: OptionalFields): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): OptionalFields; + static deserializeBinaryFromReader(msg: OptionalFields, reader: jspb.BinaryReader): OptionalFields; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: OptionalFields, writer: jspb.BinaryWriter): void; + getAString(): string; + setAString(value: string): OptionalFields; + clearAString(): OptionalFields; + hasAString(): boolean; + getABool(): boolean; + setABool(value: boolean): OptionalFields; + clearABool(): OptionalFields; + hasABool(): boolean; + getANestedMessage(): OptionalFields.Nested | null; + setANestedMessage(value: OptionalFields.Nested | null | undefined): OptionalFields; + clearANestedMessage(): OptionalFields; + hasANestedMessage(): boolean; + getARepeatedMessageList(): OptionalFields.Nested[]; + setARepeatedMessageList(value: OptionalFields.Nested[]): OptionalFields; + addARepeatedMessage(value?: OptionalFields.Nested, index?: number): OptionalFields.Nested; + clearARepeatedMessageList(): OptionalFields; + getARepeatedStringList(): string[]; + setARepeatedStringList(value: string[]): OptionalFields; + addARepeatedString(value: string, index?: number): OptionalFields; + clearARepeatedStringList(): OptionalFields; +} + +export namespace OptionalFields { + class Nested extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: OptionalFields.Nested): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): OptionalFields.Nested; + static deserializeBinaryFromReader(msg: OptionalFields.Nested, reader: jspb.BinaryReader): OptionalFields.Nested; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: OptionalFields.Nested, writer: jspb.BinaryWriter): void; + getAnInt(): number; + setAnInt(value: number): OptionalFields.Nested; + clearAnInt(): OptionalFields.Nested; + hasAnInt(): boolean; + } + +} + +export class HasExtensions extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: HasExtensions): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): HasExtensions; + static deserializeBinaryFromReader(msg: HasExtensions, reader: jspb.BinaryReader): HasExtensions; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: HasExtensions, writer: jspb.BinaryWriter): void; + getStr1(): string; + setStr1(value: string): HasExtensions; + clearStr1(): HasExtensions; + hasStr1(): boolean; + getStr2(): string; + setStr2(value: string): HasExtensions; + clearStr2(): HasExtensions; + hasStr2(): boolean; + getStr3(): string; + setStr3(value: string): HasExtensions; + clearStr3(): HasExtensions; + hasStr3(): boolean; +} + +export class Complex extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Complex): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Complex; + static deserializeBinaryFromReader(msg: Complex, reader: jspb.BinaryReader): Complex; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Complex, writer: jspb.BinaryWriter): void; + getAString(): string; + setAString(value: string): Complex; + clearAString(): Complex; + hasAString(): boolean; + getAnOutOfOrderBool(): boolean; + setAnOutOfOrderBool(value: boolean): Complex; + clearAnOutOfOrderBool(): Complex; + hasAnOutOfOrderBool(): boolean; + getANestedMessage(): Complex.Nested | null; + setANestedMessage(value: Complex.Nested | null | undefined): Complex; + clearANestedMessage(): Complex; + hasANestedMessage(): boolean; + getARepeatedMessageList(): Complex.Nested[]; + setARepeatedMessageList(value: Complex.Nested[]): Complex; + addARepeatedMessage(value?: Complex.Nested, index?: number): Complex.Nested; + clearARepeatedMessageList(): Complex; + getARepeatedStringList(): string[]; + setARepeatedStringList(value: string[]): Complex; + addARepeatedString(value: string, index?: number): Complex; + clearARepeatedStringList(): Complex; + getAFloatingPointField(): number; + setAFloatingPointField(value: number): Complex; + clearAFloatingPointField(): Complex; + hasAFloatingPointField(): boolean; +} + +export namespace Complex { + class Nested extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Complex.Nested): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Complex.Nested; + static deserializeBinaryFromReader(msg: Complex.Nested, reader: jspb.BinaryReader): Complex.Nested; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Complex.Nested, writer: jspb.BinaryWriter): void; + getAnInt(): number; + setAnInt(value: number): Complex.Nested; + clearAnInt(): Complex.Nested; + hasAnInt(): boolean; + } + +} + +export class OuterMessage extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: OuterMessage): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): OuterMessage; + static deserializeBinaryFromReader(msg: OuterMessage, reader: jspb.BinaryReader): OuterMessage; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: OuterMessage, writer: jspb.BinaryWriter): void; +} + +export namespace OuterMessage { + class Complex extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: OuterMessage.Complex): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): OuterMessage.Complex; + static deserializeBinaryFromReader(msg: OuterMessage.Complex, reader: jspb.BinaryReader): OuterMessage.Complex; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: OuterMessage.Complex, writer: jspb.BinaryWriter): void; + getInnerComplexField(): number; + setInnerComplexField(value: number): OuterMessage.Complex; + clearInnerComplexField(): OuterMessage.Complex; + hasInnerComplexField(): boolean; + } + +} + +export class MineField extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: MineField): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): MineField; + static deserializeBinaryFromReader(msg: MineField, reader: jspb.BinaryReader): MineField; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: MineField, writer: jspb.BinaryWriter): void; + getCookie(): string; + setCookie(value: string): MineField; + clearCookie(): MineField; + hasCookie(): boolean; +} + +export class IsExtension extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: IsExtension): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): IsExtension; + static deserializeBinaryFromReader(msg: IsExtension, reader: jspb.BinaryReader): IsExtension; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: IsExtension, writer: jspb.BinaryWriter): void; + getExt1(): string; + setExt1(value: string): IsExtension; + clearExt1(): IsExtension; + hasExt1(): boolean; +} + +export class IndirectExtension extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: IndirectExtension): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): IndirectExtension; + static deserializeBinaryFromReader(msg: IndirectExtension, reader: jspb.BinaryReader): IndirectExtension; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: IndirectExtension, writer: jspb.BinaryWriter): void; +} + +export class DefaultValues extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: DefaultValues): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): DefaultValues; + static deserializeBinaryFromReader(msg: DefaultValues, reader: jspb.BinaryReader): DefaultValues; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: DefaultValues, writer: jspb.BinaryWriter): void; + getStringField(): string; + setStringField(value: string): DefaultValues; + clearStringField(): DefaultValues; + hasStringField(): boolean; + getBoolField(): boolean; + setBoolField(value: boolean): DefaultValues; + clearBoolField(): DefaultValues; + hasBoolField(): boolean; + getIntField(): number; + setIntField(value: number): DefaultValues; + clearIntField(): DefaultValues; + hasIntField(): boolean; + getEnumField(): DefaultValues.Enum; + setEnumField(value: DefaultValues.Enum): DefaultValues; + clearEnumField(): DefaultValues; + hasEnumField(): boolean; + getEmptyField(): string; + setEmptyField(value: string): DefaultValues; + clearEmptyField(): DefaultValues; + hasEmptyField(): boolean; + getBytesField(): (string|Uint8Array); + getBytesField_asB64(): string; + getBytesField_asU8(): Uint8Array; + setBytesField(value: (string|Uint8Array)): DefaultValues; + clearBytesField(): DefaultValues; + hasBytesField(): boolean; +} + +export namespace DefaultValues { + enum Enum { + E1 = 13, + E2 = 77, + } + +} + +export class FloatingPointFields extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: FloatingPointFields): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): FloatingPointFields; + static deserializeBinaryFromReader(msg: FloatingPointFields, reader: jspb.BinaryReader): FloatingPointFields; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: FloatingPointFields, writer: jspb.BinaryWriter): void; + getOptionalFloatField(): number; + setOptionalFloatField(value: number): FloatingPointFields; + clearOptionalFloatField(): FloatingPointFields; + hasOptionalFloatField(): boolean; + getRequiredFloatField(): number; + setRequiredFloatField(value: number): FloatingPointFields; + clearRequiredFloatField(): FloatingPointFields; + hasRequiredFloatField(): boolean; + getRepeatedFloatFieldList(): number[]; + setRepeatedFloatFieldList(value: number[]): FloatingPointFields; + addRepeatedFloatField(value: number, index?: number): FloatingPointFields; + clearRepeatedFloatFieldList(): FloatingPointFields; + getDefaultFloatField(): number; + setDefaultFloatField(value: number): FloatingPointFields; + clearDefaultFloatField(): FloatingPointFields; + hasDefaultFloatField(): boolean; + getOptionalDoubleField(): number; + setOptionalDoubleField(value: number): FloatingPointFields; + clearOptionalDoubleField(): FloatingPointFields; + hasOptionalDoubleField(): boolean; + getRequiredDoubleField(): number; + setRequiredDoubleField(value: number): FloatingPointFields; + clearRequiredDoubleField(): FloatingPointFields; + hasRequiredDoubleField(): boolean; + getRepeatedDoubleFieldList(): number[]; + setRepeatedDoubleFieldList(value: number[]): FloatingPointFields; + addRepeatedDoubleField(value: number, index?: number): FloatingPointFields; + clearRepeatedDoubleFieldList(): FloatingPointFields; + getDefaultDoubleField(): number; + setDefaultDoubleField(value: number): FloatingPointFields; + clearDefaultDoubleField(): FloatingPointFields; + hasDefaultDoubleField(): boolean; +} + +export class BooleanFields extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: BooleanFields): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): BooleanFields; + static deserializeBinaryFromReader(msg: BooleanFields, reader: jspb.BinaryReader): BooleanFields; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: BooleanFields, writer: jspb.BinaryWriter): void; + getOptionalBooleanField(): boolean; + setOptionalBooleanField(value: boolean): BooleanFields; + clearOptionalBooleanField(): BooleanFields; + hasOptionalBooleanField(): boolean; + getRequiredBooleanField(): boolean; + setRequiredBooleanField(value: boolean): BooleanFields; + clearRequiredBooleanField(): BooleanFields; + hasRequiredBooleanField(): boolean; + getRepeatedBooleanFieldList(): boolean[]; + setRepeatedBooleanFieldList(value: boolean[]): BooleanFields; + addRepeatedBooleanField(value: boolean, index?: number): BooleanFields; + clearRepeatedBooleanFieldList(): BooleanFields; + getDefaultBooleanField(): boolean; + setDefaultBooleanField(value: boolean): BooleanFields; + clearDefaultBooleanField(): BooleanFields; + hasDefaultBooleanField(): boolean; +} + +export class TestClone extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestClone): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestClone; + static deserializeBinaryFromReader(msg: TestClone, reader: jspb.BinaryReader): TestClone; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestClone, writer: jspb.BinaryWriter): void; + getStr(): string; + setStr(value: string): TestClone; + clearStr(): TestClone; + hasStr(): boolean; + getSimple1(): Simple1 | null; + setSimple1(value: Simple1 | null | undefined): TestClone; + clearSimple1(): TestClone; + hasSimple1(): boolean; + getSimple2List(): Simple1[]; + setSimple2List(value: Simple1[]): TestClone; + addSimple2(value?: Simple1, index?: number): Simple1; + clearSimple2List(): TestClone; + getBytesField(): (string|Uint8Array); + getBytesField_asB64(): string; + getBytesField_asU8(): Uint8Array; + setBytesField(value: (string|Uint8Array)): TestClone; + clearBytesField(): TestClone; + hasBytesField(): boolean; + getUnused(): string; + setUnused(value: string): TestClone; + clearUnused(): TestClone; + hasUnused(): boolean; +} + +export class TestCloneExtension extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestCloneExtension): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestCloneExtension; + static deserializeBinaryFromReader(msg: TestCloneExtension, reader: jspb.BinaryReader): TestCloneExtension; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestCloneExtension, writer: jspb.BinaryWriter): void; + getF(): number; + setF(value: number): TestCloneExtension; + clearF(): TestCloneExtension; + hasF(): boolean; +} + +export class CloneExtension extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: CloneExtension): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): CloneExtension; + static deserializeBinaryFromReader(msg: CloneExtension, reader: jspb.BinaryReader): CloneExtension; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: CloneExtension, writer: jspb.BinaryWriter): void; + getExt(): string; + setExt(value: string): CloneExtension; + clearExt(): CloneExtension; + hasExt(): boolean; +} + +export class TestGroup extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestGroup): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestGroup; + static deserializeBinaryFromReader(msg: TestGroup, reader: jspb.BinaryReader): TestGroup; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestGroup, writer: jspb.BinaryWriter): void; + getRepeatedGroupList(): TestGroup.RepeatedGroup[]; + setRepeatedGroupList(value: TestGroup.RepeatedGroup[]): TestGroup; + addRepeatedGroup(value?: TestGroup.RepeatedGroup, index?: number): TestGroup.RepeatedGroup; + clearRepeatedGroupList(): TestGroup; + getRequiredGroup(): TestGroup.RequiredGroup; + setRequiredGroup(value: TestGroup.RequiredGroup): TestGroup; + clearRequiredGroup(): TestGroup; + hasRequiredGroup(): boolean; + getOptionalGroup(): TestGroup.OptionalGroup | null; + setOptionalGroup(value: TestGroup.OptionalGroup | null | undefined): TestGroup; + clearOptionalGroup(): TestGroup; + hasOptionalGroup(): boolean; + getId(): string; + setId(value: string): TestGroup; + clearId(): TestGroup; + hasId(): boolean; + getRequiredSimple(): Simple2; + setRequiredSimple(value: Simple2): TestGroup; + clearRequiredSimple(): TestGroup; + hasRequiredSimple(): boolean; + getOptionalSimple(): Simple2 | null; + setOptionalSimple(value: Simple2 | null | undefined): TestGroup; + clearOptionalSimple(): TestGroup; + hasOptionalSimple(): boolean; +} + +export namespace TestGroup { + class RepeatedGroup extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestGroup.RepeatedGroup): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestGroup.RepeatedGroup; + static deserializeBinaryFromReader(msg: TestGroup.RepeatedGroup, reader: jspb.BinaryReader): TestGroup.RepeatedGroup; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestGroup.RepeatedGroup, writer: jspb.BinaryWriter): void; + getId(): string; + setId(value: string): TestGroup.RepeatedGroup; + clearId(): TestGroup.RepeatedGroup; + hasId(): boolean; + getSomeBoolList(): boolean[]; + setSomeBoolList(value: boolean[]): TestGroup.RepeatedGroup; + addSomeBool(value: boolean, index?: number): TestGroup.RepeatedGroup; + clearSomeBoolList(): TestGroup.RepeatedGroup; + } + + class RequiredGroup extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestGroup.RequiredGroup): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestGroup.RequiredGroup; + static deserializeBinaryFromReader(msg: TestGroup.RequiredGroup, reader: jspb.BinaryReader): TestGroup.RequiredGroup; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestGroup.RequiredGroup, writer: jspb.BinaryWriter): void; + getId(): string; + setId(value: string): TestGroup.RequiredGroup; + clearId(): TestGroup.RequiredGroup; + hasId(): boolean; + } + + class OptionalGroup extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestGroup.OptionalGroup): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestGroup.OptionalGroup; + static deserializeBinaryFromReader(msg: TestGroup.OptionalGroup, reader: jspb.BinaryReader): TestGroup.OptionalGroup; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestGroup.OptionalGroup, writer: jspb.BinaryWriter): void; + getId(): string; + setId(value: string): TestGroup.OptionalGroup; + clearId(): TestGroup.OptionalGroup; + hasId(): boolean; + } + +} + +export class TestGroup1 extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestGroup1): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestGroup1; + static deserializeBinaryFromReader(msg: TestGroup1, reader: jspb.BinaryReader): TestGroup1; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestGroup1, writer: jspb.BinaryWriter): void; + getGroup(): TestGroup.RepeatedGroup | null; + setGroup(value: TestGroup.RepeatedGroup | null | undefined): TestGroup1; + clearGroup(): TestGroup1; + hasGroup(): boolean; +} + +export class TestReservedNames extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestReservedNames): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestReservedNames; + static deserializeBinaryFromReader(msg: TestReservedNames, reader: jspb.BinaryReader): TestReservedNames; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestReservedNames, writer: jspb.BinaryWriter): void; + getExtension$(): number; + setExtension$(value: number): TestReservedNames; + clearExtension$(): TestReservedNames; + hasExtension$(): boolean; +} + +export class TestReservedNamesExtension extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestReservedNamesExtension): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestReservedNamesExtension; + static deserializeBinaryFromReader(msg: TestReservedNamesExtension, reader: jspb.BinaryReader): TestReservedNamesExtension; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestReservedNamesExtension, writer: jspb.BinaryWriter): void; +} + +export class TestMessageWithOneof extends jspb.Message { + constructor(data?: any[] | null); + getPartialOneofCase(): TestMessageWithOneof.PartialOneofCase; + getRecursiveOneofCase(): TestMessageWithOneof.RecursiveOneofCase; + getDefaultOneofACase(): TestMessageWithOneof.DefaultOneofACase; + getDefaultOneofBCase(): TestMessageWithOneof.DefaultOneofBCase; + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestMessageWithOneof): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestMessageWithOneof; + static deserializeBinaryFromReader(msg: TestMessageWithOneof, reader: jspb.BinaryReader): TestMessageWithOneof; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestMessageWithOneof, writer: jspb.BinaryWriter): void; + getPone(): string; + setPone(value: string): TestMessageWithOneof; + clearPone(): TestMessageWithOneof; + hasPone(): boolean; + getPthree(): string; + setPthree(value: string): TestMessageWithOneof; + clearPthree(): TestMessageWithOneof; + hasPthree(): boolean; + getRone(): TestMessageWithOneof | null; + setRone(value: TestMessageWithOneof | null | undefined): TestMessageWithOneof; + clearRone(): TestMessageWithOneof; + hasRone(): boolean; + getRtwo(): string; + setRtwo(value: string): TestMessageWithOneof; + clearRtwo(): TestMessageWithOneof; + hasRtwo(): boolean; + getNormalField(): boolean; + setNormalField(value: boolean): TestMessageWithOneof; + clearNormalField(): TestMessageWithOneof; + hasNormalField(): boolean; + getRepeatedFieldList(): string[]; + setRepeatedFieldList(value: string[]): TestMessageWithOneof; + addRepeatedField(value: string, index?: number): TestMessageWithOneof; + clearRepeatedFieldList(): TestMessageWithOneof; + getAone(): number; + setAone(value: number): TestMessageWithOneof; + clearAone(): TestMessageWithOneof; + hasAone(): boolean; + getAtwo(): number; + setAtwo(value: number): TestMessageWithOneof; + clearAtwo(): TestMessageWithOneof; + hasAtwo(): boolean; + getBone(): number; + setBone(value: number): TestMessageWithOneof; + clearBone(): TestMessageWithOneof; + hasBone(): boolean; + getBtwo(): number; + setBtwo(value: number): TestMessageWithOneof; + clearBtwo(): TestMessageWithOneof; + hasBtwo(): boolean; +} + +export namespace TestMessageWithOneof { + enum PartialOneofCase { + PARTIAL_ONEOF_NOT_SET = 0, + PONE = 3, + PTHREE = 5, + } + enum RecursiveOneofCase { + RECURSIVE_ONEOF_NOT_SET = 0, + RONE = 6, + RTWO = 7, + } + enum DefaultOneofACase { + DEFAULT_ONEOF_A_NOT_SET = 0, + AONE = 10, + ATWO = 11, + } + enum DefaultOneofBCase { + DEFAULT_ONEOF_B_NOT_SET = 0, + BONE = 12, + BTWO = 13, + } +} + +export class TestEndsWithBytes extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestEndsWithBytes): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestEndsWithBytes; + static deserializeBinaryFromReader(msg: TestEndsWithBytes, reader: jspb.BinaryReader): TestEndsWithBytes; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestEndsWithBytes, writer: jspb.BinaryWriter): void; + getValue(): number; + setValue(value: number): TestEndsWithBytes; + clearValue(): TestEndsWithBytes; + hasValue(): boolean; + getData(): (string|Uint8Array); + getData_asB64(): string; + getData_asU8(): Uint8Array; + setData(value: (string|Uint8Array)): TestEndsWithBytes; + clearData(): TestEndsWithBytes; + hasData(): boolean; +} + +export class TestLastFieldBeforePivot extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestLastFieldBeforePivot): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestLastFieldBeforePivot; + static deserializeBinaryFromReader(msg: TestLastFieldBeforePivot, reader: jspb.BinaryReader): TestLastFieldBeforePivot; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestLastFieldBeforePivot, writer: jspb.BinaryWriter): void; + getLastFieldBeforePivot(): number; + setLastFieldBeforePivot(value: number): TestLastFieldBeforePivot; + clearLastFieldBeforePivot(): TestLastFieldBeforePivot; + hasLastFieldBeforePivot(): boolean; +} + +export class Int64Types extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Int64Types): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Int64Types; + static deserializeBinaryFromReader(msg: Int64Types, reader: jspb.BinaryReader): Int64Types; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Int64Types, writer: jspb.BinaryWriter): void; + getInt64Normal(): number; + setInt64Normal(value: number): Int64Types; + clearInt64Normal(): Int64Types; + hasInt64Normal(): boolean; + getInt64String(): string; + setInt64String(value: string): Int64Types; + clearInt64String(): Int64Types; + hasInt64String(): boolean; + getInt64Number(): number; + setInt64Number(value: number): Int64Types; + clearInt64Number(): Int64Types; + hasInt64Number(): boolean; +} + +export class TestMapFieldsNoBinary extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestMapFieldsNoBinary): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestMapFieldsNoBinary; + static deserializeBinaryFromReader(msg: TestMapFieldsNoBinary, reader: jspb.BinaryReader): TestMapFieldsNoBinary; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestMapFieldsNoBinary, writer: jspb.BinaryWriter): void; + getMapStringStringMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringStringMap(): TestMapFieldsNoBinary; + getMapStringInt32Map(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringInt32Map(): TestMapFieldsNoBinary; + getMapStringInt64Map(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringInt64Map(): TestMapFieldsNoBinary; + getMapStringBoolMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringBoolMap(): TestMapFieldsNoBinary; + getMapStringDoubleMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringDoubleMap(): TestMapFieldsNoBinary; + getMapStringEnumMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringEnumMap(): TestMapFieldsNoBinary; + getMapStringMsgMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringMsgMap(): TestMapFieldsNoBinary; + getMapInt32StringMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapInt32StringMap(): TestMapFieldsNoBinary; + getMapInt64StringMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapInt64StringMap(): TestMapFieldsNoBinary; + getMapBoolStringMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapBoolStringMap(): TestMapFieldsNoBinary; + getTestMapFields(): TestMapFieldsNoBinary | null; + setTestMapFields(value: TestMapFieldsNoBinary | null | undefined): TestMapFieldsNoBinary; + clearTestMapFields(): TestMapFieldsNoBinary; + hasTestMapFields(): boolean; + getMapStringTestmapfieldsMap(noLazyCreate?: boolean): jspb.Map | undefined; + clearMapStringTestmapfieldsMap(): TestMapFieldsNoBinary; +} + +export class MapValueMessageNoBinary extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: MapValueMessageNoBinary): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): MapValueMessageNoBinary; + static deserializeBinaryFromReader(msg: MapValueMessageNoBinary, reader: jspb.BinaryReader): MapValueMessageNoBinary; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: MapValueMessageNoBinary, writer: jspb.BinaryWriter): void; + getFoo(): number; + setFoo(value: number): MapValueMessageNoBinary; + clearFoo(): MapValueMessageNoBinary; + hasFoo(): boolean; +} + +export class Deeply extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Deeply): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Deeply; + static deserializeBinaryFromReader(msg: Deeply, reader: jspb.BinaryReader): Deeply; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Deeply, writer: jspb.BinaryWriter): void; +} + +export namespace Deeply { + class Nested extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Deeply.Nested): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Deeply.Nested; + static deserializeBinaryFromReader(msg: Deeply.Nested, reader: jspb.BinaryReader): Deeply.Nested; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Deeply.Nested, writer: jspb.BinaryWriter): void; + } + + namespace Nested { + class Message extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: Deeply.Nested.Message): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): Deeply.Nested.Message; + static deserializeBinaryFromReader(msg: Deeply.Nested.Message, reader: jspb.BinaryReader): Deeply.Nested.Message; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: Deeply.Nested.Message, writer: jspb.BinaryWriter): void; + getCount(): number; + setCount(value: number): Deeply.Nested.Message; + clearCount(): Deeply.Nested.Message; + hasCount(): boolean; + } + + } + +} + +export enum OuterEnum { + FOO = 1, + BAR = 2, +} + +export enum MapValueEnumNoBinary { + MAP_VALUE_FOO_NOBINARY = 0, + MAP_VALUE_BAR_NOBINARY = 1, + MAP_VALUE_BAZ_NOBINARY = 2, +} + +export enum TestAllowAliasEnum { + TEST_ALLOW_ALIAS_DEFAULT = 0, + VALUE1 = 1, +} + diff --git a/example/test.js b/example/test.js new file mode 100644 index 0000000..a78b63c --- /dev/null +++ b/example/test.js @@ -0,0 +1,9464 @@ +// source: protos/test.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +import * as jspb from 'google-protobuf'; +var goog = jspb; +var proto = {}; + +import * as google_protobuf_descriptor_pb from 'google-protobuf/google/protobuf/descriptor.js'; +export class Empty extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Empty} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Empty; + return Empty.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Empty} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Empty} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Empty.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Empty} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + }; + + +} + + + +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} + */ +Empty.prototype.toObject = function(opt_includeInstance) { + return Empty.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.jspb.test.Empty} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Empty.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class EnumContainer extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional OuterEnum outer_enum = 1; + * @return {!proto.jspb.test.OuterEnum} + */ + getOuterEnum() { + return /** @type {!proto.jspb.test.OuterEnum} */ (jspb.Message.getFieldWithDefault(this, 1, 1)); + }; + + + /** + * @param {!proto.jspb.test.OuterEnum} value + * @return {!proto.jspb.test.EnumContainer} returns this + */ + setOuterEnum(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.EnumContainer} returns this + */ + clearOuterEnum() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasOuterEnum() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.EnumContainer} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new EnumContainer; + return EnumContainer.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.EnumContainer} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.EnumContainer} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {!proto.jspb.test.OuterEnum} */ (reader.readEnum()); + msg.setOuterEnum(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + EnumContainer.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.EnumContainer} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {!proto.jspb.test.OuterEnum} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeEnum( + 1, + f + ); + } + }; + + +} + + + +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} + */ +EnumContainer.prototype.toObject = function(opt_includeInstance) { + return EnumContainer.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.jspb.test.EnumContainer} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +EnumContainer.toObject = function(includeInstance, msg) { + var f, obj = { +outerEnum: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class Simple1 extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, Simple1.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [2]; + + /** + * required string a_string = 1; + * @return {string} + */ + getAString() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.Simple1} returns this + */ + setAString(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple1} returns this + */ + clearAString() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAString() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * repeated string a_repeated_string = 2; + * @return {!Array} + */ + getARepeatedStringList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.Simple1} returns this + */ + setARepeatedStringList(value) { + return jspb.Message.setField(this, 2, value || []); + }; + + + /** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple1} returns this + */ + addARepeatedString(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Simple1} returns this + */ + clearARepeatedStringList() { + return this.setARepeatedStringList([]); + }; + + + /** + * optional bool a_boolean = 3; + * @return {boolean} + */ + getABoolean() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 3, false)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.Simple1} returns this + */ + setABoolean(value) { + return jspb.Message.setField(this, 3, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple1} returns this + */ + clearABoolean() { + return jspb.Message.setField(this, 3, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasABoolean() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Simple1} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Simple1; + return Simple1.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Simple1} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Simple1} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + case 3: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setABoolean(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Simple1.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Simple1} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeBool( + 3, + f + ); + } + }; + + +} + + + +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} + */ +Simple1.prototype.toObject = function(opt_includeInstance) { + return Simple1.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.jspb.test.Simple1} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Simple1.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f, +aBoolean: (f = jspb.Message.getBooleanField(msg, 3)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class Simple2 extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, Simple2.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [2]; + + /** + * required string a_string = 1; + * @return {string} + */ + getAString() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.Simple2} returns this + */ + setAString(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Simple2} returns this + */ + clearAString() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAString() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * repeated string a_repeated_string = 2; + * @return {!Array} + */ + getARepeatedStringList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 2)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.Simple2} returns this + */ + setARepeatedStringList(value) { + return jspb.Message.setField(this, 2, value || []); + }; + + + /** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple2} returns this + */ + addARepeatedString(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 2, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Simple2} returns this + */ + clearARepeatedStringList() { + return this.setARepeatedStringList([]); + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Simple2} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Simple2; + return Simple2.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Simple2} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Simple2} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Simple2.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Simple2} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 2, + f + ); + } + }; + + +} + + + +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} + */ +Simple2.prototype.toObject = function(opt_includeInstance) { + return Simple2.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.jspb.test.Simple2} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Simple2.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class SpecialCases extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * required string normal = 1; + * @return {string} + */ + getNormal() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ + setNormal(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ + clearNormal() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasNormal() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * required string default = 2; + * @return {string} + */ + getDefault() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ + setDefault(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ + clearDefault() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasDefault() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * required string function = 3; + * @return {string} + */ + getFunction() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ + setFunction(value) { + return jspb.Message.setField(this, 3, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ + clearFunction() { + return jspb.Message.setField(this, 3, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasFunction() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * required string var = 4; + * @return {string} + */ + getVar() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.SpecialCases} returns this + */ + setVar(value) { + return jspb.Message.setField(this, 4, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.SpecialCases} returns this + */ + clearVar() { + return jspb.Message.setField(this, 4, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasVar() { + return jspb.Message.getField(this, 4) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.SpecialCases} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new SpecialCases; + return SpecialCases.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.SpecialCases} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.SpecialCases} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setNormal(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setDefault(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setFunction(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setVar(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + SpecialCases.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.SpecialCases} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } + }; + + +} + + + +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} + */ +SpecialCases.prototype.toObject = function(opt_includeInstance) { + return SpecialCases.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.jspb.test.SpecialCases} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +SpecialCases.toObject = function(includeInstance, msg) { + var f, obj = { +normal: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +pb_default: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +pb_function: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f, +pb_var: (f = jspb.Message.getField(msg, 4)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class OptionalFields extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, OptionalFields.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [4,5]; + + /** + * optional string a_string = 1; + * @return {string} + */ + getAString() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ + setAString(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ + clearAString() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAString() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * required bool a_bool = 2; + * @return {boolean} + */ + getABool() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ + setABool(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ + clearABool() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasABool() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * optional Nested a_nested_message = 3; + * @return {?proto.jspb.test.OptionalFields.Nested} + */ + getANestedMessage() { + return /** @type{?proto.jspb.test.OptionalFields.Nested} */ ( + jspb.Message.getWrapperField(this, OptionalFields.Nested, 3)); + }; + + + /** + * @param {?proto.jspb.test.OptionalFields.Nested|undefined} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ + setANestedMessage(value) { + return jspb.Message.setWrapperField(this, 3, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.OptionalFields} returns this + */ + clearANestedMessage() { + return this.setANestedMessage(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasANestedMessage() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * repeated Nested a_repeated_message = 4; + * @return {!Array} + */ + getARepeatedMessageList() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, OptionalFields.Nested, 4)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ + setARepeatedMessageList(value) { + return jspb.Message.setRepeatedWrapperField(this, 4, value); + }; + + + /** + * @param {!proto.jspb.test.OptionalFields.Nested=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.OptionalFields.Nested} + */ + addARepeatedMessage(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 4, opt_value, OptionalFields.Nested, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.OptionalFields} returns this + */ + clearARepeatedMessageList() { + return this.setARepeatedMessageList([]); + }; + + + /** + * repeated string a_repeated_string = 5; + * @return {!Array} + */ + getARepeatedStringList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 5)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.OptionalFields} returns this + */ + setARepeatedStringList(value) { + return jspb.Message.setField(this, 5, value || []); + }; + + + /** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.OptionalFields} returns this + */ + addARepeatedString(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 5, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.OptionalFields} returns this + */ + clearARepeatedStringList() { + return this.setARepeatedStringList([]); + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.OptionalFields} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new OptionalFields; + return OptionalFields.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OptionalFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OptionalFields} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setABool(value); + break; + case 3: + var value = new OptionalFields.Nested; + reader.readMessage(value,OptionalFields.Nested.deserializeBinaryFromReader); + msg.setANestedMessage(value); + break; + case 4: + var value = new OptionalFields.Nested; + reader.readMessage(value,OptionalFields.Nested.deserializeBinaryFromReader); + msg.addARepeatedMessage(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + OptionalFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OptionalFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = message.getANestedMessage(); + if (f != null) { + writer.writeMessage( + 3, + f, + OptionalFields.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedMessageList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 4, + f, + OptionalFields.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 5, + f + ); + } + }; + + +} + + + +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} + */ +OptionalFields.prototype.toObject = function(opt_includeInstance) { + return OptionalFields.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.jspb.test.OptionalFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +OptionalFields.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +aBool: (f = jspb.Message.getBooleanField(msg, 2)) == null ? undefined : f, +aNestedMessage: (f = msg.getANestedMessage()) && OptionalFields.Nested.toObject(includeInstance, f), +aRepeatedMessageList: jspb.Message.toObjectList(msg.getARepeatedMessageList(), + OptionalFields.Nested.toObject, includeInstance), +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 5)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +OptionalFields.Nested = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional int32 an_int = 1; + * @return {number} + */ + getAnInt() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.OptionalFields.Nested} returns this + */ + setAnInt(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OptionalFields.Nested} returns this + */ + clearAnInt() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAnInt() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.OptionalFields.Nested} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new OptionalFields.Nested; + return OptionalFields.Nested.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OptionalFields.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OptionalFields.Nested} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAnInt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + OptionalFields.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OptionalFields.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + }; + + +} + + + +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} + */ +OptionalFields.Nested.prototype.toObject = function(opt_includeInstance) { + return OptionalFields.Nested.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.jspb.test.OptionalFields.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +OptionalFields.Nested.toObject = function(includeInstance, msg) { + var f, obj = { +anInt: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class HasExtensions extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 4, null, null); + }; + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensions = {}; + + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensionsBinary = {}; + + /** + * optional string str1 = 1; + * @return {string} + */ + getStr1() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ + setStr1(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ + clearStr1() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasStr1() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * optional string str2 = 2; + * @return {string} + */ + getStr2() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ + setStr2(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ + clearStr2() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasStr2() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * optional string str3 = 3; + * @return {string} + */ + getStr3() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.HasExtensions} returns this + */ + setStr3(value) { + return jspb.Message.setField(this, 3, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.HasExtensions} returns this + */ + clearStr3() { + return jspb.Message.setField(this, 3, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasStr3() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.HasExtensions} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new HasExtensions; + return HasExtensions.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.HasExtensions} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.HasExtensions} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStr1(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setStr2(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setStr3(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + HasExtensions.extensionsBinary, + HasExtensions.prototype.getExtension, + HasExtensions.prototype.setExtension); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + HasExtensions.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.HasExtensions} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + HasExtensions.extensionsBinary, HasExtensions.prototype.getExtension); + }; + + +} + + + +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} + */ +HasExtensions.prototype.toObject = function(opt_includeInstance) { + return HasExtensions.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.jspb.test.HasExtensions} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +HasExtensions.toObject = function(includeInstance, msg) { + var f, obj = { +str1: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +str2: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +str3: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + HasExtensions.extensions, HasExtensions.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class Complex extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, Complex.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [5,7]; + + /** + * required string a_string = 1; + * @return {string} + */ + getAString() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.Complex} returns this + */ + setAString(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ + clearAString() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAString() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * optional bool an_out_of_order_bool = 9; + * @return {boolean} + */ + getAnOutOfOrderBool() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 9, false)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.Complex} returns this + */ + setAnOutOfOrderBool(value) { + return jspb.Message.setField(this, 9, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ + clearAnOutOfOrderBool() { + return jspb.Message.setField(this, 9, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAnOutOfOrderBool() { + return jspb.Message.getField(this, 9) != null; + }; + + + /** + * optional Nested a_nested_message = 4; + * @return {?proto.jspb.test.Complex.Nested} + */ + getANestedMessage() { + return /** @type{?proto.jspb.test.Complex.Nested} */ ( + jspb.Message.getWrapperField(this, Complex.Nested, 4)); + }; + + + /** + * @param {?proto.jspb.test.Complex.Nested|undefined} value + * @return {!proto.jspb.test.Complex} returns this + */ + setANestedMessage(value) { + return jspb.Message.setWrapperField(this, 4, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ + clearANestedMessage() { + return this.setANestedMessage(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasANestedMessage() { + return jspb.Message.getField(this, 4) != null; + }; + + + /** + * repeated Nested a_repeated_message = 5; + * @return {!Array} + */ + getARepeatedMessageList() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, Complex.Nested, 5)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.Complex} returns this + */ + setARepeatedMessageList(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); + }; + + + /** + * @param {!proto.jspb.test.Complex.Nested=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.Complex.Nested} + */ + addARepeatedMessage(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, Complex.Nested, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Complex} returns this + */ + clearARepeatedMessageList() { + return this.setARepeatedMessageList([]); + }; + + + /** + * repeated string a_repeated_string = 7; + * @return {!Array} + */ + getARepeatedStringList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 7)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.Complex} returns this + */ + setARepeatedStringList(value) { + return jspb.Message.setField(this, 7, value || []); + }; + + + /** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.Complex} returns this + */ + addARepeatedString(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 7, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.Complex} returns this + */ + clearARepeatedStringList() { + return this.setARepeatedStringList([]); + }; + + + /** + * optional double a_floating_point_field = 10; + * @return {number} + */ + getAFloatingPointField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 10, 0.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.Complex} returns this + */ + setAFloatingPointField(value) { + return jspb.Message.setField(this, 10, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex} returns this + */ + clearAFloatingPointField() { + return jspb.Message.setField(this, 10, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAFloatingPointField() { + return jspb.Message.getField(this, 10) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Complex} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Complex; + return Complex.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Complex} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Complex} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setAString(value); + break; + case 9: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setAnOutOfOrderBool(value); + break; + case 4: + var value = new Complex.Nested; + reader.readMessage(value,Complex.Nested.deserializeBinaryFromReader); + msg.setANestedMessage(value); + break; + case 5: + var value = new Complex.Nested; + reader.readMessage(value,Complex.Nested.deserializeBinaryFromReader); + msg.addARepeatedMessage(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.addARepeatedString(value); + break; + case 10: + var value = /** @type {number} */ (reader.readDouble()); + msg.setAFloatingPointField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Complex.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Complex} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 9)); + if (f != null) { + writer.writeBool( + 9, + f + ); + } + f = message.getANestedMessage(); + if (f != null) { + writer.writeMessage( + 4, + f, + Complex.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedMessageList(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + Complex.Nested.serializeBinaryToWriter + ); + } + f = message.getARepeatedStringList(); + if (f.length > 0) { + writer.writeRepeatedString( + 7, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 10)); + if (f != null) { + writer.writeDouble( + 10, + f + ); + } + }; + + +} + + + +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} + */ +Complex.prototype.toObject = function(opt_includeInstance) { + return Complex.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.jspb.test.Complex} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Complex.toObject = function(includeInstance, msg) { + var f, obj = { +aString: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +anOutOfOrderBool: (f = jspb.Message.getBooleanField(msg, 9)) == null ? undefined : f, +aNestedMessage: (f = msg.getANestedMessage()) && Complex.Nested.toObject(includeInstance, f), +aRepeatedMessageList: jspb.Message.toObjectList(msg.getARepeatedMessageList(), + Complex.Nested.toObject, includeInstance), +aRepeatedStringList: (f = jspb.Message.getRepeatedField(msg, 7)) == null ? undefined : f, +aFloatingPointField: (f = jspb.Message.getOptionalFloatingPointField(msg, 10)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +Complex.Nested = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * required int32 an_int = 2; + * @return {number} + */ + getAnInt() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 2, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.Complex.Nested} returns this + */ + setAnInt(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Complex.Nested} returns this + */ + clearAnInt() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAnInt() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Complex.Nested} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Complex.Nested; + return Complex.Nested.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Complex.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Complex.Nested} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 2: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAnInt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Complex.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Complex.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeInt32( + 2, + f + ); + } + }; + + +} + + + +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} + */ +Complex.Nested.prototype.toObject = function(opt_includeInstance) { + return Complex.Nested.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.jspb.test.Complex.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Complex.Nested.toObject = function(includeInstance, msg) { + var f, obj = { +anInt: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class OuterMessage extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.OuterMessage} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new OuterMessage; + return OuterMessage.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OuterMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OuterMessage} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + OuterMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OuterMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + }; + + +} + + + +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} + */ +OuterMessage.prototype.toObject = function(opt_includeInstance) { + return OuterMessage.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.jspb.test.OuterMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +OuterMessage.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +OuterMessage.Complex = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional int32 inner_complex_field = 1; + * @return {number} + */ + getInnerComplexField() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.OuterMessage.Complex} returns this + */ + setInnerComplexField(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.OuterMessage.Complex} returns this + */ + clearInnerComplexField() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasInnerComplexField() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.OuterMessage.Complex} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new OuterMessage.Complex; + return OuterMessage.Complex.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.OuterMessage.Complex} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.OuterMessage.Complex} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setInnerComplexField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + OuterMessage.Complex.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.OuterMessage.Complex} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + }; + + +} + + + +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} + */ +OuterMessage.Complex.prototype.toObject = function(opt_includeInstance) { + return OuterMessage.Complex.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.jspb.test.OuterMessage.Complex} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +OuterMessage.Complex.toObject = function(includeInstance, msg) { + var f, obj = { +innerComplexField: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class MineField extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional string cookie = 1; + * @return {string} + */ + getCookie() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.MineField} returns this + */ + setCookie(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.MineField} returns this + */ + clearCookie() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasCookie() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.MineField} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new MineField; + return MineField.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.MineField} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.MineField} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setCookie(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + MineField.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.MineField} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + }; + + +} + + + +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} + */ +MineField.prototype.toObject = function(opt_includeInstance) { + return MineField.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.jspb.test.MineField} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +MineField.toObject = function(includeInstance, msg) { + var f, obj = { +cookie: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class IsExtension extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + + /** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ + static extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + IsExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + IsExtension.toObject), + 0); + /** + * optional string ext1 = 1; + * @return {string} + */ + getExt1() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.IsExtension} returns this + */ + setExt1(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.IsExtension} returns this + */ + clearExt1() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasExt1() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.IsExtension} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new IsExtension; + return IsExtension.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.IsExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.IsExtension} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setExt1(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + IsExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.IsExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + }; + + +} + + + +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} + */ +IsExtension.prototype.toObject = function(opt_includeInstance) { + return IsExtension.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.jspb.test.IsExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +IsExtension.toObject = function(includeInstance, msg) { + var f, obj = { +ext1: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +HasExtensions.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + IsExtension.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + IsExtension.serializeBinaryToWriter, + IsExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +HasExtensions.extensions[100] = IsExtension.extField; + +export class IndirectExtension extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + + /** + * A tuple of {field number, class constructor} for the extension + * field named `simple`. + * @type {!jspb.ExtensionFieldInfo} + */ + static simple = new jspb.ExtensionFieldInfo( + 101, + {simple: 0}, + Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + Simple1.toObject), + 0); + + /** + * A tuple of {field number, class constructor} for the extension + * field named `str`. + * @type {!jspb.ExtensionFieldInfo} + */ + static str = new jspb.ExtensionFieldInfo( + 102, + {str: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + + /** + * A tuple of {field number, class constructor} for the extension + * field named `repeatedStrList`. + * @type {!jspb.ExtensionFieldInfo>} + */ + static repeatedStrList = new jspb.ExtensionFieldInfo( + 103, + {repeatedStrList: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 1); + + /** + * A tuple of {field number, class constructor} for the extension + * field named `repeatedSimpleList`. + * @type {!jspb.ExtensionFieldInfo>} + */ + static repeatedSimpleList = new jspb.ExtensionFieldInfo( + 104, + {repeatedSimpleList: 0}, + Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + Simple1.toObject), + 1); + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.IndirectExtension} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new IndirectExtension; + return IndirectExtension.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.IndirectExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.IndirectExtension} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + IndirectExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.IndirectExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + }; + + +} + + + +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} + */ +IndirectExtension.prototype.toObject = function(opt_includeInstance) { + return IndirectExtension.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.jspb.test.IndirectExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +IndirectExtension.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +HasExtensions.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + IndirectExtension.simple, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + Simple1.serializeBinaryToWriter, + Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +HasExtensions.extensions[101] = IndirectExtension.simple; + + +HasExtensions.extensionsBinary[102] = new jspb.ExtensionFieldBinaryInfo( + IndirectExtension.str, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +HasExtensions.extensions[102] = IndirectExtension.str; + + +HasExtensions.extensionsBinary[103] = new jspb.ExtensionFieldBinaryInfo( + IndirectExtension.repeatedStrList, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeRepeatedString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +HasExtensions.extensions[103] = IndirectExtension.repeatedStrList; + + +HasExtensions.extensionsBinary[104] = new jspb.ExtensionFieldBinaryInfo( + IndirectExtension.repeatedSimpleList, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeRepeatedMessage, + Simple1.serializeBinaryToWriter, + Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +HasExtensions.extensions[104] = IndirectExtension.repeatedSimpleList; + +export class DefaultValues extends jspb.Message { + /** + * @enum {number} + */ + static Enum = { + E1: 13, + E2: 77 + }; + + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional string string_field = 1; + * @return {string} + */ + getStringField() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "default\x3c\x3e\x27\x22abc")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ + setStringField(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ + clearStringField() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasStringField() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * optional bool bool_field = 2; + * @return {boolean} + */ + getBoolField() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, true)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ + setBoolField(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ + clearBoolField() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasBoolField() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * optional int64 int_field = 3; + * @return {number} + */ + getIntField() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 11)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ + setIntField(value) { + return jspb.Message.setField(this, 3, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ + clearIntField() { + return jspb.Message.setField(this, 3, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasIntField() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * optional Enum enum_field = 4; + * @return {!proto.jspb.test.DefaultValues.Enum} + */ + getEnumField() { + return /** @type {!proto.jspb.test.DefaultValues.Enum} */ (jspb.Message.getFieldWithDefault(this, 4, 13)); + }; + + + /** + * @param {!proto.jspb.test.DefaultValues.Enum} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ + setEnumField(value) { + return jspb.Message.setField(this, 4, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ + clearEnumField() { + return jspb.Message.setField(this, 4, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasEnumField() { + return jspb.Message.getField(this, 4) != null; + }; + + + /** + * optional string empty_field = 6; + * @return {string} + */ + getEmptyField() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ + setEmptyField(value) { + return jspb.Message.setField(this, 6, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ + clearEmptyField() { + return jspb.Message.setField(this, 6, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasEmptyField() { + return jspb.Message.getField(this, 6) != null; + }; + + + /** + * optional bytes bytes_field = 8; + * @return {!(string|Uint8Array)} + */ + getBytesField() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 8, "bW9v")); + }; + + + /** + * optional bytes bytes_field = 8; + * This is a type-conversion wrapper around `getBytesField()` + * @return {string} + */ + getBytesField_asB64() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBytesField())); + }; + + + /** + * optional bytes bytes_field = 8; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBytesField()` + * @return {!Uint8Array} + */ + getBytesField_asU8() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBytesField())); + }; + + + /** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.DefaultValues} returns this + */ + setBytesField(value) { + return jspb.Message.setField(this, 8, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.DefaultValues} returns this + */ + clearBytesField() { + return jspb.Message.setField(this, 8, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasBytesField() { + return jspb.Message.getField(this, 8) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.DefaultValues} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new DefaultValues; + return DefaultValues.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.DefaultValues} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.DefaultValues} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStringField(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setBoolField(value); + break; + case 3: + var value = /** @type {number} */ (reader.readInt64()); + msg.setIntField(value); + break; + case 4: + var value = /** @type {!proto.jspb.test.DefaultValues.Enum} */ (reader.readEnum()); + msg.setEnumField(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setEmptyField(value); + break; + case 8: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBytesField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + DefaultValues.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.DefaultValues} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeInt64( + 3, + f + ); + } + f = /** @type {!proto.jspb.test.DefaultValues.Enum} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeEnum( + 4, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeString( + 6, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeBytes( + 8, + f + ); + } + }; + + +} + + + +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} + */ +DefaultValues.prototype.toObject = function(opt_includeInstance) { + return DefaultValues.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.jspb.test.DefaultValues} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +DefaultValues.toObject = function(includeInstance, msg) { + var f, obj = { +stringField: jspb.Message.getFieldWithDefault(msg, 1, "default\x3c\x3e\x27\x22abc"), +boolField: jspb.Message.getBooleanFieldWithDefault(msg, 2, true), +intField: jspb.Message.getFieldWithDefault(msg, 3, 11), +enumField: jspb.Message.getFieldWithDefault(msg, 4, 13), +emptyField: jspb.Message.getFieldWithDefault(msg, 6, ""), +bytesField: msg.getBytesField_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class FloatingPointFields extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, FloatingPointFields.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [3,7]; + + /** + * optional float optional_float_field = 1; + * @return {number} + */ + getOptionalFloatField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 1, 0.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setOptionalFloatField(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearOptionalFloatField() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasOptionalFloatField() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * required float required_float_field = 2; + * @return {number} + */ + getRequiredFloatField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 2, 0.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setRequiredFloatField(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearRequiredFloatField() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRequiredFloatField() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * repeated float repeated_float_field = 3; + * @return {!Array} + */ + getRepeatedFloatFieldList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedFloatingPointField(this, 3)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setRepeatedFloatFieldList(value) { + return jspb.Message.setField(this, 3, value || []); + }; + + + /** + * @param {number} value + * @param {number=} opt_index + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + addRepeatedFloatField(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearRepeatedFloatFieldList() { + return this.setRepeatedFloatFieldList([]); + }; + + + /** + * optional float default_float_field = 4; + * @return {number} + */ + getDefaultFloatField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 4, 2.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setDefaultFloatField(value) { + return jspb.Message.setField(this, 4, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearDefaultFloatField() { + return jspb.Message.setField(this, 4, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasDefaultFloatField() { + return jspb.Message.getField(this, 4) != null; + }; + + + /** + * optional double optional_double_field = 5; + * @return {number} + */ + getOptionalDoubleField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 5, 0.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setOptionalDoubleField(value) { + return jspb.Message.setField(this, 5, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearOptionalDoubleField() { + return jspb.Message.setField(this, 5, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasOptionalDoubleField() { + return jspb.Message.getField(this, 5) != null; + }; + + + /** + * required double required_double_field = 6; + * @return {number} + */ + getRequiredDoubleField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 6, 0.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setRequiredDoubleField(value) { + return jspb.Message.setField(this, 6, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearRequiredDoubleField() { + return jspb.Message.setField(this, 6, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRequiredDoubleField() { + return jspb.Message.getField(this, 6) != null; + }; + + + /** + * repeated double repeated_double_field = 7; + * @return {!Array} + */ + getRepeatedDoubleFieldList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedFloatingPointField(this, 7)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setRepeatedDoubleFieldList(value) { + return jspb.Message.setField(this, 7, value || []); + }; + + + /** + * @param {number} value + * @param {number=} opt_index + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + addRepeatedDoubleField(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 7, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearRepeatedDoubleFieldList() { + return this.setRepeatedDoubleFieldList([]); + }; + + + /** + * optional double default_double_field = 8; + * @return {number} + */ + getDefaultDoubleField() { + return /** @type {number} */ (jspb.Message.getFloatingPointFieldWithDefault(this, 8, 2.0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + setDefaultDoubleField(value) { + return jspb.Message.setField(this, 8, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.FloatingPointFields} returns this + */ + clearDefaultDoubleField() { + return jspb.Message.setField(this, 8, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasDefaultDoubleField() { + return jspb.Message.getField(this, 8) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.FloatingPointFields} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new FloatingPointFields; + return FloatingPointFields.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.FloatingPointFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.FloatingPointFields} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readFloat()); + msg.setOptionalFloatField(value); + break; + case 2: + var value = /** @type {number} */ (reader.readFloat()); + msg.setRequiredFloatField(value); + break; + case 3: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readFloat() : [reader.readFloat()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedFloatField(values[i]); + } + break; + case 4: + var value = /** @type {number} */ (reader.readFloat()); + msg.setDefaultFloatField(value); + break; + case 5: + var value = /** @type {number} */ (reader.readDouble()); + msg.setOptionalDoubleField(value); + break; + case 6: + var value = /** @type {number} */ (reader.readDouble()); + msg.setRequiredDoubleField(value); + break; + case 7: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readDouble() : [reader.readDouble()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedDoubleField(values[i]); + } + break; + case 8: + var value = /** @type {number} */ (reader.readDouble()); + msg.setDefaultDoubleField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + FloatingPointFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.FloatingPointFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeFloat( + 1, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeFloat( + 2, + f + ); + } + f = message.getRepeatedFloatFieldList(); + if (f.length > 0) { + writer.writeRepeatedFloat( + 3, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeFloat( + 4, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeDouble( + 5, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeDouble( + 6, + f + ); + } + f = message.getRepeatedDoubleFieldList(); + if (f.length > 0) { + writer.writeRepeatedDouble( + 7, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeDouble( + 8, + f + ); + } + }; + + +} + + + +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} + */ +FloatingPointFields.prototype.toObject = function(opt_includeInstance) { + return FloatingPointFields.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.jspb.test.FloatingPointFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +FloatingPointFields.toObject = function(includeInstance, msg) { + var f, obj = { +optionalFloatField: (f = jspb.Message.getOptionalFloatingPointField(msg, 1)) == null ? undefined : f, +requiredFloatField: (f = jspb.Message.getOptionalFloatingPointField(msg, 2)) == null ? undefined : f, +repeatedFloatFieldList: (f = jspb.Message.getRepeatedFloatingPointField(msg, 3)) == null ? undefined : f, +defaultFloatField: jspb.Message.getFloatingPointFieldWithDefault(msg, 4, 2.0), +optionalDoubleField: (f = jspb.Message.getOptionalFloatingPointField(msg, 5)) == null ? undefined : f, +requiredDoubleField: (f = jspb.Message.getOptionalFloatingPointField(msg, 6)) == null ? undefined : f, +repeatedDoubleFieldList: (f = jspb.Message.getRepeatedFloatingPointField(msg, 7)) == null ? undefined : f, +defaultDoubleField: jspb.Message.getFloatingPointFieldWithDefault(msg, 8, 2.0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class BooleanFields extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, BooleanFields.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [3]; + + /** + * optional bool optional_boolean_field = 1; + * @return {boolean} + */ + getOptionalBooleanField() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 1, false)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ + setOptionalBooleanField(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ + clearOptionalBooleanField() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasOptionalBooleanField() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * required bool required_boolean_field = 2; + * @return {boolean} + */ + getRequiredBooleanField() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 2, false)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ + setRequiredBooleanField(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ + clearRequiredBooleanField() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRequiredBooleanField() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * repeated bool repeated_boolean_field = 3; + * @return {!Array} + */ + getRepeatedBooleanFieldList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedBooleanField(this, 3)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ + setRepeatedBooleanFieldList(value) { + return jspb.Message.setField(this, 3, value || []); + }; + + + /** + * @param {boolean} value + * @param {number=} opt_index + * @return {!proto.jspb.test.BooleanFields} returns this + */ + addRepeatedBooleanField(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 3, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.BooleanFields} returns this + */ + clearRepeatedBooleanFieldList() { + return this.setRepeatedBooleanFieldList([]); + }; + + + /** + * optional bool default_boolean_field = 4; + * @return {boolean} + */ + getDefaultBooleanField() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 4, true)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.BooleanFields} returns this + */ + setDefaultBooleanField(value) { + return jspb.Message.setField(this, 4, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.BooleanFields} returns this + */ + clearDefaultBooleanField() { + return jspb.Message.setField(this, 4, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasDefaultBooleanField() { + return jspb.Message.getField(this, 4) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.BooleanFields} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new BooleanFields; + return BooleanFields.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.BooleanFields} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.BooleanFields} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setOptionalBooleanField(value); + break; + case 2: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setRequiredBooleanField(value); + break; + case 3: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readBool() : [reader.readBool()]); + for (var i = 0; i < values.length; i++) { + msg.addRepeatedBooleanField(values[i]); + } + break; + case 4: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setDefaultBooleanField(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + BooleanFields.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.BooleanFields} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {boolean} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeBool( + 1, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBool( + 2, + f + ); + } + f = message.getRepeatedBooleanFieldList(); + if (f.length > 0) { + writer.writeRepeatedBool( + 3, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeBool( + 4, + f + ); + } + }; + + +} + + + +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} + */ +BooleanFields.prototype.toObject = function(opt_includeInstance) { + return BooleanFields.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.jspb.test.BooleanFields} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +BooleanFields.toObject = function(includeInstance, msg) { + var f, obj = { +optionalBooleanField: (f = jspb.Message.getBooleanField(msg, 1)) == null ? undefined : f, +requiredBooleanField: (f = jspb.Message.getBooleanField(msg, 2)) == null ? undefined : f, +repeatedBooleanFieldList: (f = jspb.Message.getRepeatedBooleanField(msg, 3)) == null ? undefined : f, +defaultBooleanField: jspb.Message.getBooleanFieldWithDefault(msg, 4, true) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestClone extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 8, TestClone.repeatedFields_, null); + }; + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensions = {}; + + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensionsBinary = {}; + + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [5]; + + /** + * optional string str = 1; + * @return {string} + */ + getStr() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestClone} returns this + */ + setStr(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ + clearStr() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasStr() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * optional Simple1 simple1 = 3; + * @return {?proto.jspb.test.Simple1} + */ + getSimple1() { + return /** @type{?proto.jspb.test.Simple1} */ ( + jspb.Message.getWrapperField(this, Simple1, 3)); + }; + + + /** + * @param {?proto.jspb.test.Simple1|undefined} value + * @return {!proto.jspb.test.TestClone} returns this + */ + setSimple1(value) { + return jspb.Message.setWrapperField(this, 3, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ + clearSimple1() { + return this.setSimple1(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasSimple1() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * repeated Simple1 simple2 = 5; + * @return {!Array} + */ + getSimple2List() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, Simple1, 5)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.TestClone} returns this + */ + setSimple2List(value) { + return jspb.Message.setRepeatedWrapperField(this, 5, value); + }; + + + /** + * @param {!proto.jspb.test.Simple1=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.Simple1} + */ + addSimple2(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 5, opt_value, Simple1, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestClone} returns this + */ + clearSimple2List() { + return this.setSimple2List([]); + }; + + + /** + * optional bytes bytes_field = 6; + * @return {!(string|Uint8Array)} + */ + getBytesField() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 6, "")); + }; + + + /** + * optional bytes bytes_field = 6; + * This is a type-conversion wrapper around `getBytesField()` + * @return {string} + */ + getBytesField_asB64() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getBytesField())); + }; + + + /** + * optional bytes bytes_field = 6; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getBytesField()` + * @return {!Uint8Array} + */ + getBytesField_asU8() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getBytesField())); + }; + + + /** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.TestClone} returns this + */ + setBytesField(value) { + return jspb.Message.setField(this, 6, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ + clearBytesField() { + return jspb.Message.setField(this, 6, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasBytesField() { + return jspb.Message.getField(this, 6) != null; + }; + + + /** + * optional string unused = 7; + * @return {string} + */ + getUnused() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestClone} returns this + */ + setUnused(value) { + return jspb.Message.setField(this, 7, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestClone} returns this + */ + clearUnused() { + return jspb.Message.setField(this, 7, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasUnused() { + return jspb.Message.getField(this, 7) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestClone} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestClone; + return TestClone.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestClone} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestClone} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setStr(value); + break; + case 3: + var value = new Simple1; + reader.readMessage(value,Simple1.deserializeBinaryFromReader); + msg.setSimple1(value); + break; + case 5: + var value = new Simple1; + reader.readMessage(value,Simple1.deserializeBinaryFromReader); + msg.addSimple2(value); + break; + case 6: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setBytesField(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setUnused(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + TestClone.extensionsBinary, + TestClone.prototype.getExtension, + TestClone.prototype.setExtension); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestClone.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestClone} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getSimple1(); + if (f != null) { + writer.writeMessage( + 3, + f, + Simple1.serializeBinaryToWriter + ); + } + f = message.getSimple2List(); + if (f.length > 0) { + writer.writeRepeatedMessage( + 5, + f, + Simple1.serializeBinaryToWriter + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 6)); + if (f != null) { + writer.writeBytes( + 6, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeString( + 7, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + TestClone.extensionsBinary, TestClone.prototype.getExtension); + }; + + +} + + + +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} + */ +TestClone.prototype.toObject = function(opt_includeInstance) { + return TestClone.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.jspb.test.TestClone} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestClone.toObject = function(includeInstance, msg) { + var f, obj = { +str: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +simple1: (f = msg.getSimple1()) && Simple1.toObject(includeInstance, f), +simple2List: jspb.Message.toObjectList(msg.getSimple2List(), + Simple1.toObject, includeInstance), +bytesField: msg.getBytesField_asB64(), +unused: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + TestClone.extensions, TestClone.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestCloneExtension extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + + /** + * A tuple of {field number, class constructor} for the extension + * field named `lowExt`. + * @type {!jspb.ExtensionFieldInfo} + */ + static lowExt = new jspb.ExtensionFieldInfo( + 11, + {lowExt: 0}, + TestCloneExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + TestCloneExtension.toObject), + 0); + /** + * optional int32 f = 1; + * @return {number} + */ + getF() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestCloneExtension} returns this + */ + setF(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestCloneExtension} returns this + */ + clearF() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasF() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestCloneExtension} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestCloneExtension; + return TestCloneExtension.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestCloneExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestCloneExtension} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setF(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestCloneExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestCloneExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + }; + + +} + + + +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} + */ +TestCloneExtension.prototype.toObject = function(opt_includeInstance) { + return TestCloneExtension.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.jspb.test.TestCloneExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestCloneExtension.toObject = function(includeInstance, msg) { + var f, obj = { +f: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +TestClone.extensionsBinary[11] = new jspb.ExtensionFieldBinaryInfo( + TestCloneExtension.lowExt, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + TestCloneExtension.serializeBinaryToWriter, + TestCloneExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestClone.extensions[11] = TestCloneExtension.lowExt; + +export class CloneExtension extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + + /** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ + static extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + CloneExtension, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + CloneExtension.toObject), + 0); + /** + * optional string ext = 2; + * @return {string} + */ + getExt() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.CloneExtension} returns this + */ + setExt(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.CloneExtension} returns this + */ + clearExt() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasExt() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.CloneExtension} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new CloneExtension; + return CloneExtension.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.CloneExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.CloneExtension} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setExt(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + CloneExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.CloneExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeString( + 2, + f + ); + } + }; + + +} + + + +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} + */ +CloneExtension.prototype.toObject = function(opt_includeInstance) { + return CloneExtension.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.jspb.test.CloneExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +CloneExtension.toObject = function(includeInstance, msg) { + var f, obj = { +ext: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +TestClone.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + CloneExtension.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + CloneExtension.serializeBinaryToWriter, + CloneExtension.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestClone.extensions[100] = CloneExtension.extField; + +export class TestGroup extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, TestGroup.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [1]; + + /** + * repeated group RepeatedGroup = 1; + * @return {!Array} + */ + getRepeatedGroupList() { + return /** @type{!Array} */ ( + jspb.Message.getRepeatedWrapperField(this, TestGroup.RepeatedGroup, 1)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.TestGroup} returns this + */ + setRepeatedGroupList(value) { + return jspb.Message.setRepeatedWrapperField(this, 1, value); + }; + + + /** + * @param {!proto.jspb.test.TestGroup.RepeatedGroup=} opt_value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ + addRepeatedGroup(opt_value, opt_index) { + return jspb.Message.addToRepeatedWrapperField(this, 1, opt_value, TestGroup.RepeatedGroup, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestGroup} returns this + */ + clearRepeatedGroupList() { + return this.setRepeatedGroupList([]); + }; + + + /** + * required group RequiredGroup = 2; + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ + getRequiredGroup() { + return /** @type{!proto.jspb.test.TestGroup.RequiredGroup} */ ( + jspb.Message.getWrapperField(this, TestGroup.RequiredGroup, 2, 1)); + }; + + + /** + * @param {!proto.jspb.test.TestGroup.RequiredGroup} value + * @return {!proto.jspb.test.TestGroup} returns this + */ + setRequiredGroup(value) { + return jspb.Message.setWrapperField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ + clearRequiredGroup() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRequiredGroup() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * optional group OptionalGroup = 3; + * @return {?proto.jspb.test.TestGroup.OptionalGroup} + */ + getOptionalGroup() { + return /** @type{?proto.jspb.test.TestGroup.OptionalGroup} */ ( + jspb.Message.getWrapperField(this, TestGroup.OptionalGroup, 3)); + }; + + + /** + * @param {?proto.jspb.test.TestGroup.OptionalGroup|undefined} value + * @return {!proto.jspb.test.TestGroup} returns this + */ + setOptionalGroup(value) { + return jspb.Message.setWrapperField(this, 3, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ + clearOptionalGroup() { + return this.setOptionalGroup(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasOptionalGroup() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * optional string id = 4; + * @return {string} + */ + getId() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestGroup} returns this + */ + setId(value) { + return jspb.Message.setField(this, 4, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ + clearId() { + return jspb.Message.setField(this, 4, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasId() { + return jspb.Message.getField(this, 4) != null; + }; + + + /** + * required Simple2 required_simple = 5; + * @return {!proto.jspb.test.Simple2} + */ + getRequiredSimple() { + return /** @type{!proto.jspb.test.Simple2} */ ( + jspb.Message.getWrapperField(this, Simple2, 5, 1)); + }; + + + /** + * @param {!proto.jspb.test.Simple2} value + * @return {!proto.jspb.test.TestGroup} returns this + */ + setRequiredSimple(value) { + return jspb.Message.setWrapperField(this, 5, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ + clearRequiredSimple() { + return jspb.Message.setField(this, 5, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRequiredSimple() { + return jspb.Message.getField(this, 5) != null; + }; + + + /** + * optional Simple2 optional_simple = 6; + * @return {?proto.jspb.test.Simple2} + */ + getOptionalSimple() { + return /** @type{?proto.jspb.test.Simple2} */ ( + jspb.Message.getWrapperField(this, Simple2, 6)); + }; + + + /** + * @param {?proto.jspb.test.Simple2|undefined} value + * @return {!proto.jspb.test.TestGroup} returns this + */ + setOptionalSimple(value) { + return jspb.Message.setWrapperField(this, 6, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup} returns this + */ + clearOptionalSimple() { + return this.setOptionalSimple(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasOptionalSimple() { + return jspb.Message.getField(this, 6) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestGroup} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestGroup; + return TestGroup.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new TestGroup.RepeatedGroup; + reader.readGroup(1, value,TestGroup.RepeatedGroup.deserializeBinaryFromReader); + msg.addRepeatedGroup(value); + break; + case 2: + var value = new TestGroup.RequiredGroup; + reader.readGroup(2, value,TestGroup.RequiredGroup.deserializeBinaryFromReader); + msg.setRequiredGroup(value); + break; + case 3: + var value = new TestGroup.OptionalGroup; + reader.readGroup(3, value,TestGroup.OptionalGroup.deserializeBinaryFromReader); + msg.setOptionalGroup(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 5: + var value = new Simple2; + reader.readMessage(value,Simple2.deserializeBinaryFromReader); + msg.setRequiredSimple(value); + break; + case 6: + var value = new Simple2; + reader.readMessage(value,Simple2.deserializeBinaryFromReader); + msg.setOptionalSimple(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = message.getRepeatedGroupList(); + if (f.length > 0) { + writer.writeRepeatedGroup( + 1, + f, + TestGroup.RepeatedGroup.serializeBinaryToWriter + ); + } + f = message.getRequiredGroup(); + if (f != null) { + writer.writeGroup( + 2, + f, + TestGroup.RequiredGroup.serializeBinaryToWriter + ); + } + f = message.getOptionalGroup(); + if (f != null) { + writer.writeGroup( + 3, + f, + TestGroup.OptionalGroup.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 4)); + if (f != null) { + writer.writeString( + 4, + f + ); + } + f = message.getRequiredSimple(); + if (f != null) { + writer.writeMessage( + 5, + f, + Simple2.serializeBinaryToWriter + ); + } + f = message.getOptionalSimple(); + if (f != null) { + writer.writeMessage( + 6, + f, + Simple2.serializeBinaryToWriter + ); + } + }; + + +} + + + +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} + */ +TestGroup.prototype.toObject = function(opt_includeInstance) { + return TestGroup.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.jspb.test.TestGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestGroup.toObject = function(includeInstance, msg) { + var f, obj = { +repeatedGroupList: jspb.Message.toObjectList(msg.getRepeatedGroupList(), + TestGroup.RepeatedGroup.toObject, includeInstance), +requiredGroup: (f = msg.getRequiredGroup()) && TestGroup.RequiredGroup.toObject(includeInstance, f), +optionalGroup: (f = msg.getOptionalGroup()) && TestGroup.OptionalGroup.toObject(includeInstance, f), +id: (f = jspb.Message.getField(msg, 4)) == null ? undefined : f, +requiredSimple: (f = msg.getRequiredSimple()) && Simple2.toObject(includeInstance, f), +optionalSimple: (f = msg.getOptionalSimple()) && Simple2.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +TestGroup.RepeatedGroup = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, TestGroup.RepeatedGroup.repeatedFields_, null); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [1]; + + /** + * required string id = 1; + * @return {string} + */ + getId() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 0, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ + setId(value) { + return jspb.Message.setField(this, 0, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ + clearId() { + return jspb.Message.setField(this, 0, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasId() { + return jspb.Message.getField(this, 0) != null; + }; + + + /** + * repeated bool some_bool = 2; + * @return {!Array} + */ + getSomeBoolList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedBooleanField(this, 1)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ + setSomeBoolList(value) { + return jspb.Message.setField(this, 1, value || []); + }; + + + /** + * @param {boolean} value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ + addSomeBool(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 1, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} returns this + */ + clearSomeBoolList() { + return this.setSomeBoolList([]); + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestGroup.RepeatedGroup; + return TestGroup.RepeatedGroup.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.RepeatedGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.RepeatedGroup} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + case 2: + var values = /** @type {!Array} */ (reader.isDelimited() ? reader.readBool() : [reader.readBool()]); + for (var i = 0; i < values.length; i++) { + msg.addSomeBool(values[i]); + } + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestGroup.RepeatedGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.RepeatedGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 0)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + f = message.getSomeBoolList(); + if (f.length > 0) { + writer.writeRepeatedBool( + 2, + f + ); + } + }; + + +} + + + +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} + */ +TestGroup.RepeatedGroup.prototype.toObject = function(opt_includeInstance) { + return TestGroup.RepeatedGroup.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.jspb.test.TestGroup.RepeatedGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestGroup.RepeatedGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, 0)) == null ? undefined : f, +someBoolList: (f = jspb.Message.getRepeatedBooleanField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +TestGroup.RequiredGroup = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * required string id = 1; + * @return {string} + */ + getId() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, -1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.RequiredGroup} returns this + */ + setId(value) { + return jspb.Message.setField(this, -1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} returns this + */ + clearId() { + return jspb.Message.setField(this, -1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasId() { + return jspb.Message.getField(this, -1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestGroup.RequiredGroup; + return TestGroup.RequiredGroup.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.RequiredGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.RequiredGroup} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestGroup.RequiredGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.RequiredGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, -1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + }; + + +} + + + +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} + */ +TestGroup.RequiredGroup.prototype.toObject = function(opt_includeInstance) { + return TestGroup.RequiredGroup.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.jspb.test.TestGroup.RequiredGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestGroup.RequiredGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, -1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +TestGroup.OptionalGroup = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * required string id = 1; + * @return {string} + */ + getId() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, -2, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestGroup.OptionalGroup} returns this + */ + setId(value) { + return jspb.Message.setField(this, -2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} returns this + */ + clearId() { + return jspb.Message.setField(this, -2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasId() { + return jspb.Message.getField(this, -2) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestGroup.OptionalGroup; + return TestGroup.OptionalGroup.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup.OptionalGroup} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup.OptionalGroup} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setId(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestGroup.OptionalGroup.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup.OptionalGroup} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, -2)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + }; + + +} + + + +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} + */ +TestGroup.OptionalGroup.prototype.toObject = function(opt_includeInstance) { + return TestGroup.OptionalGroup.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.jspb.test.TestGroup.OptionalGroup} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestGroup.OptionalGroup.toObject = function(includeInstance, msg) { + var f, obj = { +id: (f = jspb.Message.getField(msg, -2)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestGroup1 extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional TestGroup.RepeatedGroup group = 1; + * @return {?proto.jspb.test.TestGroup.RepeatedGroup} + */ + getGroup() { + return /** @type{?proto.jspb.test.TestGroup.RepeatedGroup} */ ( + jspb.Message.getWrapperField(this, TestGroup.RepeatedGroup, 1)); + }; + + + /** + * @param {?proto.jspb.test.TestGroup.RepeatedGroup|undefined} value + * @return {!proto.jspb.test.TestGroup1} returns this + */ + setGroup(value) { + return jspb.Message.setWrapperField(this, 1, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestGroup1} returns this + */ + clearGroup() { + return this.setGroup(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasGroup() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestGroup1} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestGroup1; + return TestGroup1.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestGroup1} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestGroup1} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new TestGroup.RepeatedGroup; + reader.readMessage(value,TestGroup.RepeatedGroup.deserializeBinaryFromReader); + msg.setGroup(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestGroup1.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestGroup1} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = message.getGroup(); + if (f != null) { + writer.writeMessage( + 1, + f, + TestGroup.RepeatedGroup.serializeBinaryToWriter + ); + } + }; + + +} + + + +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} + */ +TestGroup1.prototype.toObject = function(opt_includeInstance) { + return TestGroup1.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.jspb.test.TestGroup1} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestGroup1.toObject = function(includeInstance, msg) { + var f, obj = { +group: (f = msg.getGroup()) && TestGroup.RepeatedGroup.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestReservedNames extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); + }; + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensions = {}; + + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensionsBinary = {}; + + /** + * optional int32 extension = 1; + * @return {number} + */ + getExtension$() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestReservedNames} returns this + */ + setExtension$(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestReservedNames} returns this + */ + clearExtension$() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasExtension$() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestReservedNames} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestReservedNames; + return TestReservedNames.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestReservedNames} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestReservedNames} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setExtension$(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + TestReservedNames.extensionsBinary, + TestReservedNames.prototype.getExtension, + TestReservedNames.prototype.setExtension); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestReservedNames.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestReservedNames} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + TestReservedNames.extensionsBinary, TestReservedNames.prototype.getExtension); + }; + + +} + + + +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} + */ +TestReservedNames.prototype.toObject = function(opt_includeInstance) { + return TestReservedNames.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.jspb.test.TestReservedNames} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestReservedNames.toObject = function(includeInstance, msg) { + var f, obj = { +extension: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + TestReservedNames.extensions, TestReservedNames.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestReservedNamesExtension extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + + /** + * A tuple of {field number, class constructor} for the extension + * field named `foo`. + * @type {!jspb.ExtensionFieldInfo} + */ + static foo = new jspb.ExtensionFieldInfo( + 10, + {foo: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestReservedNamesExtension} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestReservedNamesExtension; + return TestReservedNamesExtension.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestReservedNamesExtension} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestReservedNamesExtension} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestReservedNamesExtension.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestReservedNamesExtension} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + }; + + +} + + + +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} + */ +TestReservedNamesExtension.prototype.toObject = function(opt_includeInstance) { + return TestReservedNamesExtension.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.jspb.test.TestReservedNamesExtension} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestReservedNamesExtension.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +TestReservedNames.extensionsBinary[10] = new jspb.ExtensionFieldBinaryInfo( + TestReservedNamesExtension.foo, + jspb.BinaryReader.prototype.readInt32, + jspb.BinaryWriter.prototype.writeInt32, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestReservedNames.extensions[10] = TestReservedNamesExtension.foo; + +export class TestMessageWithOneof extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, TestMessageWithOneof.repeatedFields_, TestMessageWithOneof.oneofGroups_); + }; + /** + * List of repeated fields within this message type. + * @private {!Array} + * @const + */ + static repeatedFields_ = [9]; + + /** + * Oneof group definitions for this message. Each group defines the field + * numbers belonging to that group. When of these fields' value is set, all + * other fields in the group are cleared. During deserialization, if multiple + * fields are encountered for a group, only the last value seen will be kept. + * @private {!Array>} + * @const + */ + static oneofGroups_ = [[3,5],[6,7],[10,11],[12,13]]; + + /** + * @enum {number} + */ + static PartialOneofCase = { + PARTIAL_ONEOF_NOT_SET: 0, + PONE: 3, + PTHREE: 5 + }; + + /** + * @return {proto.jspb.test.TestMessageWithOneof.PartialOneofCase} + */ + getPartialOneofCase() { + return /** @type {proto.jspb.test.TestMessageWithOneof.PartialOneofCase} */(jspb.Message.computeOneofCase(this, TestMessageWithOneof.oneofGroups_[0])); + }; + + /** + * @enum {number} + */ + static RecursiveOneofCase = { + RECURSIVE_ONEOF_NOT_SET: 0, + RONE: 6, + RTWO: 7 + }; + + /** + * @return {proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase} + */ + getRecursiveOneofCase() { + return /** @type {proto.jspb.test.TestMessageWithOneof.RecursiveOneofCase} */(jspb.Message.computeOneofCase(this, TestMessageWithOneof.oneofGroups_[1])); + }; + + /** + * @enum {number} + */ + static DefaultOneofACase = { + DEFAULT_ONEOF_A_NOT_SET: 0, + AONE: 10, + ATWO: 11 + }; + + /** + * @return {proto.jspb.test.TestMessageWithOneof.DefaultOneofACase} + */ + getDefaultOneofACase() { + return /** @type {proto.jspb.test.TestMessageWithOneof.DefaultOneofACase} */(jspb.Message.computeOneofCase(this, TestMessageWithOneof.oneofGroups_[2])); + }; + + /** + * @enum {number} + */ + static DefaultOneofBCase = { + DEFAULT_ONEOF_B_NOT_SET: 0, + BONE: 12, + BTWO: 13 + }; + + /** + * @return {proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase} + */ + getDefaultOneofBCase() { + return /** @type {proto.jspb.test.TestMessageWithOneof.DefaultOneofBCase} */(jspb.Message.computeOneofCase(this, TestMessageWithOneof.oneofGroups_[3])); + }; + + /** + * optional string pone = 3; + * @return {string} + */ + getPone() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setPone(value) { + return jspb.Message.setOneofField(this, 3, TestMessageWithOneof.oneofGroups_[0], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearPone() { + return jspb.Message.setOneofField(this, 3, TestMessageWithOneof.oneofGroups_[0], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasPone() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * optional string pthree = 5; + * @return {string} + */ + getPthree() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setPthree(value) { + return jspb.Message.setOneofField(this, 5, TestMessageWithOneof.oneofGroups_[0], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearPthree() { + return jspb.Message.setOneofField(this, 5, TestMessageWithOneof.oneofGroups_[0], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasPthree() { + return jspb.Message.getField(this, 5) != null; + }; + + + /** + * optional TestMessageWithOneof rone = 6; + * @return {?proto.jspb.test.TestMessageWithOneof} + */ + getRone() { + return /** @type{?proto.jspb.test.TestMessageWithOneof} */ ( + jspb.Message.getWrapperField(this, TestMessageWithOneof, 6)); + }; + + + /** + * @param {?proto.jspb.test.TestMessageWithOneof|undefined} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setRone(value) { + return jspb.Message.setOneofWrapperField(this, 6, TestMessageWithOneof.oneofGroups_[1], value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearRone() { + return this.setRone(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRone() { + return jspb.Message.getField(this, 6) != null; + }; + + + /** + * optional string rtwo = 7; + * @return {string} + */ + getRtwo() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setRtwo(value) { + return jspb.Message.setOneofField(this, 7, TestMessageWithOneof.oneofGroups_[1], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearRtwo() { + return jspb.Message.setOneofField(this, 7, TestMessageWithOneof.oneofGroups_[1], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasRtwo() { + return jspb.Message.getField(this, 7) != null; + }; + + + /** + * optional bool normal_field = 8; + * @return {boolean} + */ + getNormalField() { + return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false)); + }; + + + /** + * @param {boolean} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setNormalField(value) { + return jspb.Message.setField(this, 8, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearNormalField() { + return jspb.Message.setField(this, 8, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasNormalField() { + return jspb.Message.getField(this, 8) != null; + }; + + + /** + * repeated string repeated_field = 9; + * @return {!Array} + */ + getRepeatedFieldList() { + return /** @type {!Array} */ (jspb.Message.getRepeatedField(this, 9)); + }; + + + /** + * @param {!Array} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setRepeatedFieldList(value) { + return jspb.Message.setField(this, 9, value || []); + }; + + + /** + * @param {string} value + * @param {number=} opt_index + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + addRepeatedField(value, opt_index) { + return jspb.Message.addToRepeatedField(this, 9, value, opt_index); + }; + + + /** + * Clears the list making it empty but non-null. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearRepeatedFieldList() { + return this.setRepeatedFieldList([]); + }; + + + /** + * optional int32 aone = 10; + * @return {number} + */ + getAone() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 10, 1234)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setAone(value) { + return jspb.Message.setOneofField(this, 10, TestMessageWithOneof.oneofGroups_[2], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearAone() { + return jspb.Message.setOneofField(this, 10, TestMessageWithOneof.oneofGroups_[2], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAone() { + return jspb.Message.getField(this, 10) != null; + }; + + + /** + * optional int32 atwo = 11; + * @return {number} + */ + getAtwo() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 11, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setAtwo(value) { + return jspb.Message.setOneofField(this, 11, TestMessageWithOneof.oneofGroups_[2], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearAtwo() { + return jspb.Message.setOneofField(this, 11, TestMessageWithOneof.oneofGroups_[2], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasAtwo() { + return jspb.Message.getField(this, 11) != null; + }; + + + /** + * optional int32 bone = 12; + * @return {number} + */ + getBone() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 12, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setBone(value) { + return jspb.Message.setOneofField(this, 12, TestMessageWithOneof.oneofGroups_[3], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearBone() { + return jspb.Message.setOneofField(this, 12, TestMessageWithOneof.oneofGroups_[3], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasBone() { + return jspb.Message.getField(this, 12) != null; + }; + + + /** + * optional int32 btwo = 13; + * @return {number} + */ + getBtwo() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 13, 1234)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + setBtwo(value) { + return jspb.Message.setOneofField(this, 13, TestMessageWithOneof.oneofGroups_[3], value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestMessageWithOneof} returns this + */ + clearBtwo() { + return jspb.Message.setOneofField(this, 13, TestMessageWithOneof.oneofGroups_[3], undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasBtwo() { + return jspb.Message.getField(this, 13) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestMessageWithOneof} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestMessageWithOneof; + return TestMessageWithOneof.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestMessageWithOneof} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestMessageWithOneof} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setPone(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setPthree(value); + break; + case 6: + var value = new TestMessageWithOneof; + reader.readMessage(value,TestMessageWithOneof.deserializeBinaryFromReader); + msg.setRone(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setRtwo(value); + break; + case 8: + var value = /** @type {boolean} */ (reader.readBool()); + msg.setNormalField(value); + break; + case 9: + var value = /** @type {string} */ (reader.readString()); + msg.addRepeatedField(value); + break; + case 10: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAone(value); + break; + case 11: + var value = /** @type {number} */ (reader.readInt32()); + msg.setAtwo(value); + break; + case 12: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBone(value); + break; + case 13: + var value = /** @type {number} */ (reader.readInt32()); + msg.setBtwo(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestMessageWithOneof.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestMessageWithOneof} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeString( + 3, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 5)); + if (f != null) { + writer.writeString( + 5, + f + ); + } + f = message.getRone(); + if (f != null) { + writer.writeMessage( + 6, + f, + TestMessageWithOneof.serializeBinaryToWriter + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 7)); + if (f != null) { + writer.writeString( + 7, + f + ); + } + f = /** @type {boolean} */ (jspb.Message.getField(message, 8)); + if (f != null) { + writer.writeBool( + 8, + f + ); + } + f = message.getRepeatedFieldList(); + if (f.length > 0) { + writer.writeRepeatedString( + 9, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 10)); + if (f != null) { + writer.writeInt32( + 10, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 11)); + if (f != null) { + writer.writeInt32( + 11, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 12)); + if (f != null) { + writer.writeInt32( + 12, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 13)); + if (f != null) { + writer.writeInt32( + 13, + f + ); + } + }; + + +} + + + +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} + */ +TestMessageWithOneof.prototype.toObject = function(opt_includeInstance) { + return TestMessageWithOneof.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.jspb.test.TestMessageWithOneof} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestMessageWithOneof.toObject = function(includeInstance, msg) { + var f, obj = { +pone: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f, +pthree: (f = jspb.Message.getField(msg, 5)) == null ? undefined : f, +rone: (f = msg.getRone()) && TestMessageWithOneof.toObject(includeInstance, f), +rtwo: (f = jspb.Message.getField(msg, 7)) == null ? undefined : f, +normalField: (f = jspb.Message.getBooleanField(msg, 8)) == null ? undefined : f, +repeatedFieldList: (f = jspb.Message.getRepeatedField(msg, 9)) == null ? undefined : f, +aone: jspb.Message.getFieldWithDefault(msg, 10, 1234), +atwo: (f = jspb.Message.getField(msg, 11)) == null ? undefined : f, +bone: (f = jspb.Message.getField(msg, 12)) == null ? undefined : f, +btwo: jspb.Message.getFieldWithDefault(msg, 13, 1234) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestEndsWithBytes extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional int32 value = 1; + * @return {number} + */ + getValue() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ + setValue(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ + clearValue() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasValue() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * optional bytes data = 2; + * @return {!(string|Uint8Array)} + */ + getData() { + return /** @type {!(string|Uint8Array)} */ (jspb.Message.getFieldWithDefault(this, 2, "")); + }; + + + /** + * optional bytes data = 2; + * This is a type-conversion wrapper around `getData()` + * @return {string} + */ + getData_asB64() { + return /** @type {string} */ (jspb.Message.bytesAsB64( + this.getData())); + }; + + + /** + * optional bytes data = 2; + * Note that Uint8Array is not supported on all browsers. + * @see http://caniuse.com/Uint8Array + * This is a type-conversion wrapper around `getData()` + * @return {!Uint8Array} + */ + getData_asU8() { + return /** @type {!Uint8Array} */ (jspb.Message.bytesAsU8( + this.getData())); + }; + + + /** + * @param {!(string|Uint8Array)} value + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ + setData(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestEndsWithBytes} returns this + */ + clearData() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasData() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestEndsWithBytes} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestEndsWithBytes; + return TestEndsWithBytes.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestEndsWithBytes} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestEndsWithBytes} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setValue(value); + break; + case 2: + var value = /** @type {!Uint8Array} */ (reader.readBytes()); + msg.setData(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestEndsWithBytes.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestEndsWithBytes} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + f = /** @type {!(string|Uint8Array)} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeBytes( + 2, + f + ); + } + }; + + +} + + + +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} + */ +TestEndsWithBytes.prototype.toObject = function(opt_includeInstance) { + return TestEndsWithBytes.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.jspb.test.TestEndsWithBytes} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestEndsWithBytes.toObject = function(includeInstance, msg) { + var f, obj = { +value: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +data: msg.getData_asB64() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestLastFieldBeforePivot extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); + }; + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensions = {}; + + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensionsBinary = {}; + + /** + * optional int32 last_field_before_pivot = 1; + * @return {number} + */ + getLastFieldBeforePivot() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestLastFieldBeforePivot} returns this + */ + setLastFieldBeforePivot(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} returns this + */ + clearLastFieldBeforePivot() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasLastFieldBeforePivot() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestLastFieldBeforePivot; + return TestLastFieldBeforePivot.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestLastFieldBeforePivot} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestLastFieldBeforePivot} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setLastFieldBeforePivot(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + TestLastFieldBeforePivot.extensionsBinary, + TestLastFieldBeforePivot.prototype.getExtension, + TestLastFieldBeforePivot.prototype.setExtension); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestLastFieldBeforePivot.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestLastFieldBeforePivot} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + TestLastFieldBeforePivot.extensionsBinary, TestLastFieldBeforePivot.prototype.getExtension); + }; + + +} + + + +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} + */ +TestLastFieldBeforePivot.prototype.toObject = function(opt_includeInstance) { + return TestLastFieldBeforePivot.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.jspb.test.TestLastFieldBeforePivot} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestLastFieldBeforePivot.toObject = function(includeInstance, msg) { + var f, obj = { +lastFieldBeforePivot: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + TestLastFieldBeforePivot.extensions, TestLastFieldBeforePivot.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class Int64Types extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional int64 int64_normal = 1; + * @return {number} + */ + getInt64Normal() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.Int64Types} returns this + */ + setInt64Normal(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ + clearInt64Normal() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasInt64Normal() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * optional sint64 int64_string = 2; + * @return {string} + */ + getInt64String() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "0")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.Int64Types} returns this + */ + setInt64String(value) { + return jspb.Message.setField(this, 2, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ + clearInt64String() { + return jspb.Message.setField(this, 2, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasInt64String() { + return jspb.Message.getField(this, 2) != null; + }; + + + /** + * optional uint64 int64_number = 3; + * @return {number} + */ + getInt64Number() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 3, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.Int64Types} returns this + */ + setInt64Number(value) { + return jspb.Message.setField(this, 3, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Int64Types} returns this + */ + clearInt64Number() { + return jspb.Message.setField(this, 3, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasInt64Number() { + return jspb.Message.getField(this, 3) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Int64Types} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Int64Types; + return Int64Types.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Int64Types} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Int64Types} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setInt64Normal(value); + break; + case 2: + var value = /** @type {string} */ (reader.readSint64String()); + msg.setInt64String(value); + break; + case 3: + var value = /** @type {number} */ (reader.readUint64()); + msg.setInt64Number(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Int64Types.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Int64Types} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt64( + 1, + f + ); + } + f = /** @type {string} */ (jspb.Message.getField(message, 2)); + if (f != null) { + writer.writeSint64String( + 2, + f + ); + } + f = /** @type {number} */ (jspb.Message.getField(message, 3)); + if (f != null) { + writer.writeUint64( + 3, + f + ); + } + }; + + +} + + + +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} + */ +Int64Types.prototype.toObject = function(opt_includeInstance) { + return Int64Types.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.jspb.test.Int64Types} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Int64Types.toObject = function(includeInstance, msg) { + var f, obj = { +int64Normal: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f, +int64String: (f = jspb.Message.getField(msg, 2)) == null ? undefined : f, +int64Number: (f = jspb.Message.getField(msg, 3)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class TestMapFieldsNoBinary extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * map map_string_string = 1; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringStringMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 1, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringStringMapfunction() { + this.getMapStringStringMap().clear(); + return this; + }; + + + /** + * map map_string_int32 = 2; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringInt32Map(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 2, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringInt32Mapfunction() { + this.getMapStringInt32Map().clear(); + return this; + }; + + + /** + * map map_string_int64 = 3; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringInt64Map(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 3, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringInt64Mapfunction() { + this.getMapStringInt64Map().clear(); + return this; + }; + + + /** + * map map_string_bool = 4; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringBoolMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 4, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringBoolMapfunction() { + this.getMapStringBoolMap().clear(); + return this; + }; + + + /** + * map map_string_double = 5; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringDoubleMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 5, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringDoubleMapfunction() { + this.getMapStringDoubleMap().clear(); + return this; + }; + + + /** + * map map_string_enum = 6; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringEnumMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 6, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringEnumMapfunction() { + this.getMapStringEnumMap().clear(); + return this; + }; + + + /** + * map map_string_msg = 7; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringMsgMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 7, opt_noLazyCreate, + MapValueMessageNoBinary)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringMsgMapfunction() { + this.getMapStringMsgMap().clear(); + return this; + }; + + + /** + * map map_int32_string = 8; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapInt32StringMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 8, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapInt32StringMapfunction() { + this.getMapInt32StringMap().clear(); + return this; + }; + + + /** + * map map_int64_string = 9; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapInt64StringMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 9, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapInt64StringMapfunction() { + this.getMapInt64StringMap().clear(); + return this; + }; + + + /** + * map map_bool_string = 10; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapBoolStringMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 10, opt_noLazyCreate, + null)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapBoolStringMapfunction() { + this.getMapBoolStringMap().clear(); + return this; + }; + + + /** + * optional TestMapFieldsNoBinary test_map_fields = 11; + * @return {?proto.jspb.test.TestMapFieldsNoBinary} + */ + getTestMapFields() { + return /** @type{?proto.jspb.test.TestMapFieldsNoBinary} */ ( + jspb.Message.getWrapperField(this, TestMapFieldsNoBinary, 11)); + }; + + + /** + * @param {?proto.jspb.test.TestMapFieldsNoBinary|undefined} value + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + setTestMapFields(value) { + return jspb.Message.setWrapperField(this, 11, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearTestMapFields() { + return this.setTestMapFields(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasTestMapFields() { + return jspb.Message.getField(this, 11) != null; + }; + + + /** + * map map_string_testmapfields = 12; + * @param {boolean=} opt_noLazyCreate Do not create the map if + * empty, instead returning `undefined` + * @return {!jspb.Map} + */ + getMapStringTestmapfieldsMap(opt_noLazyCreate) { + return /** @type {!jspb.Map} */ ( + jspb.Message.getMapField(this, 12, opt_noLazyCreate, + TestMapFieldsNoBinary)); + }; + + + /** + * Clears values from the map. The map will be non-null. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} returns this + */ + clearMapStringTestmapfieldsMapfunction() { + this.getMapStringTestmapfieldsMap().clear(); + return this; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestMapFieldsNoBinary; + return TestMapFieldsNoBinary.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestMapFieldsNoBinary} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestMapFieldsNoBinary} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = msg.getMapStringStringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readString, null, "", ""); + }); + break; + case 2: + var value = msg.getMapStringInt32Map(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readInt32, null, "", 0); + }); + break; + case 3: + var value = msg.getMapStringInt64Map(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readInt64, null, "", 0); + }); + break; + case 4: + var value = msg.getMapStringBoolMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readBool, null, "", false); + }); + break; + case 5: + var value = msg.getMapStringDoubleMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readDouble, null, "", 0.0); + }); + break; + case 6: + var value = msg.getMapStringEnumMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readEnum, null, "", 0); + }); + break; + case 7: + var value = msg.getMapStringMsgMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, MapValueMessageNoBinary.deserializeBinaryFromReader, "", new MapValueMessageNoBinary()); + }); + break; + case 8: + var value = msg.getMapInt32StringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt32, jspb.BinaryReader.prototype.readString, null, 0, ""); + }); + break; + case 9: + var value = msg.getMapInt64StringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readInt64, jspb.BinaryReader.prototype.readString, null, 0, ""); + }); + break; + case 10: + var value = msg.getMapBoolStringMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readBool, jspb.BinaryReader.prototype.readString, null, false, ""); + }); + break; + case 11: + var value = new TestMapFieldsNoBinary; + reader.readMessage(value,TestMapFieldsNoBinary.deserializeBinaryFromReader); + msg.setTestMapFields(value); + break; + case 12: + var value = msg.getMapStringTestmapfieldsMap(); + reader.readMessage(value, function(message, reader) { + jspb.Map.deserializeBinary(message, reader, jspb.BinaryReader.prototype.readString, jspb.BinaryReader.prototype.readMessage, TestMapFieldsNoBinary.deserializeBinaryFromReader, "", new TestMapFieldsNoBinary()); + }); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestMapFieldsNoBinary.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestMapFieldsNoBinary} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = message.getMapStringStringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(1, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapStringInt32Map(true); + if (f && f.getLength() > 0) { + f.serializeBinary(2, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeInt32); + } + f = message.getMapStringInt64Map(true); + if (f && f.getLength() > 0) { + f.serializeBinary(3, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeInt64); + } + f = message.getMapStringBoolMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(4, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeBool); + } + f = message.getMapStringDoubleMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(5, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeDouble); + } + f = message.getMapStringEnumMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(6, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeEnum); + } + f = message.getMapStringMsgMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(7, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, MapValueMessageNoBinary.serializeBinaryToWriter); + } + f = message.getMapInt32StringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(8, writer, jspb.BinaryWriter.prototype.writeInt32, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapInt64StringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(9, writer, jspb.BinaryWriter.prototype.writeInt64, jspb.BinaryWriter.prototype.writeString); + } + f = message.getMapBoolStringMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(10, writer, jspb.BinaryWriter.prototype.writeBool, jspb.BinaryWriter.prototype.writeString); + } + f = message.getTestMapFields(); + if (f != null) { + writer.writeMessage( + 11, + f, + TestMapFieldsNoBinary.serializeBinaryToWriter + ); + } + f = message.getMapStringTestmapfieldsMap(true); + if (f && f.getLength() > 0) { + f.serializeBinary(12, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, TestMapFieldsNoBinary.serializeBinaryToWriter); + } + }; + + +} + + + +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} + */ +TestMapFieldsNoBinary.prototype.toObject = function(opt_includeInstance) { + return TestMapFieldsNoBinary.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.jspb.test.TestMapFieldsNoBinary} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestMapFieldsNoBinary.toObject = function(includeInstance, msg) { + var f, obj = { +mapStringStringMap: (f = msg.getMapStringStringMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringInt32Map: (f = msg.getMapStringInt32Map()) ? f.toObject(includeInstance, undefined) : [], +mapStringInt64Map: (f = msg.getMapStringInt64Map()) ? f.toObject(includeInstance, undefined) : [], +mapStringBoolMap: (f = msg.getMapStringBoolMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringDoubleMap: (f = msg.getMapStringDoubleMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringEnumMap: (f = msg.getMapStringEnumMap()) ? f.toObject(includeInstance, undefined) : [], +mapStringMsgMap: (f = msg.getMapStringMsgMap()) ? f.toObject(includeInstance, MapValueMessageNoBinary.toObject) : [], +mapInt32StringMap: (f = msg.getMapInt32StringMap()) ? f.toObject(includeInstance, undefined) : [], +mapInt64StringMap: (f = msg.getMapInt64StringMap()) ? f.toObject(includeInstance, undefined) : [], +mapBoolStringMap: (f = msg.getMapBoolStringMap()) ? f.toObject(includeInstance, undefined) : [], +testMapFields: (f = msg.getTestMapFields()) && TestMapFieldsNoBinary.toObject(includeInstance, f), +mapStringTestmapfieldsMap: (f = msg.getMapStringTestmapfieldsMap()) ? f.toObject(includeInstance, TestMapFieldsNoBinary.toObject) : [] + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class MapValueMessageNoBinary extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional int32 foo = 1; + * @return {number} + */ + getFoo() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.MapValueMessageNoBinary} returns this + */ + setFoo(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.MapValueMessageNoBinary} returns this + */ + clearFoo() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasFoo() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.MapValueMessageNoBinary} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new MapValueMessageNoBinary; + return MapValueMessageNoBinary.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.MapValueMessageNoBinary} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.MapValueMessageNoBinary} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setFoo(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + MapValueMessageNoBinary.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.MapValueMessageNoBinary} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + }; + + +} + + + +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} + */ +MapValueMessageNoBinary.prototype.toObject = function(opt_includeInstance) { + return MapValueMessageNoBinary.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.jspb.test.MapValueMessageNoBinary} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +MapValueMessageNoBinary.toObject = function(includeInstance, msg) { + var f, obj = { +foo: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class Deeply extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Deeply; + return Deeply.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Deeply.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + }; + + +} + + + +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} + */ +Deeply.prototype.toObject = function(opt_includeInstance) { + return Deeply.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.jspb.test.Deeply} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Deeply.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +Deeply.Nested = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply.Nested} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Deeply.Nested; + return Deeply.Nested.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply.Nested} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply.Nested} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Deeply.Nested.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply.Nested} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + }; + + +} + + + +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} + */ +Deeply.Nested.prototype.toObject = function(opt_includeInstance) { + return Deeply.Nested.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.jspb.test.Deeply.Nested} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Deeply.Nested.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +Deeply.Nested.Message = class extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional int32 count = 1; + * @return {number} + */ + getCount() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.Deeply.Nested.Message} returns this + */ + setCount(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.Deeply.Nested.Message} returns this + */ + clearCount() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasCount() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.Deeply.Nested.Message} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new Deeply.Nested.Message; + return Deeply.Nested.Message.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.Deeply.Nested.Message} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.Deeply.Nested.Message} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setCount(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + Deeply.Nested.Message.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.Deeply.Nested.Message} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + }; + + +} + + + +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} + */ +Deeply.Nested.Message.prototype.toObject = function(opt_includeInstance) { + return Deeply.Nested.Message.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.jspb.test.Deeply.Nested.Message} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +Deeply.Nested.Message.toObject = function(includeInstance, msg) { + var f, obj = { +count: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * @enum {number} + */ +export const OuterEnum = { + FOO: 1, + BAR: 2 +}; + +/** + * @enum {number} + */ +export const MapValueEnumNoBinary = { + MAP_VALUE_FOO_NOBINARY: 0, + MAP_VALUE_BAR_NOBINARY: 1, + MAP_VALUE_BAZ_NOBINARY: 2 +}; + +/** + * @enum {number} + */ +export const TestAllowAliasEnum = { + TEST_ALLOW_ALIAS_DEFAULT: 0, + VALUE1: 1 +}; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `simple1`. + * @type {!jspb.ExtensionFieldInfo} + */ +export const simple1 = new jspb.ExtensionFieldInfo( + 105, + {simple1: 0}, + Simple1, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + Simple1.toObject), + 0); + +HasExtensions.extensionsBinary[105] = new jspb.ExtensionFieldBinaryInfo( + simple1, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + Simple1.serializeBinaryToWriter, + Simple1.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +HasExtensions.extensions[105] = simple1; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extendTestLastFieldBeforePivotField`. + * @type {!jspb.ExtensionFieldInfo} + */ +export const extendTestLastFieldBeforePivotField = new jspb.ExtensionFieldInfo( + 101, + {extendTestLastFieldBeforePivotField: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +TestLastFieldBeforePivot.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + extendTestLastFieldBeforePivotField, + jspb.BinaryReader.prototype.readInt32, + jspb.BinaryWriter.prototype.writeInt32, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestLastFieldBeforePivot.extensions[101] = extendTestLastFieldBeforePivotField; + +export const ComplexNested = Complex.Nested; +export const DeeplyNested = Deeply.Nested; +export const DeeplyNestedMessage = Deeply.Nested.Message; +export const DefaultValuesEnum = DefaultValues.Enum; +export const OptionalFieldsNested = OptionalFields.Nested; +export const OuterMessageComplex = OuterMessage.Complex; +export const TestGroupOptionalGroup = TestGroup.OptionalGroup; +export const TestGroupRepeatedGroup = TestGroup.RepeatedGroup; +export const TestGroupRequiredGroup = TestGroup.RequiredGroup; +export const TestMessageWithOneofDefaultOneofACase = TestMessageWithOneof.DefaultOneofACase; +export const TestMessageWithOneofDefaultOneofBCase = TestMessageWithOneof.DefaultOneofBCase; +export const TestMessageWithOneofPartialOneofCase = TestMessageWithOneof.PartialOneofCase; +export const TestMessageWithOneofRecursiveOneofCase = TestMessageWithOneof.RecursiveOneofCase; diff --git a/example/test2.closure-new.js b/example/test2.closure-new.js new file mode 100644 index 0000000..437a3df --- /dev/null +++ b/example/test2.closure-new.js @@ -0,0 +1,650 @@ +// source: protos/test2.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + + +goog.provide('proto.jspb.test.ExtensionMessage'); +goog.provide('proto.jspb.test.ForeignNestedFieldMessage'); +goog.provide('proto.jspb.test.TestExtensionsMessage'); +goog.provide('proto.jspb.test.floatingMsgField'); +goog.provide('proto.jspb.test.floatingStrField'); + +goog.require('jspb.BinaryReader'); +goog.require('jspb.BinaryWriter'); +goog.require('jspb.ExtensionFieldBinaryInfo'); +goog.require('jspb.ExtensionFieldInfo'); +goog.require('jspb.Message'); +goog.require('proto.jspb.test.Deeply.Nested.Message'); + +/** + * 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.jspb.test.TestExtensionsMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); +}; +goog.inherits(proto.jspb.test.TestExtensionsMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestExtensionsMessage.displayName = 'proto.jspb.test.TestExtensionsMessage'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestExtensionsMessage.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestExtensionsMessage.extensionsBinary = {}; + +/** + * 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.jspb.test.ExtensionMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.ExtensionMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.ExtensionMessage.displayName = 'proto.jspb.test.ExtensionMessage'; +} +/** + * 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.jspb.test.ForeignNestedFieldMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.ForeignNestedFieldMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.ForeignNestedFieldMessage.displayName = 'proto.jspb.test.ForeignNestedFieldMessage'; +} + + + +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.jspb.test.TestExtensionsMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestExtensionsMessage.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.jspb.test.TestExtensionsMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestExtensionsMessage.toObject = function(includeInstance, msg) { + var f, obj = { +intfield: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestExtensionsMessage.extensions, proto.jspb.test.TestExtensionsMessage.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestExtensionsMessage} + */ +proto.jspb.test.TestExtensionsMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestExtensionsMessage; + return proto.jspb.test.TestExtensionsMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestExtensionsMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestExtensionsMessage} + */ +proto.jspb.test.TestExtensionsMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setIntfield(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestExtensionsMessage.extensionsBinary, + proto.jspb.test.TestExtensionsMessage.prototype.getExtension, + proto.jspb.test.TestExtensionsMessage.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestExtensionsMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestExtensionsMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestExtensionsMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestExtensionsMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestExtensionsMessage.extensionsBinary, proto.jspb.test.TestExtensionsMessage.prototype.getExtension); +}; + + +/** + * optional int32 intfield = 1; + * @return {number} + */ +proto.jspb.test.TestExtensionsMessage.prototype.getIntfield = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestExtensionsMessage} returns this + */ +proto.jspb.test.TestExtensionsMessage.prototype.setIntfield = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestExtensionsMessage} returns this + */ +proto.jspb.test.TestExtensionsMessage.prototype.clearIntfield = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestExtensionsMessage.prototype.hasIntfield = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.ExtensionMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.ExtensionMessage.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.jspb.test.ExtensionMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ExtensionMessage.toObject = function(includeInstance, msg) { + var f, obj = { +ext1: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.ExtensionMessage} + */ +proto.jspb.test.ExtensionMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.ExtensionMessage; + return proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.ExtensionMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.ExtensionMessage} + */ +proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setExt1(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.ExtensionMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.ExtensionMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.ExtensionMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ExtensionMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.ExtensionMessage.extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + proto.jspb.test.ExtensionMessage, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.ExtensionMessage.toObject), + 0); + +proto.jspb.test.TestExtensionsMessage.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.ExtensionMessage.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.ExtensionMessage.serializeBinaryToWriter, + proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestExtensionsMessage.extensions[100] = proto.jspb.test.ExtensionMessage.extField; + +/** + * optional string ext1 = 1; + * @return {string} + */ +proto.jspb.test.ExtensionMessage.prototype.getExt1 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.ExtensionMessage} returns this + */ +proto.jspb.test.ExtensionMessage.prototype.setExt1 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.ExtensionMessage} returns this + */ +proto.jspb.test.ExtensionMessage.prototype.clearExt1 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.ExtensionMessage.prototype.hasExt1 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.ForeignNestedFieldMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.ForeignNestedFieldMessage.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.jspb.test.ForeignNestedFieldMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ForeignNestedFieldMessage.toObject = function(includeInstance, msg) { + var f, obj = { +deeplyNestedMessage: (f = msg.getDeeplyNestedMessage()) && proto.jspb.test.Deeply.Nested.Message.toObject(includeInstance, 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.jspb.test.ForeignNestedFieldMessage} + */ +proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.ForeignNestedFieldMessage; + return proto.jspb.test.ForeignNestedFieldMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.ForeignNestedFieldMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} + */ +proto.jspb.test.ForeignNestedFieldMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.jspb.test.Deeply.Nested.Message; + reader.readMessage(value,proto.jspb.test.Deeply.Nested.Message.deserializeBinaryFromReader); + msg.setDeeplyNestedMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.ForeignNestedFieldMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.ForeignNestedFieldMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ForeignNestedFieldMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDeeplyNestedMessage(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.jspb.test.Deeply.Nested.Message.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Deeply.Nested.Message deeply_nested_message = 1; + * @return {?proto.jspb.test.Deeply.Nested.Message} + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.getDeeplyNestedMessage = function() { + return /** @type{?proto.jspb.test.Deeply.Nested.Message} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Deeply.Nested.Message, 1)); +}; + + +/** + * @param {?proto.jspb.test.Deeply.Nested.Message|undefined} value + * @return {!proto.jspb.test.ForeignNestedFieldMessage} returns this +*/ +proto.jspb.test.ForeignNestedFieldMessage.prototype.setDeeplyNestedMessage = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} returns this + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.clearDeeplyNestedMessage = function() { + return this.setDeeplyNestedMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.hasDeeplyNestedMessage = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `floatingMsgField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.floatingMsgField = new jspb.ExtensionFieldInfo( + 101, + {floatingMsgField: 0}, + proto.jspb.test.ExtensionMessage, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.ExtensionMessage.toObject), + 0); + +proto.jspb.test.TestExtensionsMessage.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.floatingMsgField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.ExtensionMessage.serializeBinaryToWriter, + proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestExtensionsMessage.extensions[101] = proto.jspb.test.floatingMsgField; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `floatingStrField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.floatingStrField = new jspb.ExtensionFieldInfo( + 102, + {floatingStrField: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.TestExtensionsMessage.extensionsBinary[102] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.floatingStrField, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestExtensionsMessage.extensions[102] = proto.jspb.test.floatingStrField; + diff --git a/example/test2.closure-old.js b/example/test2.closure-old.js new file mode 100644 index 0000000..437a3df --- /dev/null +++ b/example/test2.closure-old.js @@ -0,0 +1,650 @@ +// source: protos/test2.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + + +goog.provide('proto.jspb.test.ExtensionMessage'); +goog.provide('proto.jspb.test.ForeignNestedFieldMessage'); +goog.provide('proto.jspb.test.TestExtensionsMessage'); +goog.provide('proto.jspb.test.floatingMsgField'); +goog.provide('proto.jspb.test.floatingStrField'); + +goog.require('jspb.BinaryReader'); +goog.require('jspb.BinaryWriter'); +goog.require('jspb.ExtensionFieldBinaryInfo'); +goog.require('jspb.ExtensionFieldInfo'); +goog.require('jspb.Message'); +goog.require('proto.jspb.test.Deeply.Nested.Message'); + +/** + * 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.jspb.test.TestExtensionsMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); +}; +goog.inherits(proto.jspb.test.TestExtensionsMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.TestExtensionsMessage.displayName = 'proto.jspb.test.TestExtensionsMessage'; +} + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestExtensionsMessage.extensions = {}; + + +/** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ +proto.jspb.test.TestExtensionsMessage.extensionsBinary = {}; + +/** + * 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.jspb.test.ExtensionMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.ExtensionMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.ExtensionMessage.displayName = 'proto.jspb.test.ExtensionMessage'; +} +/** + * 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.jspb.test.ForeignNestedFieldMessage = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.jspb.test.ForeignNestedFieldMessage, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.jspb.test.ForeignNestedFieldMessage.displayName = 'proto.jspb.test.ForeignNestedFieldMessage'; +} + + + +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.jspb.test.TestExtensionsMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.TestExtensionsMessage.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.jspb.test.TestExtensionsMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestExtensionsMessage.toObject = function(includeInstance, msg) { + var f, obj = { +intfield: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + proto.jspb.test.TestExtensionsMessage.extensions, proto.jspb.test.TestExtensionsMessage.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestExtensionsMessage} + */ +proto.jspb.test.TestExtensionsMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.TestExtensionsMessage; + return proto.jspb.test.TestExtensionsMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestExtensionsMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestExtensionsMessage} + */ +proto.jspb.test.TestExtensionsMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setIntfield(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + proto.jspb.test.TestExtensionsMessage.extensionsBinary, + proto.jspb.test.TestExtensionsMessage.prototype.getExtension, + proto.jspb.test.TestExtensionsMessage.prototype.setExtension); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.TestExtensionsMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.TestExtensionsMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestExtensionsMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.TestExtensionsMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + proto.jspb.test.TestExtensionsMessage.extensionsBinary, proto.jspb.test.TestExtensionsMessage.prototype.getExtension); +}; + + +/** + * optional int32 intfield = 1; + * @return {number} + */ +proto.jspb.test.TestExtensionsMessage.prototype.getIntfield = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** + * @param {number} value + * @return {!proto.jspb.test.TestExtensionsMessage} returns this + */ +proto.jspb.test.TestExtensionsMessage.prototype.setIntfield = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestExtensionsMessage} returns this + */ +proto.jspb.test.TestExtensionsMessage.prototype.clearIntfield = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.TestExtensionsMessage.prototype.hasIntfield = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.ExtensionMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.ExtensionMessage.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.jspb.test.ExtensionMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ExtensionMessage.toObject = function(includeInstance, msg) { + var f, obj = { +ext1: (f = jspb.Message.getField(msg, 1)) == 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.jspb.test.ExtensionMessage} + */ +proto.jspb.test.ExtensionMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.ExtensionMessage; + return proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.ExtensionMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.ExtensionMessage} + */ +proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setExt1(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.ExtensionMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.ExtensionMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.ExtensionMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ExtensionMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.ExtensionMessage.extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + proto.jspb.test.ExtensionMessage, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.ExtensionMessage.toObject), + 0); + +proto.jspb.test.TestExtensionsMessage.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.ExtensionMessage.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.ExtensionMessage.serializeBinaryToWriter, + proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestExtensionsMessage.extensions[100] = proto.jspb.test.ExtensionMessage.extField; + +/** + * optional string ext1 = 1; + * @return {string} + */ +proto.jspb.test.ExtensionMessage.prototype.getExt1 = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); +}; + + +/** + * @param {string} value + * @return {!proto.jspb.test.ExtensionMessage} returns this + */ +proto.jspb.test.ExtensionMessage.prototype.setExt1 = function(value) { + return jspb.Message.setField(this, 1, value); +}; + + +/** + * Clears the field making it undefined. + * @return {!proto.jspb.test.ExtensionMessage} returns this + */ +proto.jspb.test.ExtensionMessage.prototype.clearExt1 = function() { + return jspb.Message.setField(this, 1, undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.ExtensionMessage.prototype.hasExt1 = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + + + +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.jspb.test.ForeignNestedFieldMessage.prototype.toObject = function(opt_includeInstance) { + return proto.jspb.test.ForeignNestedFieldMessage.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.jspb.test.ForeignNestedFieldMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ForeignNestedFieldMessage.toObject = function(includeInstance, msg) { + var f, obj = { +deeplyNestedMessage: (f = msg.getDeeplyNestedMessage()) && proto.jspb.test.Deeply.Nested.Message.toObject(includeInstance, 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.jspb.test.ForeignNestedFieldMessage} + */ +proto.jspb.test.ForeignNestedFieldMessage.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.jspb.test.ForeignNestedFieldMessage; + return proto.jspb.test.ForeignNestedFieldMessage.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.ForeignNestedFieldMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} + */ +proto.jspb.test.ForeignNestedFieldMessage.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new proto.jspb.test.Deeply.Nested.Message; + reader.readMessage(value,proto.jspb.test.Deeply.Nested.Message.deserializeBinaryFromReader); + msg.setDeeplyNestedMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.jspb.test.ForeignNestedFieldMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.ForeignNestedFieldMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.jspb.test.ForeignNestedFieldMessage.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getDeeplyNestedMessage(); + if (f != null) { + writer.writeMessage( + 1, + f, + proto.jspb.test.Deeply.Nested.Message.serializeBinaryToWriter + ); + } +}; + + +/** + * optional Deeply.Nested.Message deeply_nested_message = 1; + * @return {?proto.jspb.test.Deeply.Nested.Message} + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.getDeeplyNestedMessage = function() { + return /** @type{?proto.jspb.test.Deeply.Nested.Message} */ ( + jspb.Message.getWrapperField(this, proto.jspb.test.Deeply.Nested.Message, 1)); +}; + + +/** + * @param {?proto.jspb.test.Deeply.Nested.Message|undefined} value + * @return {!proto.jspb.test.ForeignNestedFieldMessage} returns this +*/ +proto.jspb.test.ForeignNestedFieldMessage.prototype.setDeeplyNestedMessage = function(value) { + return jspb.Message.setWrapperField(this, 1, value); +}; + + +/** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} returns this + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.clearDeeplyNestedMessage = function() { + return this.setDeeplyNestedMessage(undefined); +}; + + +/** + * Returns whether this field is set. + * @return {boolean} + */ +proto.jspb.test.ForeignNestedFieldMessage.prototype.hasDeeplyNestedMessage = function() { + return jspb.Message.getField(this, 1) != null; +}; + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `floatingMsgField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.floatingMsgField = new jspb.ExtensionFieldInfo( + 101, + {floatingMsgField: 0}, + proto.jspb.test.ExtensionMessage, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + proto.jspb.test.ExtensionMessage.toObject), + 0); + +proto.jspb.test.TestExtensionsMessage.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.floatingMsgField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + proto.jspb.test.ExtensionMessage.serializeBinaryToWriter, + proto.jspb.test.ExtensionMessage.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestExtensionsMessage.extensions[101] = proto.jspb.test.floatingMsgField; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `floatingStrField`. + * @type {!jspb.ExtensionFieldInfo} + */ +proto.jspb.test.floatingStrField = new jspb.ExtensionFieldInfo( + 102, + {floatingStrField: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +proto.jspb.test.TestExtensionsMessage.extensionsBinary[102] = new jspb.ExtensionFieldBinaryInfo( + proto.jspb.test.floatingStrField, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +proto.jspb.test.TestExtensionsMessage.extensions[102] = proto.jspb.test.floatingStrField; + diff --git a/example/test2.closure.diff b/example/test2.closure.diff new file mode 100644 index 0000000..e69de29 diff --git a/example/test2.d.ts b/example/test2.d.ts new file mode 100644 index 0000000..acdc5e1 --- /dev/null +++ b/example/test2.d.ts @@ -0,0 +1,50 @@ +import * as jspb from 'google-protobuf'; + +// comment added after generation for code review: +// ""../protos/" as the path is probably not correct. i.e. here it shouild be either './' or '../example/' +// ideally in the code we'd replace `proto_path` from the command line with `options.output_dir`. I don't see an +// easy way to get at `proto_path`, though, since that parameter goes directly to `protoc`, not to the plugin. +import * as protos_test_pb from '../protos/test.js'; + +export class TestExtensionsMessage extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: TestExtensionsMessage): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): TestExtensionsMessage; + static deserializeBinaryFromReader(msg: TestExtensionsMessage, reader: jspb.BinaryReader): TestExtensionsMessage; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: TestExtensionsMessage, writer: jspb.BinaryWriter): void; + getIntfield(): number; + setIntfield(value: number): TestExtensionsMessage; + clearIntfield(): TestExtensionsMessage; + hasIntfield(): boolean; +} + +export class ExtensionMessage extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: ExtensionMessage): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): ExtensionMessage; + static deserializeBinaryFromReader(msg: ExtensionMessage, reader: jspb.BinaryReader): ExtensionMessage; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: ExtensionMessage, writer: jspb.BinaryWriter): void; + getExt1(): string; + setExt1(value: string): ExtensionMessage; + clearExt1(): ExtensionMessage; + hasExt1(): boolean; +} + +export class ForeignNestedFieldMessage extends jspb.Message { + constructor(data?: any[] | null); + toObject(includeInstance?: boolean): { [key: string]: unknown }; + static toObject(includeInstance: boolean | undefined, msg: ForeignNestedFieldMessage): { [key: string]: unknown }; + static deserializeBinary(bytes: jspb.ByteSource): ForeignNestedFieldMessage; + static deserializeBinaryFromReader(msg: ForeignNestedFieldMessage, reader: jspb.BinaryReader): ForeignNestedFieldMessage; + serializeBinary(): Uint8Array; + static serializeBinaryToWriter(message: ForeignNestedFieldMessage, writer: jspb.BinaryWriter): void; + getDeeplyNestedMessage(): protos_test_pb.Deeply.Nested.Message | null; + setDeeplyNestedMessage(value: protos_test_pb.Deeply.Nested.Message | null | undefined): ForeignNestedFieldMessage; + clearDeeplyNestedMessage(): ForeignNestedFieldMessage; + hasDeeplyNestedMessage(): boolean; +} + diff --git a/example/test2.js b/example/test2.js new file mode 100644 index 0000000..556beb3 --- /dev/null +++ b/example/test2.js @@ -0,0 +1,623 @@ +// source: protos/test2.proto +/** + * @fileoverview + * @enhanceable + * @suppress {missingRequire} reports error on implicit type usages. + * @suppress {messageConventions} JS Compiler reports an error if a variable or + * field starts with 'MSG_' and isn't a translatable message. + * @public + */ +// GENERATED CODE -- DO NOT EDIT! +/* eslint-disable */ +// @ts-nocheck + +import * as jspb from 'google-protobuf'; +var goog = jspb; +var proto = {}; + +import * as protos_test_pb from '../protos/test.js'; +export class TestExtensionsMessage extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, 2, null, null); + }; + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensions = {}; + + + /** + * The extensions registered with this message class. This is a map of + * extension field number to fieldInfo object. + * + * For example: + * { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, ctor: proto.example.MyMessage} } + * + * fieldName contains the JsCompiler renamed field name property so that it + * works in OPTIMIZED mode. + * + * @type {!Object} + */ + static extensionsBinary = {}; + + /** + * optional int32 intfield = 1; + * @return {number} + */ + getIntfield() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); + }; + + + /** + * @param {number} value + * @return {!proto.jspb.test.TestExtensionsMessage} returns this + */ + setIntfield(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.TestExtensionsMessage} returns this + */ + clearIntfield() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasIntfield() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.TestExtensionsMessage} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new TestExtensionsMessage; + return TestExtensionsMessage.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.TestExtensionsMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.TestExtensionsMessage} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt32()); + msg.setIntfield(value); + break; + default: + jspb.Message.readBinaryExtension(msg, reader, + TestExtensionsMessage.extensionsBinary, + TestExtensionsMessage.prototype.getExtension, + TestExtensionsMessage.prototype.setExtension); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + TestExtensionsMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.TestExtensionsMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {number} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeInt32( + 1, + f + ); + } + jspb.Message.serializeBinaryExtensions(message, writer, + TestExtensionsMessage.extensionsBinary, TestExtensionsMessage.prototype.getExtension); + }; + + +} + + + +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} + */ +TestExtensionsMessage.prototype.toObject = function(opt_includeInstance) { + return TestExtensionsMessage.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.jspb.test.TestExtensionsMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +TestExtensionsMessage.toObject = function(includeInstance, msg) { + var f, obj = { +intfield: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), obj, + TestExtensionsMessage.extensions, TestExtensionsMessage.prototype.getExtension, + includeInstance); + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +export class ExtensionMessage extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + + /** + * A tuple of {field number, class constructor} for the extension + * field named `extField`. + * @type {!jspb.ExtensionFieldInfo} + */ + static extField = new jspb.ExtensionFieldInfo( + 100, + {extField: 0}, + ExtensionMessage, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + ExtensionMessage.toObject), + 0); + /** + * optional string ext1 = 1; + * @return {string} + */ + getExt1() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 1, "")); + }; + + + /** + * @param {string} value + * @return {!proto.jspb.test.ExtensionMessage} returns this + */ + setExt1(value) { + return jspb.Message.setField(this, 1, value); + }; + + + /** + * Clears the field making it undefined. + * @return {!proto.jspb.test.ExtensionMessage} returns this + */ + clearExt1() { + return jspb.Message.setField(this, 1, undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasExt1() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.ExtensionMessage} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new ExtensionMessage; + return ExtensionMessage.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.ExtensionMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.ExtensionMessage} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {string} */ (reader.readString()); + msg.setExt1(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + ExtensionMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.ExtensionMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = /** @type {string} */ (jspb.Message.getField(message, 1)); + if (f != null) { + writer.writeString( + 1, + f + ); + } + }; + + +} + + + +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} + */ +ExtensionMessage.prototype.toObject = function(opt_includeInstance) { + return ExtensionMessage.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.jspb.test.ExtensionMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +ExtensionMessage.toObject = function(includeInstance, msg) { + var f, obj = { +ext1: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +TestExtensionsMessage.extensionsBinary[100] = new jspb.ExtensionFieldBinaryInfo( + ExtensionMessage.extField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + ExtensionMessage.serializeBinaryToWriter, + ExtensionMessage.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestExtensionsMessage.extensions[100] = ExtensionMessage.extField; + +export class ForeignNestedFieldMessage extends jspb.Message { + /** + * 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 + */ + constructor(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); + }; + /** + * optional Deeply.Nested.Message deeply_nested_message = 1; + * @return {?proto.jspb.test.Deeply.Nested.Message} + */ + getDeeplyNestedMessage() { + return /** @type{?proto.jspb.test.Deeply.Nested.Message} */ ( + jspb.Message.getWrapperField(this, protos_test_pb.Deeply.Nested.Message, 1)); + }; + + + /** + * @param {?proto.jspb.test.Deeply.Nested.Message|undefined} value + * @return {!proto.jspb.test.ForeignNestedFieldMessage} returns this + */ + setDeeplyNestedMessage(value) { + return jspb.Message.setWrapperField(this, 1, value); + }; + + + /** + * Clears the message field making it undefined. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} returns this + */ + clearDeeplyNestedMessage() { + return this.setDeeplyNestedMessage(undefined); + }; + + + /** + * Returns whether this field is set. + * @return {boolean} + */ + hasDeeplyNestedMessage() { + return jspb.Message.getField(this, 1) != null; + }; + + + /** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} + */ + static deserializeBinary(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new ForeignNestedFieldMessage; + return ForeignNestedFieldMessage.deserializeBinaryFromReader(msg, reader); + }; + + + /** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.jspb.test.ForeignNestedFieldMessage} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.jspb.test.ForeignNestedFieldMessage} + */ + static deserializeBinaryFromReader(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = new protos_test_pb.Deeply.Nested.Message; + reader.readMessage(value,protos_test_pb.Deeply.Nested.Message.deserializeBinaryFromReader); + msg.setDeeplyNestedMessage(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; + }; + + + /** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ + serializeBinary() { + var writer = new jspb.BinaryWriter(); + ForeignNestedFieldMessage.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); + }; + + + /** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.jspb.test.ForeignNestedFieldMessage} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ + static serializeBinaryToWriter(message, writer) { + var f = undefined; + f = message.getDeeplyNestedMessage(); + if (f != null) { + writer.writeMessage( + 1, + f, + protos_test_pb.Deeply.Nested.Message.serializeBinaryToWriter + ); + } + }; + + +} + + + +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} + */ +ForeignNestedFieldMessage.prototype.toObject = function(opt_includeInstance) { + return ForeignNestedFieldMessage.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.jspb.test.ForeignNestedFieldMessage} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +ForeignNestedFieldMessage.toObject = function(includeInstance, msg) { + var f, obj = { +deeplyNestedMessage: (f = msg.getDeeplyNestedMessage()) && protos_test_pb.Deeply.Nested.Message.toObject(includeInstance, f) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `floatingMsgField`. + * @type {!jspb.ExtensionFieldInfo} + */ +export const floatingMsgField = new jspb.ExtensionFieldInfo( + 101, + {floatingMsgField: 0}, + ExtensionMessage, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + ExtensionMessage.toObject), + 0); + +TestExtensionsMessage.extensionsBinary[101] = new jspb.ExtensionFieldBinaryInfo( + floatingMsgField, + jspb.BinaryReader.prototype.readMessage, + jspb.BinaryWriter.prototype.writeMessage, + ExtensionMessage.serializeBinaryToWriter, + ExtensionMessage.deserializeBinaryFromReader, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestExtensionsMessage.extensions[101] = floatingMsgField; + + +/** + * A tuple of {field number, class constructor} for the extension + * field named `floatingStrField`. + * @type {!jspb.ExtensionFieldInfo} + */ +export const floatingStrField = new jspb.ExtensionFieldInfo( + 102, + {floatingStrField: 0}, + null, + /** @type {?function((boolean|undefined),!jspb.Message=): !Object} */ ( + null), + 0); + +TestExtensionsMessage.extensionsBinary[102] = new jspb.ExtensionFieldBinaryInfo( + floatingStrField, + jspb.BinaryReader.prototype.readString, + jspb.BinaryWriter.prototype.writeString, + undefined, + undefined, + false); +// This registers the extension field with the extended class, so that +// toObject() will function correctly. +TestExtensionsMessage.extensions[102] = floatingStrField; + diff --git a/generator/js_generator.cc b/generator/js_generator.cc index 6ca0ad3..e2553b1 100644 --- a/generator/js_generator.cc +++ b/generator/js_generator.cc @@ -180,11 +180,12 @@ std::string GetNestedMessageName(const Descriptor* descriptor) { return result; } -// Returns the path prefix for a message or enumeration that -// lives under the given file and containing type. -std::string GetPrefix(const GeneratorOptions& options, - const FileDescriptor* file_descriptor, - const Descriptor* containing_type) { +// Returns the fully-qualified path prefix for a message or enumeration that +// lives under the given file and containing type. Used for everything non-ES6, +// as well as specific ES6 uses where fully-qualified is needed. +std::string GetQualifiedPrefix(const GeneratorOptions& options, + const FileDescriptor* file_descriptor, + const Descriptor* containing_type) { std::string prefix = GetNamespace(options, file_descriptor) + GetNestedMessageName(containing_type); if (!prefix.empty()) { @@ -193,56 +194,157 @@ std::string GetPrefix(const GeneratorOptions& options, return prefix; } -// Returns the fully normalized JavaScript path prefix for the given +// Returns the import-relative path prefix for a message or enumeration that +// lives under the given file and containing type. Used for ES6 in most cases. +std::string GetRelativePrefix(const GeneratorOptions& options, + const FileDescriptor* file_descriptor, + const Descriptor* containing_type) { + std::string prefix = GetNestedMessageName(containing_type); + if (!prefix.empty()) { + prefix = prefix.substr(1, prefix.length() - 1); + prefix += "."; + } + return prefix; +} + +// Returns the normalized fully-qualified JavaScript path prefix for the given // message descriptor. -std::string GetMessagePathPrefix(const GeneratorOptions& options, - const Descriptor* descriptor) { - return GetPrefix(options, descriptor->file(), descriptor->containing_type()); +std::string GetQualifiedMessagePathPrefix(const GeneratorOptions& options, + const Descriptor* descriptor) { + return GetQualifiedPrefix(options, descriptor->file(), + descriptor->containing_type()); } -// Returns the fully normalized JavaScript path for the given +// Returns the normalized import-relative JavaScript path prefix for the given // message descriptor. -std::string GetMessagePath(const GeneratorOptions& options, - const Descriptor* descriptor) { - return GetMessagePathPrefix(options, descriptor) + descriptor->name(); +std::string GetRelativeMessagePathPrefix(const GeneratorOptions& options, + const Descriptor* descriptor) { + return GetRelativePrefix(options, descriptor->file(), + descriptor->containing_type()); +} + +// Returns the normalized fully-qualified JavaScript path for the given +// message descriptor. +std::string GetQualifiedMessagePath(const GeneratorOptions& options, + const Descriptor* descriptor) { + return GetQualifiedMessagePathPrefix(options, descriptor) + + descriptor->name(); +} + +// Returns the normalized import-relative JavaScript path for the given +// message descriptor. +std::string GetRelativeMessagePath(const GeneratorOptions& options, + const Descriptor* descriptor) { + return GetRelativeMessagePathPrefix(options, descriptor) + descriptor->name(); +} + +// Returns the normalized fully-qualified JavaScript path prefix for the given +// enumeration descriptor. +std::string GetQualifiedEnumPathPrefix(const GeneratorOptions& options, + const EnumDescriptor* enum_descriptor) { + return GetQualifiedPrefix(options, enum_descriptor->file(), + enum_descriptor->containing_type()); } -// Returns the fully normalized JavaScript path prefix for the given +// Returns the normalized import-relative JavaScript path prefix for the given // enumeration descriptor. -std::string GetEnumPathPrefix(const GeneratorOptions& options, - const EnumDescriptor* enum_descriptor) { - return GetPrefix(options, enum_descriptor->file(), - enum_descriptor->containing_type()); +std::string GetRelativeEnumPathPrefix(const GeneratorOptions& options, + const EnumDescriptor* enum_descriptor) { + return GetRelativePrefix(options, enum_descriptor->file(), + enum_descriptor->containing_type()); } -// Returns the fully normalized JavaScript path for the given +// Returns the normalized fully-qualified JavaScript path for the given // enumeration descriptor. -std::string GetEnumPath(const GeneratorOptions& options, - const EnumDescriptor* enum_descriptor) { - return GetEnumPathPrefix(options, enum_descriptor) + enum_descriptor->name(); +std::string GetQualifiedEnumPath(const GeneratorOptions& options, + const EnumDescriptor* enum_descriptor) { + return GetQualifiedEnumPathPrefix(options, enum_descriptor) + + enum_descriptor->name(); +} + +// Returns the normalized import-relative JavaScript path for the given +// enumeration descriptor. +std::string GetRelativeEnumPath(const GeneratorOptions& options, + const EnumDescriptor* enum_descriptor) { + return GetRelativeEnumPathPrefix(options, enum_descriptor) + + enum_descriptor->name(); +} + +bool IsExportedMessage(const GeneratorOptions& options, + const Descriptor* desc) { + return options.import_style == GeneratorOptions::kImportEs6 && + GetNestedMessageName(desc->containing_type()).empty(); +} + +std::string LocalMessageRef(const GeneratorOptions& options, + const Descriptor* to_message) { + if (options.import_style == GeneratorOptions::kImportEs6) { + // in the same file for ES6, use the relative name directly + return GetRelativeMessagePath(options, to_message); + } else { + // Within a single file we use a full name. + return GetQualifiedMessagePath(options, to_message); + } } -std::string MaybeCrossFileRef(const GeneratorOptions& options, - const FileDescriptor* from_file, - const Descriptor* to_message) { +std::string MaybeCrossFileMessageRef(const GeneratorOptions& options, + const FileDescriptor* from_file, + const Descriptor* to_message) { if ((options.import_style == GeneratorOptions::kImportCommonJs || - options.import_style == GeneratorOptions::kImportCommonJsStrict) && + options.import_style == GeneratorOptions::kImportCommonJsStrict || + options.import_style == GeneratorOptions::kImportEs6) && from_file != to_message->file()) { - // Cross-file ref in CommonJS needs to use the module alias instead of - // the global name. - return ModuleAlias(to_message->file()->name()) + - GetNestedMessageName(to_message->containing_type()) + "." + - to_message->name(); + // Cross-file ref in CommonJS or ES6 needs to use the module alias instead + // of the global name. + return ModuleAlias(to_message->file()->name()) + "." + + GetRelativeMessagePath(options, to_message); + } else { + return LocalMessageRef(options, to_message); + } +} + +std::string LocalEnumRef(const GeneratorOptions& options, + const EnumDescriptor* to_enum) { + if (options.import_style == GeneratorOptions::kImportEs6) { + // in the same file for ES6, use the relative name directly + return GetRelativeEnumPath(options, to_enum); } else { // Within a single file we use a full name. - return GetMessagePath(options, to_message); + return GetQualifiedEnumPath(options, to_enum); + } +} + +bool IsExportedEnum(const GeneratorOptions& options, + const EnumDescriptor* desc) { + return options.import_style == GeneratorOptions::kImportEs6 && + GetNestedMessageName(desc->containing_type()).empty(); +} + +std::string MaybeCrossFileEnumRef(const GeneratorOptions& options, + const FileDescriptor* from_file, + const EnumDescriptor* to_enum) { + if ((options.import_style == GeneratorOptions::kImportCommonJs || + options.import_style == GeneratorOptions::kImportCommonJsStrict || + options.import_style == GeneratorOptions::kImportEs6) && + from_file != to_enum->file()) { + // Cross-file ref in CommonJS or ES6 needs to use the module alias instead + // of the global name. + return ModuleAlias(to_enum->file()->name()) + "." + + GetRelativeEnumPath(options, to_enum); + } else if (options.import_style == GeneratorOptions::kImportEs6) { + // in the same file for ES6, use the relative name directly + return GetRelativeEnumPath(options, to_enum); + } else { + // Within a single file we use a full name. + return GetQualifiedEnumPath(options, to_enum); } } std::string SubmessageTypeRef(const GeneratorOptions& options, const FieldDescriptor* field) { ABSL_CHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE); - return MaybeCrossFileRef(options, field->file(), field->message_type()); + return MaybeCrossFileMessageRef(options, field->file(), + field->message_type()); } // - Object field name: LOWER_UNDERSCORE -> LOWER_CAMEL, except for group fields @@ -892,11 +994,11 @@ std::string ProtoTypeName(const GeneratorOptions& options, case FieldDescriptor::TYPE_BYTES: return "bytes"; case FieldDescriptor::TYPE_GROUP: - return GetMessagePath(options, field->message_type()); + return GetQualifiedMessagePath(options, field->message_type()); case FieldDescriptor::TYPE_ENUM: - return GetEnumPath(options, field->enum_type()); + return GetQualifiedEnumPath(options, field->enum_type()); case FieldDescriptor::TYPE_MESSAGE: - return GetMessagePath(options, field->message_type()); + return GetQualifiedMessagePath(options, field->message_type()); default: return ""; } @@ -944,9 +1046,9 @@ std::string JSTypeName(const GeneratorOptions& options, case FieldDescriptor::CPPTYPE_STRING: return JSStringTypeName(options, field, bytes_mode); case FieldDescriptor::CPPTYPE_ENUM: - return GetEnumPath(options, field->enum_type()); + return GetQualifiedEnumPath(options, field->enum_type()); case FieldDescriptor::CPPTYPE_MESSAGE: - return GetMessagePath(options, field->message_type()); + return GetQualifiedMessagePath(options, field->message_type()); default: return ""; } @@ -1161,7 +1263,7 @@ static const char* kRepeatedFieldArrayName = ".repeatedFields_"; std::string RepeatedFieldsArrayName(const GeneratorOptions& options, const Descriptor* desc) { return HasRepeatedFields(options, desc) - ? (GetMessagePath(options, desc) + kRepeatedFieldArrayName) + ? (LocalMessageRef(options, desc) + kRepeatedFieldArrayName) : "null"; } @@ -1179,7 +1281,7 @@ static const char* kOneofGroupArrayName = ".oneofGroups_"; std::string OneofFieldsArrayName(const GeneratorOptions& options, const Descriptor* desc) { return HasOneofFields(desc) - ? (GetMessagePath(options, desc) + kOneofGroupArrayName) + ? (LocalMessageRef(options, desc) + kOneofGroupArrayName) : "null"; } @@ -1255,7 +1357,7 @@ std::string JSExtensionsObjectName(const GeneratorOptions& options, // TODO(haberman): fix this for the kImportCommonJs case. return "jspb.Message.messageSetExtensions"; } else { - return MaybeCrossFileRef(options, from_file, desc) + ".extensions"; + return MaybeCrossFileMessageRef(options, from_file, desc) + ".extensions"; } } @@ -1664,8 +1766,9 @@ void Generator::FindProvides(const GeneratorOptions& options, void FindProvidesForOneOfEnum(const GeneratorOptions& options, const OneofDescriptor* oneof, std::set* provided) { - std::string name = GetMessagePath(options, oneof->containing_type()) + "." + - JSOneofName(oneof) + "Case"; + std::string name = + GetQualifiedMessagePath(options, oneof->containing_type()) + "." + + JSOneofName(oneof) + "Case"; provided->insert(name); } @@ -1690,7 +1793,7 @@ void Generator::FindProvidesForMessage(const GeneratorOptions& options, return; } - std::string name = GetMessagePath(options, desc); + std::string name = GetQualifiedMessagePath(options, desc); provided->insert(name); for (int i = 0; i < desc->enum_type_count(); i++) { @@ -1707,7 +1810,7 @@ void Generator::FindProvidesForEnum(const GeneratorOptions& options, io::Printer* printer, const EnumDescriptor* enumdesc, std::set* provided) const { - std::string name = GetEnumPath(options, enumdesc); + std::string name = GetQualifiedEnumPath(options, enumdesc); provided->insert(name); } @@ -1750,6 +1853,9 @@ void Generator::GenerateProvides(const GeneratorOptions& options, namespaceObject.erase(0, 6); printer->Print("goog.exportSymbol('$name$', null, proto);\n", "name", namespaceObject); + } else if (options.import_style == GeneratorOptions::kImportEs6) { + // do nothing. we don't need `goog.*` behavior for ES6, and instead + // we'll `export ` things when we generate them. } else { printer->Print("goog.exportSymbol('$name$', null, global);\n", "name", *it); @@ -1817,7 +1923,8 @@ void Generator::GenerateRequiresForLibrary( } if (extension->containing_type()->full_name() != "google.protobuf.bridge.MessageSet") { - required.insert(GetMessagePath(options, extension->containing_type())); + required.insert( + GetQualifiedMessagePath(options, extension->containing_type())); } FindRequiresForField(options, extension, &required, &forwards); have_extensions = true; @@ -1928,13 +2035,13 @@ void Generator::FindRequiresForField(const GeneratorOptions& options, // dependencies, as per original codegen. !(field->is_extension() && field->extension_scope() == nullptr)) { if (options.add_require_for_enums) { - required->insert(GetEnumPath(options, field->enum_type())); + required->insert(GetQualifiedEnumPath(options, field->enum_type())); } else { - forwards->insert(GetEnumPath(options, field->enum_type())); + forwards->insert(GetQualifiedEnumPath(options, field->enum_type())); } } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { if (!IgnoreMessage(field->message_type())) { - required->insert(GetMessagePath(options, field->message_type())); + required->insert(GetQualifiedMessagePath(options, field->message_type())); } } } @@ -1944,7 +2051,8 @@ void Generator::FindRequiresForExtension( std::set* required, std::set* forwards) const { if (field->containing_type()->full_name() != "google.protobuf.bridge.MessageSet") { - required->insert(GetMessagePath(options, field->containing_type())); + required->insert( + GetQualifiedMessagePath(options, field->containing_type())); } FindRequiresForField(options, field, required, forwards); } @@ -1960,12 +2068,18 @@ void Generator::GenerateTestOnly(const GeneratorOptions& options, void Generator::GenerateClassesAndEnums(const GeneratorOptions& options, io::Printer* printer, const FileDescriptor* file) const { - for (int i = 0; i < file->message_type_count(); i++) { - GenerateClassConstructorAndDeclareExtensionFieldInfo(options, printer, - file->message_type(i)); - } - for (int i = 0; i < file->message_type_count(); i++) { - GenerateClass(options, printer, file->message_type(i)); + if (options.import_style == GeneratorOptions::kImportEs6) { + for (int i = 0; i < file->message_type_count(); i++) { + GenerateES6Class(options, printer, file->message_type(i)); + } + } else { + for (int i = 0; i < file->message_type_count(); i++) { + GenerateClassConstructorAndDeclareExtensionFieldInfo( + options, printer, file->message_type(i)); + } + for (int i = 0; i < file->message_type_count(); i++) { + GenerateClass(options, printer, file->message_type(i)); + } } for (int i = 0; i < file->enum_type_count(); i++) { GenerateEnum(options, printer, file->enum_type(i)); @@ -2031,11 +2145,18 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options, " * valid.\n" " * @extends {jspb.Message}\n" " * @constructor\n" - " */\n" - "$classprefix$$classname$ = function(opt_data) {\n", - "classprefix", GetMessagePathPrefix(options, desc), "classname", - desc->name()); - printer->Annotate("classname", desc); + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("constructor(opt_data) {\n"); + } else if (IsExportedMessage(options, desc)) { + printer->Print("export function $classname$(opt_data) {\n", "classname", + LocalMessageRef(options, desc)); + printer->Annotate("classname", desc); + } else { + printer->Print("$classname$ = function(opt_data) {\n", "classname", + LocalMessageRef(options, desc)); + printer->Annotate("classname", desc); + } std::string message_id = GetMessageId(desc); printer->Print( " jspb.Message.initialize(this, opt_data, $messageId$, $pivot$, " @@ -2046,19 +2167,66 @@ void Generator::GenerateClassConstructor(const GeneratorOptions& options, "pivot", GetPivot(desc), "rptfields", RepeatedFieldsArrayName(options, desc), "oneoffields", OneofFieldsArrayName(options, desc)); - printer->Print( - "};\n" - "goog.inherits($classname$, jspb.Message);\n" - "if (goog.DEBUG && !COMPILED) {\n" - // displayName overrides Function.prototype.displayName - // http://google3/javascript/externs/es3.js?l=511 - " /**\n" - " * @public\n" - " * @override\n" - " */\n" - " $classname$.displayName = '$classname$';\n" - "}\n", - "classname", GetMessagePath(options, desc)); + printer->Print("};\n"); + if (options.import_style != GeneratorOptions::kImportEs6) { + printer->Print( + "goog.inherits($classname$, jspb.Message);\n" + "if (goog.DEBUG && !COMPILED) {\n" + // displayName overrides Function.prototype.displayName + // http://google3/javascript/externs/es3.js?l=511 + " /**\n" + " * @public\n" + " * @override\n" + " */\n" + " $classname$.displayName = '$displayname$';\n" + "}\n", + "classname", LocalMessageRef(options, desc), "displayname", + GetQualifiedMessagePath(options, desc)); + } +} + +void Generator::GenerateES6Class(const GeneratorOptions& options, + io::Printer* printer, + const Descriptor* desc) const { + if (IgnoreMessage(desc)) { + return; + } + + if (IsExportedMessage(options, desc)) { + printer->Print("export class $classname$ extends jspb.Message {\n", + "classname", LocalMessageRef(options, desc)); + } else { + printer->Print("$classname$ = class extends jspb.Message {\n", + "classname", LocalMessageRef(options, desc)); + } + printer->Annotate("classname", desc); + printer->Indent(); + + for (int i = 0; i < desc->enum_type_count(); i++) { + GenerateEnum(options, printer, desc->enum_type(i)); + } + + GenerateClassConstructor(options, printer, desc); + + if (IsExtendable(desc) && desc->full_name() != "google.protobuf.bridge.MessageSet") { + GenerateClassExtensionFieldInfo(options, printer, desc); + } + + GenerateClassExtensionDeclarations(options, printer, desc); + GenerateClassFieldInfo(options, printer, desc); + GenerateClassFields(options, printer, desc); + GenerateClassDeserializeBinary(options, printer, desc); + GenerateClassSerializeBinary(options, printer, desc); + + printer->Outdent(); + printer->Print("}\n\n"); + + GenerateClassToObject(options, printer, desc); + GenerateClassExtensionRegistration(options, printer, desc); + + for (int i = 0; i < desc->nested_type_count(); i++) { + GenerateES6Class(options, printer, desc->nested_type(i)); + } } void Generator::GenerateClassConstructorAndDeclareExtensionFieldInfo( @@ -2088,12 +2256,18 @@ void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, " * List of repeated fields within this message type.\n" " * @private {!Array}\n" " * @const\n" - " */\n" - "$classname$$rptfieldarray$ = $rptfields$;\n" - "\n", - "classname", GetMessagePath(options, desc), "rptfieldarray", - kRepeatedFieldArrayName, "rptfields", - RepeatedFieldNumberList(options, desc)); + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static repeatedFields_ = $rptfields$;\n\n", + "rptfields", RepeatedFieldNumberList(options, desc)); + } else { + printer->Print( + "$classname$$rptfieldarray$ = $rptfields$;\n" + "\n", + "classname", LocalMessageRef(options, desc), "rptfieldarray", + kRepeatedFieldArrayName, "rptfields", + RepeatedFieldNumberList(options, desc)); + } } if (HasOneofFields(desc)) { @@ -2109,11 +2283,16 @@ void Generator::GenerateClassFieldInfo(const GeneratorOptions& options, "be kept.\n" " * @private {!Array>}\n" " * @const\n" - " */\n" - "$classname$$oneofgrouparray$ = $oneofgroups$;\n" - "\n", - "classname", GetMessagePath(options, desc), "oneofgrouparray", - kOneofGroupArrayName, "oneofgroups", OneofGroupList(desc)); + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static oneofGroups_ = $oneofgroups$;\n\n", + "oneofgroups", OneofGroupList(desc)); + } else { + printer->Print("$classname$$oneofgrouparray$ = $oneofgroups$;\n" + "\n", + "classname", LocalMessageRef(options, desc), "oneofgrouparray", + kOneofGroupArrayName, "oneofgroups", OneofGroupList(desc)); + } for (int i = 0; i < desc->oneof_decl_count(); i++) { if (IgnoreOneof(desc->oneof_decl(i))) { @@ -2130,8 +2309,9 @@ void Generator::GenerateClassXid(const GeneratorOptions& options, printer->Print( "\n" "\n" - "$class$.prototype.messageXid = xid('$class$');\n", - "class", GetMessagePath(options, desc)); + "$class$.prototype.messageXid = xid('$xid$');\n", + "class", LocalMessageRef(options, desc), "xid", + GetQualifiedMessagePath(options, desc)); } void Generator::GenerateOneofCaseDefinition( @@ -2140,11 +2320,16 @@ void Generator::GenerateOneofCaseDefinition( printer->Print( "/**\n" " * @enum {number}\n" - " */\n" - "$classname$.$oneof$Case = {\n" - " $upcase$_NOT_SET: 0", - "classname", GetMessagePath(options, oneof->containing_type()), "oneof", - JSOneofName(oneof), "upcase", ToEnumCase(oneof->name())); + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static $oneof$Case = {\n", + "oneof", JSOneofName(oneof)); + } else { + printer->Print("$classname$.$oneof$Case = {\n", + "classname", LocalMessageRef(options, oneof->containing_type()), + "oneof", JSOneofName(oneof)); + } + printer->Print(" $upcase$_NOT_SET: 0", "upcase", ToEnumCase(oneof->name())); for (int i = 0; i < oneof->field_count(); i++) { if (IgnoreField(oneof->field(i))) { @@ -2164,14 +2349,25 @@ void Generator::GenerateOneofCaseDefinition( "};\n" "\n" "/**\n" - " * @return {$class$.$oneof$Case}\n" - " */\n" - "$class$.prototype.get$oneof$Case = function() {\n" - " return /** @type {$class$.$oneof$Case} */(jspb.Message." + " * @return {$type$.$oneof$Case}\n" + " */\n", + "type", GetQualifiedMessagePath(options, oneof->containing_type()), + "oneof", JSOneofName(oneof)); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("get$oneof$Case() {\n", + "oneof", JSOneofName(oneof)); + } else { + printer->Print("$class$.prototype.get$oneof$Case = function() {\n", + "class", LocalMessageRef(options, oneof->containing_type()), + "oneof", JSOneofName(oneof)); + } + printer->Print( + " return /** @type {$type$.$oneof$Case} */(jspb.Message." "computeOneofCase(this, $class$.oneofGroups_[$oneofindex$]));\n" "};\n" "\n", - "class", GetMessagePath(options, oneof->containing_type()), "oneof", + "type", GetQualifiedMessagePath(options, oneof->containing_type()), + "class", LocalMessageRef(options, oneof->containing_type()), "oneof", JSOneofName(oneof), "oneofindex", JSOneofIndex(oneof)); } @@ -2207,13 +2403,14 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options, "include\n" " * the JSPB instance for transitional soy proto support:\n" " * http://goto/soy-param-migration\n" - " * @param {!$classname$} msg The msg instance to transform.\n" + " * @param {!$typename$} msg The msg instance to transform.\n" " * @return {!Object}\n" " * @suppress {unusedLocalVariables} f is only used for nested messages\n" " */\n" "$classname$.toObject = function(includeInstance, msg) {\n" " var f, obj = {", - "classname", GetMessagePath(options, desc)); + "classname", LocalMessageRef(options, desc), "typename", + GetQualifiedMessagePath(options, desc)); bool first = true; for (int i = 0; i < desc->field_count(); i++) { @@ -2245,7 +2442,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options, " $extObject$, $class$.prototype.getExtension,\n" " includeInstance);\n", "extObject", JSExtensionsObjectName(options, desc->file(), desc), - "class", GetMessagePath(options, desc)); + "class", LocalMessageRef(options, desc)); } printer->Print( @@ -2256,8 +2453,7 @@ void Generator::GenerateClassToObject(const GeneratorOptions& options, "};\n" "}\n" "\n" - "\n", - "classname", GetMessagePath(options, desc)); + "\n"); } void Generator::GenerateFieldValueExpression(io::Printer* printer, @@ -2321,7 +2517,7 @@ void Generator::GenerateClassFieldToObject(const GeneratorOptions& options, std::string value_to_object; if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { value_to_object = - GetMessagePath(options, value_field->message_type()) + ".toObject"; + LocalMessageRef(options, value_field->message_type()) + ".toObject"; } else { value_to_object = "undefined"; } @@ -2381,7 +2577,8 @@ void Generator::GenerateObjectTypedef(const GeneratorOptions& options, const Descriptor* desc) const { // TODO(b/122687752): Consider renaming nested messages called ObjectFormat // to prevent collisions. - const std::string type_name = GetMessagePath(options, desc) + ".ObjectFormat"; + const std::string type_name = + LocalMessageRef(options, desc) + ".ObjectFormat"; printer->Print( "/**\n" @@ -2417,13 +2614,14 @@ void Generator::GenerateClassFromObject(const GeneratorOptions& options, printer->Print( "/**\n" " * Loads data from an object into a new instance of this proto.\n" - " * @param {!$classname$.ObjectFormat} obj\n" + " * @param {!$typename$.ObjectFormat} obj\n" " * The object representation of this proto to load the data from.\n" - " * @return {!$classname$}\n" + " * @return {!$typename$}\n" " */\n" "$classname$.fromObject = function(obj) {\n" " var msg = new $classname$();\n", - "classname", GetMessagePath(options, desc)); + "classname", LocalMessageRef(options, desc), "typename", + GetQualifiedMessagePath(options, desc)); for (int i = 0; i < desc->field_count(); i++) { const FieldDescriptor* field = desc->field(i); @@ -2452,7 +2650,7 @@ void Generator::GenerateClassFieldFromObject( "$fieldclass$.fromObject));\n", "name", JSObjectFieldName(options, field), "index", JSFieldIndex(field), "fieldclass", - GetMessagePath(options, value_field->message_type())); + LocalMessageRef(options, value_field->message_type())); } else { // `msg` is a newly-constructed message object that has not yet built any // map containers wrapping underlying arrays, so we can simply directly @@ -2505,6 +2703,33 @@ void Generator::GenerateClassRegistration(const GeneratorOptions& options, } } +void Generator::GenerateClassExtensionDeclarations( + const GeneratorOptions& options, io::Printer* printer, + const Descriptor* desc) const { + // Just declare any extensions defined inside this message type, without + // registering. Registration happens later with a call to + // GenerateClassExtensionRegistration. + for (int i = 0; i < desc->extension_count(); i++) { + const FieldDescriptor* extension = desc->extension(i); + if (ShouldGenerateExtension(extension)) { + GenerateExtensionDeclaration(options, printer, extension); + } + } +} + +void Generator::GenerateClassExtensionRegistration( + const GeneratorOptions& options, io::Printer* printer, + const Descriptor* desc) const { + // Register the extensions defined inside this message type. Declaration + // happened earlier with a call to GenerateClassExtensionDeclarations. + for (int i = 0; i < desc->extension_count(); i++) { + const FieldDescriptor* extension = desc->extension(i); + if (ShouldGenerateExtension(extension)) { + GenerateExtensionRegistration(options, printer, extension); + } + } +} + void Generator::GenerateClassFields(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { @@ -2522,31 +2747,48 @@ void GenerateBytesWrapper(const GeneratorOptions& options, io::Printer* printer, /* is_setter_argument = */ false, /* force_present = */ false, /* singular_if_not_packed = */ false, bytes_mode); + std::string name = JSGetterName(options, field, bytes_mode); + std::string defname = JSGetterName(options, field, BYTES_DEFAULT); printer->Print( "/**\n" " * $fielddef$\n" "$comment$" " * This is a type-conversion wrapper around `get$defname$()`\n" " * @return {$type$}\n" - " */\n" - "$class$.prototype.get$name$ = function() {\n" + " */\n", + "fielddef", FieldDefinition(options, field), + "comment", FieldComments(field, bytes_mode), + "type", type, + "defname", defname); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("get$name$() {\n", + "name", name); + } else { + printer->Print("$class$.prototype.get$name$ = function() {\n", + "class", LocalMessageRef(options, field->containing_type()), + "name", name); + } + printer->Print( " return /** @type {$type$} */ (jspb.Message.bytes$list$As$suffix$(\n" " this.get$defname$()));\n" "};\n" "\n" "\n", - "fielddef", FieldDefinition(options, field), "comment", - FieldComments(field, bytes_mode), "type", type, "class", - GetMessagePath(options, field->containing_type()), "name", - JSGetterName(options, field, bytes_mode), "list", - field->is_repeated() ? "List" : "", "suffix", - JSByteGetterSuffix(bytes_mode), "defname", - JSGetterName(options, field, BYTES_DEFAULT)); + "type", type, + "list", field->is_repeated() ? "List" : "", + "suffix", JSByteGetterSuffix(bytes_mode), + "defname", defname); } void Generator::GenerateClassField(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { + std::string classname = LocalMessageRef(options, field->containing_type()); + std::string gettername = "get" + JSGetterName(options, field); + std::string settername = "set" + JSGetterName(options, field); + std::string clearername = "clear" + JSGetterName(options, field); + std::string hasername = "has" + JSGetterName(options, field); + if (field->is_map()) { const FieldDescriptor* key_field = MapFieldKey(field); const FieldDescriptor* value_field = MapFieldValue(field); @@ -2571,13 +2813,21 @@ void Generator::GenerateClassField(const GeneratorOptions& options, " */\n", "fielddef", FieldDefinition(options, field), "keytype", key_type, "valuetype", value_type); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$gettername$(opt_noLazyCreate) {\n", + "gettername", gettername); + } else { + printer->Print( + "$class$.prototype.$gettername$ = function(opt_noLazyCreate) {\n", + "class", classname, + "gettername", gettername); + } + printer->Annotate("gettername", field); printer->Print( - "$class$.prototype.$gettername$ = function(opt_noLazyCreate) {\n" " return /** @type {!jspb.Map<$keytype$,$valuetype$>} */ (\n", - "class", GetMessagePath(options, field->containing_type()), - "gettername", "get" + JSGetterName(options, field), "keytype", key_type, + "class", classname, + "keytype", key_type, "valuetype", value_type); - printer->Annotate("gettername", field); printer->Print( " jspb.Message.getMapField(this, $index$, opt_noLazyCreate", "index", JSFieldIndex(field)); @@ -2586,7 +2836,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, printer->Print( ",\n" " $messageType$", - "messageType", GetMessagePath(options, value_field->message_type())); + "messageType", LocalMessageRef(options, value_field->message_type())); } else { printer->Print( ",\n" @@ -2615,16 +2865,23 @@ void Generator::GenerateClassField(const GeneratorOptions& options, /* is_setter_argument = */ false, /* force_present = */ false, /* singular_if_not_packed = */ false)); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$gettername$() {\n", + "gettername", gettername); + } else { + printer->Print("$class$.prototype.$gettername$ = function() {\n", + "class", classname, + "gettername", gettername); + } + printer->Annotate("gettername", field); printer->Print( - "$class$.prototype.$gettername$ = function() {\n" " return /** @type{$type$} */ (\n" " jspb.Message.get$rpt$WrapperField(this, $wrapperclass$, " "$index$$required$));\n" "};\n" "\n" "\n", - "class", GetMessagePath(options, field->containing_type()), - "gettername", "get" + JSGetterName(options, field), "type", + "type", JSFieldTypeAnnotation(options, field, /* is_setter_argument = */ false, /* force_present = */ false, @@ -2633,24 +2890,31 @@ void Generator::GenerateClassField(const GeneratorOptions& options, JSFieldIndex(field), "wrapperclass", SubmessageTypeRef(options, field), "required", (field->label() == FieldDescriptor::LABEL_REQUIRED ? ", 1" : "")); - printer->Annotate("gettername", field); printer->Print( "/**\n" " * @param {$optionaltype$} value\n" - " * @return {!$class$} returns this\n" - "*/\n" - "$class$.prototype.$settername$ = function(value) {\n" - " return jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", + " * @return {!$returntype$} returns this\n" + "*/\n", "optionaltype", JSFieldTypeAnnotation(options, field, /* is_setter_argument = */ true, /* force_present = */ false, /* singular_if_not_packed = */ false), - "class", GetMessagePath(options, field->containing_type()), - "settername", "set" + JSGetterName(options, field), "oneoftag", - (InRealOneof(field) ? "Oneof" : ""), "repeatedtag", - (field->is_repeated() ? "Repeated" : "")); + "returntype", + GetQualifiedMessagePath(options, field->containing_type())); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$settername$(value) {\n", + "settername", settername); + } else { + printer->Print("$class$.prototype.$settername$ = function(value) {\n", + "class", classname, + "settername", settername); + } printer->Annotate("settername", field); + printer->Print( + " return jspb.Message.set$oneoftag$$repeatedtag$WrapperField(", + "oneoftag", (InRealOneof(field) ? "Oneof" : ""), + "repeatedtag", (field->is_repeated() ? "Repeated" : "")); printer->Print( "this, $index$$oneofgroup$, value);\n" @@ -2698,9 +2962,14 @@ void Generator::GenerateClassField(const GeneratorOptions& options, FieldComments(field, bytes_mode), "type", typed_annotation); } - printer->Print("$class$.prototype.$gettername$ = function() {\n", "class", - GetMessagePath(options, field->containing_type()), - "gettername", "get" + JSGetterName(options, field)); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$gettername$() {\n", + "gettername", gettername); + } else { + printer->Print("$class$.prototype.$gettername$ = function() {\n", + "class", classname, + "gettername", gettername); + } printer->Annotate("gettername", field); if (untyped) { @@ -2749,7 +3018,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, " * @param {$optionaltype$} value\n" " * @return {!$class$} returns this\n" " */\n", - "class", GetMessagePath(options, field->containing_type()), + "class", GetQualifiedMessagePath(options, field->containing_type()), "optionaltype", untyped ? "*" : JSFieldTypeAnnotation(options, field, @@ -2757,30 +3026,32 @@ void Generator::GenerateClassField(const GeneratorOptions& options, /* force_present = */ false, /* singular_if_not_packed = */ false)); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$settername$(value) {\n", + "settername", settername); + } else { + printer->Print("$class$.prototype.$settername$ = function(value) {\n", + "class", classname, + "settername", settername); + } + printer->Annotate("settername", field); if (!field->is_repeated() && !field->is_map() && !field->has_presence()) { // Proto3 non-repeated and non-map fields without presence use the // setProto3*Field function. printer->Print( - "$class$.prototype.$settername$ = function(value) {\n" " return jspb.Message.setProto3$typetag$Field(this, $index$, " "value);" "\n" "};\n" "\n" "\n", - "class", GetMessagePath(options, field->containing_type()), - "settername", "set" + JSGetterName(options, field), "typetag", - JSTypeTag(field), "index", JSFieldIndex(field)); - printer->Annotate("settername", field); + "typetag", JSTypeTag(field), + "index", JSFieldIndex(field)); } else { // Otherwise, use the regular setField function. - printer->Print( - "$class$.prototype.$settername$ = function(value) {\n" - " return jspb.Message.set$oneoftag$Field(this, $index$", - "class", GetMessagePath(options, field->containing_type()), - "settername", "set" + JSGetterName(options, field), "oneoftag", - (InRealOneof(field) ? "Oneof" : ""), "index", JSFieldIndex(field)); - printer->Annotate("settername", field); + printer->Print(" return jspb.Message.set$oneoftag$Field(this, $index$", + "oneoftag", (InRealOneof(field) ? "Oneof" : ""), + "index", JSFieldIndex(field)); printer->Print( "$oneofgroup$, $type$value$rptvalueinit$$typeclose$);\n" "};\n" @@ -2799,7 +3070,7 @@ void Generator::GenerateClassField(const GeneratorOptions& options, " * Clears the value.\n" " * @return {!$class$} returns this\n" " */\n", - "class", GetMessagePath(options, field->containing_type())); + "class", GetQualifiedMessagePath(options, field->containing_type())); } if (field->is_repeated()) { @@ -2814,19 +3085,26 @@ void Generator::GenerateClassField(const GeneratorOptions& options, printer->Print( "/**\n" " * Clears values from the map. The map will be non-null.\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$clearername$ = function() {\n" + " * @return {!$returntype$} returns this\n" + " */\n", + "returntype", GetQualifiedMessagePath(options, field->containing_type())); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$clearername$function() {\n", + "clearername", clearername); + } else { + printer->Print("$class$.prototype.$clearername$ = function() {\n", + "class", classname, + "clearername", clearername); + } + printer->Annotate("clearername", field); + printer->Print( " this.$gettername$().clear();\n" " return this;\n" "};\n" "\n" "\n", - "class", GetMessagePath(options, field->containing_type()), - "clearername", "clear" + JSGetterName(options, field), - "gettername", "get" + JSGetterName(options, field)); + "gettername", gettername); // clang-format on - printer->Annotate("clearername", field); } else if (field->is_repeated() || (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && !field->is_required())) { @@ -2835,22 +3113,29 @@ void Generator::GenerateClassField(const GeneratorOptions& options, printer->Print( "/**\n" " * $jsdoc$\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$clearername$ = function() {\n" + " * @return {!$returntype$} returns this\n" + " */\n", + "jsdoc", field->is_repeated() + ? "Clears the list making it empty but non-null." + : "Clears the message field making it undefined.", + "returntype", GetQualifiedMessagePath(options, field->containing_type())); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$clearername$() {\n", + "clearername", clearername); + } else { + printer->Print("$class$.prototype.$clearername$ = function() {\n", + "class", classname, + "clearername", clearername); + } + printer->Annotate("clearername", field); + printer->Print( " return this.$settername$($clearedvalue$);\n" "};\n" "\n" "\n", - "jsdoc", field->is_repeated() - ? "Clears the list making it empty but non-null." - : "Clears the message field making it undefined.", - "class", GetMessagePath(options, field->containing_type()), - "clearername", "clear" + JSGetterName(options, field), - "settername", "set" + JSGetterName(options, field), + "settername", settername, "clearedvalue", (field->is_repeated() ? "[]" : "undefined")); // clang-format on - printer->Annotate("clearername", field); } else if (HasFieldPresence(options, field)) { // Fields where we can't delegate to the regular setter because it doesn't // accept "undefined" as an argument. @@ -2858,20 +3143,27 @@ void Generator::GenerateClassField(const GeneratorOptions& options, printer->Print( "/**\n" " * Clears the field making it undefined.\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$clearername$ = function() {\n" + " * @return {!$returntype$} returns this\n" + " */\n", + "returntype", GetQualifiedMessagePath(options, field->containing_type())); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$clearername$() {\n", + "clearername", clearername); + } else { + printer->Print("$class$.prototype.$clearername$ = function() {\n", + "class", classname, + "clearername", clearername); + } + printer->Annotate("clearername", field); + printer->Print( " return jspb.Message.set$maybeoneof$Field(this, " "$index$$maybeoneofgroup$, ", - "class", GetMessagePath(options, field->containing_type()), - "clearername", "clear" + JSGetterName(options, field), "maybeoneof", (InRealOneof(field) ? "Oneof" : ""), "maybeoneofgroup", (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "index", JSFieldIndex(field)); // clang-format on - printer->Annotate("clearername", field); printer->Print( "$clearedvalue$);\n" "};\n" @@ -2885,34 +3177,37 @@ void Generator::GenerateClassField(const GeneratorOptions& options, "/**\n" " * Returns whether this field is set.\n" " * @return {boolean}\n" - " */\n" - "$class$.prototype.$hasername$ = function() {\n" + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$hasername$() {\n", + "hasername", hasername); + } else { + printer->Print("$class$.prototype.$hasername$ = function() {\n", + "class", classname, + "hasername", hasername); + } + printer->Annotate("hasername", field); + printer->Print( " return jspb.Message.getField(this, $index$) != null;\n" "};\n" "\n" "\n", - "class", GetMessagePath(options, field->containing_type()), "hasername", - "has" + JSGetterName(options, field), "index", JSFieldIndex(field)); - printer->Annotate("hasername", field); + "index", JSFieldIndex(field)); } } void Generator::GenerateRepeatedPrimitiveHelperMethods( const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field, bool untyped) const { + std::string addername = "add" + JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true); // clang-format off printer->Print( "/**\n" " * @param {$optionaltype$} value\n" " * @param {number=} opt_index\n" - " * @return {!$class$} returns this\n" - " */\n" - "$class$.prototype.$addername$ = function(value, opt_index) {\n" - " return jspb.Message.addToRepeatedField(this, " - "$index$", - "class", GetMessagePath(options, field->containing_type()), "addername", - "add" + JSGetterName(options, field, BYTES_DEFAULT, - /* drop_list = */ true), + " * @return {!$returntype$} returns this\n" + " */\n", + "returntype", GetQualifiedMessagePath(options, field->containing_type()), "optionaltype", JSFieldTypeAnnotation( options, field, @@ -2920,9 +3215,19 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods( /* force_present = */ true, /* singular_if_not_packed = */ false, BYTES_DEFAULT, - /* force_singular = */ true), - "index", JSFieldIndex(field)); + /* force_singular = */ true)); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$addername$(value, opt_index) {\n", + "addername", addername); + } else { + printer->Print("$class$.prototype.$addername$ = function(value, opt_index) {\n", + "class", LocalMessageRef(options, field->containing_type()), + "addername", addername); + } printer->Annotate("addername", field); + printer->Print( + " return jspb.Message.addToRepeatedField(this, $index$", + "index", JSFieldIndex(field)); printer->Print( "$oneofgroup$, $type$value$rptvalueinit$$typeclose$, " "opt_index);\n" @@ -2939,18 +3244,25 @@ void Generator::GenerateRepeatedPrimitiveHelperMethods( void Generator::GenerateRepeatedMessageHelperMethods( const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { + std::string addername = "add" + JSGetterName(options, field, BYTES_DEFAULT, /* drop_list = */ true); printer->Print( "/**\n" - " * @param {!$optionaltype$=} opt_value\n" + " * @param {$optionaltype$=} opt_value\n" " * @param {number=} opt_index\n" - " * @return {!$optionaltype$}\n" - " */\n" - "$class$.prototype.$addername$ = function(opt_value, opt_index) {\n" - " return jspb.Message.addTo$repeatedtag$WrapperField(", - "optionaltype", JSTypeName(options, field, BYTES_DEFAULT), "class", - GetMessagePath(options, field->containing_type()), "addername", - "add" + JSGetterName(options, field, BYTES_DEFAULT, - /* drop_list = */ true), + " * @return {$optionaltype$}\n" + " */\n", + "optionaltype", + JSFieldTypeAnnotation(options, field, false, true, false, BYTES_DEFAULT, + true)); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("$addername$(opt_value, opt_index) {\n", + "addername", addername); + } else { + printer->Print("$class$.prototype.$addername$ = function(opt_value, opt_index) {\n", + "class", LocalMessageRef(options, field->containing_type()), + "addername", addername); + } + printer->Print(" return jspb.Message.addTo$repeatedtag$WrapperField(", "repeatedtag", (field->is_repeated() ? "Repeated" : "")); printer->Annotate("addername", field); @@ -2961,7 +3273,7 @@ void Generator::GenerateRepeatedMessageHelperMethods( "\n", "index", JSFieldIndex(field), "oneofgroup", (InRealOneof(field) ? (", " + JSOneofArray(options, field)) : ""), "ctor", - GetMessagePath(options, field->message_type())); + LocalMessageRef(options, field->message_type())); } void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, @@ -2984,10 +3296,14 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, " * works in OPTIMIZED mode.\n" " *\n" " * @type {!Object}\n" - " */\n" - "$class$.extensions = {};\n" - "\n", - "class", GetMessagePath(options, desc)); + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static extensions = {};\n\n"); + } else { + printer->Print("$class$.extensions = {};\n" + "\n", + "class", LocalMessageRef(options, desc)); + } printer->Print( "\n" @@ -3005,10 +3321,14 @@ void Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options, " * works in OPTIMIZED mode.\n" " *\n" " * @type {!Object}\n" - " */\n" - "$class$.extensionsBinary = {};\n" - "\n", - "class", GetMessagePath(options, desc)); + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static extensionsBinary = {};\n\n"); + } else { + printer->Print("$class$.extensionsBinary = {};\n" + "\n", + "class", LocalMessageRef(options, desc)); + } } } @@ -3018,30 +3338,45 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options, // TODO(cfallin): Handle lazy decoding when requested by field option and/or // by default for 'bytes' fields and packed repeated fields. + std::string classname = LocalMessageRef(options, desc); + std::string classtype = GetQualifiedMessagePath(options, desc); printer->Print( "/**\n" " * Deserializes binary data (in protobuf wire format).\n" " * @param {jspb.ByteSource} bytes The bytes to deserialize.\n" - " * @return {!$class$}\n" - " */\n" - "$class$.deserializeBinary = function(bytes) {\n" + " * @return {!$classtype$}\n" + " */\n", + "classtype", classtype); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static deserializeBinary(bytes) {\n"); + } else { + printer->Print("$classname$.deserializeBinary = function(bytes) {\n", + "classname", classname); + } + printer->Print( " var reader = new jspb.BinaryReader(bytes);\n" - " var msg = new $class$;\n" - " return $class$.deserializeBinaryFromReader(msg, reader);\n" + " var msg = new $classname$;\n" + " return $classname$.deserializeBinaryFromReader(msg, reader);\n" "};\n" "\n" "\n" "/**\n" " * Deserializes binary data (in protobuf wire format) from the\n" " * given reader into the given message object.\n" - " * @param {!$class$} msg The message object to deserialize into.\n" + " * @param {!$classtype$} msg The message object to deserialize into.\n" " * @param {!jspb.BinaryReader} reader The BinaryReader to use.\n" - " * @return {!$class$}\n" - " */\n" - "$class$.deserializeBinaryFromReader = function(msg, reader) {\n" - " while (reader.nextField()) {\n", - "class", GetMessagePath(options, desc)); + " * @return {!$classtype$}\n" + " */\n", + "classname", classname, + "classtype", classtype); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static deserializeBinaryFromReader(msg, reader) {\n"); + } else { + printer->Print("$classname$.deserializeBinaryFromReader = function(msg, reader) {\n", + "classname", classname); + } printer->Print( + " while (reader.nextField()) {\n" " if (reader.isEndGroup()) {\n" " break;\n" " }\n" @@ -3063,8 +3398,8 @@ void Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options, " $class$.prototype.setExtension);\n" " break;\n" " }\n", - "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class", - GetMessagePath(options, desc)); + "extobj", JSExtensionsObjectName(options, desc->file(), desc), + "class", classname); } else { printer->Print( " reader.skipField();\n" @@ -3102,14 +3437,14 @@ void Generator::GenerateClassDeserializeBinaryField( if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { printer->Print(", $messageType$.deserializeBinaryFromReader", "messageType", - GetMessagePath(options, value_field->message_type())); + LocalMessageRef(options, value_field->message_type())); } else { printer->Print(", null"); } printer->Print(", $defaultKey$", "defaultKey", JSFieldDefault(key_field)); if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { printer->Print(", new $messageType$()", "messageType", - GetMessagePath(options, value_field->message_type())); + LocalMessageRef(options, value_field->message_type())); } else { printer->Print(", $defaultValue$", "defaultValue", JSFieldDefault(value_field)); @@ -3174,14 +3509,22 @@ void Generator::GenerateClassDeserializeBinaryField( void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const { + std::string classname = LocalMessageRef(options, desc); + std::string classtype = GetQualifiedMessagePath(options, desc); printer->Print( "/**\n" " * Serializes the message to binary data (in protobuf wire format).\n" " * @return {!Uint8Array}\n" - " */\n" - "$class$.prototype.serializeBinary = function() {\n" + " */\n"); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("serializeBinary() {\n"); + } else { + printer->Print("$classname$.prototype.serializeBinary = function() {\n", + "classname", classname); + } + printer->Print( " var writer = new jspb.BinaryWriter();\n" - " $class$.serializeBinaryToWriter(this, writer);\n" + " $classname$.serializeBinaryToWriter(this, writer);\n" " return writer.getResultBuffer();\n" "};\n" "\n" @@ -3189,14 +3532,19 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, "/**\n" " * Serializes the given message to binary data (in protobuf wire\n" " * format), writing to the given BinaryWriter.\n" - " * @param {!$class$} message\n" + " * @param {!$classtype$} message\n" " * @param {!jspb.BinaryWriter} writer\n" " * @suppress {unusedLocalVariables} f is only used for nested messages\n" - " */\n" - "$class$.serializeBinaryToWriter = function(message, " - "writer) {\n" - " var f = undefined;\n", - "class", GetMessagePath(options, desc)); + " */\n", + "classname", classname, + "classtype", classtype); + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static serializeBinaryToWriter(message, writer) {\n"); + } else { + printer->Print("$classname$.serializeBinaryToWriter = function(message, writer) {\n", + "classname", classname); + } + printer->Print(" var f = undefined;\n"); for (int i = 0; i < desc->field_count(); i++) { if (!IgnoreField(desc->field(i))) { @@ -3209,7 +3557,7 @@ void Generator::GenerateClassSerializeBinary(const GeneratorOptions& options, " jspb.Message.serializeBinaryExtensions(message, writer,\n" " $extobj$Binary, $class$.prototype.getExtension);\n", "extobj", JSExtensionsObjectName(options, desc->file(), desc), "class", - GetMessagePath(options, desc)); + LocalMessageRef(options, desc)); } printer->Print( @@ -3302,7 +3650,7 @@ void Generator::GenerateClassSerializeBinaryField( if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) { printer->Print(", $messageType$.serializeBinaryToWriter", "messageType", - GetMessagePath(options, value_field->message_type())); + LocalMessageRef(options, value_field->message_type())); } printer->Print(");\n"); @@ -3337,11 +3685,18 @@ void Generator::GenerateEnum(const GeneratorOptions& options, printer->Print( "/**\n" " * @enum {number}\n" - " */\n" - "$enumprefix$$name$ = {\n", - "enumprefix", GetEnumPathPrefix(options, enumdesc), "name", - enumdesc->name()); - printer->Annotate("name", enumdesc); + " */\n"); + if (IsExportedEnum(options, enumdesc)) { + printer->Print("export const $enumname$ = {\n", "enumname", + LocalEnumRef(options, enumdesc)); + } else if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static $enumname$ = {\n", + "enumname", enumdesc->name()); + } else { + printer->Print("$enumname$ = {\n", "enumname", + LocalEnumRef(options, enumdesc)); + } + printer->Annotate("enumname", enumdesc); std::set used_name; std::vector valid_index; @@ -3368,11 +3723,13 @@ void Generator::GenerateEnum(const GeneratorOptions& options, void Generator::GenerateExtension(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const { - std::string extension_scope = - (field->extension_scope() - ? GetMessagePath(options, field->extension_scope()) - : GetNamespace(options, field->file())); + GenerateExtensionDeclaration(options, printer, field); + GenerateExtensionRegistration(options, printer, field); +} +void Generator::GenerateExtensionDeclaration( + const GeneratorOptions& options, io::Printer* printer, + const FieldDescriptor* field) const { const std::string extension_object_name = JSObjectFieldName(options, field); printer->Print( "\n" @@ -3380,14 +3737,29 @@ void Generator::GenerateExtension(const GeneratorOptions& options, " * A tuple of {field number, class constructor} for the extension\n" " * field named `$nameInComment$`.\n" " * @type {!jspb.ExtensionFieldInfo<$extensionType$>}\n" - " */\n" - "$class$.$name$ = new jspb.ExtensionFieldInfo(\n", - "nameInComment", extension_object_name, "name", extension_object_name, - "class", extension_scope, "extensionType", + " */\n", + "nameInComment", extension_object_name, "extensionType", JSFieldTypeAnnotation(options, field, /* is_setter_argument = */ false, /* force_present = */ true, /* singular_if_not_packed = */ false)); + + const Descriptor* scope_desc = field->extension_scope(); + std::string extension_scope = + (scope_desc ? MaybeCrossFileMessageRef(options, field->file(), scope_desc) + : GetNamespace(options, field->file())); + if (!scope_desc && options.import_style == GeneratorOptions::kImportEs6) { + extension_scope = ""; + printer->Print("export const $name$ = new jspb.ExtensionFieldInfo(\n", + "name", extension_object_name); + } else if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("static $name$ = new jspb.ExtensionFieldInfo(\n", + "name", extension_object_name); + } else { + extension_scope += "."; + printer->Print("$class$$name$ = new jspb.ExtensionFieldInfo(\n", "class", + extension_scope, "name", extension_object_name); + } printer->Annotate("name", field); printer->Print( " $index$,\n" @@ -3397,7 +3769,8 @@ void Generator::GenerateExtension(const GeneratorOptions& options, "!Object} */ (\n" " $toObject$),\n" " $repeated$);\n", - "index", absl::StrCat(field->number()), "name", extension_object_name, "ctor", + "index", absl::StrCat(field->number()), "name", extension_object_name, + "ctor", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ? SubmessageTypeRef(options, field) : std::string("null")), @@ -3406,11 +3779,28 @@ void Generator::GenerateExtension(const GeneratorOptions& options, ? (SubmessageTypeRef(options, field) + ".toObject") : std::string("null")), "repeated", (field->is_repeated() ? "1" : "0")); +} + +void Generator::GenerateExtensionRegistration( + const GeneratorOptions& options, io::Printer* printer, + const FieldDescriptor* field) const { + + const std::string extension_object_name = JSObjectFieldName(options, field); + const Descriptor* scope_desc = field->extension_scope(); + std::string extension_scope = + (scope_desc ? MaybeCrossFileMessageRef(options, field->file(), scope_desc) + : GetNamespace(options, field->file())); + + if (!scope_desc && options.import_style == GeneratorOptions::kImportEs6) { + extension_scope = ""; + } else { + extension_scope += "."; + } printer->Print( "\n" "$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\n" - " $class$.$name$,\n" + " $class$$name$,\n" " $binaryReaderFn$,\n" " $binaryWriterFn$,\n" " $binaryMessageSerializeFn$,\n" @@ -3435,7 +3825,7 @@ void Generator::GenerateExtension(const GeneratorOptions& options, printer->Print( "// This registers the extension field with the extended class, so that\n" "// toObject() will function correctly.\n" - "$extendName$[$index$] = $class$.$name$;\n" + "$extendName$[$index$] = $class$$name$;\n" "\n", "extendName", JSExtensionsObjectName(options, field->file(), field->containing_type()), @@ -3468,7 +3858,7 @@ bool GeneratorOptions::ParseFromOptions( } else if (option.first == "error_on_name_conflict") { ABSL_LOG(WARNING) << "Ignoring error_on_name_conflict option, this " - "will be removed in a future release"; + "will be removed in a future release"; } else if (option.first == "output_dir") { output_dir = option.second; } else if (option.first == "namespace_prefix") { @@ -3504,6 +3894,12 @@ bool GeneratorOptions::ParseFromOptions( return false; } annotate_code = true; + } else if (option.first == "generate_dts") { + if (!option.second.empty()) { + *error = "Unexpected option value for generate_dts"; + return false; + } + generate_dts = true; } else { // Assume any other option is an output directory, as long as it is a bare // `key` rather than a `key=value` option. @@ -3516,22 +3912,38 @@ bool GeneratorOptions::ParseFromOptions( } if (import_style != kImportClosure && - (add_require_for_enums || testonly || !library.empty() || - extension != ".js" || one_output_file_per_input_file)) { + (add_require_for_enums || testonly || extension != ".js" || + one_output_file_per_input_file)) { *error = - "The add_require_for_enums, testonly, library, extension, and " + "The add_require_for_enums, testonly, extension, and " "one_output_file_per_input_file options should only be " "used for import_style=closure"; return false; } + if (import_style != kImportClosure && import_style != kImportEs6 && + !library.empty()) { + *error = + "The library option should only be " + "used for import_style=closure or es6"; + return false; + } + + if (generate_dts && (import_style != kImportEs6 || library.empty())) { + *error = + "The generate_dts option should only be " + "used for import_style=es6 and with library set"; + return false; + } + return true; } GeneratorOptions::OutputMode GeneratorOptions::output_mode() const { - // We use one output file per input file if we are not using Closure or if - // this is explicitly requested. - if (import_style != kImportClosure || one_output_file_per_input_file) { + // We use one output file per input file if we are not using Closure or ES6, + // or if this is explicitly requested. + if ((import_style != kImportClosure && import_style != kImportEs6) || + one_output_file_per_input_file) { return kOneOutputFilePerInputFile; } @@ -3540,6 +3952,10 @@ GeneratorOptions::OutputMode GeneratorOptions::output_mode() const { return kEverythingInOneFile; } + // SCC for ES6 is not implemented + ABSL_CHECK(import_style != kImportEs6) + << "ES6 must specify either one_output_file_per_input_file or library"; + // Otherwise, we create one output file per SCC. return kOneOutputFilePerSCC; } @@ -3584,12 +4000,7 @@ void Generator::GenerateFileAndDeps( bool Generator::GenerateFile(const FileDescriptor* file, const GeneratorOptions& options, GeneratorContext* context, - bool use_short_name) const { - std::string filename = - options.output_dir + "/" + - GetJSFilename(options, use_short_name - ? file->name().substr(file->name().rfind('/')) - : file->name()); + const std::string& filename) const { std::unique_ptr output(context->Open(filename)); ABSL_CHECK(output); GeneratedCodeInfo annotations; @@ -3618,12 +4029,18 @@ void Generator::GenerateFile(const GeneratorOptions& options, // Generate "require" statements. if ((options.import_style == GeneratorOptions::kImportCommonJs || - options.import_style == GeneratorOptions::kImportCommonJsStrict)) { - printer->Print("var jspb = require('google-protobuf');\n"); + options.import_style == GeneratorOptions::kImportCommonJsStrict || + options.import_style == GeneratorOptions::kImportEs6)) { + if (options.import_style == GeneratorOptions::kImportEs6) { + printer->Print("import * as jspb from 'google-protobuf';\n"); + } else { + printer->Print("var jspb = require('google-protobuf');\n"); + } printer->Print("var goog = jspb;\n"); - // Do not use global scope in strict mode - if (options.import_style == GeneratorOptions::kImportCommonJsStrict) { + // Do not use global scope in strict mode or with ES6 + if (options.import_style == GeneratorOptions::kImportCommonJsStrict || + options.import_style == GeneratorOptions::kImportEs6) { printer->Print("var proto = {};\n\n"); } else { // To get the global object we call a function with .call(null), this will @@ -3648,13 +4065,23 @@ void Generator::GenerateFile(const GeneratorOptions& options, " Function('return this')();\n\n"); } - for (int i = 0; i < file->dependency_count(); i++) { - const std::string& name = file->dependency(i)->name(); - printer->Print( - "var $alias$ = require('$file$');\n" - "goog.object.extend(proto, $alias$);\n", - "alias", ModuleAlias(name), "file", - GetRootPath(file->name(), name) + GetJSFilename(options, name)); + if (options.import_style == GeneratorOptions::kImportEs6) { + for (int i = 0; i < file->dependency_count(); i++) { + const std::string& name = file->dependency(i)->name(); + printer->Print( + "import * as $alias$ from '$file$';\n", "alias", ModuleAlias(name), + "file", + GetRootPath(file->name(), name) + GetJSFilename(options, name)); + } + } else { + for (int i = 0; i < file->dependency_count(); i++) { + const std::string& name = file->dependency(i)->name(); + printer->Print( + "var $alias$ = require('$file$');\n" + "goog.object.extend(proto, $alias$);\n", + "alias", ModuleAlias(name), "file", + GetRootPath(file->name(), name) + GetJSFilename(options, name)); + } } } @@ -3698,6 +4125,23 @@ void Generator::GenerateFile(const GeneratorOptions& options, } else if (options.import_style == GeneratorOptions::kImportCommonJsStrict) { printer->Print("goog.object.extend(exports, proto);\n", "package", GetNamespace(options, file)); + } else if (options.import_style == GeneratorOptions::kImportEs6) { + std::string package = GetNamespace(options, file); + for (std::set::iterator it = provided.begin(); + it != provided.end(); ++it) { + std::string fullname = *it; + std::string localname = fullname.substr(package.length() + 1); + std::string exportedname = localname; + std::string::iterator iend = + std::remove(exportedname.begin(), exportedname.end(), '.'); + exportedname.resize(exportedname.length() - (exportedname.end() - iend)); + exportedname.shrink_to_fit(); + // when exported name == local name, it's top level and already exported + if (exportedname != localname) { + printer->Print("export const $exportedname$ = $localname$;\n", + "exportedname", exportedname, "localname", localname); + } + } } // Emit well-known type methods. @@ -3709,6 +4153,351 @@ void Generator::GenerateFile(const GeneratorOptions& options, } } +bool Generator::GenerateDTS(const FileDescriptor* file, + const GeneratorOptions& options, + GeneratorContext* context, + const std::string& js_filename) const { + if (!options.generate_dts) { + return true; + } + + ABSL_CHECK(options.import_style == GeneratorOptions::kImportEs6); + + std::string dts_filename = + js_filename.substr(0, js_filename.length() - options.extension.length()) + + ".d.ts"; + std::unique_ptr output(context->Open(dts_filename)); + ABSL_CHECK(output); + io::Printer printer(output.get(), '$', nullptr); + + GenerateDTS(options, &printer, file); + + return !printer.failed(); +} + +const std::string DTS_INDENT = " "; + +void Generator::GenerateDTS(const GeneratorOptions& options, + io::Printer* printer, + const FileDescriptor* file) const { + printer->Print("import * as jspb from 'google-protobuf';\n"); + for (int i = 0; i < file->dependency_count(); i++) { + const std::string& name = file->dependency(i)->name(); + printer->Print( + "import * as $alias$ from '$file$';\n", "alias", ModuleAlias(name), + "file", GetRootPath(file->name(), name) + GetJSFilename(options, name)); + } + printer->Print("\n"); + + for (int i = 0; i < file->message_type_count(); i++) { + auto desc = file->message_type(i); + GenerateMessageDTS(options, printer, desc); + } + + for (int i = 0; i < file->enum_type_count(); i++) { + auto enumdesc = file->enum_type(i); + GenerateEnumDTS(options, printer, enumdesc); + } + + // Emit well-known type methods. + for (FileToc* toc = well_known_types_js; toc->name != NULL; toc++) { + std::string name = std::string("google/protobuf/") + toc->name; + if (name == StripProto(file->name()) + ".js") { + printer->Print(toc->dts_data); + } + } +} + +void Generator::GenerateMessageDTS(const GeneratorOptions& options, + io::Printer* printer, + const Descriptor* desc) const { + if (IgnoreMessage(desc)) { + return; + } + + const std::string prefix = + IsExportedMessage(options, desc) ? "export " : ""; + printer->Print("$prefix$class $classname$ extends jspb.Message {\n", + "classname", desc->name(), "prefix", prefix); + + printer->Indent(); + printer->Print("constructor(data?: any[] | null);\n"); + + if (HasOneofFields(desc)) { + for (int i = 0; i < desc->oneof_decl_count(); i++) { + GenerateOneofMethodDTS(options, printer, desc->oneof_decl(i)); + } + } + + printer->Print( + "toObject(includeInstance?: boolean): { [key: string]: unknown " + "};\n" + "static toObject(includeInstance: boolean | undefined, msg: " + "$class$): { [key: string]: unknown };\n" + "static deserializeBinary(bytes: jspb.ByteSource): $class$;\n" + "static deserializeBinaryFromReader(msg: $class$, reader: " + "jspb.BinaryReader): $class$;\n" + "serializeBinary(): Uint8Array;\n" + "static serializeBinaryToWriter(message: $class$, writer: " + "jspb.BinaryWriter): void;\n", + "class", LocalMessageRef(options, desc)); + + for (int i = 0; i < desc->field_count(); i++) { + if (!IgnoreField(desc->field(i))) { + GenerateFieldDTS(options, printer, desc->field(i)); + } + } + + printer->Outdent(); + printer->Print("}\n\n"); + + bool has_subtypes = false; + if (HasOneofFields(desc)) { + for (int i = 0; i < desc->oneof_decl_count(); i++) { + has_subtypes = has_subtypes || !IgnoreOneof(desc->oneof_decl(i)); + } + } + for (int i = 0; i < desc->nested_type_count(); i++) { + has_subtypes = has_subtypes || !IgnoreMessage(desc->nested_type(i)); + } + for (int i = 0; i < desc->enum_type_count(); i++) { + has_subtypes = true; + } + + if (has_subtypes) { + printer->Print("$prefix$namespace $classname$ {\n", "prefix", prefix, + "classname", desc->name()); + printer->Indent(); + + if (HasOneofFields(desc)) { + for (int i = 0; i < desc->oneof_decl_count(); i++) { + GenerateOneofEnumDTS(options, printer, desc->oneof_decl(i)); + } + } + + for (int i = 0; i < desc->nested_type_count(); i++) { + GenerateMessageDTS(options, printer, desc->nested_type(i)); + } + for (int i = 0; i < desc->enum_type_count(); i++) { + GenerateEnumDTS(options, printer, desc->enum_type(i)); + } + + printer->Outdent(); + printer->Print("}\n\n"); + } +} + +void Generator::GenerateOneofEnumDTS(const GeneratorOptions& options, + io::Printer* printer, + const OneofDescriptor* oneof) const { + if (IgnoreOneof(oneof)) { + return; + } + + printer->Print("enum $oneof$Case {\n", "oneof", JSOneofName(oneof)); + printer->Indent(); + + printer->Print("$upcase$_NOT_SET = 0,\n", "upcase", + ToEnumCase(oneof->name())); + + for (int i = 0; i < oneof->field_count(); i++) { + auto field = oneof->field(i); + if (IgnoreField(field)) { + continue; + } + printer->Print("$upcase$ = $number$,\n", "upcase", + ToEnumCase(field->name()), "number", JSFieldIndex(field)); + } + + printer->Outdent(); + printer->Print("}\n"); +} + +void Generator::GenerateOneofMethodDTS(const GeneratorOptions& options, + io::Printer* printer, + const OneofDescriptor* oneof) const { + if (IgnoreOneof(oneof)) { + return; + } + + printer->Print("get$oneof$Case(): $class$.$oneof$Case;\n", "class", + LocalMessageRef(options, oneof->containing_type()), "oneof", + JSOneofName(oneof)); +} + +std::string DTSTypeName(const GeneratorOptions& options, + const FieldDescriptor* field, BytesMode bytes_mode) { + switch (field->cpp_type()) { + case FieldDescriptor::CPPTYPE_BOOL: + return "boolean"; + case FieldDescriptor::CPPTYPE_INT32: + case FieldDescriptor::CPPTYPE_INT64: + case FieldDescriptor::CPPTYPE_UINT32: + case FieldDescriptor::CPPTYPE_UINT64: + return JSIntegerTypeName(field); + case FieldDescriptor::CPPTYPE_FLOAT: + case FieldDescriptor::CPPTYPE_DOUBLE: + return "number"; + case FieldDescriptor::CPPTYPE_STRING: + return JSStringTypeName(options, field, bytes_mode); + case FieldDescriptor::CPPTYPE_ENUM: + return MaybeCrossFileEnumRef(options, field->file(), field->enum_type()); + case FieldDescriptor::CPPTYPE_MESSAGE: + return MaybeCrossFileMessageRef(options, field->file(), + field->message_type()); + default: + return ""; + } +} + +std::string DTSFieldType(const GeneratorOptions& options, + const FieldDescriptor* field, + BytesMode bytes_mode = BYTES_DEFAULT, + bool force_singular = false) { + std::string dtstype = DTSTypeName(options, field, bytes_mode); + if (!force_singular && field->is_repeated()) { + if (field->type() == FieldDescriptor::TYPE_BYTES && + bytes_mode == BYTES_DEFAULT) { + dtstype = "Uint8Array[] | string[]"; + } else { + dtstype += "[]"; + } + } + return dtstype; +} + +std::string DTSFieldReturnType(const GeneratorOptions& options, + const FieldDescriptor* field, + BytesMode bytes_mode = BYTES_DEFAULT) { + std::string jstype = DTSFieldType(options, field, bytes_mode); + if (DeclaredReturnTypeIsNullable(options, field)) { + jstype += " | null"; + } + return jstype; +} + +std::string DTSFieldSetterType(const GeneratorOptions& options, + const FieldDescriptor* field) { + std::string jstype = DTSFieldType(options, field); + if (SetterAcceptsNull(options, field)) { + jstype += " | null"; + } + if (SetterAcceptsUndefined(options, field)) { + jstype += " | undefined"; + } + return jstype; +} + +void Generator::GenerateFieldDTS(const GeneratorOptions& options, + io::Printer* printer, + const FieldDescriptor* field) const { + if (field->is_map()) { + printer->Print( + "$gettername$(noLazyCreate?: boolean): " + "jspb.Map<$keytype$,$valuetype$> " + "| undefined;\n", + "gettername", "get" + JSGetterName(options, field), "keytype", + DTSFieldType(options, MapFieldKey(field)), "valuetype", + DTSFieldType(options, MapFieldValue(field))); + } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) { + printer->Print("$gettername$(): $type$;\n", "gettername", + "get" + JSGetterName(options, field), "type", + DTSFieldReturnType(options, field)); + printer->Print("$settername$(value: $optionaltype$): $class$;\n", + "settername", "set" + JSGetterName(options, field), + "optionaltype", DTSFieldSetterType(options, field), "class", + LocalMessageRef(options, field->containing_type())); + if (field->is_repeated()) { + printer->Print( + "$addername$(value?: $optionaltype$, index?: number): " + "$optionaltype$;\n", + "addername", + "add" + + JSGetterName(options, field, BYTES_DEFAULT, /* drop_list */ true), + "optionaltype", + DTSFieldType(options, field, BYTES_DEFAULT, + /* force_singular */ true)); + } + } else { + BytesMode bytes_mode = + field->type() == FieldDescriptor::TYPE_BYTES && !options.binary + ? BYTES_B64 + : BYTES_DEFAULT; + printer->Print("$gettername$(): $type$;\n", "gettername", + "get" + JSGetterName(options, field), "type", + DTSFieldReturnType(options, field, bytes_mode)); + + if (field->type() == FieldDescriptor::TYPE_BYTES) { + printer->Print("get$name$(): $type$;\n", "type", + DTSFieldReturnType(options, field, BYTES_B64), "name", + JSGetterName(options, field, BYTES_B64)); + printer->Print("get$name$(): $type$;\n", "type", + DTSFieldReturnType(options, field, BYTES_U8), "name", + JSGetterName(options, field, BYTES_U8)); + } + + printer->Print("$settername$(value: $optionaltype$): $class$;\n", + "settername", "set" + JSGetterName(options, field), + "optionaltype", DTSFieldSetterType(options, field), "class", + LocalMessageRef(options, field->containing_type())); + + if (field->is_repeated()) { + printer->Print( + "$addername$(value: $optionaltype$, index?: number): " + "$class$;\n", + "addername", + "add" + JSGetterName(options, field, BYTES_DEFAULT, + /* drop_list = */ true), + "optionaltype", DTSFieldType(options, field, BYTES_DEFAULT, true), + "class", LocalMessageRef(options, field->containing_type())); + } + } + + if (field->is_map() || field->is_repeated() || + (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE && + !field->is_required()) || + HasFieldPresence(options, field)) { + printer->Print("$clearername$(): $class$;\n", "clearername", + "clear" + JSGetterName(options, field), "class", + LocalMessageRef(options, field->containing_type())); + } + + if (HasFieldPresence(options, field)) { + printer->Print("$hasername$(): boolean;\n", "hasername", + "has" + JSGetterName(options, field)); + } +} + +void Generator::GenerateEnumDTS(const GeneratorOptions& options, + io::Printer* printer, + const EnumDescriptor* enumdesc) const { + const std::string prefix = + IsExportedEnum(options, enumdesc) ? "export " : ""; + printer->Print("$prefix$enum $name$ {\n", "prefix", prefix, "name", + enumdesc->name()); + printer->Indent(); + + std::set used_name; + std::vector valid_values; + for (int i = 0; i < enumdesc->value_count(); i++) { + const EnumValueDescriptor* value = enumdesc->value(i); + if (enumdesc->options().allow_alias() && + !used_name.insert(ToEnumCase(value->name())).second) { + continue; + } + valid_values.push_back(value); + } + + for (auto value : valid_values) { + printer->Print("$name$ = $value$,\n", + "name", ToEnumCase(value->name()), "value", + absl::StrCat(value->number())); + } + + printer->Outdent(); + printer->Print("}\n\n"); +} + bool Generator::GenerateAll(const std::vector& files, const std::string& parameter, GeneratorContext* context, @@ -3724,6 +4513,16 @@ bool Generator::GenerateAll(const std::vector& files, // All output should go in a single file. std::string filename = options.output_dir + "/" + options.library + options.GetFileNameExtension(); + if (options.import_style == GeneratorOptions::kImportEs6) { + // all-in-one for ES6 not actually supported. but we abuse this branch to + // allow specifying the output name via library when there's a single + // input. + ABSL_CHECK(files.size() == 1) + << "ES6 only supports one input file with library option"; + return GenerateFile(files[0], options, context, filename) && + GenerateDTS(files[0], options, context, filename); + } + std::unique_ptr output(context->Open(filename)); ABSL_CHECK(output.get()); GeneratedCodeInfo annotations; @@ -3782,7 +4581,11 @@ bool Generator::GenerateAll(const std::vector& files, for (auto file : files) { // Force well known type to generate in a whole file. if (IsWellKnownTypeFile(file)) { - if (!GenerateFile(file, options, context, true)) { + std::string filename = + options.output_dir + "/" + + GetJSFilename(options, + file->name().substr(file->name().rfind('/'))); + if (!GenerateFile(file, options, context, filename)) { return false; } generated = true; @@ -3929,7 +4732,9 @@ bool Generator::GenerateAll(const std::vector& files, // Generate one output file per input (.proto) file. for (auto file : files) { - if (!GenerateFile(file, options, context, false)) { + std::string filename = + options.output_dir + "/" + GetJSFilename(options, file->name()); + if (!GenerateFile(file, options, context, filename)) { return false; } } diff --git a/generator/js_generator.h b/generator/js_generator.h index 98b8126..1b297fb 100644 --- a/generator/js_generator.h +++ b/generator/js_generator.h @@ -81,7 +81,8 @@ struct GeneratorOptions { library(""), extension(".js"), one_output_file_per_input_file(false), - annotate_code(false) {} + annotate_code(false), + generate_dts(false) {} bool ParseFromOptions( const std::vector >& options, @@ -89,7 +90,10 @@ struct GeneratorOptions { // Returns the file name extension to use for generated code. std::string GetFileNameExtension() const { - return import_style == kImportClosure ? extension : "_pb.js"; + return (import_style == kImportClosure || + (import_style == kImportEs6 && !library.empty())) + ? extension + : "_pb.js"; } enum OutputMode { @@ -124,6 +128,9 @@ struct GeneratorOptions { // are encoded as base64 proto of GeneratedCodeInfo message (see // descriptor.proto). bool annotate_code; + // If true, generate a .d.ts output in addition to library output. Only valid + // with import_style=es6 and library. + bool generate_dts; }; // CodeGenerator implementation which generates a JavaScript source file and @@ -220,10 +227,32 @@ class Generator : public CodeGenerator { // If use_short_name is true, the generated file's name will only be short // name that without directory, otherwise filename equals file->name() bool GenerateFile(const FileDescriptor* file, const GeneratorOptions& options, - GeneratorContext* context, bool use_short_name) const; + GeneratorContext* context, + const std::string& filename) const; void GenerateFile(const GeneratorOptions& options, io::Printer* printer, const FileDescriptor* file) const; + // Generate declarations for all things in a proto file into one .d.ts file. + // If use_short_name is true, the generated file's name will only be short + // name that without directory, otherwise filename equals file->name() + bool GenerateDTS(const FileDescriptor* file, const GeneratorOptions& options, + GeneratorContext* context, + const std::string& filename) const; + void GenerateDTS(const GeneratorOptions& options, io::Printer* printer, + const FileDescriptor* file) const; + void GenerateMessageDTS(const GeneratorOptions& options, io::Printer* printer, + const Descriptor* desc) const; + void GenerateOneofMethodDTS(const GeneratorOptions& options, + io::Printer* printer, + const OneofDescriptor* oneof) const; + void GenerateOneofEnumDTS(const GeneratorOptions& options, + io::Printer* printer, + const OneofDescriptor* oneof) const; + void GenerateFieldDTS(const GeneratorOptions& options, io::Printer* printer, + const FieldDescriptor* field) const; + void GenerateEnumDTS(const GeneratorOptions& options, io::Printer* printer, + const EnumDescriptor* enumdesc) const; + // Generate definitions for all message classes and enums in all files, // processing the files in dependence order. void GenerateFilesInDepOrder( @@ -248,6 +277,8 @@ class Generator : public CodeGenerator { // Generate definition for one class. void GenerateClass(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const; + void GenerateES6Class(const GeneratorOptions& options, io::Printer* printer, + const Descriptor* desc) const; void GenerateClassConstructor(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const; @@ -280,6 +311,13 @@ class Generator : public CodeGenerator { void GenerateClassRegistration(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const; + void GenerateClassExtensionDeclarations(const GeneratorOptions& options, + io::Printer* printer, + const Descriptor* desc) const; + void GenerateClassExtensionRegistration(const GeneratorOptions& options, + io::Printer* printer, + const Descriptor* desc) const; + void GenerateClassFields(const GeneratorOptions& options, io::Printer* printer, const Descriptor* desc) const; void GenerateClassField(const GeneratorOptions& options, io::Printer* printer, @@ -310,6 +348,12 @@ class Generator : public CodeGenerator { // Generate an extension definition. void GenerateExtension(const GeneratorOptions& options, io::Printer* printer, const FieldDescriptor* field) const; + void GenerateExtensionDeclaration(const GeneratorOptions& options, + io::Printer* printer, + const FieldDescriptor* field) const; + void GenerateExtensionRegistration(const GeneratorOptions& options, + io::Printer* printer, + const FieldDescriptor* field) const; // Generate addFoo() method for repeated primitive fields. void GenerateRepeatedPrimitiveHelperMethods(const GeneratorOptions& options, diff --git a/generator/well_known_types_embed.cc b/generator/well_known_types_embed.cc index 08c3820..6feabcf 100644 --- a/generator/well_known_types_embed.cc +++ b/generator/well_known_types_embed.cc @@ -86,8 +86,67 @@ struct FileToc well_known_types_js[] = { " } else {\n" " return null;\n" " }\n" + "};\n", + "/* This code will be inserted into generated ES6 code for\n" + " * google/protobuf/any.proto. */\n" + "\n" + "/**\n" + " * Returns the type name contained in this instance, if any.\n" + " * @return {string|undefined}\n" + " */\n" + "Any.prototype.getTypeName = function() {\n" + " return this.getTypeUrl().split('/').pop();\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Packs the given message instance into this Any.\n" + " * For binary format usage only.\n" + " * @param {!Uint8Array} serialized The serialized data to pack.\n" + " * @param {string} name The type name of this message object.\n" + " * @param {string=} opt_typeUrlPrefix the type URL prefix.\n" + " */\n" + "Any.prototype.pack = function(serialized, name, opt_typeUrlPrefix) " + "{\n" + " if (!opt_typeUrlPrefix) {\n" + " opt_typeUrlPrefix = 'type.googleapis.com/';\n" + " }\n" + "\n" + " if (opt_typeUrlPrefix.substr(-1) != '/') {\n" + " this.setTypeUrl(opt_typeUrlPrefix + '/' + name);\n" + " } else {\n" + " this.setTypeUrl(opt_typeUrlPrefix + name);\n" + " }\n" + "\n" + " this.setValue(serialized);\n" "};\n" - }, + "\n" + "\n" + "/**\n" + " * @template T\n" + " * Unpacks this Any into the given message object.\n" + " * @param {function(Uint8Array):T} deserialize Function that will " + "deserialize\n" + " * the binary data properly.\n" + " * @param {string} name The expected type name of this message object.\n" + " * @return {?T} If the name matched the expected name, returns the " + "deserialized\n" + " * object, otherwise returns null.\n" + " */\n" + "Any.prototype.unpack = function(deserialize, name) " + "{\n" + " if (this.getTypeName() == name) {\n" + " return deserialize(this.getValue_asU8());\n" + " } else {\n" + " return null;\n" + " }\n" + "};\n", + "export class Any {\n" + " getTypeName(): string;\n" + " pack(serialized: Uint8Array, name: string, typeUrlPrefix?: string): " + "void;\n" + " unpack(deserialize: (Uint8Array) => T, name: string): T | null;\n" + "}\n"}, {"timestamp.js", "/* This code will be inserted into generated code for\n" " * google/protobuf/timestamp.proto. */\n" @@ -124,7 +183,48 @@ struct FileToc well_known_types_js[] = { " var timestamp = new proto.google.protobuf.Timestamp();\n" " timestamp.fromDate(value);\n" " return timestamp;\n" - "};\n"}, + "};\n", + "/* This code will be inserted into generated ES6 code for\n" + " * google/protobuf/timestamp.proto. */\n" + "\n" + "/**\n" + " * Returns a JavaScript 'Date' object corresponding to this Timestamp.\n" + " * @return {!Date}\n" + " */\n" + "Timestamp.prototype.toDate = function() {\n" + " var seconds = this.getSeconds();\n" + " var nanos = this.getNanos();\n" + "\n" + " return new Date((seconds * 1000) + (nanos / 1000000));\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Sets the value of this Timestamp object to be the given Date.\n" + " * @param {!Date} value The value to set.\n" + " */\n" + "Timestamp.prototype.fromDate = function(value) {\n" + " this.setSeconds(Math.floor(value.getTime() / 1000));\n" + " this.setNanos(value.getMilliseconds() * 1000000);\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Factory method that returns a Timestamp object with value equal to\n" + " * the given Date.\n" + " * @param {!Date} value The value to set.\n" + " * @return {!proto.google.protobuf.Timestamp}\n" + " */\n" + "Timestamp.fromDate = function(value) {\n" + " var timestamp = new Timestamp();\n" + " timestamp.fromDate(value);\n" + " return timestamp;\n" + "};\n", + "export class Timestamp {\n" + " toDate(): Date;\n" + " fromDate(value: Date): void;\n" + " static fromDate(value: Date): Timestamp;\n" + "}"}, {"struct.js", "/* This code will be inserted into generated code for\n" " * google/protobuf/struct.proto. */\n" @@ -265,6 +365,162 @@ struct FileToc well_known_types_js[] = { " }\n" "\n" " return ret;\n" - "};\n"}, - {NULL, NULL} // Terminate the list. + "};\n", + "/* This code will be inserted into generated ES6 code for\n" + " * google/protobuf/struct.proto. */\n" + "\n" + "/**\n" + " * Typedef representing plain JavaScript values that can go into a\n" + " * Struct.\n" + " * @typedef {null|number|string|boolean|Array|Object}\n" + " */\n" + "JavaScriptValue;\n" + "\n" + "\n" + "/**\n" + " * Converts this Value object to a plain JavaScript value.\n" + " * @return {?proto.google.protobuf.JavaScriptValue} a plain JavaScript\n" + " * value representing this Struct.\n" + " */\n" + "Value.prototype.toJavaScript = function() {\n" + " var kindCase = Value.KindCase;\n" + " switch (this.getKindCase()) {\n" + " case kindCase.NULL_VALUE:\n" + " return null;\n" + " case kindCase.NUMBER_VALUE:\n" + " return this.getNumberValue();\n" + " case kindCase.STRING_VALUE:\n" + " return this.getStringValue();\n" + " case kindCase.BOOL_VALUE:\n" + " return this.getBoolValue();\n" + " case kindCase.STRUCT_VALUE:\n" + " return this.getStructValue().toJavaScript();\n" + " case kindCase.LIST_VALUE:\n" + " return this.getListValue().toJavaScript();\n" + " default:\n" + " throw new Error('Unexpected struct type');\n" + " }\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this JavaScript value to a new Value proto.\n" + " * @param {!JavaScriptValue} value The value to\n" + " * convert.\n" + " * @return {!proto.google.protobuf.Value} The newly constructed value.\n" + " */\n" + "Value.fromJavaScript = function(value) {\n" + " var ret = new Value();\n" + " switch (goog.typeOf(value)) {\n" + " case 'string':\n" + " ret.setStringValue(/** @type {string} */ (value));\n" + " break;\n" + " case 'number':\n" + " ret.setNumberValue(/** @type {number} */ (value));\n" + " break;\n" + " case 'boolean':\n" + " ret.setBoolValue(/** @type {boolean} */ (value));\n" + " break;\n" + " case 'null':\n" + " ret.setNullValue(NullValue.NULL_VALUE);\n" + " break;\n" + " case 'array':\n" + " ret.setListValue(ListValue.fromJavaScript(\n" + " /** @type{!Array} */ (value)));\n" + " break;\n" + " case 'object':\n" + " ret.setStructValue(Struct.fromJavaScript(\n" + " /** @type{!Object} */ (value)));\n" + " break;\n" + " default:\n" + " throw new Error('Unexpected struct type.');\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this ListValue object to a plain JavaScript array.\n" + " * @return {!Array} a plain JavaScript array representing this List.\n" + " */\n" + "ListValue.prototype.toJavaScript = function() {\n" + " var ret = [];\n" + " var values = this.getValuesList();\n" + "\n" + " for (var i = 0; i < values.length; i++) {\n" + " ret[i] = values[i].toJavaScript();\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Constructs a ListValue protobuf from this plain JavaScript array.\n" + " * @param {!Array} array a plain JavaScript array\n" + " * @return {proto.google.protobuf.ListValue} a new ListValue object\n" + " */\n" + "ListValue.fromJavaScript = function(array) {\n" + " var ret = new ListValue();\n" + "\n" + " for (var i = 0; i < array.length; i++) {\n" + " " + "ret.addValues(Value.fromJavaScript(array[i]));\n" + " }\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Converts this Struct object to a plain JavaScript object.\n" + " * @return {!Object} a " + "plain\n" + " * JavaScript object representing this Struct.\n" + " */\n" + "Struct.prototype.toJavaScript = function() {\n" + " var ret = {};\n" + "\n" + " this.getFieldsMap().forEach(function(value, key) {\n" + " ret[key] = value.toJavaScript();\n" + " });\n" + "\n" + " return ret;\n" + "};\n" + "\n" + "\n" + "/**\n" + " * Constructs a Struct protobuf from this plain JavaScript object.\n" + " * @param {!Object} obj a plain JavaScript object\n" + " * @return {proto.google.protobuf.Struct} a new Struct object\n" + " */\n" + "Struct.fromJavaScript = function(obj) {\n" + " var ret = new Struct();\n" + " var map = ret.getFieldsMap();\n" + "\n" + " for (var property in obj) {\n" + " var val = obj[property];\n" + " map.set(property, Value.fromJavaScript(val));\n" + " }\n" + "\n" + " return ret;\n" + "};\n", + "export type JavaScriptValue = " + "null|number|string|boolean|JavaScriptValue[]|{ [field: string]: " + "JavaScriptValue }};\n" + "export class Value {\n" + " toJavaScript(): JavaScriptValue;\n" + " static fromJavaScript(value: JavaScriptValue): Value;\n" + "}\n" + "export class ListValue {\n" + " toJavaScript(): JavaScriptValue[];\n" + " static fromJavaScript(value: JavaScriptValue[]): ListValue;\n" + "}\n" + "export class Struct {\n" + " toJavaScript(): { [field: string]: JavaScriptValue };\n" + " static fromJavaScript(value: { [field: string]: JavaScriptValue }): " + "Struct;\n" + "}\n"}, + {NULL, NULL, NULL, NULL} // Terminate the list. }; diff --git a/generator/well_known_types_embed.h b/generator/well_known_types_embed.h index 84bad43..f9e2355 100644 --- a/generator/well_known_types_embed.h +++ b/generator/well_known_types_embed.h @@ -36,6 +36,8 @@ struct FileToc { const char* name; const char* data; + const char* es6_data; + const char* dts_data; }; extern struct FileToc well_known_types_js[];