protobufjs 5.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/.travis.yml +2 -1
  2. package/README.md +144 -22
  3. package/bin/pbjs +2 -2
  4. package/bower.json +2 -2
  5. package/cli/pbjs/targets/amd.js +1 -1
  6. package/cli/pbjs/targets/json.js +8 -0
  7. package/cli/pbjs/util.js +1 -1
  8. package/cli/pbjs.js +1 -1
  9. package/dist/protobuf-light.js +166 -128
  10. package/dist/protobuf-light.min.js +88 -81
  11. package/dist/protobuf-light.min.js.gz +0 -0
  12. package/dist/protobuf-light.min.map +4 -4
  13. package/dist/protobuf.js +171 -129
  14. package/dist/protobuf.min.js +106 -98
  15. package/dist/protobuf.min.js.gz +0 -0
  16. package/dist/protobuf.min.map +4 -4
  17. package/docs/ProtoBuf.Builder.Message.html +1408 -971
  18. package/docs/ProtoBuf.Builder.Service.html +266 -197
  19. package/docs/ProtoBuf.Builder.html +758 -542
  20. package/docs/ProtoBuf.DotProto.Parser.html +223 -161
  21. package/docs/ProtoBuf.DotProto.Tokenizer.html +344 -248
  22. package/docs/ProtoBuf.DotProto.html +20 -12
  23. package/docs/ProtoBuf.Element.html +554 -554
  24. package/docs/ProtoBuf.Map.html +158 -123
  25. package/docs/ProtoBuf.Reflect.Element.html +286 -143
  26. package/docs/ProtoBuf.Reflect.Enum.Value.html +329 -228
  27. package/docs/ProtoBuf.Reflect.Enum.html +757 -537
  28. package/docs/ProtoBuf.Reflect.Extension.html +73 -56
  29. package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +1013 -740
  30. package/docs/ProtoBuf.Reflect.Message.Field.html +926 -649
  31. package/docs/ProtoBuf.Reflect.Message.OneOf.html +327 -245
  32. package/docs/ProtoBuf.Reflect.Message.html +915 -651
  33. package/docs/ProtoBuf.Reflect.Namespace.html +648 -447
  34. package/docs/ProtoBuf.Reflect.Service.Method.html +363 -251
  35. package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +545 -397
  36. package/docs/ProtoBuf.Reflect.Service.html +721 -511
  37. package/docs/ProtoBuf.Reflect.T.html +268 -197
  38. package/docs/ProtoBuf.Reflect.html +20 -12
  39. package/docs/ProtoBuf.Util.html +169 -118
  40. package/docs/ProtoBuf.html +840 -628
  41. package/docs/ProtoBuf.js.html +177 -134
  42. package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
  43. package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
  44. package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
  45. package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  46. package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
  47. package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  48. package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
  49. package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
  50. package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
  51. package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
  52. package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
  53. package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
  54. package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  55. package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
  56. package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  57. package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
  58. package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
  59. package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
  60. package/docs/index.html +7 -5
  61. package/docs/styles/jsdoc-default.css +95 -75
  62. package/docs/styles/prettify-tomorrow.css +1 -1
  63. package/examples/protoify/json.js +123 -123
  64. package/examples/protoify/json.json +123 -123
  65. package/examples/websocket/server.js +4 -4
  66. package/externs/protobuf.js +1 -1
  67. package/jsdoc.json +1 -1
  68. package/package.json +2 -2
  69. package/scripts/build.js +53 -53
  70. package/src/ProtoBuf/Builder/Message.js +9 -5
  71. package/src/ProtoBuf/Builder.js +19 -2
  72. package/src/ProtoBuf/DotProto/Parser.js +5 -1
  73. package/src/ProtoBuf/Reflect/Element.js +13 -1
  74. package/src/ProtoBuf/Reflect/Message/Field.js +2 -2
  75. package/src/ProtoBuf/Reflect/Message.js +6 -1
  76. package/src/ProtoBuf/Util.js +116 -116
  77. package/src/bower.json +1 -1
  78. package/src/google/protobuf/descriptor.json +27 -1
  79. package/tests/bench.txt +373 -373
  80. package/tests/complex.json +8 -1
  81. package/tests/custom-options.json +169 -169
  82. package/tests/extend.json +71 -71
  83. package/tests/imports.json +83 -83
  84. package/tests/nodeunit-browser/nodeunit.css +70 -70
  85. package/tests/nodeunit-browser/nodeunit.js +2108 -2108
  86. package/tests/options.json +32 -32
  87. package/tests/proto2js/Bar.json +46 -46
  88. package/tests/suite.js +43 -1
  89. package/sandbox/gapi/googleapis/google/api/annotations.proto +0 -29
  90. package/sandbox/gapi/googleapis/google/api/http.proto +0 -245
  91. package/sandbox/gapi/googleapis/google/datastore/v1beta3/datastore.proto +0 -281
  92. package/sandbox/gapi/googleapis/google/datastore/v1beta3/entity.proto +0 -189
  93. package/sandbox/gapi/googleapis/google/datastore/v1beta3/query.proto +0 -281
  94. package/sandbox/gapi/googleapis/google/longrunning/operations.proto +0 -144
  95. package/sandbox/gapi/googleapis/google/protobuf/any.proto +0 -98
  96. package/sandbox/gapi/googleapis/google/protobuf/any_test.proto +0 -41
  97. package/sandbox/gapi/googleapis/google/protobuf/api.proto +0 -201
  98. package/sandbox/gapi/googleapis/google/protobuf/descriptor.proto +0 -773
  99. package/sandbox/gapi/googleapis/google/protobuf/duration.proto +0 -95
  100. package/sandbox/gapi/googleapis/google/protobuf/empty.proto +0 -50
  101. package/sandbox/gapi/googleapis/google/protobuf/field_mask.proto +0 -167
  102. package/sandbox/gapi/googleapis/google/protobuf/map_lite_unittest.proto +0 -130
  103. package/sandbox/gapi/googleapis/google/protobuf/map_proto2_unittest.proto +0 -60
  104. package/sandbox/gapi/googleapis/google/protobuf/map_unittest.proto +0 -129
  105. package/sandbox/gapi/googleapis/google/protobuf/map_unittest_proto3.proto +0 -120
  106. package/sandbox/gapi/googleapis/google/protobuf/source_context.proto +0 -47
  107. package/sandbox/gapi/googleapis/google/protobuf/struct.proto +0 -94
  108. package/sandbox/gapi/googleapis/google/protobuf/timestamp.proto +0 -107
  109. package/sandbox/gapi/googleapis/google/protobuf/type.proto +0 -176
  110. package/sandbox/gapi/googleapis/google/protobuf/unittest.proto +0 -878
  111. package/sandbox/gapi/googleapis/google/protobuf/unittest_arena.proto +0 -46
  112. package/sandbox/gapi/googleapis/google/protobuf/unittest_custom_options.proto +0 -394
  113. package/sandbox/gapi/googleapis/google/protobuf/unittest_drop_unknown_fields.proto +0 -58
  114. package/sandbox/gapi/googleapis/google/protobuf/unittest_embed_optimize_for.proto +0 -51
  115. package/sandbox/gapi/googleapis/google/protobuf/unittest_empty.proto +0 -38
  116. package/sandbox/gapi/googleapis/google/protobuf/unittest_enormous_descriptor.proto +0 -1048
  117. package/sandbox/gapi/googleapis/google/protobuf/unittest_import.proto +0 -66
  118. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_lite.proto +0 -52
  119. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_proto3.proto +0 -68
  120. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public.proto +0 -41
  121. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_lite.proto +0 -43
  122. package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_proto3.proto +0 -42
  123. package/sandbox/gapi/googleapis/google/protobuf/unittest_lite.proto +0 -385
  124. package/sandbox/gapi/googleapis/google/protobuf/unittest_lite_imports_nonlite.proto +0 -44
  125. package/sandbox/gapi/googleapis/google/protobuf/unittest_mset.proto +0 -82
  126. package/sandbox/gapi/googleapis/google/protobuf/unittest_mset_wire_format.proto +0 -52
  127. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena.proto +0 -202
  128. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_import.proto +0 -37
  129. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_lite.proto +0 -42
  130. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_field_presence.proto +0 -138
  131. package/sandbox/gapi/googleapis/google/protobuf/unittest_no_generic_services.proto +0 -54
  132. package/sandbox/gapi/googleapis/google/protobuf/unittest_optimize_for.proto +0 -67
  133. package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum.proto +0 -71
  134. package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum2.proto +0 -50
  135. package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3.proto +0 -388
  136. package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3_arena.proto +0 -206
  137. package/sandbox/gapi/googleapis/google/protobuf/unittest_well_known_types.proto +0 -112
  138. package/sandbox/gapi/googleapis/google/protobuf/unknown_enum_test.proto +0 -62
  139. package/sandbox/gapi/googleapis/google/protobuf/wrappers.proto +0 -117
  140. package/sandbox/gapi/googleapis/google/rpc/code.proto +0 -190
  141. package/sandbox/gapi/googleapis/google/rpc/error_details.proto +0 -157
  142. package/sandbox/gapi/googleapis/google/rpc/status.proto +0 -90
  143. package/sandbox/gapi/googleapis/google/type/color.proto +0 -163
  144. package/sandbox/gapi/googleapis/google/type/date.proto +0 -43
  145. package/sandbox/gapi/googleapis/google/type/dayofweek.proto +0 -50
  146. package/sandbox/gapi/googleapis/google/type/latlng.proto +0 -36
  147. package/sandbox/gapi/googleapis/google/type/money.proto +0 -40
  148. package/sandbox/gapi/googleapis/google/type/timeofday.proto +0 -42
  149. package/sandbox/gapi/test.js +0 -17
  150. package/sandbox/gapi/test.proto +0 -12
  151. package/sandbox/issue146/MyOptions.proto +0 -28
  152. package/sandbox/issue146/Sample.proto +0 -21
  153. package/sandbox/issue146/main.js +0 -3
  154. package/sandbox/issue147/enum.proto +0 -8
  155. package/sandbox/issue147/main.js +0 -3
  156. package/sandbox/issue182/commands.proto +0 -10
  157. package/sandbox/issue182/execute.js +0 -22
  158. package/sandbox/issue182/session_commands.proto +0 -14
  159. package/sandbox/issue289/A.proto +0 -8
  160. package/sandbox/issue289/B.proto +0 -8
  161. package/sandbox/issue289/common.proto +0 -5
  162. package/sandbox/issue289/main.js +0 -7
  163. package/sandbox/issue300/IAuth.proto +0 -14
  164. package/sandbox/issue300/Request.proto +0 -14
  165. package/sandbox/issue300/main.js +0 -26
  166. package/sandbox/issue347/index.js +0 -27
  167. package/sandbox/issue355/main.proto +0 -15
  168. package/sandbox/issue42/innerextend.proto +0 -18
  169. package/sandbox/issue42/main.js +0 -8
  170. package/sandbox/issue42/outerextend.proto +0 -17
