protobufjs 4.1.2 → 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.
- package/.travis.yml +3 -1
- package/README.md +147 -25
- package/bin/pbjs +2 -2
- package/bower.json +3 -3
- package/cli/pbjs/targets/amd.js +1 -1
- package/cli/pbjs/targets/json.js +9 -1
- package/cli/pbjs/targets/proto.js +48 -24
- package/cli/pbjs/util.js +1 -1
- package/cli/pbjs.js +9 -2
- package/dist/README.md +10 -10
- package/dist/{ProtoBuf-light.js → protobuf-light.js} +207 -152
- package/dist/protobuf-light.min.js +94 -0
- package/dist/protobuf-light.min.js.gz +0 -0
- package/dist/protobuf-light.min.map +8 -0
- package/dist/{ProtoBuf.js → protobuf.js} +265 -175
- package/dist/protobuf.min.js +116 -0
- package/dist/protobuf.min.js.gz +0 -0
- package/dist/protobuf.min.map +8 -0
- package/docs/ProtoBuf.Builder.Message.html +1473 -967
- package/docs/ProtoBuf.Builder.Service.html +266 -197
- package/docs/ProtoBuf.Builder.html +758 -542
- package/docs/ProtoBuf.DotProto.Parser.html +223 -161
- package/docs/ProtoBuf.DotProto.Tokenizer.html +344 -248
- package/docs/ProtoBuf.DotProto.html +20 -12
- package/docs/ProtoBuf.Element.html +554 -554
- package/docs/ProtoBuf.Map.html +158 -123
- package/docs/ProtoBuf.Reflect.Element.html +286 -143
- package/docs/ProtoBuf.Reflect.Enum.Value.html +329 -228
- package/docs/ProtoBuf.Reflect.Enum.html +757 -537
- package/docs/ProtoBuf.Reflect.Extension.html +73 -56
- package/docs/ProtoBuf.Reflect.Message.ExtensionField.html +1013 -740
- package/docs/ProtoBuf.Reflect.Message.Field.html +926 -649
- package/docs/ProtoBuf.Reflect.Message.OneOf.html +327 -245
- package/docs/ProtoBuf.Reflect.Message.html +919 -652
- package/docs/ProtoBuf.Reflect.Namespace.html +648 -447
- package/docs/ProtoBuf.Reflect.Service.Method.html +363 -251
- package/docs/ProtoBuf.Reflect.Service.RPCMethod.html +545 -397
- package/docs/ProtoBuf.Reflect.Service.html +721 -511
- package/docs/ProtoBuf.Reflect.T.html +268 -197
- package/docs/ProtoBuf.Reflect.html +20 -12
- package/docs/ProtoBuf.Util.html +169 -118
- package/docs/ProtoBuf.html +840 -628
- package/docs/ProtoBuf.js.html +271 -180
- package/docs/fonts/OpenSans-Bold-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Bold-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Bold-webfont.woff +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Italic-webfont.svg +1830 -0
- package/docs/fonts/OpenSans-Italic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Light-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Light-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Light-webfont.woff +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.eot +0 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.svg +1835 -0
- package/docs/fonts/OpenSans-LightItalic-webfont.woff +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.eot +0 -0
- package/docs/fonts/OpenSans-Regular-webfont.svg +1831 -0
- package/docs/fonts/OpenSans-Regular-webfont.woff +0 -0
- package/docs/index.html +7 -5
- package/docs/styles/jsdoc-default.css +95 -75
- package/docs/styles/prettify-tomorrow.css +1 -1
- package/donate.png +0 -0
- package/examples/protoify/json.js +123 -123
- package/examples/protoify/json.json +123 -123
- package/examples/websocket/server.js +4 -4
- package/externs/{ProtoBuf.js → protobuf.js} +933 -922
- package/index.js +1 -18
- package/jsdoc.json +1 -1
- package/package.json +11 -11
- package/protobuf.png +0 -0
- package/scripts/build.js +53 -58
- package/src/ProtoBuf/Builder/Message.js +18 -9
- package/src/ProtoBuf/Builder/Service.js +3 -0
- package/src/ProtoBuf/Builder.js +34 -10
- package/src/ProtoBuf/DotProto/Parser.js +58 -23
- package/src/ProtoBuf/Reflect/Element.js +17 -4
- package/src/ProtoBuf/Reflect/Message/Field.js +6 -5
- package/src/ProtoBuf/Reflect/Message.js +9 -4
- package/src/ProtoBuf/Util.js +116 -116
- package/src/bower.json +2 -2
- package/src/google/protobuf/descriptor.json +55 -15
- package/src/{ProtoBuf.js → protobuf.js} +0 -0
- package/src/wrap.js +4 -4
- package/tests/bench.txt +373 -373
- package/tests/complex.json +8 -1
- package/tests/custom-options.json +169 -169
- package/tests/extend.json +71 -71
- package/tests/imports-weak.proto +7 -0
- package/tests/imports.json +83 -83
- package/tests/nodeunit-browser/nodeunit.css +70 -70
- package/tests/nodeunit-browser/nodeunit.js +2108 -2108
- package/tests/options.json +32 -32
- package/tests/proto2js/Bar.json +46 -46
- package/tests/suite.js +107 -82
- package/ProtoBuf.png +0 -0
- package/dist/ProtoBuf-light.min.js +0 -87
- package/dist/ProtoBuf-light.min.js.gz +0 -0
- package/dist/ProtoBuf-light.min.map +0 -8
- package/dist/ProtoBuf.min.js +0 -108
- package/dist/ProtoBuf.min.js.gz +0 -0
- package/dist/ProtoBuf.min.map +0 -8
- package/externs/ByteBuffer.js +0 -767
- package/externs/Long.js +0 -328
- package/sandbox/gapi/googleapis/google/api/annotations.proto +0 -29
- package/sandbox/gapi/googleapis/google/api/http.proto +0 -245
- package/sandbox/gapi/googleapis/google/datastore/v1beta3/datastore.proto +0 -281
- package/sandbox/gapi/googleapis/google/datastore/v1beta3/entity.proto +0 -189
- package/sandbox/gapi/googleapis/google/datastore/v1beta3/query.proto +0 -281
- package/sandbox/gapi/googleapis/google/longrunning/operations.proto +0 -144
- package/sandbox/gapi/googleapis/google/protobuf/any.proto +0 -98
- package/sandbox/gapi/googleapis/google/protobuf/any_test.proto +0 -41
- package/sandbox/gapi/googleapis/google/protobuf/api.proto +0 -201
- package/sandbox/gapi/googleapis/google/protobuf/descriptor.proto +0 -773
- package/sandbox/gapi/googleapis/google/protobuf/duration.proto +0 -95
- package/sandbox/gapi/googleapis/google/protobuf/empty.proto +0 -50
- package/sandbox/gapi/googleapis/google/protobuf/field_mask.proto +0 -167
- package/sandbox/gapi/googleapis/google/protobuf/map_lite_unittest.proto +0 -130
- package/sandbox/gapi/googleapis/google/protobuf/map_proto2_unittest.proto +0 -60
- package/sandbox/gapi/googleapis/google/protobuf/map_unittest.proto +0 -129
- package/sandbox/gapi/googleapis/google/protobuf/map_unittest_proto3.proto +0 -120
- package/sandbox/gapi/googleapis/google/protobuf/source_context.proto +0 -47
- package/sandbox/gapi/googleapis/google/protobuf/struct.proto +0 -94
- package/sandbox/gapi/googleapis/google/protobuf/timestamp.proto +0 -107
- package/sandbox/gapi/googleapis/google/protobuf/type.proto +0 -176
- package/sandbox/gapi/googleapis/google/protobuf/unittest.proto +0 -878
- package/sandbox/gapi/googleapis/google/protobuf/unittest_arena.proto +0 -46
- package/sandbox/gapi/googleapis/google/protobuf/unittest_custom_options.proto +0 -394
- package/sandbox/gapi/googleapis/google/protobuf/unittest_drop_unknown_fields.proto +0 -58
- package/sandbox/gapi/googleapis/google/protobuf/unittest_embed_optimize_for.proto +0 -51
- package/sandbox/gapi/googleapis/google/protobuf/unittest_empty.proto +0 -38
- package/sandbox/gapi/googleapis/google/protobuf/unittest_enormous_descriptor.proto +0 -1048
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import.proto +0 -66
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_lite.proto +0 -52
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_proto3.proto +0 -68
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public.proto +0 -41
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_lite.proto +0 -43
- package/sandbox/gapi/googleapis/google/protobuf/unittest_import_public_proto3.proto +0 -42
- package/sandbox/gapi/googleapis/google/protobuf/unittest_lite.proto +0 -385
- package/sandbox/gapi/googleapis/google/protobuf/unittest_lite_imports_nonlite.proto +0 -44
- package/sandbox/gapi/googleapis/google/protobuf/unittest_mset.proto +0 -82
- package/sandbox/gapi/googleapis/google/protobuf/unittest_mset_wire_format.proto +0 -52
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena.proto +0 -202
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_import.proto +0 -37
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_arena_lite.proto +0 -42
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_field_presence.proto +0 -138
- package/sandbox/gapi/googleapis/google/protobuf/unittest_no_generic_services.proto +0 -54
- package/sandbox/gapi/googleapis/google/protobuf/unittest_optimize_for.proto +0 -67
- package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum.proto +0 -71
- package/sandbox/gapi/googleapis/google/protobuf/unittest_preserve_unknown_enum2.proto +0 -50
- package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3.proto +0 -388
- package/sandbox/gapi/googleapis/google/protobuf/unittest_proto3_arena.proto +0 -206
- package/sandbox/gapi/googleapis/google/protobuf/unittest_well_known_types.proto +0 -112
- package/sandbox/gapi/googleapis/google/protobuf/unknown_enum_test.proto +0 -62
- package/sandbox/gapi/googleapis/google/protobuf/wrappers.proto +0 -117
- package/sandbox/gapi/googleapis/google/rpc/code.proto +0 -190
- package/sandbox/gapi/googleapis/google/rpc/error_details.proto +0 -157
- package/sandbox/gapi/googleapis/google/rpc/status.proto +0 -90
- package/sandbox/gapi/googleapis/google/type/color.proto +0 -163
- package/sandbox/gapi/googleapis/google/type/date.proto +0 -43
- package/sandbox/gapi/googleapis/google/type/dayofweek.proto +0 -50
- package/sandbox/gapi/googleapis/google/type/latlng.proto +0 -36
- package/sandbox/gapi/googleapis/google/type/money.proto +0 -40
- package/sandbox/gapi/googleapis/google/type/timeofday.proto +0 -42
- package/sandbox/gapi/test.js +0 -17
- package/sandbox/gapi/test.proto +0 -12
- package/sandbox/issue146/MyOptions.proto +0 -28
- package/sandbox/issue146/Sample.proto +0 -21
- package/sandbox/issue146/main.js +0 -3
- package/sandbox/issue147/enum.proto +0 -8
- package/sandbox/issue147/main.js +0 -3
- package/sandbox/issue182/commands.proto +0 -10
- package/sandbox/issue182/execute.js +0 -22
- package/sandbox/issue182/session_commands.proto +0 -14
- package/sandbox/issue289/A.proto +0 -8
- package/sandbox/issue289/B.proto +0 -8
- package/sandbox/issue289/common.proto +0 -5
- package/sandbox/issue289/main.js +0 -7
- package/sandbox/issue300/IAuth.proto +0 -14
- package/sandbox/issue300/Request.proto +0 -14
- package/sandbox/issue300/main.js +0 -26
- package/sandbox/issue42/innerextend.proto +0 -18
- package/sandbox/issue42/main.js +0 -8
- package/sandbox/issue42/outerextend.proto +0 -17
- package/tests/gtfs-realtime.proto +0 -552
- package/webpack.config.js +0 -9
package/docs/ProtoBuf.js.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<title>JSDoc: Source:
|
|
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:
|
|
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>
|
|
@@ -42,14 +43,14 @@
|
|
|
42
43
|
*/
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
|
-
* @license
|
|
46
|
+
* @license protobuf.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
46
47
|
* Released under the Apache License, Version 2.0
|
|
47
|
-
* see: https://github.com/dcodeIO/
|
|
48
|
+
* see: https://github.com/dcodeIO/protobuf.js for details
|
|
48
49
|
*/
|
|
49
50
|
(function(global, factory) {
|
|
50
51
|
|
|
51
52
|
/* AMD */ if (typeof define === 'function' && define["amd"])
|
|
52
|
-
define(["
|
|
53
|
+
define(["bytebuffer"], factory);
|
|
53
54
|
/* CommonJS */ else if (typeof require === "function" && typeof module === "object" && module && module["exports"])
|
|
54
55
|
module["exports"] = factory(require("bytebuffer"), true);
|
|
55
56
|
/* Global */ else
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
* @const
|
|
85
86
|
* @expose
|
|
86
87
|
*/
|
|
87
|
-
ProtoBuf.VERSION = "
|
|
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' && process+'' === '[object process]' && !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<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 && 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 && 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 && 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' && process+'' === '[object process]' && !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<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 && 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 && 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 && 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.
|
|
@@ -752,7 +753,8 @@
|
|
|
752
753
|
// "syntax": undefined
|
|
753
754
|
};
|
|
754
755
|
var token,
|
|
755
|
-
head = true
|
|
756
|
+
head = true,
|
|
757
|
+
weak;
|
|
756
758
|
try {
|
|
757
759
|
while (token = this.tn.next()) {
|
|
758
760
|
switch (token) {
|
|
@@ -769,11 +771,12 @@
|
|
|
769
771
|
if (!head)
|
|
770
772
|
throw Error("unexpected 'import'");
|
|
771
773
|
token = this.tn.peek();
|
|
772
|
-
if (token === "public") // ignored
|
|
774
|
+
if (token === "public" || (weak = token === "weak")) // token ignored
|
|
773
775
|
this.tn.next();
|
|
774
776
|
token = this._readString();
|
|
775
777
|
this.tn.skip(";");
|
|
776
|
-
|
|
778
|
+
if (!weak) // import ignored
|
|
779
|
+
topLevel["imports"].push(token);
|
|
777
780
|
break;
|
|
778
781
|
case 'syntax':
|
|
779
782
|
if (!head)
|
|
@@ -1098,6 +1101,7 @@
|
|
|
1098
1101
|
"enums": [],
|
|
1099
1102
|
"messages": [],
|
|
1100
1103
|
"options": {},
|
|
1104
|
+
"services": [],
|
|
1101
1105
|
"oneofs": {}
|
|
1102
1106
|
// "extensions": undefined
|
|
1103
1107
|
};
|
|
@@ -1124,8 +1128,16 @@
|
|
|
1124
1128
|
this._parseMessage(msg);
|
|
1125
1129
|
else if (token === "option")
|
|
1126
1130
|
this._parseOption(msg);
|
|
1131
|
+
else if (token === "service")
|
|
1132
|
+
this._parseService(msg);
|
|
1127
1133
|
else if (token === "extensions")
|
|
1128
|
-
|
|
1134
|
+
if (msg.hasOwnProperty("extensions")) {
|
|
1135
|
+
msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges())
|
|
1136
|
+
} else {
|
|
1137
|
+
msg["extensions"] = this._parseExtensionRanges();
|
|
1138
|
+
}
|
|
1139
|
+
else if (token === "reserved")
|
|
1140
|
+
this._parseIgnored(); // TODO
|
|
1129
1141
|
else if (token === "extend")
|
|
1130
1142
|
this._parseExtend(msg);
|
|
1131
1143
|
else if (Lang.TYPEREF.test(token)) {
|
|
@@ -1140,6 +1152,16 @@
|
|
|
1140
1152
|
return msg;
|
|
1141
1153
|
};
|
|
1142
1154
|
|
|
1155
|
+
/**
|
|
1156
|
+
* Parses an ignored statement.
|
|
1157
|
+
* @private
|
|
1158
|
+
*/
|
|
1159
|
+
ParserPrototype._parseIgnored = function() {
|
|
1160
|
+
while (this.tn.peek() !== ';')
|
|
1161
|
+
this.tn.next();
|
|
1162
|
+
this.tn.skip(";");
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1143
1165
|
/**
|
|
1144
1166
|
* Parses a message field.
|
|
1145
1167
|
* @param {!Object} msg Message definition
|
|
@@ -1302,29 +1324,43 @@
|
|
|
1302
1324
|
};
|
|
1303
1325
|
|
|
1304
1326
|
/**
|
|
1305
|
-
* Parses
|
|
1306
|
-
* @
|
|
1327
|
+
* Parses extension / reserved ranges.
|
|
1328
|
+
* @returns {!Array.<!Array.<number>>}
|
|
1307
1329
|
* @private
|
|
1308
1330
|
*/
|
|
1309
|
-
ParserPrototype.
|
|
1310
|
-
var
|
|
1331
|
+
ParserPrototype._parseExtensionRanges = function() {
|
|
1332
|
+
var ranges = [];
|
|
1333
|
+
var token,
|
|
1334
|
+
range,
|
|
1335
|
+
value;
|
|
1336
|
+
do {
|
|
1311
1337
|
range = [];
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1338
|
+
while (true) {
|
|
1339
|
+
token = this.tn.next();
|
|
1340
|
+
switch (token) {
|
|
1341
|
+
case "min":
|
|
1342
|
+
value = ProtoBuf.ID_MIN;
|
|
1343
|
+
break;
|
|
1344
|
+
case "max":
|
|
1345
|
+
value = ProtoBuf.ID_MAX;
|
|
1346
|
+
break;
|
|
1347
|
+
default:
|
|
1348
|
+
value = mkNumber(token);
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
range.push(value);
|
|
1352
|
+
if (range.length === 2)
|
|
1353
|
+
break;
|
|
1354
|
+
if (this.tn.peek() !== "to") {
|
|
1355
|
+
range.push(value);
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
this.tn.next();
|
|
1359
|
+
}
|
|
1360
|
+
ranges.push(range);
|
|
1361
|
+
} while (this.tn.omit(","));
|
|
1326
1362
|
this.tn.skip(";");
|
|
1327
|
-
|
|
1363
|
+
return ranges;
|
|
1328
1364
|
};
|
|
1329
1365
|
|
|
1330
1366
|
/**
|
|
@@ -1705,9 +1741,11 @@
|
|
|
1705
1741
|
* converted to string form if so.
|
|
1706
1742
|
* @param {string} syntax Syntax level of defining message type, e.g.,
|
|
1707
1743
|
* proto2 or proto3.
|
|
1744
|
+
* @param {string} name Name of the field containing this element (for error
|
|
1745
|
+
* messages)
|
|
1708
1746
|
* @constructor
|
|
1709
1747
|
*/
|
|
1710
|
-
var Element = function(type, resolvedType, isMapKey, syntax) {
|
|
1748
|
+
var Element = function(type, resolvedType, isMapKey, syntax, name) {
|
|
1711
1749
|
|
|
1712
1750
|
/**
|
|
1713
1751
|
* Element type, as a string (e.g., int32).
|
|
@@ -1733,6 +1771,12 @@
|
|
|
1733
1771
|
*/
|
|
1734
1772
|
this.syntax = syntax;
|
|
1735
1773
|
|
|
1774
|
+
/**
|
|
1775
|
+
* Name of the field containing this element (for error messages)
|
|
1776
|
+
* @type {string}
|
|
1777
|
+
*/
|
|
1778
|
+
this.name = name;
|
|
1779
|
+
|
|
1736
1780
|
if (isMapKey && ProtoBuf.MAP_KEY_TYPES.indexOf(type) < 0)
|
|
1737
1781
|
throw Error("Invalid map key type: " + type.name);
|
|
1738
1782
|
};
|
|
@@ -1783,6 +1827,10 @@
|
|
|
1783
1827
|
throw Error("not convertible to Long");
|
|
1784
1828
|
}
|
|
1785
1829
|
|
|
1830
|
+
ElementPrototype.toString = function() {
|
|
1831
|
+
return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element';
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1786
1834
|
/**
|
|
1787
1835
|
* Checks if the given value can be set for an element of this type (singular
|
|
1788
1836
|
* field or one element of a repeated field or map).
|
|
@@ -1792,9 +1840,10 @@
|
|
|
1792
1840
|
* @expose
|
|
1793
1841
|
*/
|
|
1794
1842
|
ElementPrototype.verifyValue = function(value) {
|
|
1795
|
-
var
|
|
1796
|
-
|
|
1797
|
-
|
|
1843
|
+
var self = this;
|
|
1844
|
+
function fail(val, msg) {
|
|
1845
|
+
throw Error("Illegal value for "+self.toString(true)+" of type "+self.type.name+": "+val+" ("+msg+")");
|
|
1846
|
+
}
|
|
1798
1847
|
switch (this.type) {
|
|
1799
1848
|
// Signed 32bit
|
|
1800
1849
|
case ProtoBuf.TYPES["int32"]:
|
|
@@ -2284,10 +2333,10 @@
|
|
|
2284
2333
|
|
|
2285
2334
|
/**
|
|
2286
2335
|
* Extensions range.
|
|
2287
|
-
* @type {!Array.<number
|
|
2336
|
+
* @type {!Array.<number>|undefined}
|
|
2288
2337
|
* @expose
|
|
2289
2338
|
*/
|
|
2290
|
-
this.extensions =
|
|
2339
|
+
this.extensions = undefined;
|
|
2291
2340
|
|
|
2292
2341
|
/**
|
|
2293
2342
|
* Runtime message class.
|
|
@@ -2456,9 +2505,11 @@
|
|
|
2456
2505
|
MessagePrototype.set = function(keyOrObj, value, noAssert) {
|
|
2457
2506
|
if (keyOrObj && typeof keyOrObj === 'object') {
|
|
2458
2507
|
noAssert = value;
|
|
2459
|
-
for (var ikey in keyOrObj)
|
|
2460
|
-
if
|
|
2508
|
+
for (var ikey in keyOrObj) {
|
|
2509
|
+
// Check if virtual oneof field - don't set these
|
|
2510
|
+
if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined' && T._oneofsByName[ikey] === undefined)
|
|
2461
2511
|
this.$set(ikey, value, noAssert);
|
|
2512
|
+
}
|
|
2462
2513
|
return this;
|
|
2463
2514
|
}
|
|
2464
2515
|
var field = T._fieldsByName[keyOrObj];
|
|
@@ -2686,18 +2737,19 @@
|
|
|
2686
2737
|
* @name ProtoBuf.Builder.Message#encodeDelimited
|
|
2687
2738
|
* @function
|
|
2688
2739
|
* @param {(!ByteBuffer|boolean)=} buffer ByteBuffer to encode to. Will create a new one and flip it if omitted.
|
|
2740
|
+
* @param {boolean=} noVerify Whether to not verify field values, defaults to `false`
|
|
2689
2741
|
* @return {!ByteBuffer} Encoded message as a ByteBuffer
|
|
2690
2742
|
* @throws {Error} If the message cannot be encoded or if required fields are missing. The later still
|
|
2691
2743
|
* returns the encoded ByteBuffer in the `encoded` property on the error.
|
|
2692
2744
|
* @expose
|
|
2693
2745
|
*/
|
|
2694
|
-
MessagePrototype.encodeDelimited = function(buffer) {
|
|
2746
|
+
MessagePrototype.encodeDelimited = function(buffer, noVerify) {
|
|
2695
2747
|
var isNew = false;
|
|
2696
2748
|
if (!buffer)
|
|
2697
2749
|
buffer = new ByteBuffer(),
|
|
2698
2750
|
isNew = true;
|
|
2699
2751
|
var enc = new ByteBuffer().LE();
|
|
2700
|
-
T.encode(this, enc).flip();
|
|
2752
|
+
T.encode(this, enc, noVerify).flip();
|
|
2701
2753
|
buffer.writeVarint32(enc.remaining());
|
|
2702
2754
|
buffer.append(enc);
|
|
2703
2755
|
return isNew ? buffer.flip() : buffer;
|
|
@@ -2844,7 +2896,7 @@
|
|
|
2844
2896
|
return binaryAsBase64 ? obj.toBase64() : obj.toBuffer();
|
|
2845
2897
|
// Convert Longs to proper objects or strings
|
|
2846
2898
|
if (ProtoBuf.Long.isLong(obj))
|
|
2847
|
-
return longsAsStrings ? obj.toString() :
|
|
2899
|
+
return longsAsStrings ? obj.toString() : ProtoBuf.Long.fromValue(obj);
|
|
2848
2900
|
var clone;
|
|
2849
2901
|
// Clone arrays
|
|
2850
2902
|
if (Array.isArray(obj)) {
|
|
@@ -2906,6 +2958,7 @@
|
|
|
2906
2958
|
* @name ProtoBuf.Builder.Message.decode
|
|
2907
2959
|
* @function
|
|
2908
2960
|
* @param {!ByteBuffer|!ArrayBuffer|!Buffer|string} buffer Buffer to decode from
|
|
2961
|
+
* @param {(number|string)=} length Message length. Defaults to decode all the remainig data.
|
|
2909
2962
|
* @param {string=} enc Encoding if buffer is a string: hex, utf8 (not recommended), defaults to base64
|
|
2910
2963
|
* @return {!ProtoBuf.Builder.Message} Decoded message
|
|
2911
2964
|
* @throws {Error} If the message cannot be decoded or if required fields are missing. The later still
|
|
@@ -2914,13 +2967,17 @@
|
|
|
2914
2967
|
* @see ProtoBuf.Builder.Message.decode64
|
|
2915
2968
|
* @see ProtoBuf.Builder.Message.decodeHex
|
|
2916
2969
|
*/
|
|
2917
|
-
Message.decode = function(buffer, enc) {
|
|
2970
|
+
Message.decode = function(buffer, length, enc) {
|
|
2971
|
+
if (typeof length === 'string')
|
|
2972
|
+
enc = length,
|
|
2973
|
+
length = -1;
|
|
2918
2974
|
if (typeof buffer === 'string')
|
|
2919
2975
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2920
|
-
|
|
2976
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
2977
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2921
2978
|
var le = buffer.littleEndian;
|
|
2922
2979
|
try {
|
|
2923
|
-
var msg = T.decode(buffer.LE());
|
|
2980
|
+
var msg = T.decode(buffer.LE(), length);
|
|
2924
2981
|
buffer.LE(le);
|
|
2925
2982
|
return msg;
|
|
2926
2983
|
} catch (e) {
|
|
@@ -2943,7 +3000,8 @@
|
|
|
2943
3000
|
Message.decodeDelimited = function(buffer, enc) {
|
|
2944
3001
|
if (typeof buffer === 'string')
|
|
2945
3002
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2946
|
-
|
|
3003
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
3004
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2947
3005
|
if (buffer.remaining() < 1)
|
|
2948
3006
|
return null;
|
|
2949
3007
|
var off = buffer.offset,
|
|
@@ -3065,6 +3123,7 @@
|
|
|
3065
3123
|
this._fields = [];
|
|
3066
3124
|
this._fieldsById = {};
|
|
3067
3125
|
this._fieldsByName = {};
|
|
3126
|
+
this._oneofsByName = {};
|
|
3068
3127
|
for (var i=0, k=this.children.length, child; i<k; i++) {
|
|
3069
3128
|
child = this.children[i];
|
|
3070
3129
|
if (child instanceof Enum || child instanceof Message || child instanceof Service) {
|
|
@@ -3076,6 +3135,9 @@
|
|
|
3076
3135
|
this._fields.push(child),
|
|
3077
3136
|
this._fieldsById[child.id] = child,
|
|
3078
3137
|
this._fieldsByName[child.name] = child;
|
|
3138
|
+
else if (child instanceof Message.OneOf) {
|
|
3139
|
+
this._oneofsByName[child.name] = child;
|
|
3140
|
+
}
|
|
3079
3141
|
else if (!(child instanceof Message.OneOf) && !(child instanceof Extension)) // Not built
|
|
3080
3142
|
throw Error("Illegal reflect child of "+this.toString(true)+": "+this.children[i].toString(true));
|
|
3081
3143
|
}
|
|
@@ -3175,14 +3237,15 @@
|
|
|
3175
3237
|
/**
|
|
3176
3238
|
* Decodes an encoded message and returns the decoded message.
|
|
3177
3239
|
* @param {ByteBuffer} buffer ByteBuffer to decode from
|
|
3178
|
-
* @param {number=} length Message length. Defaults to decode all
|
|
3240
|
+
* @param {number=} length Message length. Defaults to decode all remaining data.
|
|
3179
3241
|
* @param {number=} expectedGroupEndId Expected GROUPEND id if this is a legacy group
|
|
3180
3242
|
* @return {ProtoBuf.Builder.Message} Decoded message
|
|
3181
3243
|
* @throws {Error} If the message cannot be decoded
|
|
3182
3244
|
* @expose
|
|
3183
3245
|
*/
|
|
3184
3246
|
MessagePrototype.decode = function(buffer, length, expectedGroupEndId) {
|
|
3185
|
-
|
|
3247
|
+
if (typeof length !== 'number')
|
|
3248
|
+
length = -1;
|
|
3186
3249
|
var start = buffer.offset,
|
|
3187
3250
|
msg = new (this.clazz)(),
|
|
3188
3251
|
tag, wireType, id, field;
|
|
@@ -3401,9 +3464,9 @@
|
|
|
3401
3464
|
* @expose
|
|
3402
3465
|
*/
|
|
3403
3466
|
FieldPrototype.build = function() {
|
|
3404
|
-
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);
|
|
3405
3468
|
if (this.map)
|
|
3406
|
-
this.keyElement = new Element(this.keyType, undefined, true, this.syntax);
|
|
3469
|
+
this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name);
|
|
3407
3470
|
|
|
3408
3471
|
// In proto3, fields do not have field presence, and every field is set to
|
|
3409
3472
|
// its type's default value ("", 0, 0.0, or false).
|
|
@@ -3425,9 +3488,10 @@
|
|
|
3425
3488
|
*/
|
|
3426
3489
|
FieldPrototype.verifyValue = function(value, skipRepeated) {
|
|
3427
3490
|
skipRepeated = skipRepeated || false;
|
|
3428
|
-
var
|
|
3429
|
-
|
|
3430
|
-
|
|
3491
|
+
var self = this;
|
|
3492
|
+
function fail(val, msg) {
|
|
3493
|
+
throw Error("Illegal value for "+self.toString(true)+" of type "+self.type.name+": "+val+" ("+msg+")");
|
|
3494
|
+
}
|
|
3431
3495
|
if (value === null) { // NULL values for optional fields
|
|
3432
3496
|
if (this.required)
|
|
3433
3497
|
fail(typeof value, "required");
|
|
@@ -4041,6 +4105,9 @@
|
|
|
4041
4105
|
callback(err);
|
|
4042
4106
|
return;
|
|
4043
4107
|
}
|
|
4108
|
+
// Coalesce to empty string when service response has empty content
|
|
4109
|
+
if (res === null)
|
|
4110
|
+
res = ''
|
|
4044
4111
|
try { res = method.resolvedResponseType.clazz.decode(res); } catch (notABuffer) {}
|
|
4045
4112
|
if (!res || !(res instanceof method.resolvedResponseType.clazz)) {
|
|
4046
4113
|
callback(Error("Illegal response type received in service method "+ T.name+"#"+method.name));
|
|
@@ -4484,13 +4551,12 @@
|
|
|
4484
4551
|
subObj.push(svc);
|
|
4485
4552
|
});
|
|
4486
4553
|
|
|
4487
|
-
// Set extension
|
|
4554
|
+
// Set extension ranges
|
|
4488
4555
|
if (def["extensions"]) {
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
obj.extensions[1] = ProtoBuf.ID_MAX;
|
|
4556
|
+
if (typeof def["extensions"][0] === 'number') // pre 5.0.1
|
|
4557
|
+
obj.extensions = [ def["extensions"] ];
|
|
4558
|
+
else
|
|
4559
|
+
obj.extensions = def["extensions"];
|
|
4494
4560
|
}
|
|
4495
4561
|
|
|
4496
4562
|
// Create on top of current namespace
|
|
@@ -4529,8 +4595,16 @@
|
|
|
4529
4595
|
def["fields"].forEach(function(fld) {
|
|
4530
4596
|
if (obj.getChild(fld['id']|0) !== null)
|
|
4531
4597
|
throw Error("duplicate extended field id in "+obj.name+": "+fld['id']);
|
|
4532
|
-
if
|
|
4533
|
-
|
|
4598
|
+
// Check if field id is allowed to be extended
|
|
4599
|
+
if (obj.extensions) {
|
|
4600
|
+
var valid = false;
|
|
4601
|
+
obj.extensions.forEach(function(range) {
|
|
4602
|
+
if (fld["id"] >= range[0] && fld["id"] <= range[1])
|
|
4603
|
+
valid = true;
|
|
4604
|
+
});
|
|
4605
|
+
if (!valid)
|
|
4606
|
+
throw Error("illegal extended field id in "+obj.name+": "+fld['id']+" (not within valid ranges)");
|
|
4607
|
+
}
|
|
4534
4608
|
// Convert extension field names to camel case notation if the override is set
|
|
4535
4609
|
var name = fld["name"];
|
|
4536
4610
|
if (this.options['convertFieldsToCamelCase'])
|
|
@@ -4611,7 +4685,11 @@
|
|
|
4611
4685
|
root = require("path")['resolve'](root);
|
|
4612
4686
|
if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0)
|
|
4613
4687
|
delim = '\\';
|
|
4614
|
-
var fname
|
|
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;
|
|
4615
4693
|
if (this.files[fname] === true)
|
|
4616
4694
|
return this.reset();
|
|
4617
4695
|
this.files[fname] = true;
|
|
@@ -4657,7 +4735,10 @@
|
|
|
4657
4735
|
var importFilename = json['imports'][i];
|
|
4658
4736
|
if (importFilename === "google/protobuf/descriptor.proto")
|
|
4659
4737
|
continue; // Not needed and therefore not used
|
|
4660
|
-
|
|
4738
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4739
|
+
importFilename = require("path")['join'](importRoot, importFilename);
|
|
4740
|
+
else
|
|
4741
|
+
importFilename = importRoot + delim + importFilename;
|
|
4661
4742
|
if (this.files[importFilename] === true)
|
|
4662
4743
|
continue; // Already imported
|
|
4663
4744
|
if (/\.proto$/i.test(importFilename) && !ProtoBuf.DotProto) // If this is a light build
|
|
@@ -4755,6 +4836,16 @@
|
|
|
4755
4836
|
this.ptr.keyType = ProtoBuf.TYPES[this.ptr.keyType];
|
|
4756
4837
|
}
|
|
4757
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' &&
|
|
4843
|
+
this.ptr.repeated && this.ptr.options.packed === undefined &&
|
|
4844
|
+
ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType) !== -1
|
|
4845
|
+
) {
|
|
4846
|
+
this.ptr.options.packed = true;
|
|
4847
|
+
}
|
|
4848
|
+
|
|
4758
4849
|
} else if (this.ptr instanceof ProtoBuf.Reflect.Service.Method) {
|
|
4759
4850
|
|
|
4760
4851
|
if (this.ptr instanceof ProtoBuf.Reflect.Service.RPCMethod) {
|
|
@@ -5210,13 +5301,13 @@
|
|
|
5210
5301
|
</div>
|
|
5211
5302
|
|
|
5212
5303
|
<nav>
|
|
5213
|
-
<h2><a href="index.html">
|
|
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>
|
|
5214
5305
|
</nav>
|
|
5215
5306
|
|
|
5216
|
-
<br
|
|
5307
|
+
<br class="clear">
|
|
5217
5308
|
|
|
5218
5309
|
<footer>
|
|
5219
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.
|
|
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)
|
|
5220
5311
|
</footer>
|
|
5221
5312
|
|
|
5222
5313
|
<script> prettyPrint(); </script>
|