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.
- package/.travis.yml +2 -1
- package/README.md +144 -22
- package/bin/pbjs +2 -2
- package/bower.json +2 -2
- package/cli/pbjs/targets/amd.js +1 -1
- package/cli/pbjs/targets/json.js +8 -0
- package/cli/pbjs/util.js +1 -1
- package/cli/pbjs.js +1 -1
- package/dist/protobuf-light.js +166 -128
- package/dist/protobuf-light.min.js +88 -81
- package/dist/protobuf-light.min.js.gz +0 -0
- package/dist/protobuf-light.min.map +4 -4
- package/dist/protobuf.js +171 -129
- package/dist/protobuf.min.js +106 -98
- package/dist/protobuf.min.js.gz +0 -0
- package/dist/protobuf.min.map +4 -4
- package/docs/ProtoBuf.Builder.Message.html +1408 -971
- 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 +915 -651
- 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 +177 -134
- 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/examples/protoify/json.js +123 -123
- package/examples/protoify/json.json +123 -123
- package/examples/websocket/server.js +4 -4
- package/externs/protobuf.js +1 -1
- package/jsdoc.json +1 -1
- package/package.json +2 -2
- package/scripts/build.js +53 -53
- package/src/ProtoBuf/Builder/Message.js +9 -5
- package/src/ProtoBuf/Builder.js +19 -2
- package/src/ProtoBuf/DotProto/Parser.js +5 -1
- package/src/ProtoBuf/Reflect/Element.js +13 -1
- package/src/ProtoBuf/Reflect/Message/Field.js +2 -2
- package/src/ProtoBuf/Reflect/Message.js +6 -1
- package/src/ProtoBuf/Util.js +116 -116
- package/src/bower.json +1 -1
- package/src/google/protobuf/descriptor.json +27 -1
- 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.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 +43 -1
- 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/issue347/index.js +0 -27
- package/sandbox/issue355/main.proto +0 -15
- package/sandbox/issue42/innerextend.proto +0 -18
- package/sandbox/issue42/main.js +0 -8
- package/sandbox/issue42/outerextend.proto +0 -17
package/dist/protobuf.js
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
* @const
|
|
58
58
|
* @expose
|
|
59
59
|
*/
|
|
60
|
-
ProtoBuf.VERSION = "5.0.
|
|
60
|
+
ProtoBuf.VERSION = "5.0.2";
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Wire types.
|
|
@@ -289,122 +289,122 @@
|
|
|
289
289
|
*/
|
|
290
290
|
ProtoBuf.populateDefaults = true;
|
|
291
291
|
|
|
292
|
-
/**
|
|
293
|
-
* @alias ProtoBuf.Util
|
|
294
|
-
* @expose
|
|
295
|
-
*/
|
|
296
|
-
ProtoBuf.Util = (function() {
|
|
297
|
-
"use strict";
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* ProtoBuf utilities.
|
|
301
|
-
* @exports ProtoBuf.Util
|
|
302
|
-
* @namespace
|
|
303
|
-
*/
|
|
304
|
-
var Util = {};
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Flag if running in node or not.
|
|
308
|
-
* @type {boolean}
|
|
309
|
-
* @const
|
|
310
|
-
* @expose
|
|
311
|
-
*/
|
|
312
|
-
Util.IS_NODE = !!(
|
|
313
|
-
typeof process === 'object' && process+'' === '[object process]' && !process['browser']
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Constructs a XMLHttpRequest object.
|
|
318
|
-
* @return {XMLHttpRequest}
|
|
319
|
-
* @throws {Error} If XMLHttpRequest is not supported
|
|
320
|
-
* @expose
|
|
321
|
-
*/
|
|
322
|
-
Util.XHR = function() {
|
|
323
|
-
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
324
|
-
var XMLHttpFactories = [
|
|
325
|
-
function () {return new XMLHttpRequest()},
|
|
326
|
-
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
327
|
-
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
328
|
-
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
329
|
-
];
|
|
330
|
-
/** @type {?XMLHttpRequest} */
|
|
331
|
-
var xhr = null;
|
|
332
|
-
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
333
|
-
try { xhr = XMLHttpFactories[i](); }
|
|
334
|
-
catch (e) { continue; }
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
if (!xhr)
|
|
338
|
-
throw Error("XMLHttpRequest is not supported");
|
|
339
|
-
return xhr;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* Fetches a resource.
|
|
344
|
-
* @param {string} path Resource path
|
|
345
|
-
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
346
|
-
* be fetched synchronously. If the request failed, contents will be null.
|
|
347
|
-
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
348
|
-
* @expose
|
|
349
|
-
*/
|
|
350
|
-
Util.fetch = function(path, callback) {
|
|
351
|
-
if (callback && typeof callback != 'function')
|
|
352
|
-
callback = null;
|
|
353
|
-
if (Util.IS_NODE) {
|
|
354
|
-
var fs = require("fs");
|
|
355
|
-
if (callback) {
|
|
356
|
-
fs.readFile(path, function(err, data) {
|
|
357
|
-
if (err)
|
|
358
|
-
callback(null);
|
|
359
|
-
else
|
|
360
|
-
callback(""+data);
|
|
361
|
-
});
|
|
362
|
-
} else
|
|
363
|
-
try {
|
|
364
|
-
return fs.readFileSync(path);
|
|
365
|
-
} catch (e) {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
} else {
|
|
369
|
-
var xhr = Util.XHR();
|
|
370
|
-
xhr.open('GET', path, callback ? true : false);
|
|
371
|
-
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
372
|
-
xhr.setRequestHeader('Accept', 'text/plain');
|
|
373
|
-
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
374
|
-
if (callback) {
|
|
375
|
-
xhr.onreadystatechange = function() {
|
|
376
|
-
if (xhr.readyState != 4) return;
|
|
377
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
378
|
-
callback(xhr.responseText);
|
|
379
|
-
else
|
|
380
|
-
callback(null);
|
|
381
|
-
};
|
|
382
|
-
if (xhr.readyState == 4)
|
|
383
|
-
return;
|
|
384
|
-
xhr.send(null);
|
|
385
|
-
} else {
|
|
386
|
-
xhr.send(null);
|
|
387
|
-
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
388
|
-
return xhr.responseText;
|
|
389
|
-
return null;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Converts a string to camel case.
|
|
396
|
-
* @param {string} str
|
|
397
|
-
* @returns {string}
|
|
398
|
-
* @expose
|
|
399
|
-
*/
|
|
400
|
-
Util.toCamelCase = function(str) {
|
|
401
|
-
return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
|
|
402
|
-
return $1.toUpperCase();
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
return Util;
|
|
407
|
-
})();
|
|
292
|
+
/**
|
|
293
|
+
* @alias ProtoBuf.Util
|
|
294
|
+
* @expose
|
|
295
|
+
*/
|
|
296
|
+
ProtoBuf.Util = (function() {
|
|
297
|
+
"use strict";
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* ProtoBuf utilities.
|
|
301
|
+
* @exports ProtoBuf.Util
|
|
302
|
+
* @namespace
|
|
303
|
+
*/
|
|
304
|
+
var Util = {};
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Flag if running in node or not.
|
|
308
|
+
* @type {boolean}
|
|
309
|
+
* @const
|
|
310
|
+
* @expose
|
|
311
|
+
*/
|
|
312
|
+
Util.IS_NODE = !!(
|
|
313
|
+
typeof process === 'object' && process+'' === '[object process]' && !process['browser']
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Constructs a XMLHttpRequest object.
|
|
318
|
+
* @return {XMLHttpRequest}
|
|
319
|
+
* @throws {Error} If XMLHttpRequest is not supported
|
|
320
|
+
* @expose
|
|
321
|
+
*/
|
|
322
|
+
Util.XHR = function() {
|
|
323
|
+
// No dependencies please, ref: http://www.quirksmode.org/js/xmlhttp.html
|
|
324
|
+
var XMLHttpFactories = [
|
|
325
|
+
function () {return new XMLHttpRequest()},
|
|
326
|
+
function () {return new ActiveXObject("Msxml2.XMLHTTP")},
|
|
327
|
+
function () {return new ActiveXObject("Msxml3.XMLHTTP")},
|
|
328
|
+
function () {return new ActiveXObject("Microsoft.XMLHTTP")}
|
|
329
|
+
];
|
|
330
|
+
/** @type {?XMLHttpRequest} */
|
|
331
|
+
var xhr = null;
|
|
332
|
+
for (var i=0;i<XMLHttpFactories.length;i++) {
|
|
333
|
+
try { xhr = XMLHttpFactories[i](); }
|
|
334
|
+
catch (e) { continue; }
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
if (!xhr)
|
|
338
|
+
throw Error("XMLHttpRequest is not supported");
|
|
339
|
+
return xhr;
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Fetches a resource.
|
|
344
|
+
* @param {string} path Resource path
|
|
345
|
+
* @param {function(?string)=} callback Callback receiving the resource's contents. If omitted the resource will
|
|
346
|
+
* be fetched synchronously. If the request failed, contents will be null.
|
|
347
|
+
* @return {?string|undefined} Resource contents if callback is omitted (null if the request failed), else undefined.
|
|
348
|
+
* @expose
|
|
349
|
+
*/
|
|
350
|
+
Util.fetch = function(path, callback) {
|
|
351
|
+
if (callback && typeof callback != 'function')
|
|
352
|
+
callback = null;
|
|
353
|
+
if (Util.IS_NODE) {
|
|
354
|
+
var fs = require("fs");
|
|
355
|
+
if (callback) {
|
|
356
|
+
fs.readFile(path, function(err, data) {
|
|
357
|
+
if (err)
|
|
358
|
+
callback(null);
|
|
359
|
+
else
|
|
360
|
+
callback(""+data);
|
|
361
|
+
});
|
|
362
|
+
} else
|
|
363
|
+
try {
|
|
364
|
+
return fs.readFileSync(path);
|
|
365
|
+
} catch (e) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
var xhr = Util.XHR();
|
|
370
|
+
xhr.open('GET', path, callback ? true : false);
|
|
371
|
+
// xhr.setRequestHeader('User-Agent', 'XMLHTTP/1.0');
|
|
372
|
+
xhr.setRequestHeader('Accept', 'text/plain');
|
|
373
|
+
if (typeof xhr.overrideMimeType === 'function') xhr.overrideMimeType('text/plain');
|
|
374
|
+
if (callback) {
|
|
375
|
+
xhr.onreadystatechange = function() {
|
|
376
|
+
if (xhr.readyState != 4) return;
|
|
377
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
378
|
+
callback(xhr.responseText);
|
|
379
|
+
else
|
|
380
|
+
callback(null);
|
|
381
|
+
};
|
|
382
|
+
if (xhr.readyState == 4)
|
|
383
|
+
return;
|
|
384
|
+
xhr.send(null);
|
|
385
|
+
} else {
|
|
386
|
+
xhr.send(null);
|
|
387
|
+
if (/* remote */ xhr.status == 200 || /* local */ (xhr.status == 0 && typeof xhr.responseText === 'string'))
|
|
388
|
+
return xhr.responseText;
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Converts a string to camel case.
|
|
396
|
+
* @param {string} str
|
|
397
|
+
* @returns {string}
|
|
398
|
+
* @expose
|
|
399
|
+
*/
|
|
400
|
+
Util.toCamelCase = function(str) {
|
|
401
|
+
return str.replace(/_([a-zA-Z])/g, function ($0, $1) {
|
|
402
|
+
return $1.toUpperCase();
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
return Util;
|
|
407
|
+
})();
|
|
408
408
|
|
|
409
409
|
/**
|
|
410
410
|
* Language expressions.
|
|
@@ -1103,7 +1103,11 @@
|
|
|
1103
1103
|
else if (token === "service")
|
|
1104
1104
|
this._parseService(msg);
|
|
1105
1105
|
else if (token === "extensions")
|
|
1106
|
-
msg
|
|
1106
|
+
if (msg.hasOwnProperty("extensions")) {
|
|
1107
|
+
msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges())
|
|
1108
|
+
} else {
|
|
1109
|
+
msg["extensions"] = this._parseExtensionRanges();
|
|
1110
|
+
}
|
|
1107
1111
|
else if (token === "reserved")
|
|
1108
1112
|
this._parseIgnored(); // TODO
|
|
1109
1113
|
else if (token === "extend")
|
|
@@ -1709,9 +1713,11 @@
|
|
|
1709
1713
|
* converted to string form if so.
|
|
1710
1714
|
* @param {string} syntax Syntax level of defining message type, e.g.,
|
|
1711
1715
|
* proto2 or proto3.
|
|
1716
|
+
* @param {string} name Name of the field containing this element (for error
|
|
1717
|
+
* messages)
|
|
1712
1718
|
* @constructor
|
|
1713
1719
|
*/
|
|
1714
|
-
var Element = function(type, resolvedType, isMapKey, syntax) {
|
|
1720
|
+
var Element = function(type, resolvedType, isMapKey, syntax, name) {
|
|
1715
1721
|
|
|
1716
1722
|
/**
|
|
1717
1723
|
* Element type, as a string (e.g., int32).
|
|
@@ -1737,6 +1743,12 @@
|
|
|
1737
1743
|
*/
|
|
1738
1744
|
this.syntax = syntax;
|
|
1739
1745
|
|
|
1746
|
+
/**
|
|
1747
|
+
* Name of the field containing this element (for error messages)
|
|
1748
|
+
* @type {string}
|
|
1749
|
+
*/
|
|
1750
|
+
this.name = name;
|
|
1751
|
+
|
|
1740
1752
|
if (isMapKey && ProtoBuf.MAP_KEY_TYPES.indexOf(type) < 0)
|
|
1741
1753
|
throw Error("Invalid map key type: " + type.name);
|
|
1742
1754
|
};
|
|
@@ -1787,6 +1799,10 @@
|
|
|
1787
1799
|
throw Error("not convertible to Long");
|
|
1788
1800
|
}
|
|
1789
1801
|
|
|
1802
|
+
ElementPrototype.toString = function() {
|
|
1803
|
+
return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element';
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1790
1806
|
/**
|
|
1791
1807
|
* Checks if the given value can be set for an element of this type (singular
|
|
1792
1808
|
* field or one element of a repeated field or map).
|
|
@@ -2461,9 +2477,11 @@
|
|
|
2461
2477
|
MessagePrototype.set = function(keyOrObj, value, noAssert) {
|
|
2462
2478
|
if (keyOrObj && typeof keyOrObj === 'object') {
|
|
2463
2479
|
noAssert = value;
|
|
2464
|
-
for (var ikey in keyOrObj)
|
|
2465
|
-
if
|
|
2480
|
+
for (var ikey in keyOrObj) {
|
|
2481
|
+
// Check if virtual oneof field - don't set these
|
|
2482
|
+
if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined' && T._oneofsByName[ikey] === undefined)
|
|
2466
2483
|
this.$set(ikey, value, noAssert);
|
|
2484
|
+
}
|
|
2467
2485
|
return this;
|
|
2468
2486
|
}
|
|
2469
2487
|
var field = T._fieldsByName[keyOrObj];
|
|
@@ -2927,10 +2945,11 @@
|
|
|
2927
2945
|
length = -1;
|
|
2928
2946
|
if (typeof buffer === 'string')
|
|
2929
2947
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2930
|
-
|
|
2948
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
2949
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2931
2950
|
var le = buffer.littleEndian;
|
|
2932
2951
|
try {
|
|
2933
|
-
var msg = T.decode(buffer.LE());
|
|
2952
|
+
var msg = T.decode(buffer.LE(), length);
|
|
2934
2953
|
buffer.LE(le);
|
|
2935
2954
|
return msg;
|
|
2936
2955
|
} catch (e) {
|
|
@@ -2953,7 +2972,8 @@
|
|
|
2953
2972
|
Message.decodeDelimited = function(buffer, enc) {
|
|
2954
2973
|
if (typeof buffer === 'string')
|
|
2955
2974
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
2956
|
-
|
|
2975
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
2976
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
2957
2977
|
if (buffer.remaining() < 1)
|
|
2958
2978
|
return null;
|
|
2959
2979
|
var off = buffer.offset,
|
|
@@ -3075,6 +3095,7 @@
|
|
|
3075
3095
|
this._fields = [];
|
|
3076
3096
|
this._fieldsById = {};
|
|
3077
3097
|
this._fieldsByName = {};
|
|
3098
|
+
this._oneofsByName = {};
|
|
3078
3099
|
for (var i=0, k=this.children.length, child; i<k; i++) {
|
|
3079
3100
|
child = this.children[i];
|
|
3080
3101
|
if (child instanceof Enum || child instanceof Message || child instanceof Service) {
|
|
@@ -3086,6 +3107,9 @@
|
|
|
3086
3107
|
this._fields.push(child),
|
|
3087
3108
|
this._fieldsById[child.id] = child,
|
|
3088
3109
|
this._fieldsByName[child.name] = child;
|
|
3110
|
+
else if (child instanceof Message.OneOf) {
|
|
3111
|
+
this._oneofsByName[child.name] = child;
|
|
3112
|
+
}
|
|
3089
3113
|
else if (!(child instanceof Message.OneOf) && !(child instanceof Extension)) // Not built
|
|
3090
3114
|
throw Error("Illegal reflect child of "+this.toString(true)+": "+this.children[i].toString(true));
|
|
3091
3115
|
}
|
|
@@ -3192,7 +3216,8 @@
|
|
|
3192
3216
|
* @expose
|
|
3193
3217
|
*/
|
|
3194
3218
|
MessagePrototype.decode = function(buffer, length, expectedGroupEndId) {
|
|
3195
|
-
|
|
3219
|
+
if (typeof length !== 'number')
|
|
3220
|
+
length = -1;
|
|
3196
3221
|
var start = buffer.offset,
|
|
3197
3222
|
msg = new (this.clazz)(),
|
|
3198
3223
|
tag, wireType, id, field;
|
|
@@ -3411,9 +3436,9 @@
|
|
|
3411
3436
|
* @expose
|
|
3412
3437
|
*/
|
|
3413
3438
|
FieldPrototype.build = function() {
|
|
3414
|
-
this.element = new Element(this.type, this.resolvedType, false, this.syntax);
|
|
3439
|
+
this.element = new Element(this.type, this.resolvedType, false, this.syntax, this.name);
|
|
3415
3440
|
if (this.map)
|
|
3416
|
-
this.keyElement = new Element(this.keyType, undefined, true, this.syntax);
|
|
3441
|
+
this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name);
|
|
3417
3442
|
|
|
3418
3443
|
// In proto3, fields do not have field presence, and every field is set to
|
|
3419
3444
|
// its type's default value ("", 0, 0.0, or false).
|
|
@@ -4632,7 +4657,11 @@
|
|
|
4632
4657
|
root = require("path")['resolve'](root);
|
|
4633
4658
|
if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0)
|
|
4634
4659
|
delim = '\\';
|
|
4635
|
-
var fname
|
|
4660
|
+
var fname;
|
|
4661
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4662
|
+
fname = require("path")['join'](root, filename.file);
|
|
4663
|
+
else
|
|
4664
|
+
fname = root + delim + filename.file;
|
|
4636
4665
|
if (this.files[fname] === true)
|
|
4637
4666
|
return this.reset();
|
|
4638
4667
|
this.files[fname] = true;
|
|
@@ -4678,7 +4707,10 @@
|
|
|
4678
4707
|
var importFilename = json['imports'][i];
|
|
4679
4708
|
if (importFilename === "google/protobuf/descriptor.proto")
|
|
4680
4709
|
continue; // Not needed and therefore not used
|
|
4681
|
-
|
|
4710
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
4711
|
+
importFilename = require("path")['join'](importRoot, importFilename);
|
|
4712
|
+
else
|
|
4713
|
+
importFilename = importRoot + delim + importFilename;
|
|
4682
4714
|
if (this.files[importFilename] === true)
|
|
4683
4715
|
continue; // Already imported
|
|
4684
4716
|
if (/\.proto$/i.test(importFilename) && !ProtoBuf.DotProto) // If this is a light build
|
|
@@ -4776,6 +4808,16 @@
|
|
|
4776
4808
|
this.ptr.keyType = ProtoBuf.TYPES[this.ptr.keyType];
|
|
4777
4809
|
}
|
|
4778
4810
|
|
|
4811
|
+
// If it's a repeated and packable field then proto3 mandates it should be packed by
|
|
4812
|
+
// default
|
|
4813
|
+
if (
|
|
4814
|
+
this.ptr.syntax === 'proto3' &&
|
|
4815
|
+
this.ptr.repeated && this.ptr.options.packed === undefined &&
|
|
4816
|
+
ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType) !== -1
|
|
4817
|
+
) {
|
|
4818
|
+
this.ptr.options.packed = true;
|
|
4819
|
+
}
|
|
4820
|
+
|
|
4779
4821
|
} else if (this.ptr instanceof ProtoBuf.Reflect.Service.Method) {
|
|
4780
4822
|
|
|
4781
4823
|
if (this.ptr instanceof ProtoBuf.Reflect.Service.RPCMethod) {
|