2 // --- Scope ------------------
\r
3 // T : Reflect.Message instance
\r
5 var fields = T.getChildren(ProtoBuf.Reflect.Message.Field),
\r
6 oneofs = T.getChildren(ProtoBuf.Reflect.Message.OneOf);
\r
9 * Constructs a new runtime Message.
\r
10 * @name ProtoBuf.Builder.Message
\r
11 * @class Barebone of all runtime messages.
\r
12 * @param {!Object.<string,*>|string} values Preset values
\r
13 * @param {...string} var_args
\r
15 * @throws {Error} If the message cannot be created
\r
17 var Message = function(values, var_args) {
\r
18 ProtoBuf.Builder.Message.call(this);
\r
20 // Create virtual oneof properties
\r
21 for (var i=0, k=oneofs.length; i<k; ++i)
\r
22 this[oneofs[i].name] = null;
\r
23 // Create fields and set default values
\r
24 for (i=0, k=fields.length; i<k; ++i) {
\r
25 var field = fields[i];
\r
27 field.repeated ? [] :
\r
28 (field.map ? new ProtoBuf.Map(field) : null);
\r
29 if ((field.required || T.syntax === 'proto3') &&
\r
30 field.defaultValue !== null)
\r
31 this[field.name] = field.defaultValue;
\r
34 if (arguments.length > 0) {
\r
36 // Set field values from a values object
\r
37 if (arguments.length === 1 && values !== null && typeof values === 'object' &&
\r
38 /* not _another_ Message */ (typeof values.encode !== 'function' || values instanceof Message) &&
\r
39 /* not a repeated field */ !Array.isArray(values) &&
\r
40 /* not a Map */ !(values instanceof ProtoBuf.Map) &&
\r
41 /* not a ByteBuffer */ !ByteBuffer.isByteBuffer(values) &&
\r
42 /* not an ArrayBuffer */ !(values instanceof ArrayBuffer) &&
\r
43 /* not a Long */ !(ProtoBuf.Long && values instanceof ProtoBuf.Long)) {
\r
45 } else // Set field values from arguments, in declaration order
\r
46 for (i=0, k=arguments.length; i<k; ++i)
\r
47 if (typeof (value = arguments[i]) !== 'undefined')
\r
48 this.$set(fields[i].name, value); // May throw
\r
53 * @alias ProtoBuf.Builder.Message.prototype
\r
56 var MessagePrototype = Message.prototype = Object.create(ProtoBuf.Builder.Message.prototype);
\r
59 * Adds a value to a repeated field.
\r
60 * @name ProtoBuf.Builder.Message#add
\r
62 * @param {string} key Field name
\r
63 * @param {*} value Value to add
\r
64 * @param {boolean=} noAssert Whether to assert the value or not (asserts by default)
\r
65 * @returns {!ProtoBuf.Builder.Message} this
\r
66 * @throws {Error} If the value cannot be added
\r
69 MessagePrototype.add = function(key, value, noAssert) {
\r
70 var field = T._fieldsByName[key];
\r
73 throw Error(this+"#"+key+" is undefined");
\r
74 if (!(field instanceof ProtoBuf.Reflect.Message.Field))
\r
75 throw Error(this+"#"+key+" is not a field: "+field.toString(true)); // May throw if it's an enum or embedded message
\r
76 if (!field.repeated)
\r
77 throw Error(this+"#"+key+" is not a repeated field");
\r
78 value = field.verifyValue(value, true);
\r
80 if (this[key] === null)
\r
82 this[key].push(value);
\r
87 * Adds a value to a repeated field. This is an alias for {@link ProtoBuf.Builder.Message#add}.
\r
88 * @name ProtoBuf.Builder.Message#$add
\r
90 * @param {string} key Field name
\r
91 * @param {*} value Value to add
\r
92 * @param {boolean=} noAssert Whether to assert the value or not (asserts by default)
\r
93 * @returns {!ProtoBuf.Builder.Message} this
\r
94 * @throws {Error} If the value cannot be added
\r
97 MessagePrototype.$add = MessagePrototype.add;
\r
100 * Sets a field's value.
\r
101 * @name ProtoBuf.Builder.Message#set
\r
103 * @param {string|!Object.<string,*>} keyOrObj String key or plain object holding multiple values
\r
104 * @param {(*|boolean)=} value Value to set if key is a string, otherwise omitted
\r
105 * @param {boolean=} noAssert Whether to not assert for an actual field / proper value type, defaults to `false`
\r
106 * @returns {!ProtoBuf.Builder.Message} this
\r
107 * @throws {Error} If the value cannot be set
\r
110 MessagePrototype.set = function(keyOrObj, value, noAssert) {
\r
111 if (keyOrObj && typeof keyOrObj === 'object') {
\r
113 for (var ikey in keyOrObj) {
\r
114 // Check if virtual oneof field - don't set these
\r
115 if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined' && T._oneofsByName[ikey] === undefined)
\r
116 this.$set(ikey, value, noAssert);
\r
120 var field = T._fieldsByName[keyOrObj];
\r
123 throw Error(this+"#"+keyOrObj+" is not a field: undefined");
\r
124 if (!(field instanceof ProtoBuf.Reflect.Message.Field))
\r
125 throw Error(this+"#"+keyOrObj+" is not a field: "+field.toString(true));
\r
126 this[field.name] = (value = field.verifyValue(value)); // May throw
\r
128 this[keyOrObj] = value;
\r
129 if (field && field.oneof) { // Field is part of an OneOf (not a virtual OneOf field)
\r
130 var currentField = this[field.oneof.name]; // Virtual field references currently set field
\r
131 if (value !== null) {
\r
132 if (currentField !== null && currentField !== field.name)
\r
133 this[currentField] = null; // Clear currently set field
\r
134 this[field.oneof.name] = field.name; // Point virtual field at this field
\r
135 } else if (/* value === null && */currentField === keyOrObj)
\r
136 this[field.oneof.name] = null; // Clear virtual field (current field explicitly cleared)
\r
142 * Sets a field's value. This is an alias for [@link ProtoBuf.Builder.Message#set}.
\r
143 * @name ProtoBuf.Builder.Message#$set
\r
145 * @param {string|!Object.<string,*>} keyOrObj String key or plain object holding multiple values
\r
146 * @param {(*|boolean)=} value Value to set if key is a string, otherwise omitted
\r
147 * @param {boolean=} noAssert Whether to not assert the value, defaults to `false`
\r
148 * @throws {Error} If the value cannot be set
\r
151 MessagePrototype.$set = MessagePrototype.set;
\r
154 * Gets a field's value.
\r
155 * @name ProtoBuf.Builder.Message#get
\r
157 * @param {string} key Key
\r
158 * @param {boolean=} noAssert Whether to not assert for an actual field, defaults to `false`
\r
159 * @return {*} Value
\r
160 * @throws {Error} If there is no such field
\r
163 MessagePrototype.get = function(key, noAssert) {
\r
166 var field = T._fieldsByName[key];
\r
167 if (!field || !(field instanceof ProtoBuf.Reflect.Message.Field))
\r
168 throw Error(this+"#"+key+" is not a field: undefined");
\r
169 if (!(field instanceof ProtoBuf.Reflect.Message.Field))
\r
170 throw Error(this+"#"+key+" is not a field: "+field.toString(true));
\r
171 return this[field.name];
\r
175 * Gets a field's value. This is an alias for {@link ProtoBuf.Builder.Message#$get}.
\r
176 * @name ProtoBuf.Builder.Message#$get
\r
178 * @param {string} key Key
\r
179 * @return {*} Value
\r
180 * @throws {Error} If there is no such field
\r
183 MessagePrototype.$get = MessagePrototype.get;
\r
185 // Getters and setters
\r
187 for (var i=0; i<fields.length; i++) {
\r
188 var field = fields[i];
\r
189 // no setters for extension fields as these are named by their fqn
\r
190 if (field instanceof ProtoBuf.Reflect.Message.ExtensionField)
\r
193 if (T.builder.options['populateAccessors'])
\r
195 // set/get[SomeValue]
\r
196 var Name = field.originalName.replace(/(_[a-zA-Z])/g, function(match) {
\r
197 return match.toUpperCase().replace('_','');
\r
199 Name = Name.substring(0,1).toUpperCase() + Name.substring(1);
\r
201 // set/get_[some_value] FIXME: Do we really need these?
\r
202 var name = field.originalName.replace(/([A-Z])/g, function(match) {
\r
207 * The current field's unbound setter function.
\r
210 * @param {boolean=} noAssert
\r
211 * @returns {!ProtoBuf.Builder.Message}
\r
214 var setter = function(value, noAssert) {
\r
215 this[field.name] = noAssert ? value : field.verifyValue(value);
\r
220 * The current field's unbound getter function.
\r
225 var getter = function() {
\r
226 return this[field.name];
\r
229 if (T.getChild("set"+Name) === null)
\r
231 * Sets a value. This method is present for each field, but only if there is no name conflict with
\r
233 * @name ProtoBuf.Builder.Message#set[SomeField]
\r
235 * @param {*} value Value to set
\r
236 * @param {boolean=} noAssert Whether to not assert the value, defaults to `false`
\r
237 * @returns {!ProtoBuf.Builder.Message} this
\r
239 * @throws {Error} If the value cannot be set
\r
241 MessagePrototype["set"+Name] = setter;
\r
243 if (T.getChild("set_"+name) === null)
\r
245 * Sets a value. This method is present for each field, but only if there is no name conflict with
\r
247 * @name ProtoBuf.Builder.Message#set_[some_field]
\r
249 * @param {*} value Value to set
\r
250 * @param {boolean=} noAssert Whether to not assert the value, defaults to `false`
\r
251 * @returns {!ProtoBuf.Builder.Message} this
\r
253 * @throws {Error} If the value cannot be set
\r
255 MessagePrototype["set_"+name] = setter;
\r
257 if (T.getChild("get"+Name) === null)
\r
259 * Gets a value. This method is present for each field, but only if there is no name conflict with
\r
261 * @name ProtoBuf.Builder.Message#get[SomeField]
\r
264 * @return {*} The value
\r
266 MessagePrototype["get"+Name] = getter;
\r
268 if (T.getChild("get_"+name) === null)
\r
270 * Gets a value. This method is present for each field, but only if there is no name conflict with
\r
272 * @name ProtoBuf.Builder.Message#get_[some_field]
\r
274 * @return {*} The value
\r
277 MessagePrototype["get_"+name] = getter;
\r
285 * Encodes the message.
\r
286 * @name ProtoBuf.Builder.Message#$encode
\r
288 * @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted.
\r
289 * @param {boolean=} noVerify Whether to not verify field values, defaults to `false`
\r
290 * @return {!ByteBuffer} Encoded message as a ByteBuffer
\r
291 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
292 * returns the encoded ByteBuffer in the `encoded` property on the error.
\r
294 * @see ProtoBuf.Builder.Message#encode64
\r
295 * @see ProtoBuf.Builder.Message#encodeHex
\r
296 * @see ProtoBuf.Builder.Message#encodeAB
\r
298 MessagePrototype.encode = function(buffer, noVerify) {
\r
299 if (typeof buffer === 'boolean')
\r
301 buffer = undefined;
\r
304 buffer = new ByteBuffer(),
\r
306 var le = buffer.littleEndian;
\r
308 T.encode(this, buffer.LE(), noVerify);
\r
309 return (isNew ? buffer.flip() : buffer).LE(le);
\r
317 * Encodes a message using the specified data payload.
\r
318 * @param {!Object.<string,*>} data Data payload
\r
319 * @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted.
\r
320 * @param {boolean=} noVerify Whether to not verify field values, defaults to `false`
\r
321 * @return {!ByteBuffer} Encoded message as a ByteBuffer
\r
324 Message.encode = function(data, buffer, noVerify) {
\r
325 return new Message(data).encode(buffer, noVerify);
\r
329 * Calculates the byte length of the message.
\r
330 * @name ProtoBuf.Builder.Message#calculate
\r
332 * @returns {number} Byte length
\r
333 * @throws {Error} If the message cannot be calculated or if required fields are missing.
\r
336 MessagePrototype.calculate = function() {
\r
337 return T.calculate(this);
\r
341 * Encodes the varint32 length-delimited message.
\r
342 * @name ProtoBuf.Builder.Message#encodeDelimited
\r
344 * @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted.
\r
345 * @param {boolean=} noVerify Whether to not verify field values, defaults to `false`
\r
346 * @return {!ByteBuffer} Encoded message as a ByteBuffer
\r
347 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
348 * returns the encoded ByteBuffer in the `encoded` property on the error.
\r
351 MessagePrototype.encodeDelimited = function(buffer, noVerify) {
\r
354 buffer = new ByteBuffer(),
\r
356 var enc = new ByteBuffer().LE();
\r
357 T.encode(this, enc, noVerify).flip();
\r
358 buffer.writeVarint32(enc.remaining());
\r
359 buffer.append(enc);
\r
360 return isNew ? buffer.flip() : buffer;
\r
364 * Directly encodes the message to an ArrayBuffer.
\r
365 * @name ProtoBuf.Builder.Message#encodeAB
\r
367 * @return {ArrayBuffer} Encoded message as ArrayBuffer
\r
368 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
369 * returns the encoded ArrayBuffer in the `encoded` property on the error.
\r
372 MessagePrototype.encodeAB = function() {
\r
374 return this.encode().toArrayBuffer();
\r
376 if (e["encoded"]) e["encoded"] = e["encoded"].toArrayBuffer();
\r
382 * Returns the message as an ArrayBuffer. This is an alias for {@link ProtoBuf.Builder.Message#encodeAB}.
\r
383 * @name ProtoBuf.Builder.Message#toArrayBuffer
\r
385 * @return {ArrayBuffer} Encoded message as ArrayBuffer
\r
386 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
387 * returns the encoded ArrayBuffer in the `encoded` property on the error.
\r
390 MessagePrototype.toArrayBuffer = MessagePrototype.encodeAB;
\r
393 * Directly encodes the message to a node Buffer.
\r
394 * @name ProtoBuf.Builder.Message#encodeNB
\r
396 * @return {!Buffer}
\r
397 * @throws {Error} If the message cannot be encoded, not running under node.js or if required fields are
\r
398 * missing. The later still returns the encoded node Buffer in the `encoded` property on the error.
\r
401 MessagePrototype.encodeNB = function() {
\r
403 return this.encode().toBuffer();
\r
405 if (e["encoded"]) e["encoded"] = e["encoded"].toBuffer();
\r
411 * Returns the message as a node Buffer. This is an alias for {@link ProtoBuf.Builder.Message#encodeNB}.
\r
412 * @name ProtoBuf.Builder.Message#toBuffer
\r
414 * @return {!Buffer}
\r
415 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
416 * returns the encoded node Buffer in the `encoded` property on the error.
\r
419 MessagePrototype.toBuffer = MessagePrototype.encodeNB;
\r
422 * Directly encodes the message to a base64 encoded string.
\r
423 * @name ProtoBuf.Builder.Message#encode64
\r
425 * @return {string} Base64 encoded string
\r
426 * @throws {Error} If the underlying buffer cannot be encoded or if required fields are missing. The later
\r
427 * still returns the encoded base64 string in the `encoded` property on the error.
\r
430 MessagePrototype.encode64 = function() {
\r
432 return this.encode().toBase64();
\r
434 if (e["encoded"]) e["encoded"] = e["encoded"].toBase64();
\r
440 * Returns the message as a base64 encoded string. This is an alias for {@link ProtoBuf.Builder.Message#encode64}.
\r
441 * @name ProtoBuf.Builder.Message#toBase64
\r
443 * @return {string} Base64 encoded string
\r
444 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
445 * returns the encoded base64 string in the `encoded` property on the error.
\r
448 MessagePrototype.toBase64 = MessagePrototype.encode64;
\r
451 * Directly encodes the message to a hex encoded string.
\r
452 * @name ProtoBuf.Builder.Message#encodeHex
\r
454 * @return {string} Hex encoded string
\r
455 * @throws {Error} If the underlying buffer cannot be encoded or if required fields are missing. The later
\r
456 * still returns the encoded hex string in the `encoded` property on the error.
\r
459 MessagePrototype.encodeHex = function() {
\r
461 return this.encode().toHex();
\r
463 if (e["encoded"]) e["encoded"] = e["encoded"].toHex();
\r
469 * Returns the message as a hex encoded string. This is an alias for {@link ProtoBuf.Builder.Message#encodeHex}.
\r
470 * @name ProtoBuf.Builder.Message#toHex
\r
472 * @return {string} Hex encoded string
\r
473 * @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
\r
474 * returns the encoded hex string in the `encoded` property on the error.
\r
477 MessagePrototype.toHex = MessagePrototype.encodeHex;
\r
480 * Clones a message object or field value to a raw object.
\r
481 * @param {*} obj Object to clone
\r
482 * @param {boolean} binaryAsBase64 Whether to include binary data as base64 strings or as a buffer otherwise
\r
483 * @param {boolean} longsAsStrings Whether to encode longs as strings
\r
484 * @param {!ProtoBuf.Reflect.T=} resolvedType The resolved field type if a field
\r
485 * @returns {*} Cloned object
\r
488 function cloneRaw(obj, binaryAsBase64, longsAsStrings, resolvedType) {
\r
489 if (obj === null || typeof obj !== 'object') {
\r
490 // Convert enum values to their respective names
\r
491 if (resolvedType && resolvedType instanceof ProtoBuf.Reflect.Enum) {
\r
492 var name = ProtoBuf.Reflect.Enum.getName(resolvedType.object, obj);
\r
496 // Pass-through string, number, boolean, null...
\r
499 // Convert ByteBuffers to raw buffer or strings
\r
500 if (ByteBuffer.isByteBuffer(obj))
\r
501 return binaryAsBase64 ? obj.toBase64() : obj.toBuffer();
\r
502 // Convert Longs to proper objects or strings
\r
503 if (ProtoBuf.Long.isLong(obj))
\r
504 return longsAsStrings ? obj.toString() : ProtoBuf.Long.fromValue(obj);
\r
507 if (Array.isArray(obj)) {
\r
509 obj.forEach(function(v, k) {
\r
510 clone[k] = cloneRaw(v, binaryAsBase64, longsAsStrings, resolvedType);
\r
515 // Convert maps to objects
\r
516 if (obj instanceof ProtoBuf.Map) {
\r
517 var it = obj.entries();
\r
518 for (var e = it.next(); !e.done; e = it.next())
\r
519 clone[obj.keyElem.valueToString(e.value[0])] = cloneRaw(e.value[1], binaryAsBase64, longsAsStrings, obj.valueElem.resolvedType);
\r
522 // Everything else is a non-null object
\r
523 var type = obj.$type,
\r
526 if (obj.hasOwnProperty(i)) {
\r
527 if (type && (field = type.getChild(i)))
\r
528 clone[i] = cloneRaw(obj[i], binaryAsBase64, longsAsStrings, field.resolvedType);
\r
530 clone[i] = cloneRaw(obj[i], binaryAsBase64, longsAsStrings);
\r
536 * Returns the message's raw payload.
\r
537 * @param {boolean=} binaryAsBase64 Whether to include binary data as base64 strings instead of Buffers, defaults to `false`
\r
538 * @param {boolean} longsAsStrings Whether to encode longs as strings
\r
539 * @returns {Object.<string,*>} Raw payload
\r
542 MessagePrototype.toRaw = function(binaryAsBase64, longsAsStrings) {
\r
543 return cloneRaw(this, !!binaryAsBase64, !!longsAsStrings, this.$type);
\r
547 * Encodes a message to JSON.
\r
548 * @returns {string} JSON string
\r
551 MessagePrototype.encodeJSON = function() {
\r
552 return JSON.stringify(
\r
554 /* binary-as-base64 */ true,
\r
555 /* longs-as-strings */ true,
\r
562 * Decodes a message from the specified buffer or string.
\r
563 * @name ProtoBuf.Builder.Message.decode
\r
565 * @param {!ByteBuffer|!ArrayBuffer|!Buffer|string} buffer Buffer to decode from
\r
566 * @param {(number|string)=} length Message length. Defaults to decode all the remainig data.
\r
567 * @param {string=} enc Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64
\r
568 * @return {!ProtoBuf.Builder.Message} Decoded message
\r
569 * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still
\r
570 * returns the decoded message with missing fields in the `decoded` property on the error.
\r
572 * @see ProtoBuf.Builder.Message.decode64
\r
573 * @see ProtoBuf.Builder.Message.decodeHex
\r
575 Message.decode = function(buffer, length, enc) {
\r
576 if (typeof length === 'string')
\r
579 if (typeof buffer === 'string')
\r
580 buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
\r
581 else if (!ByteBuffer.isByteBuffer(buffer))
\r
582 buffer = ByteBuffer.wrap(buffer); // May throw
\r
583 var le = buffer.littleEndian;
\r
585 var msg = T.decode(buffer.LE(), length);
\r
595 * Decodes a varint32 length-delimited message from the specified buffer or string.
\r
596 * @name ProtoBuf.Builder.Message.decodeDelimited
\r
598 * @param {!ByteBuffer|!ArrayBuffer|!Buffer|string} buffer Buffer to decode from
\r
599 * @param {string=} enc Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64
\r
600 * @return {ProtoBuf.Builder.Message} Decoded message or `null` if not enough bytes are available yet
\r
601 * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still
\r
602 * returns the decoded message with missing fields in the `decoded` property on the error.
\r
605 Message.decodeDelimited = function(buffer, enc) {
\r
606 if (typeof buffer === 'string')
\r
607 buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
\r
608 else if (!ByteBuffer.isByteBuffer(buffer))
\r
609 buffer = ByteBuffer.wrap(buffer); // May throw
\r
610 if (buffer.remaining() < 1)
\r
612 var off = buffer.offset,
\r
613 len = buffer.readVarint32();
\r
614 if (buffer.remaining() < len) {
\r
615 buffer.offset = off;
\r
619 var msg = T.decode(buffer.slice(buffer.offset, buffer.offset + len).LE());
\r
620 buffer.offset += len;
\r
623 buffer.offset += len;
\r
629 * Decodes the message from the specified base64 encoded string.
\r
630 * @name ProtoBuf.Builder.Message.decode64
\r
632 * @param {string} str String to decode from
\r
633 * @return {!ProtoBuf.Builder.Message} Decoded message
\r
634 * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still
\r
635 * returns the decoded message with missing fields in the `decoded` property on the error.
\r
638 Message.decode64 = function(str) {
\r
639 return Message.decode(str, "base64");
\r
643 * Decodes the message from the specified hex encoded string.
\r
644 * @name ProtoBuf.Builder.Message.decodeHex
\r
646 * @param {string} str String to decode from
\r
647 * @return {!ProtoBuf.Builder.Message} Decoded message
\r
648 * @throws {Error} If the message cannot be decoded or if required fields are missing. The later still
\r
649 * returns the decoded message with missing fields in the `decoded` property on the error.
\r
652 Message.decodeHex = function(str) {
\r
653 return Message.decode(str, "hex");
\r
657 * Decodes the message from a JSON string.
\r
658 * @name ProtoBuf.Builder.Message.decodeJSON
\r
660 * @param {string} str String to decode from
\r
661 * @return {!ProtoBuf.Builder.Message} Decoded message
\r
662 * @throws {Error} If the message cannot be decoded or if required fields are
\r
666 Message.decodeJSON = function(str) {
\r
667 return new Message(JSON.parse(str));
\r
673 * Returns a string representation of this Message.
\r
674 * @name ProtoBuf.Builder.Message#toString
\r
676 * @return {string} String representation as of ".Fully.Qualified.MessageName"
\r
679 MessagePrototype.toString = function() {
\r
680 return T.toString();
\r
687 * @name ProtoBuf.Builder.Message.$options
\r
688 * @type {Object.<string,*>}
\r
691 var $optionsS; // cc needs this
\r
695 * @name ProtoBuf.Builder.Message#$options
\r
696 * @type {Object.<string,*>}
\r
703 * @name ProtoBuf.Builder.Message.$type
\r
704 * @type {!ProtoBuf.Reflect.Message}
\r
711 * @name ProtoBuf.Builder.Message#$type
\r
712 * @type {!ProtoBuf.Reflect.Message}
\r
717 if (Object.defineProperty)
\r
718 Object.defineProperty(Message, '$options', { "value": T.buildOpt() }),
\r
719 Object.defineProperty(MessagePrototype, "$options", { "value": Message["$options"] }),
\r
720 Object.defineProperty(Message, "$type", { "value": T }),
\r
721 Object.defineProperty(MessagePrototype, "$type", { "value": T });
\r