This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathprotocol.js
More file actions
87 lines (76 loc) · 2.29 KB
/
Copy pathprotocol.js
File metadata and controls
87 lines (76 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var { Actor, ActorClassWithSpec } = require("./protocol/Actor");
var { Pool } = require("./protocol/Pool");
var {
types,
registeredTypes,
registerFront,
getFront,
} = require("./protocol/types");
var { method } = require("./protocol/utils");
var { Front } = require("./protocol/Front");
var { FrontClassWithSpec } = require("./protocol/Front/FrontClassWithSpec");
var { Arg, Option } = require("./protocol/Request");
const { RetVal } = require("./protocol/Response");
const { generateActorSpec } = require("./protocol/Actor/generateActorSpec");
exports.Front = Front;
exports.Pool = Pool;
exports.Actor = Actor;
exports.ActorClassWithSpec = ActorClassWithSpec;
exports.types = types;
exports.generateActorSpec = generateActorSpec;
exports.FrontClassWithSpec = FrontClassWithSpec;
exports.Arg = Arg;
exports.Option = Option;
exports.RetVal = RetVal;
exports.registerFront = registerFront;
exports.getFront = getFront;
exports.method = method;
exports.dumpActorSpec = function(type) {
const actorSpec = type.actorSpec;
const ret = {
category: "actor",
typeName: type.name,
methods: [],
events: {},
};
for (const _method of actorSpec.methods) {
ret.methods.push({
name: _method.name,
release: _method.release || undefined,
oneway: _method.oneway || undefined,
request: _method.request.describe(),
response: _method.response.describe(),
});
}
if (actorSpec.events) {
for (const [name, request] of actorSpec.events) {
ret.events[name] = request.describe();
}
}
JSON.stringify(ret);
return ret;
};
exports.dumpProtocolSpec = function() {
const ret = {
types: {},
};
for (let [name, type] of registeredTypes) {
// Force lazy instantiation if needed.
type = types.getType(name);
const category = type.category || undefined;
if (category === "dict") {
ret.types[name] = {
category: "dict",
typeName: name,
specializations: type.specializations,
};
} else if (category === "actor") {
ret.types[name] = exports.dumpActorSpec(type);
}
}
return ret;
};