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
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
{
|
|
2
|
-
"package": "js",
|
|
3
|
-
"messages": [
|
|
4
|
-
{
|
|
5
|
-
"name": "Value",
|
|
6
|
-
"fields": [
|
|
7
|
-
{
|
|
8
|
-
"rule": "optional",
|
|
9
|
-
"options": {},
|
|
10
|
-
"type": "sint32",
|
|
11
|
-
"name": "integer",
|
|
12
|
-
"id": 1,
|
|
13
|
-
"oneof": "type"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"rule": "optional",
|
|
17
|
-
"options": {},
|
|
18
|
-
"type": "double",
|
|
19
|
-
"name": "double",
|
|
20
|
-
"id": 2,
|
|
21
|
-
"oneof": "type"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"rule": "optional",
|
|
25
|
-
"options": {},
|
|
26
|
-
"type": "string",
|
|
27
|
-
"name": "string",
|
|
28
|
-
"id": 3,
|
|
29
|
-
"oneof": "type"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"rule": "optional",
|
|
33
|
-
"options": {},
|
|
34
|
-
"type": "bool",
|
|
35
|
-
"name": "boolean",
|
|
36
|
-
"id": 4,
|
|
37
|
-
"oneof": "type"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"rule": "optional",
|
|
41
|
-
"options": {},
|
|
42
|
-
"type": "bool",
|
|
43
|
-
"name": "null",
|
|
44
|
-
"id": 5,
|
|
45
|
-
"oneof": "type"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
"rule": "optional",
|
|
49
|
-
"options": {},
|
|
50
|
-
"type": "Array",
|
|
51
|
-
"name": "array",
|
|
52
|
-
"id": 6,
|
|
53
|
-
"oneof": "type"
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"rule": "optional",
|
|
57
|
-
"options": {},
|
|
58
|
-
"type": "Object",
|
|
59
|
-
"name": "object",
|
|
60
|
-
"id": 7,
|
|
61
|
-
"oneof": "type"
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
"enums": [],
|
|
65
|
-
"messages": [],
|
|
66
|
-
"options": {},
|
|
67
|
-
"oneofs": {
|
|
68
|
-
"type": [
|
|
69
|
-
1,
|
|
70
|
-
2,
|
|
71
|
-
3,
|
|
72
|
-
4,
|
|
73
|
-
5,
|
|
74
|
-
6,
|
|
75
|
-
7
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"name": "Array",
|
|
81
|
-
"fields": [
|
|
82
|
-
{
|
|
83
|
-
"rule": "repeated",
|
|
84
|
-
"options": {},
|
|
85
|
-
"type": "Value",
|
|
86
|
-
"name": "values",
|
|
87
|
-
"id": 1
|
|
88
|
-
}
|
|
89
|
-
],
|
|
90
|
-
"enums": [],
|
|
91
|
-
"messages": [],
|
|
92
|
-
"options": {},
|
|
93
|
-
"oneofs": {}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"name": "Object",
|
|
97
|
-
"fields": [
|
|
98
|
-
{
|
|
99
|
-
"rule": "repeated",
|
|
100
|
-
"options": {},
|
|
101
|
-
"type": "Value",
|
|
102
|
-
"name": "keys",
|
|
103
|
-
"id": 1
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"rule": "repeated",
|
|
107
|
-
"options": {},
|
|
108
|
-
"type": "Value",
|
|
109
|
-
"name": "values",
|
|
110
|
-
"id": 2
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
"enums": [],
|
|
114
|
-
"messages": [],
|
|
115
|
-
"options": {},
|
|
116
|
-
"oneofs": {}
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
"enums": [],
|
|
120
|
-
"imports": [],
|
|
121
|
-
"options": {},
|
|
122
|
-
"services": []
|
|
123
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"package": "js",
|
|
3
|
+
"messages": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Value",
|
|
6
|
+
"fields": [
|
|
7
|
+
{
|
|
8
|
+
"rule": "optional",
|
|
9
|
+
"options": {},
|
|
10
|
+
"type": "sint32",
|
|
11
|
+
"name": "integer",
|
|
12
|
+
"id": 1,
|
|
13
|
+
"oneof": "type"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"rule": "optional",
|
|
17
|
+
"options": {},
|
|
18
|
+
"type": "double",
|
|
19
|
+
"name": "double",
|
|
20
|
+
"id": 2,
|
|
21
|
+
"oneof": "type"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"rule": "optional",
|
|
25
|
+
"options": {},
|
|
26
|
+
"type": "string",
|
|
27
|
+
"name": "string",
|
|
28
|
+
"id": 3,
|
|
29
|
+
"oneof": "type"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"rule": "optional",
|
|
33
|
+
"options": {},
|
|
34
|
+
"type": "bool",
|
|
35
|
+
"name": "boolean",
|
|
36
|
+
"id": 4,
|
|
37
|
+
"oneof": "type"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"rule": "optional",
|
|
41
|
+
"options": {},
|
|
42
|
+
"type": "bool",
|
|
43
|
+
"name": "null",
|
|
44
|
+
"id": 5,
|
|
45
|
+
"oneof": "type"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"rule": "optional",
|
|
49
|
+
"options": {},
|
|
50
|
+
"type": "Array",
|
|
51
|
+
"name": "array",
|
|
52
|
+
"id": 6,
|
|
53
|
+
"oneof": "type"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"rule": "optional",
|
|
57
|
+
"options": {},
|
|
58
|
+
"type": "Object",
|
|
59
|
+
"name": "object",
|
|
60
|
+
"id": 7,
|
|
61
|
+
"oneof": "type"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"enums": [],
|
|
65
|
+
"messages": [],
|
|
66
|
+
"options": {},
|
|
67
|
+
"oneofs": {
|
|
68
|
+
"type": [
|
|
69
|
+
1,
|
|
70
|
+
2,
|
|
71
|
+
3,
|
|
72
|
+
4,
|
|
73
|
+
5,
|
|
74
|
+
6,
|
|
75
|
+
7
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "Array",
|
|
81
|
+
"fields": [
|
|
82
|
+
{
|
|
83
|
+
"rule": "repeated",
|
|
84
|
+
"options": {},
|
|
85
|
+
"type": "Value",
|
|
86
|
+
"name": "values",
|
|
87
|
+
"id": 1
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"enums": [],
|
|
91
|
+
"messages": [],
|
|
92
|
+
"options": {},
|
|
93
|
+
"oneofs": {}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "Object",
|
|
97
|
+
"fields": [
|
|
98
|
+
{
|
|
99
|
+
"rule": "repeated",
|
|
100
|
+
"options": {},
|
|
101
|
+
"type": "Value",
|
|
102
|
+
"name": "keys",
|
|
103
|
+
"id": 1
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"rule": "repeated",
|
|
107
|
+
"options": {},
|
|
108
|
+
"type": "Value",
|
|
109
|
+
"name": "values",
|
|
110
|
+
"id": 2
|
|
111
|
+
}
|
|
112
|
+
],
|
|
113
|
+
"enums": [],
|
|
114
|
+
"messages": [],
|
|
115
|
+
"options": {},
|
|
116
|
+
"oneofs": {}
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
"enums": [],
|
|
120
|
+
"imports": [],
|
|
121
|
+
"options": {},
|
|
122
|
+
"services": []
|
|
123
|
+
}
|
|
@@ -8,9 +8,9 @@ var http = require("http"),
|
|
|
8
8
|
|
|
9
9
|
// Copy dependencies to "www/" (example specific, you usually don't have to care
|
|
10
10
|
var deps = [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
["Long.min.js", "./node_modules/long/dist/Long.min.js"],
|
|
12
|
+
["ByteBufferAB.min.js", "./node_modules/bytebuffer/dist/ByteBufferAB.min.js"],
|
|
13
|
+
["ProtoBuf.min.js", "./node_modules/protobufjs/dist/ProtoBuf.min.js"]
|
|
14
14
|
];
|
|
15
15
|
for (var i=0, dep, data; i<deps.length; i++) {
|
|
16
16
|
dep = deps[i];
|
|
@@ -68,7 +68,7 @@ server.on("error", function(err) {
|
|
|
68
68
|
console.log("Failed to start server:", err);
|
|
69
69
|
process.exit(1);
|
|
70
70
|
});
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
// WebSocket adapter
|
|
73
73
|
var wss = new ws.Server({server: server});
|
|
74
74
|
wss.on("connection", function(socket) {
|
package/externs/protobuf.js
CHANGED
|
@@ -349,7 +349,7 @@ ProtoBuf.Reflect.Message.prototype.calculate = function(message) {};
|
|
|
349
349
|
/**
|
|
350
350
|
* @param {!ProtoBuf.Builder.Message} message
|
|
351
351
|
* @param {!ByteBuffer} buffer
|
|
352
|
-
* @param {
|
|
352
|
+
* @param {boolean} noVerify
|
|
353
353
|
* @return {!ByteBuffer}
|
|
354
354
|
* @throws {Error}
|
|
355
355
|
*/
|
package/jsdoc.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "protobufjs",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Protocol Buffers for JavaScript. Finally.",
|
|
5
5
|
"author": "Daniel Wirtz <dcode@dcode.io>",
|
|
6
6
|
"contributors": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"ascli": "~1",
|
|
32
32
|
"bytebuffer": "~5",
|
|
33
|
-
"glob": "^
|
|
33
|
+
"glob": "^7.0.5",
|
|
34
34
|
"yargs": "^3.10.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
package/scripts/build.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
|
|
3
|
-
|
|
4
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
you may not use this file except in compliance with the License.
|
|
6
|
-
You may obtain a copy of the License at
|
|
7
|
-
|
|
8
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
|
|
10
|
-
Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
See the License for the specific language governing permissions and
|
|
14
|
-
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
var MetaScript = require("metascript"),
|
|
18
|
-
path = require("path"),
|
|
19
|
-
fs = require("fs");
|
|
20
|
-
|
|
21
|
-
var rootDir = path.join(__dirname, ".."),
|
|
22
|
-
srcDir = path.join(rootDir, "src"),
|
|
23
|
-
distDir = path.join(rootDir, "dist"),
|
|
24
|
-
pkg = require(path.join(rootDir, "package.json")),
|
|
25
|
-
filename;
|
|
26
|
-
|
|
27
|
-
var scope = {
|
|
28
|
-
VERSION: pkg.version, // Version
|
|
29
|
-
DOTPROTO: true // Whether to include the ProtoBuf.DotProto package for .proto syntax support
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Make full build
|
|
33
|
-
console.log("Building protobuf.js with scope", JSON.stringify(scope, null, 2));
|
|
34
|
-
fs.writeFileSync(
|
|
35
|
-
path.join(distDir, "protobuf.js"),
|
|
36
|
-
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// Make light build
|
|
40
|
-
scope.DOTPROTO = false;
|
|
41
|
-
console.log("Building protobuf-light.js with scope", JSON.stringify(scope, null, 2));
|
|
42
|
-
fs.writeFileSync(
|
|
43
|
-
path.join(distDir, "protobuf-light.js"),
|
|
44
|
-
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// Update bower.json
|
|
48
|
-
scope = { VERSION: pkg.version };
|
|
49
|
-
console.log("Updating bower.json with scope", JSON.stringify(scope, null, 2));
|
|
50
|
-
fs.writeFileSync(
|
|
51
|
-
path.join(rootDir, "bower.json"),
|
|
52
|
-
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bower.json")), filename, scope, srcDir)
|
|
53
|
-
);
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2013 Daniel Wirtz <dcode@dcode.io>
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
var MetaScript = require("metascript"),
|
|
18
|
+
path = require("path"),
|
|
19
|
+
fs = require("fs");
|
|
20
|
+
|
|
21
|
+
var rootDir = path.join(__dirname, ".."),
|
|
22
|
+
srcDir = path.join(rootDir, "src"),
|
|
23
|
+
distDir = path.join(rootDir, "dist"),
|
|
24
|
+
pkg = require(path.join(rootDir, "package.json")),
|
|
25
|
+
filename;
|
|
26
|
+
|
|
27
|
+
var scope = {
|
|
28
|
+
VERSION: pkg.version, // Version
|
|
29
|
+
DOTPROTO: true // Whether to include the ProtoBuf.DotProto package for .proto syntax support
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Make full build
|
|
33
|
+
console.log("Building protobuf.js with scope", JSON.stringify(scope, null, 2));
|
|
34
|
+
fs.writeFileSync(
|
|
35
|
+
path.join(distDir, "protobuf.js"),
|
|
36
|
+
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Make light build
|
|
40
|
+
scope.DOTPROTO = false;
|
|
41
|
+
console.log("Building protobuf-light.js with scope", JSON.stringify(scope, null, 2));
|
|
42
|
+
fs.writeFileSync(
|
|
43
|
+
path.join(distDir, "protobuf-light.js"),
|
|
44
|
+
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Update bower.json
|
|
48
|
+
scope = { VERSION: pkg.version };
|
|
49
|
+
console.log("Updating bower.json with scope", JSON.stringify(scope, null, 2));
|
|
50
|
+
fs.writeFileSync(
|
|
51
|
+
path.join(rootDir, "bower.json"),
|
|
52
|
+
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "bower.json")), filename, scope, srcDir)
|
|
53
|
+
);
|
|
@@ -110,9 +110,11 @@ MessagePrototype.$add = MessagePrototype.add;
|
|
|
110
110
|
MessagePrototype.set = function(keyOrObj, value, noAssert) {
|
|
111
111
|
if (keyOrObj && typeof keyOrObj === 'object') {
|
|
112
112
|
noAssert = value;
|
|
113
|
-
for (var ikey in keyOrObj)
|
|
114
|
-
if
|
|
113
|
+
for (var ikey in keyOrObj) {
|
|
114
|
+
// Check if virtual oneof field - don't set these
|
|
115
|
+
if (keyOrObj.hasOwnProperty(ikey) && typeof (value = keyOrObj[ikey]) !== 'undefined' && T._oneofsByName[ikey] === undefined)
|
|
115
116
|
this.$set(ikey, value, noAssert);
|
|
117
|
+
}
|
|
116
118
|
return this;
|
|
117
119
|
}
|
|
118
120
|
var field = T._fieldsByName[keyOrObj];
|
|
@@ -576,10 +578,11 @@ Message.decode = function(buffer, length, enc) {
|
|
|
576
578
|
length = -1;
|
|
577
579
|
if (typeof buffer === 'string')
|
|
578
580
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
579
|
-
|
|
581
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
582
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
580
583
|
var le = buffer.littleEndian;
|
|
581
584
|
try {
|
|
582
|
-
var msg = T.decode(buffer.LE());
|
|
585
|
+
var msg = T.decode(buffer.LE(), length);
|
|
583
586
|
buffer.LE(le);
|
|
584
587
|
return msg;
|
|
585
588
|
} catch (e) {
|
|
@@ -602,7 +605,8 @@ Message.decode = function(buffer, length, enc) {
|
|
|
602
605
|
Message.decodeDelimited = function(buffer, enc) {
|
|
603
606
|
if (typeof buffer === 'string')
|
|
604
607
|
buffer = ByteBuffer.wrap(buffer, enc ? enc : "base64");
|
|
605
|
-
|
|
608
|
+
else if (!ByteBuffer.isByteBuffer(buffer))
|
|
609
|
+
buffer = ByteBuffer.wrap(buffer); // May throw
|
|
606
610
|
if (buffer.remaining() < 1)
|
|
607
611
|
return null;
|
|
608
612
|
var off = buffer.offset,
|
package/src/ProtoBuf/Builder.js
CHANGED
|
@@ -377,7 +377,11 @@ ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) {
|
|
|
377
377
|
root = require("path")['resolve'](root);
|
|
378
378
|
if (root.indexOf("\\") >= 0 || filename.file.indexOf("\\") >= 0)
|
|
379
379
|
delim = '\\';
|
|
380
|
-
var fname
|
|
380
|
+
var fname;
|
|
381
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
382
|
+
fname = require("path")['join'](root, filename.file);
|
|
383
|
+
else
|
|
384
|
+
fname = root + delim + filename.file;
|
|
381
385
|
if (this.files[fname] === true)
|
|
382
386
|
return this.reset();
|
|
383
387
|
this.files[fname] = true;
|
|
@@ -423,7 +427,10 @@ ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) {
|
|
|
423
427
|
var importFilename = json['imports'][i];
|
|
424
428
|
if (importFilename === "google/protobuf/descriptor.proto")
|
|
425
429
|
continue; // Not needed and therefore not used
|
|
426
|
-
|
|
430
|
+
if (ProtoBuf.Util.IS_NODE)
|
|
431
|
+
importFilename = require("path")['join'](importRoot, importFilename);
|
|
432
|
+
else
|
|
433
|
+
importFilename = importRoot + delim + importFilename;
|
|
427
434
|
if (this.files[importFilename] === true)
|
|
428
435
|
continue; // Already imported
|
|
429
436
|
if (/\.proto$/i.test(importFilename) && !ProtoBuf.DotProto) // If this is a light build
|
|
@@ -521,6 +528,16 @@ ProtoBuf.Builder = (function(ProtoBuf, Lang, Reflect) {
|
|
|
521
528
|
this.ptr.keyType = ProtoBuf.TYPES[this.ptr.keyType];
|
|
522
529
|
}
|
|
523
530
|
|
|
531
|
+
// If it's a repeated and packable field then proto3 mandates it should be packed by
|
|
532
|
+
// default
|
|
533
|
+
if (
|
|
534
|
+
this.ptr.syntax === 'proto3' &&
|
|
535
|
+
this.ptr.repeated && this.ptr.options.packed === undefined &&
|
|
536
|
+
ProtoBuf.PACKABLE_WIRE_TYPES.indexOf(this.ptr.type.wireType) !== -1
|
|
537
|
+
) {
|
|
538
|
+
this.ptr.options.packed = true;
|
|
539
|
+
}
|
|
540
|
+
|
|
524
541
|
} else if (this.ptr instanceof ProtoBuf.Reflect.Service.Method) {
|
|
525
542
|
|
|
526
543
|
if (this.ptr instanceof ProtoBuf.Reflect.Service.RPCMethod) {
|
|
@@ -428,7 +428,11 @@ ParserPrototype._parseMessage = function(parent, fld) {
|
|
|
428
428
|
else if (token === "service")
|
|
429
429
|
this._parseService(msg);
|
|
430
430
|
else if (token === "extensions")
|
|
431
|
-
msg
|
|
431
|
+
if (msg.hasOwnProperty("extensions")) {
|
|
432
|
+
msg["extensions"] = msg["extensions"].concat(this._parseExtensionRanges())
|
|
433
|
+
} else {
|
|
434
|
+
msg["extensions"] = this._parseExtensionRanges();
|
|
435
|
+
}
|
|
432
436
|
else if (token === "reserved")
|
|
433
437
|
this._parseIgnored(); // TODO
|
|
434
438
|
else if (token === "extend")
|
|
@@ -15,9 +15,11 @@
|
|
|
15
15
|
* converted to string form if so.
|
|
16
16
|
* @param {string} syntax Syntax level of defining message type, e.g.,
|
|
17
17
|
* proto2 or proto3.
|
|
18
|
+
* @param {string} name Name of the field containing this element (for error
|
|
19
|
+
* messages)
|
|
18
20
|
* @constructor
|
|
19
21
|
*/
|
|
20
|
-
var Element = function(type, resolvedType, isMapKey, syntax) {
|
|
22
|
+
var Element = function(type, resolvedType, isMapKey, syntax, name) {
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Element type, as a string (e.g., int32).
|
|
@@ -43,6 +45,12 @@ var Element = function(type, resolvedType, isMapKey, syntax) {
|
|
|
43
45
|
*/
|
|
44
46
|
this.syntax = syntax;
|
|
45
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Name of the field containing this element (for error messages)
|
|
50
|
+
* @type {string}
|
|
51
|
+
*/
|
|
52
|
+
this.name = name;
|
|
53
|
+
|
|
46
54
|
if (isMapKey && ProtoBuf.MAP_KEY_TYPES.indexOf(type) < 0)
|
|
47
55
|
throw Error("Invalid map key type: " + type.name);
|
|
48
56
|
};
|
|
@@ -93,6 +101,10 @@ function mkLong(value, unsigned) {
|
|
|
93
101
|
throw Error("not convertible to Long");
|
|
94
102
|
}
|
|
95
103
|
|
|
104
|
+
ElementPrototype.toString = function() {
|
|
105
|
+
return (this.name || '') + (this.isMapKey ? 'map' : 'value') + ' element';
|
|
106
|
+
}
|
|
107
|
+
|
|
96
108
|
/**
|
|
97
109
|
* Checks if the given value can be set for an element of this type (singular
|
|
98
110
|
* field or one element of a repeated field or map).
|
|
@@ -141,9 +141,9 @@ var FieldPrototype = Field.prototype = Object.create(T.prototype);
|
|
|
141
141
|
* @expose
|
|
142
142
|
*/
|
|
143
143
|
FieldPrototype.build = function() {
|
|
144
|
-
this.element = new Element(this.type, this.resolvedType, false, this.syntax);
|
|
144
|
+
this.element = new Element(this.type, this.resolvedType, false, this.syntax, this.name);
|
|
145
145
|
if (this.map)
|
|
146
|
-
this.keyElement = new Element(this.keyType, undefined, true, this.syntax);
|
|
146
|
+
this.keyElement = new Element(this.keyType, undefined, true, this.syntax, this.name);
|
|
147
147
|
|
|
148
148
|
// In proto3, fields do not have field presence, and every field is set to
|
|
149
149
|
// its type's default value ("", 0, 0.0, or false).
|
|
@@ -94,6 +94,7 @@ MessagePrototype.build = function(rebuild) {
|
|
|
94
94
|
this._fields = [];
|
|
95
95
|
this._fieldsById = {};
|
|
96
96
|
this._fieldsByName = {};
|
|
97
|
+
this._oneofsByName = {};
|
|
97
98
|
for (var i=0, k=this.children.length, child; i<k; i++) {
|
|
98
99
|
child = this.children[i];
|
|
99
100
|
if (child instanceof Enum || child instanceof Message || child instanceof Service) {
|
|
@@ -105,6 +106,9 @@ MessagePrototype.build = function(rebuild) {
|
|
|
105
106
|
this._fields.push(child),
|
|
106
107
|
this._fieldsById[child.id] = child,
|
|
107
108
|
this._fieldsByName[child.name] = child;
|
|
109
|
+
else if (child instanceof Message.OneOf) {
|
|
110
|
+
this._oneofsByName[child.name] = child;
|
|
111
|
+
}
|
|
108
112
|
else if (!(child instanceof Message.OneOf) && !(child instanceof Extension)) // Not built
|
|
109
113
|
throw Error("Illegal reflect child of "+this.toString(true)+": "+this.children[i].toString(true));
|
|
110
114
|
}
|
|
@@ -211,7 +215,8 @@ function skipTillGroupEnd(expectedId, buf) {
|
|
|
211
215
|
* @expose
|
|
212
216
|
*/
|
|
213
217
|
MessagePrototype.decode = function(buffer, length, expectedGroupEndId) {
|
|
214
|
-
|
|
218
|
+
if (typeof length !== 'number')
|
|
219
|
+
length = -1;
|
|
215
220
|
var start = buffer.offset,
|
|
216
221
|
msg = new (this.clazz)(),
|
|
217
222
|
tag, wireType, id, field;
|