@@ -2,7 +2,7 @@
2
2
  <html lang="en">
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>JSDoc: Source: ProtoBuf.js</title>
5
+ <title>JSDoc: Source: protobuf.js</title>
6
6
 
7
7
  <script src="scripts/prettify/prettify.js"> </script>
8
8
  <script src="scripts/prettify/lang-css.js"> </script>
@@ -17,11 +17,12 @@
17
17
 
18
18
  <div id="main">
19
19
 
20
- <h1 class="page-title">Source: ProtoBuf.js</h1>
20
+ <h1 class="page-title">Source: protobuf.js</h1>
21
21
 
22
22
 
23
23
 
24
24
 
25
+
25
26
 
26
27
  <section>
27
28
  <article>
@@ -84,7 +85,7 @@
84
85
  * @const
85
86
  * @expose
86
87
  */
87
- ProtoBuf.VERSION = "5.0.1";
88
+ ProtoBuf.VERSION = "5.0.2";
88
89
 
89
90
  /**
90
91
  * Wire types.
@@ -316,122 +317,122 @@
316
317
  */
317
318
  ProtoBuf.populateDefaults = true;
318
319
 
319
- /**
320
- * @alias ProtoBuf.Util
321
- * @expose
322
- */
323
- ProtoBuf.Util = (function() {
324
- "use strict";
325
-
326
- /**
327
- * ProtoBuf utilities.
328
- * @exports ProtoBuf.Util
329
- * @namespace
330
- */
331
- var Util = {};
332
-
333
- /**
334
- * Flag if running in node or not.
335
- * @type {boolean}
336
- * @const
337
- * @expose
338
- */
339
- Util.IS_NODE = !!(
340
- typeof process === 'object' &amp;&amp; process+'' === '[object process]' &amp;&amp; !process['browser']
341
- );
342
-
343
- /**
344
- * Constructs a XMLHttpRequest object.
345
- * @return {XMLHttpRequest}
346
- * @throws {Error} If XMLHttpRequest is not supported
347
- * @expose
348
- */
349
- Util.XHR = function() {
350
- // No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
351
- var XMLHttpFactories = [
352
- function () {return new XMLHttpRequest()},
353
- function () {return new ActiveXObject("Msxml2.XMLHTTP")},
354
- function () {return new ActiveXObject("Msxml3.XMLHTTP")},
355
- function () {return new ActiveXObject("Microsoft.XMLHTTP")}
356
- ];
357
- /** @type {?XMLHttpRequest} */
358
- var xhr = null;
359
- for (var i=0;i&lt;XMLHttpFactories.length;i++) {
360
- try { xhr = XMLHttpFactories[i](); }
361
- catch (e) { continue; }
362
- break;
363
- }
364
- if (!xhr)
365
- throw Error("XMLHttpRequest is not supported");
366
- return xhr;
367
- };
368
-
369
- /**
370
- * Fetches a resource.
371
- * @param {string} path Resource path
372
- * @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
373
- * be fetched synchronously. If the request failed, contents will be null.
374
- * @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
375
- * @expose
376
- */
377
- Util.fetch = function(path, callback) {
378
- if (callback &amp;&amp; typeof callback != 'function')
379
- callback = null;
380
- if (Util.IS_NODE) {
381
- var fs = require("fs");
382
- if (callback) {
383
- fs.readFile(path, function(err, data) {
384
- if (err)
385
- callback(null);
386
- else
387
- callback(""+data);
388
- });
389
- } else
390
- try {
391
- return fs.readFileSync(path);
392
- } catch (e) {
393
- return null;
394
- }
395
- } else {
396
- var xhr = Util.XHR();
397
- xhr.open('GET', path, callback ? true : false);
398
- // xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
399
- xhr.setRequestHeader('Accept', 'text/plain');
400
- if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
401
- if (callback) {
402
- xhr.onreadystatechange = function() {
403
- if (xhr.readyState != 4) return;
404
- if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 &amp;&amp; typeof xhr.responseText === 'string'))
405
- callback(xhr.responseText);
406
- else
407
- callback(null);
408
- };
409
- if (xhr.readyState == 4)
410
- return;
411
- xhr.send(null);
412
- } else {
413
- xhr.send(null);
414
- if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 &amp;&amp; typeof xhr.responseText === 'string'))
415
- return xhr.responseText;
416
- return null;
417
- }
418
- }
419
- };
420
-
421
- /**
422
- * Converts a string to camel case.
423
- * @param {string} str
424
- * @returns {string}
425
- * @expose
426
- */
427
- Util.toCamelCase = function(str) {
428
- return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
429
- return $1.toUpperCase();
430
- });
431
- };
432
-
433
- return Util;
434
- })();
320
+ /**
321
+ * @alias ProtoBuf.Util
322
+ * @expose
323
+ */
324
+ ProtoBuf.Util = (function() {
325
+ "use strict";
326
+
327
+ /**
328
+ * ProtoBuf utilities.
329
+ * @exports ProtoBuf.Util
330
+ * @namespace
331
+ */
332
+ var Util = {};
333
+
334
+ /**
335
+ * Flag if running in node or not.
336
+ * @type {boolean}
337
+ * @const
338
+ * @expose
339
+ */
340
+ Util.IS_NODE = !!(
341
+ typeof process === 'object' &amp;&amp; process+'' === '[object process]' &amp;&amp; !process['browser']
342
+ );
343
+
344
+ /**
345
+ * Constructs a XMLHttpRequest object.
346
+ * @return {XMLHttpRequest}
347
+ * @throws {Error} If XMLHttpRequest is not supported
348
+ * @expose
349
+ */
350
+ Util.XHR = function() {
351
+ // No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
352
+ var XMLHttpFactories = [
353
+ function () {return new XMLHttpRequest()},
354
+ function () {return new ActiveXObject("Msxml2.XMLHTTP")},
355
+ function () {return new ActiveXObject("Msxml3.XMLHTTP")},
356
+ function () {return new ActiveXObject("Microsoft.XMLHTTP")}
357
+ ];
358
+ /** @type {?XMLHttpRequest} */
359
+ var xhr = null;
360
+ for (var i=0;i&lt;XMLHttpFactories.length;i++) {
361
+ try { xhr = XMLHttpFactories[i](); }
362
+ catch (e) { continue; }
363
+ break;
364
+ }
365
+ if (!xhr)
366
+ throw Error("XMLHttpRequest is not supported");
367
+ return xhr;
368
+ };
369
+
370
+ /**
371
+ * Fetches a resource.
372
+ * @param {string} path Resource path
373
+ * @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
374
+ * be fetched synchronously. If the request failed, contents will be null.
375
+ * @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
376
+ * @expose
377
+ */
378
+ Util.fetch = function(path, callback) {
379
+ if (callback &amp;&amp; typeof callback != 'function')
380
+ callback = null;
381
+ if (Util.IS_NODE) {
382
+ var fs = require("fs");
383
+ if (callback) {
384
+ fs.readFile(path, function(err, data) {
385
+ if (err)
386
+ callback(null);
387
+ else
388
+ callback(""+data);
389
+ });
390
+ } else
391
+ try {
392
+ return fs.readFileSync(path);
393
+ } catch (e) {
394
+ return null;
395
+ }
396
+ } else {
397
+ var xhr = Util.XHR();
398
+ xhr.open('GET', path, callback ? true : false);
399
+ // xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
400
+ xhr.setRequestHeader('Accept', 'text/plain');
401
+ if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
402
+ if (callback) {
403
+ xhr.onreadystatechange = function() {
404
+ if (xhr.readyState != 4) return;
405
+ if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 &amp;&amp; typeof xhr.responseText === 'string'))
406
+ callback(xhr.responseText);
407
+ else
408
+ callback(null);
409
+ };
410
+ if (xhr.readyState == 4)
411
+ return;
412
+ xhr.send(null);
413
+ } else {
414
+ xhr.send(null);
415
+ if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 &amp;&amp; typeof xhr.responseText === 'string'))
416
+ return xhr.responseText;
417
+ return null;
418
+ }
419
+ }
420
+ };
421
+
422
+ /**
423
+ * Converts a string to camel case.
424
+ * @param {string} str
425
+ * @returns {string}
426
+ * @expose
427
+ */
428
+ Util.toCamelCase = function(str) {
429
+ return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
430
+ return $1.toUpperCase();
431
+ });
432
+ };
433
+
434
+ return Util;
435
+ })();
435
436
 
