2013-06-06 23:29:27 +04:00
|
|
|
/* 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";
|
|
|
|
|
2019-06-26 18:53:20 +03:00
|
|
|
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");
|
2013-06-06 23:29:27 +04:00
|
|
|
|
2019-06-26 18:53:20 +03:00
|
|
|
exports.Front = Front;
|
2013-06-06 23:29:27 +04:00
|
|
|
exports.Pool = Pool;
|
|
|
|
exports.Actor = Actor;
|
2016-08-22 17:25:57 +03:00
|
|
|
exports.ActorClassWithSpec = ActorClassWithSpec;
|
2019-06-26 18:53:20 +03:00
|
|
|
exports.types = types;
|
|
|
|
exports.generateActorSpec = generateActorSpec;
|
2016-08-22 17:25:57 +03:00
|
|
|
exports.FrontClassWithSpec = FrontClassWithSpec;
|
2019-06-26 18:53:20 +03:00
|
|
|
exports.Arg = Arg;
|
|
|
|
exports.Option = Option;
|
|
|
|
exports.RetVal = RetVal;
|
|
|
|
exports.registerFront = registerFront;
|
|
|
|
exports.getFront = getFront;
|
|
|
|
exports.method = method;
|
2018-12-11 19:32:41 +03:00
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
exports.dumpActorSpec = function(type) {
|
2018-06-01 13:36:09 +03:00
|
|
|
const actorSpec = type.actorSpec;
|
|
|
|
const ret = {
|
2014-04-18 03:25:07 +04:00
|
|
|
category: "actor",
|
|
|
|
typeName: type.name,
|
|
|
|
methods: [],
|
2018-10-19 15:55:39 +03:00
|
|
|
events: {},
|
2014-04-18 03:25:07 +04:00
|
|
|
};
|
|
|
|
|
2019-06-26 18:53:20 +03:00
|
|
|
for (const _method of actorSpec.methods) {
|
2014-04-18 03:25:07 +04:00
|
|
|
ret.methods.push({
|
2019-06-26 18:53:20 +03:00
|
|
|
name: _method.name,
|
|
|
|
release: _method.release || undefined,
|
|
|
|
oneway: _method.oneway || undefined,
|
|
|
|
request: _method.request.describe(),
|
|
|
|
response: _method.response.describe(),
|
2014-04-18 03:25:07 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actorSpec.events) {
|
2018-06-01 13:36:09 +03:00
|
|
|
for (const [name, request] of actorSpec.events) {
|
2014-04-18 03:25:07 +04:00
|
|
|
ret.events[name] = request.describe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
JSON.stringify(ret);
|
|
|
|
|
|
|
|
return ret;
|
2016-05-17 21:25:54 +03:00
|
|
|
};
|
2014-04-18 03:25:07 +04:00
|
|
|
|
2018-03-12 21:24:38 +03:00
|
|
|
exports.dumpProtocolSpec = function() {
|
2018-06-01 13:36:09 +03:00
|
|
|
const ret = {
|
2014-04-18 03:25:07 +04:00
|
|
|
types: {},
|
|
|
|
};
|
|
|
|
|
|
|
|
for (let [name, type] of registeredTypes) {
|
|
|
|
// Force lazy instantiation if needed.
|
|
|
|
type = types.getType(name);
|
2018-06-01 13:36:09 +03:00
|
|
|
const category = type.category || undefined;
|
2014-05-15 18:36:03 +04:00
|
|
|
if (category === "dict") {
|
2014-04-18 03:25:07 +04:00
|
|
|
ret.types[name] = {
|
|
|
|
category: "dict",
|
|
|
|
typeName: name,
|
2018-10-19 15:55:39 +03:00
|
|
|
specializations: type.specializations,
|
2016-05-17 21:25:54 +03:00
|
|
|
};
|
2014-05-15 18:36:03 +04:00
|
|
|
} else if (category === "actor") {
|
2014-04-18 03:25:07 +04:00
|
|
|
ret.types[name] = exports.dumpActorSpec(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2016-05-17 21:25:54 +03:00
|
|
|
};
|