436
437
  /**
437
438
  * Language expressions.
@@ -1130,7 +1131,11 @@
1130
1131
  else if (token === "service")
1131
1132
  this._parseService(msg);
1132
1133
  else if (token === "extensions")
1133
- msg["extensions"] = this._parseExtensionRanges();
1134
+ if (msg.hasOwnProperty("extensions")) {
1135
+ msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges())
1136
+ } else {
1137
+ msg["extensions"] = this._parseExtensionRanges();
1138
+ }
1134
1139
  else if (token === "reserved")
1135
1140
  this._parseIgnored(); // TODO
1136
1141
  else if (token === "extend")
@@ -1736,9 +1741,11 @@
1736
1741
  * converted to string form if so.
1737
1742
  * @param {string} syntax Syntax level of defining message type, e.g.,
1738
1743
  * proto2 or proto3.
1744
+ * @param {string} name Name of the field containing this element (for error
1745
+ * messages)
1739
1746
  * @constructor
1740
1747
  */
1741
- var Element = function(type, resolvedType, isMapKey, syntax) {
1748
+ var Element = function(type, resolvedType, isMapKey, syntax, name) {
1742
1749
 
1743
1750
  /**
1744
1751
  * Element type, as a string (e.g., int32).
@@ -1764,6 +1771,12 @@
1764
1771
  */
1765
1772
  this.syntax = syntax;
1766
1773
 
1774
+ /**
1775
+ * Name of the field containing this element (for error messages)
1776
+ * @type {string}
1777
+ */
1778
+ this.name = name;
1779
+
1767
1780
  if (isMapKey &amp;&amp; ProtoBuf.MAP_KEY_TYPES.indexOf(type) &lt; 0)
1768
1781
  throw Error("Invalid map key type: " + type.name);
1769
1782
  };
@@ -1814,6 +1827,10 @@
1814
1827
  throw Error("not convertible to Long");
1815
1828
  }
1816
1829
 
1830
+ ElementPrototype.toString = function() {
1831
+ return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element';
1832
+ }
1833
+
1817
1834
  /**
1818
1835
  * Checks if the given value can be set for an element of this type (singular
1819
1836
  * field or one element of a repeated field or map).
@@ -2488,9 +2505,11 @@
2488
2505
  MessagePrototype.set = function(keyOrObj, value, noAssert) {
2489
2506
  if (keyOrObj &amp;&amp; typeof keyOrObj === 'object') {
2490
2507
  noAssert = value;
2491
- for (var ikey in keyOrObj)
2492
- if (keyOrObj.hasOwnProperty(ikey) &amp;&amp; typeof (value = keyOrObj[ikey]) !== 'undefined')
2508
+ for (var ikey in keyOrObj) {
2509
+ // Check if virtual oneof field - don't set these
2510
+ if (keyOrObj.hasOwnProperty(ikey) &amp;&amp; typeof (value = keyOrObj[ikey]) !== 'undefined' &amp;&amp; T._oneofsByName[ikey] === undefined)
2493
2511
  this.$set(ikey, value, noAssert);
2512
+ }
2494
2513
  return this;
2495
2514
  }
2496
2515
  var field = T._fieldsByName[keyOrObj];
@@ -2954,10 +2973,11 @@
2954
2973
  length = -1;
2955
2974
  if (typeof buffer === 'string')
2956
2975
  buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
2957
- buffer = ByteBuffer.isByteBuffer(buffer) ? buffer : ByteBuffer.wrap(buffer); // May throw
2976
+ else if (!ByteBuffer.isByteBuffer(buffer))
2977
+ buffer = ByteBuffer.wrap(buffer); // May throw
2958
2978
  var le = buffer.littleEndian;
2959
2979
  try {
2960
- var msg = T.decode(buffer.LE());
2980
+ var msg = T.decode(buffer.LE(), length);
2961
2981
  buffer.LE(le);
2962
2982
  return msg;
2963
2983
  } catch (e) {
@@ -2980,7 +3000,8 @@
2980
3000
  Message.decodeDelimited = function(buffer, enc) {
2981
3001
  if (typeof buffer === 'string')
2982
3002
  buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
2983
- buffer = ByteBuffer.isByteBuffer(buffer) ? buffer : ByteBuffer.wrap(buffer); // May throw
3003
+ else if (!ByteBuffer.isByteBuffer(buffer))
3004
+ buffer = ByteBuffer.wrap(buffer); // May throw
2984
3005
  if (buffer.remaining() &lt; 1)
2985
3006
  return null;
2986
3007
  var off = buffer.offset,
@@ -3102,6 +3123,7 @@
3102
3123
  this._fields = [];
3103
3124
  this._fieldsById = {};
3104
3125
  this._fieldsByName = {};
3126
+ this._oneofsByName = {};
3105
3127
  for (var i=0, k=this.children.length, child; i&lt;k; i++) {
3106
3128
  child = this.children[i];
3107
3129
  if (child instanceof Enum || child instanceof Message || child instanceof Service) {
@@ -3113,6 +3135,9 @@
3113
3135
  this._fields.push(child),
3114
3136
  this._fieldsById[child.id] = child,
3115
3137
  this._fieldsByName[child.name] = child;
3138
+ else if (child instanceof Message.OneOf) {
3139
+ this._oneofsByName[child.name] = child;
3140
+ }
3116
3141
  else if (!(child instanceof Message.OneOf) &amp;&amp; !(child instanceof Extension)) // Not built
3117
3142
  throw Error("Illegal reflect child of "+this.toString(true)+": "+this.children[i].toString(true));
3118
3143
  }
@@ -3219,7 +3244,8 @@
3219
3244
  * @expose
3220
3245
  */
3221
3246
  MessagePrototype.decode = function(buffer, length, expectedGroupEndId) {
3222
- length = typeof length === 'number' ? length : -1;
3247
+ if (typeof length !== 'number')
3248
+ length = -1;
3223
3249
  var start = buffer.offset,
3224
3250
  msg = new (this.clazz)(),
3225
3251
  tag, wireType, id, field;
@@ -3438,9 +3464,9 @@
3438
3464
  * @expose
3439
3465
  */
3440
3466
  FieldPrototype.build = function() {
3441
- this.element = new Element(this.type, this.resolvedType, false, this.syntax);
3467
+ this.element = new Element(this.type, this.resolvedType, false, this.syntax, this.name);
3442
3468
  if (this.map)
3443
- this.keyElement = new Element(this.keyType, undefined, true, this.syntax);
3469
+ this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name);
3444
3470
 
3445
3471
  // In proto3, fields do not have field presence, and every field is set to
3446
3472
  // its type's default value ("", 0, 0.0, or false).
@@ -4659,7 +4685,11 @@
4659
4685
  root = require("path")['resolve'](root);
4660
4686
  if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0)
4661
4687
  delim = '\\';
4662
- var fname = root + delim + filename.file;
4688
+ var fname;
4689
+ if (ProtoBuf.Util.IS_NODE)
4690
+ fname = require("path")['join'](root, filename.file);
4691
+ else
4692
+ fname = root + delim + filename.file;
4663
4693
  if (this.files[fname] === true)
4664
4694
  return this.reset();
4665
4695
  this.files[fname] = true;
@@ -4705,7 +4735,10 @@
4705
4735
  var importFilename = json['imports'][i];
4706
4736
  if (importFilename === "google/protobuf/descriptor.proto")
4707
4737
  continue; // Not needed and therefore not used
4708
- importFilename = importRoot + delim + importFilename;
4738
+ if (ProtoBuf.Util.IS_NODE)
4739
+ importFilename = require("path")['join'](importRoot, importFilename);
4740
+ else
4741
+ importFilename = importRoot + delim + importFilename;
4709
4742
  if (this.files[importFilename] === true)
4710
4743
  continue; // Already imported
4711
4744
  if (/\.proto$/i.test(importFilename) &amp;&amp; !ProtoBuf.DotProto) // If this is a light build
@@ -4803,6 +4836,16 @@
4803
4836
  this.ptr.keyType = ProtoBuf.TYPES[this.ptr.keyType];
4804
4837
  }
4805
4838
 
4839
+ // If it's a repeated and packable field then proto3 mandates it should be packed by
4840
+ // default
4841
+ if (
4842
+ this.ptr.syntax === 'proto3' &amp;&amp;
4843
+ this.ptr.repeated &amp;&amp; this.ptr.options.packed === undefined &amp;&amp;
4844
+ ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType) !== -1
4845
+ ) {
4846
+ this.ptr.options.packed = true;
4847
+ }
4848
+
4806
4849
  } else if (this.ptr instanceof ProtoBuf.Reflect.Service.Method) {
4807
4850
 
4808
4851
  if (this.ptr instanceof ProtoBuf.Reflect.Service.RPCMethod) {
@@ -5258,13 +5301,13 @@
5258
5301
  </div>
5259
5302
 
5260
5303
  <nav>
5261
- <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="ProtoBuf.Builder.html">Builder</a></li><li><a href="ProtoBuf.Builder.Message.html">Message</a></li><li><a href="ProtoBuf.Builder.Service.html">Service</a></li><li><a href="ProtoBuf.DotProto.Parser.html">Parser</a></li><li><a href="ProtoBuf.DotProto.Tokenizer.html">Tokenizer</a></li><li><a href="ProtoBuf.Map.html">Map</a></li><li><a href="ProtoBuf.Reflect.Element.html">Element</a></li><li><a href="ProtoBuf.Reflect.Enum.html">Enum</a></li><li><a href="ProtoBuf.Reflect.Enum.Value.html">Value</a></li><li><a href="ProtoBuf.Reflect.Extension.html">Extension</a></li><li><a href="ProtoBuf.Reflect.Message.html">Message</a></li><li><a href="ProtoBuf.Reflect.Message.ExtensionField.html">ExtensionField</a></li><li><a href="ProtoBuf.Reflect.Message.Field.html">Field</a></li><li><a href="ProtoBuf.Reflect.Message.OneOf.html">OneOf</a></li><li><a href="ProtoBuf.Reflect.Namespace.html">Namespace</a></li><li><a href="ProtoBuf.Reflect.Service.html">Service</a></li><li><a href="ProtoBuf.Reflect.Service.Method.html">Method</a></li><li><a href="ProtoBuf.Reflect.Service.RPCMethod.html">RPCMethod</a></li><li><a href="ProtoBuf.Reflect.T.html">T</a></li></ul><h3>Namespaces</h3><ul><li><a href="ProtoBuf.html">ProtoBuf</a></li><li><a href="ProtoBuf.DotProto.html">DotProto</a></li><li><a href="ProtoBuf.Reflect.html">Reflect</a></li><li><a href="ProtoBuf.Util.html">Util</a></li></ul>
5304
+ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="ProtoBuf.Builder.html">Builder</a></li><li><a href="ProtoBuf.Builder.Message.html">Message</a></li><li><a href="ProtoBuf.Builder.Service.html">Service</a></li><li><a href="ProtoBuf.DotProto.Parser.html">Parser</a></li><li><a href="ProtoBuf.DotProto.Tokenizer.html">Tokenizer</a></li><li><a href="ProtoBuf.Map.html">Map</a></li><li><a href="ProtoBuf.Reflect.Element.html">Element</a></li><li><a href="ProtoBuf.Reflect.Enum.html">Enum</a></li><li><a href="ProtoBuf.Reflect.Enum.Value.html">Value</a></li><li><a href="ProtoBuf.Reflect.Extension.html">Extension</a></li><li><a href="ProtoBuf.Reflect.Message.html">Message</a></li><li><a href="ProtoBuf.Reflect.Message.ExtensionField.html">ExtensionField</a></li><li><a href="ProtoBuf.Reflect.Message.Field.html">Field</a></li><li><a href="ProtoBuf.Reflect.Message.OneOf.html">OneOf</a></li><li><a href="ProtoBuf.Reflect.Namespace.html">Namespace</a></li><li><a href="ProtoBuf.Reflect.Service.html">Service</a></li><li><a href="ProtoBuf.Reflect.Service.Method.html">Method</a></li><li><a href="ProtoBuf.Reflect.Service.RPCMethod.html">RPCMethod</a></li><li><a href="ProtoBuf.Reflect.T.html">T</a></li></ul><h3>Namespaces</h3><ul><li><a href="ProtoBuf.html">ProtoBuf</a></li><li><a href="ProtoBuf.DotProto.html">DotProto</a></li><li><a href="ProtoBuf.Reflect.html">Reflect</a></li><li><a href="ProtoBuf.Util.html">Util</a></li></ul>
5262
5305
  </nav>
5263
5306
 
5264
- <br clear="both">
5307
+ <br class="clear">
5265
5308
 
5266
5309
  <footer>
5267
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha9</a> on Wed Jan 06 2016 01:34:58 GMT+0100 (Mitteleuropäische Zeit)
5310
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Fri Jan 27 2017 17:03:55 GMT+0100 (Mitteleuropäische Zeit)
5268
5311
  </footer>
5269
5312
 
5270
5313
  <script> prettyPrint(); </script>