summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/.babelrc9
-rw-r--r--js/.jshintrc4
-rwxr-xr-xjs/allTests.py1
-rw-r--r--js/bin/HttpServer.js35
-rw-r--r--js/gulp/bundle.js6
-rw-r--r--js/gulpfile.js212
-rw-r--r--js/package.json38
-rw-r--r--js/src/Ice/ACM.js189
-rw-r--r--js/src/Ice/Address.js16
-rw-r--r--js/src/Ice/ArrayUtil.js86
-rw-r--r--js/src/Ice/AsyncResult.js129
-rw-r--r--js/src/Ice/AsyncResultBase.js71
-rw-r--r--js/src/Ice/AsyncStatus.js4
-rw-r--r--js/src/Ice/Base64.js396
-rw-r--r--js/src/Ice/BatchRequestQueue.js61
-rw-r--r--js/src/Ice/Buffer.js398
-rw-r--r--js/src/Ice/Class.js55
-rw-r--r--js/src/Ice/Communicator.js161
-rw-r--r--js/src/Ice/CompactIdRegistry.js4
-rw-r--r--js/src/Ice/ConnectRequestHandler.js170
-rw-r--r--js/src/Ice/ConnectionI.js657
-rw-r--r--js/src/Ice/ConnectionRequestHandler.js41
-rw-r--r--js/src/Ice/Debug.js21
-rw-r--r--js/src/Ice/DefaultsAndOverrides.js201
-rw-r--r--js/src/Ice/DispatchStatus.js4
-rw-r--r--js/src/Ice/EndpointFactoryManager.js99
-rw-r--r--js/src/Ice/EndpointI.js46
-rw-r--r--js/src/Ice/EnumBase.js101
-rw-r--r--js/src/Ice/ExUtil.js8
-rw-r--r--js/src/Ice/Exception.js164
-rw-r--r--js/src/Ice/FormatType.js2
-rw-r--r--js/src/Ice/HashMap.js252
-rw-r--r--js/src/Ice/HashUtil.js34
-rw-r--r--js/src/Ice/IPEndpointI.js126
-rw-r--r--js/src/Ice/Ice.js5
-rw-r--r--js/src/Ice/IdentityUtil.js59
-rw-r--r--js/src/Ice/ImplicitContextI.js92
-rw-r--r--js/src/Ice/IncomingAsync.js146
-rw-r--r--js/src/Ice/Initialize.js12
-rw-r--r--js/src/Ice/Instance.js343
-rw-r--r--js/src/Ice/LocatorInfo.js276
-rw-r--r--js/src/Ice/LocatorManager.js40
-rw-r--r--js/src/Ice/LocatorTable.js94
-rw-r--r--js/src/Ice/Logger.js62
-rw-r--r--js/src/Ice/Long.js32
-rw-r--r--js/src/Ice/MapUtil.js51
-rw-r--r--js/src/Ice/ModuleRegistry.js39
-rw-r--r--js/src/Ice/Object.js265
-rw-r--r--js/src/Ice/ObjectAdapterFactory.js84
-rw-r--r--js/src/Ice/ObjectAdapterI.js393
-rw-r--r--js/src/Ice/ObjectFactory.js17
-rw-r--r--js/src/Ice/ObjectPrx.js859
-rw-r--r--js/src/Ice/OpaqueEndpointI.js186
-rw-r--r--js/src/Ice/Operation.js247
-rw-r--r--js/src/Ice/OptionalFormat.js2
-rw-r--r--js/src/Ice/OutgoingAsync.js346
-rw-r--r--js/src/Ice/OutgoingConnectionFactory.js703
-rw-r--r--js/src/Ice/ProcessLogger.js6
-rw-r--r--js/src/Ice/Promise.js295
-rw-r--r--js/src/Ice/Properties.js247
-rw-r--r--js/src/Ice/Property.js40
-rw-r--r--js/src/Ice/PropertyNames.js8
-rw-r--r--js/src/Ice/Protocol.js46
-rw-r--r--js/src/Ice/ProtocolInstance.js72
-rw-r--r--js/src/Ice/ProxyFactory.js106
-rw-r--r--js/src/Ice/Reference.js1258
-rw-r--r--js/src/Ice/ReferenceMode.js2
-rw-r--r--js/src/Ice/RequestHandlerFactory.js36
-rw-r--r--js/src/Ice/RetryException.js23
-rw-r--r--js/src/Ice/RetryQueue.js129
-rw-r--r--js/src/Ice/RouterInfo.js143
-rw-r--r--js/src/Ice/RouterManager.js44
-rw-r--r--js/src/Ice/ServantManager.js157
-rw-r--r--js/src/Ice/SocketOperation.js2
-rw-r--r--js/src/Ice/Stream.js1825
-rw-r--r--js/src/Ice/StreamHelpers.js149
-rw-r--r--js/src/Ice/StringUtil.js120
-rw-r--r--js/src/Ice/Struct.js64
-rw-r--r--js/src/Ice/TcpEndpointFactory.js47
-rw-r--r--js/src/Ice/TcpEndpointI.js126
-rw-r--r--js/src/Ice/TcpTransceiver.js237
-rw-r--r--js/src/Ice/Timer.js72
-rw-r--r--js/src/Ice/TimerUtil.js6
-rw-r--r--js/src/Ice/TraceLevels.js113
-rw-r--r--js/src/Ice/TraceUtil.js345
-rw-r--r--js/src/Ice/UUID.js8
-rw-r--r--js/src/Ice/UnknownSlicedValue.js111
-rw-r--r--js/src/Ice/ValueFactoryManagerI.js43
-rw-r--r--js/src/Ice/WSEndpoint.js118
-rw-r--r--js/src/Ice/WSEndpointFactory.js44
-rw-r--r--js/src/Ice/browser/Buffer.js419
-rw-r--r--js/src/Ice/browser/Debug.js27
-rw-r--r--js/src/Ice/browser/ModuleRegistry.js20
-rw-r--r--js/src/Ice/browser/TimerUtil.js179
-rw-r--r--js/src/Ice/browser/WSTransceiver.js188
-rw-r--r--js/src/Ice/sources.json5
-rw-r--r--js/test/Common/Common.js5
-rw-r--r--js/test/Common/TestCases.json8
-rw-r--r--js/test/Common/TestRunner.js76
-rw-r--r--js/test/Common/TestSuite.js22
-rw-r--r--js/test/Common/Worker.js21
-rw-r--r--js/test/Glacier2/router/Client.js65
-rw-r--r--js/test/Ice/acm/Client.js453
-rw-r--r--js/test/Ice/ami/Client.js291
-rw-r--r--js/test/Ice/binding/Client.js168
-rw-r--r--js/test/Ice/defaultValue/Client.js11
-rw-r--r--js/test/Ice/enums/Client.js76
-rw-r--r--js/test/Ice/exceptions/Client.js54
-rw-r--r--js/test/Ice/exceptionsBidir/AMDThrowerI.js86
-rw-r--r--js/test/Ice/exceptionsBidir/ThrowerI.js85
-rw-r--r--js/test/Ice/facets/Client.js70
-rw-r--r--js/test/Ice/facetsBidir/Client.js12
-rw-r--r--js/test/Ice/facetsBidir/TestI.js66
-rw-r--r--js/test/Ice/hashmap/Client.js253
-rw-r--r--js/test/Ice/hashmap/run.js10
-rwxr-xr-xjs/test/Ice/hashmap/run.py23
-rw-r--r--js/test/Ice/hold/Client.js9
-rw-r--r--js/test/Ice/info/Client.js9
-rw-r--r--js/test/Ice/inheritance/Client.js209
-rw-r--r--js/test/Ice/inheritanceBidir/InitialI.js181
-rw-r--r--js/test/Ice/location/Client.js152
-rw-r--r--js/test/Ice/number/Client.js3
-rw-r--r--js/test/Ice/objects/Client.js288
-rw-r--r--js/test/Ice/operations/BatchOneways.js106
-rw-r--r--js/test/Ice/operations/Client.js47
-rw-r--r--js/test/Ice/operations/Oneways.js35
-rw-r--r--js/test/Ice/operations/Twoways.js476
-rw-r--r--js/test/Ice/operationsBidir/AMDMyDerivedClassI.js459
-rw-r--r--js/test/Ice/operationsBidir/Client.js40
-rw-r--r--js/test/Ice/operationsBidir/MyDerivedClassI.js460
-rw-r--r--js/test/Ice/optional/Client.js369
-rw-r--r--js/test/Ice/optionalBidir/AMDInitialI.js224
-rw-r--r--js/test/Ice/optionalBidir/Client.js42
-rw-r--r--js/test/Ice/optionalBidir/InitialI.js225
-rw-r--r--js/test/Ice/promise/.gitignore1
-rw-r--r--js/test/Ice/promise/Client.js889
-rw-r--r--js/test/Ice/promise/run.js10
-rwxr-xr-xjs/test/Ice/promise/run.py24
-rw-r--r--js/test/Ice/properties/Client.js21
-rw-r--r--js/test/Ice/proxy/Client.js104
-rw-r--r--js/test/Ice/retry/Client.js68
-rw-r--r--js/test/Ice/slicing/exceptions/Client.js42
-rw-r--r--js/test/Ice/slicing/objects/Client.js164
-rw-r--r--js/test/Ice/timeout/Client.js227
144 files changed, 9810 insertions, 11963 deletions
diff --git a/js/.babelrc b/js/.babelrc
new file mode 100644
index 00000000000..ab1b412cc06
--- /dev/null
+++ b/js/.babelrc
@@ -0,0 +1,9 @@
+{
+
+"presets": ["babel-preset-es2015-script"],
+"plugins": [
+ ["babel-plugin-transform-builtin-extend", {
+ globals: ["Error", "Promise"]
+ }]
+ ]
+}
diff --git a/js/.jshintrc b/js/.jshintrc
index d7efda94bcf..f1969068d41 100644
--- a/js/.jshintrc
+++ b/js/.jshintrc
@@ -1,4 +1,5 @@
{
+ "esversion": 6,
"node": true,
"undef": true,
"evil": true,
@@ -10,6 +11,5 @@
"navigator": false,
"escape" : false,
"unescape": false
- },
- "predef": ["-Promise"]
+ }
}
diff --git a/js/allTests.py b/js/allTests.py
index 1e8d0afa7d4..88f600df599 100755
--- a/js/allTests.py
+++ b/js/allTests.py
@@ -45,7 +45,6 @@ tests = [
("Ice/operationsBidir", ["once"]),
("Ice/optional", ["core"]),
("Ice/optionalBidir", ["once"]),
- ("Ice/promise", ["once"]),
("Ice/properties", ["once"]),
("Ice/proxy", ["core"]),
("Ice/retry", ["core"]),
diff --git a/js/bin/HttpServer.js b/js/bin/HttpServer.js
index ae5ea56f674..12845731add 100644
--- a/js/bin/HttpServer.js
+++ b/js/bin/HttpServer.js
@@ -60,8 +60,11 @@ function Init()
var match = req.url.pathname.match("^\/test/(.*)/index\.html");
if(match)
{
+ var es5 = match[1].indexOf("/es5/") !== -1;
+ var m = es5 ? match[1].replace("/es5/", "/") : match[1];
+
// That is a test case
- var testCase = TestCases[match[1]];
+ var testCase = TestCases[m];
if(testCase === undefined)
{
res.writeHead(404);
@@ -70,7 +73,7 @@ function Init()
}
else
{
- TestData.current = match[1];
+ TestData.current = m;
if(req.url.query.next == "true")
{
var testCase = TestData.tests[0];
@@ -100,6 +103,11 @@ function Init()
protocol = "http";
}
+ if(es5)
+ {
+ testCase = testCase.replace("Ice/", "Ice/es5/");
+ }
+
var location = url.format(
{
protocol: protocol,
@@ -117,13 +125,30 @@ function Init()
{
if(req.url.query.worker != "true")
{
- TestData.scripts =
+ TestData.scripts = [];
+
+ if(es5)
+ {
+ TestData.scripts =
[
- "/lib/Ice.js",
+ "/node_modules/babel-polyfill/dist/polyfill.js",
+ "/node_modules/regenerator-runtime/runtime.js",
+ "/lib/es5/Ice.js",
"/test/Common/TestRunner.js",
"/test/Common/TestSuite.js",
- "/test/Common/Controller.js"
+ "/test/Common/es5/Controller.js"
].concat(testCase.files);
+ }
+ else
+ {
+ TestData.scripts =
+ [
+ "/lib/Ice.js",
+ "/test/Common/TestRunner.js",
+ "/test/Common/TestSuite.js",
+ "/test/Common/Controller.js"
+ ].concat(testCase.files);
+ }
}
else
{
diff --git a/js/gulp/bundle.js b/js/gulp/bundle.js
index df3763de5ba..b05ca2c9ea7 100644
--- a/js/gulp/bundle.js
+++ b/js/gulp/bundle.js
@@ -322,7 +322,7 @@ function bundle(args)
var sb = new StringBuffer();
sb.write(preamble);
- sb.write(" var __root = typeof(window) !== \"undefined\" ? window : self;\n");
+ sb.write(" var __root = typeof(window) !== \"undefined\" ? window : typeof(global) !== \"undefined\" ? global : typeof(self) !== \"undefined\" ? self : {};\n");
lineOffset += 3;
args.modules.forEach(
function(m){
@@ -378,7 +378,7 @@ function bundle(args)
// Get rid of require statements, the bundle include all required files,
// so require statements are not required.
//
- if(line.match(/var .* require\(".*"\).*;/))
+ if(line.match(/const .* require\(".*"\).*;/))
{
continue;
}
@@ -397,7 +397,7 @@ function bundle(args)
// Get rid of __M.module statements, in browser top level modules are
// global.
//
- if(line.match(/var .* = __M.module\(/))
+ if(line.match(/const .* = __M.module\(/))
{
if(line.lastIndexOf(";") === -1)
{
diff --git a/js/gulpfile.js b/js/gulpfile.js
index 4df32f9fbe0..f87294069b1 100644
--- a/js/gulpfile.js
+++ b/js/gulpfile.js
@@ -7,7 +7,8 @@
//
// **********************************************************************
-var bower = require("bower"),
+var babel = require("gulp-babel"),
+ bower = require("bower"),
bundle = require("./gulp/bundle"),
concat = require('gulp-concat'),
del = require("del"),
@@ -17,7 +18,7 @@ var bower = require("bower"),
gzip = require('gulp-gzip'),
iceBuilder = require('gulp-ice-builder'),
jshint = require('gulp-jshint'),
- minifycss = require('gulp-minify-css'),
+ cleancss = require('gulp-clean-css'),
newer = require('gulp-newer'),
open = require("gulp-open"),
path = require('path'),
@@ -121,17 +122,16 @@ gulp.task("common:slice", [],
.pipe(gulp.dest("test/Common"));
});
-gulp.task("common:slice:clean", [],
+gulp.task("common:slice-babel", ["common:slice"],
function(){
- del(["test/Common/Controller.js", "test/Common/.depend"]);
+ return gulp.src(["test/Common/Controller.js"])
+ .pipe(babel({compact: false}))
+ .pipe(gulp.dest("test/Common/es5"));
});
-gulp.task("common:slice:watch", ["common:slice"],
+gulp.task("common:slice:clean", [],
function(){
- gulp.watch(["test/Common/Controller.ice"],
- function(){
- gulp.start("common:slice");
- });
+ del(["test/Common/Controller.js", "test/Common/.depend", "test/Common/es5/Controller.js"]);
});
gulp.task("common:js", ["bower"],
@@ -139,48 +139,33 @@ gulp.task("common:js", ["bower"],
return gulp.src(common.scripts)
.pipe(newer("assets/common.min.js"))
.pipe(concat("common.min.js"))
- .pipe(uglify())
+ //.pipe(uglify()) // TODO: uglify doesn't support es6
.pipe(gulp.dest("assets"))
.pipe(gzip())
.pipe(gulp.dest("assets"));
});
-gulp.task("common:js:watch", ["common:js"],
- function(){
- gulp.watch(common.scripts,
- function(){
- gulp.start("common:js");
- });
- });
-
gulp.task("common:css", ["bower"],
function(){
return gulp.src(common.styles)
.pipe(newer("assets/common.css"))
.pipe(concat("common.css"))
- .pipe(minifycss())
+ .pipe(cleancss())
.pipe(gulp.dest("assets"))
.pipe(gzip())
.pipe(gulp.dest("assets"));
});
-gulp.task("common:css:watch", ["common:css"],
- function(){
- gulp.watch(common.styles,
- function(){
- gulp.start("common:css");
- });
- });
-
gulp.task("common:clean", [],
function(){
del(["assets/common.css", "assets/common.min.js"]);
});
-function testTask(name) { return name.replace("/", "_"); }
-function testWatchTask(name) { return testTask(name) + ":watch"; }
+function testTask(name) { return name.replace(/\//g, "_"); }
+function testBabelTask(name) { return testTask(name) + "-babel"; }
function testCleanDependTask(name) { return testTask(name) + "-depend:clean"; }
function testCleanTask(name) { return testTask(name) + ":clean"; }
+function testBabelCleanTask(name) { return testCleanTask(name) + "-babel"; }
tests.forEach(
function(name){
@@ -194,13 +179,13 @@ tests.forEach(
}))
.pipe(gulp.dest(name));
});
-
- gulp.task(testWatchTask(name), [testTask(name)],
+
+ gulp.task(testBabelTask(name), [testTask(name)],
function(){
- gulp.watch([path.join(name, "*.ice")], [testTask(name)]);
-
- gulp.watch(
- [path.join(name, "*.js"), path.join(name, "browser", "*.js")]);
+ return gulp.src([path.join(name, "*.js"), "!" + path.join(name, "run.js")])
+ .pipe(babel({compact: false}))
+ .pipe(gulp.dest(name.replace("test/Ice/", "test/Ice/es5/")
+ .replace("test/Glacier2/", "test/Glacier2/es5/")));
});
gulp.task(testCleanDependTask(name), [],
@@ -215,14 +200,20 @@ tests.forEach(
.pipe(extreplace(".js"))
.pipe(paths(del));
});
+
+ gulp.task(testBabelCleanTask(name), [testCleanTask(name)],
+ function(){
+ var s = name.replace("test/Ice/", "test/Ice/es5/")
+ .replace("test/Glacier2/", "test/Glacier2/es5/");
+
+ return gulp.src([path.join(s, "*.js"), "!" + path.join(s, "run.js")])
+ .pipe(paths(del));
+ });
});
-gulp.task("test", tests.map(testTask).concat(["common:slice", "common:js", "common:css"]));
+gulp.task("test", tests.map(testBabelTask).concat(["common:slice-babel", "common:js", "common:css"]));
-gulp.task("test:watch", tests.map(testWatchTask).concat(
- ["common:slice:watch", "common:css:watch", "common:js:watch"]));
-
-gulp.task("test:clean", tests.map(testCleanTask).concat(["common:slice:clean"]));
+gulp.task("test:clean", tests.map(testBabelCleanTask).concat(["common:slice:clean"]));
//
// Tasks to build IceJS Distribution
@@ -232,19 +223,31 @@ var libs = ["Ice", "Glacier2", "IceStorm", "IceGrid"];
function generateTask(name){ return name.toLowerCase() + ":generate"; }
function libTask(name){ return name.toLowerCase() + ":lib"; }
-function minLibTask(name){ return name.toLowerCase() + ":lib-min"; }
+function minLibTask(name){ return libTask(name) + "-min"; }
+function babelTask(name){ return name.toLowerCase() + ":babel"; }
+function babelLibTask(name){ return libTask(name) + "-babel";}
+function babelMinLibTask(name){ return libTask(name) + "-babel-min"; }
+
function libFile(name) { return path.join(root, "lib", name + ".js"); }
function libFileMin(name) { return path.join(root, "lib", name + ".min.js"); }
+
+function babelLibFile(name) { return path.join(root, "lib", "es5", name + ".js"); }
+function babelLibFileMin(name) { return path.join(root, "lib", "es5", name + ".min.js"); }
+
function srcDir(name) { return "src/" + name; }
function libCleanTask(lib) { return lib + ":clean"; }
-function libWatchTask(lib) { return lib + ":watch"; }
function libFiles(name){
return [
path.join(root, "lib", name + ".js"),
path.join(root, "lib", name + ".js.gz"),
path.join(root, "lib", name + ".min.js"),
- path.join(root, "lib", name + ".min.js.gz")];
+ path.join(root, "lib", name + ".min.js.gz"),
+
+ path.join(root, "lib", "es5", name + ".js"),
+ path.join(root, "lib", "es5", name + ".js.gz"),
+ path.join(root, "lib", "es5", name + ".min.js"),
+ path.join(root, "lib", "es5", name + ".min.js.gz")];
}
function mapFiles(name){
@@ -252,7 +255,12 @@ function mapFiles(name){
path.join(root, "lib", name + ".js.map"),
path.join(root, "lib", name + ".js.map.gz"),
path.join(root, "lib", name + ".min.js.map"),
- path.join(root, "lib", name + ".min.js.map.gz")];
+ path.join(root, "lib", name + ".min.js.map.gz"),
+
+ path.join(root, "lib", "es5", name + ".js.map"),
+ path.join(root, "lib", "es5", name + ".js.map.gz"),
+ path.join(root, "lib", "es5", name + ".min.js.map"),
+ path.join(root, "lib", "es5", name + ".min.js.map.gz")];
}
function libSources(lib, sources){
@@ -278,21 +286,12 @@ function libGeneratedFiles(lib, sources){
{
return path.join(srcDir(lib), path.basename(f, ".ice") + ".js");
})
+ .concat(path.join("src", "es5", lib, "*.js"))
.concat(libFiles(lib))
.concat(mapFiles(lib))
.concat([path.join(srcDir(lib), ".depend", "*")]);
}
-function watchSources(lib, sources){
- var srcs = sources.common || [];
- if(sources.browser){
- srcs = sources.common.concat(sources.browser); }
- srcs = srcs.map(
- function(f){
- return path.join(srcDir(lib), f); });
- return srcs;
-}
-
function sliceFile(f){ return path.join(sliceDir, f); }
libs.forEach(
@@ -328,19 +327,47 @@ libs.forEach(
return gulp.src(libFile(lib))
.pipe(newer(libFileMin(lib)))
.pipe(sourcemaps.init({loadMaps:true, sourceRoot:"./"}))
- .pipe(uglify({compress:false}))
+ //.pipe(uglify({compress:false})) // TODO: uglify doesn't support ES6
.pipe(extreplace(".min.js"))
.pipe(sourcemaps.write("../lib", {includeContent: false, addComment: false}))
.pipe(gulp.dest("lib"))
.pipe(gzip())
.pipe(gulp.dest("lib"));
});
+
+ gulp.task(babelTask(lib), [generateTask(lib)],
+ function(){
+ return gulp.src(path.join("src", lib, "*.js"))
+ .pipe(babel({compact:false}))
+ .pipe(gulp.dest(path.join("src", "es5", lib)));
+ });
- gulp.task(libCleanTask(lib), [], function(){ del(libGeneratedFiles(lib, sources)); });
- gulp.task(libWatchTask(lib), [minLibTask(lib)],
+ gulp.task(babelLibTask(lib), [libTask(lib)],
function(){
- gulp.watch(sources.slice.map(sliceFile).concat(watchSources(lib, sources)));
+ return gulp.src(libFile(lib))
+ .pipe(newer(babelLibFile(lib)))
+ .pipe(sourcemaps.init())
+ .pipe(babel({compact:false}))
+ .pipe(sourcemaps.write("."))
+ .pipe(gulp.dest("lib/es5"))
+ .pipe(gzip())
+ .pipe(gulp.dest("lib/es5"));
});
+
+ gulp.task(babelMinLibTask(lib), [babelLibTask(lib)],
+ function(){
+ return gulp.src(babelLibFile(lib))
+ .pipe(newer(babelLibFileMin(lib)))
+ .pipe(sourcemaps.init({loadMaps:true, sourceRoot:"./"}))
+ .pipe(uglify({compress:false}))
+ .pipe(extreplace(".min.js"))
+ .pipe(sourcemaps.write(".", {includeContent: false, addComment: false}))
+ .pipe(gulp.dest("lib/es5"))
+ .pipe(gzip())
+ .pipe(gulp.dest("lib/es5"));
+ });
+
+ gulp.task(libCleanTask(lib), [], function(){ del(libGeneratedFiles(lib, sources)); });
});
gulp.task("bower", [],
@@ -354,40 +381,47 @@ gulp.task("dist:libs", ["bower"],
.pipe(gulp.dest("lib"));
});
-gulp.task("dist", useBinDist ? ["dist:libs"] : libs.map(minLibTask));
-gulp.task("dist:watch", libs.map(libWatchTask));
+gulp.task("dist", useBinDist ? ["dist:libs"] : libs.map(minLibTask).concat(libs.map(babelMinLibTask)).concat(libs.map(babelTask)));
gulp.task("dist:clean", libs.map(libCleanTask));
-gulp.task("watch", ["test:watch"].concat(useBinDist ? [] : ["dist:watch"]));
-gulp.task("test:run-with-browser", ["watch"].concat(useBinDist ? ["test"] : ["build"]),
- function(){
- require("./bin/HttpServer")();
- var cmd = ["../scripts/TestController.py"];
- cmd = cmd.concat(process.argv.slice(3));
- var p = require("child_process").spawn("python", cmd, {stdio: "inherit"});
- p.on("error", function(err)
- {
- if(err.message == "spawn python ENOENT")
- {
- console.log("Error: python is required in PATH to run tests");
- process.exit(1);
- }
- else
- {
- throw err;
- }
- });
- process.on(process.platform == "win32" ? "SIGBREAK" : "SIGINT",
- function()
+function runTestsWithBrowser(url)
+{
+ require("./bin/HttpServer")();
+ var cmd = ["../scripts/TestController.py"];
+ cmd = cmd.concat(process.argv.slice(3));
+ var p = require("child_process").spawn("python", cmd, {stdio: "inherit"});
+ p.on("error", function(err)
+ {
+ if(err.message == "spawn python ENOENT")
{
- process.exit();
- });
- process.on("exit", function()
+ console.log("Error: python is required in PATH to run tests");
+ process.exit(1);
+ }
+ else
{
- p.kill();
- });
- return gulp.src("")
- .pipe(open({uri: "http://127.0.0.1:8080/test/Ice/acm/index.html"}));
+ throw err;
+ }
+ });
+ process.on(process.platform == "win32" ? "SIGBREAK" : "SIGINT",
+ function()
+ {
+ process.exit();
+ });
+ process.on("exit", function()
+ {
+ p.kill();
+ });
+ return gulp.src("").pipe(open({uri: url}));
+}
+
+gulp.task("test:run-with-browser", useBinDist ? ["test"] : ["build"],
+ function(url){
+ return runTestsWithBrowser("http://127.0.0.1:8080/test/Ice/acm/index.html");
+ });
+
+gulp.task("test:run-with-browser-es5", useBinDist ? ["test"] : ["build"],
+ function(url){
+ return runTestsWithBrowser("http://127.0.0.1:8080/test/Ice/es5/acm/index.html");
});
gulp.task("test:run-with-node", (useBinDist ? ["test"] : ["build"]),
@@ -434,6 +468,8 @@ gulp.task("lint:js", ["build"],
"src/**/*.js",
"src/**/browser/*.js",
"test/**/*.js",
+ "!src/es5/**/*.js",
+ "!test/**/es5/**/*.js",
"!**/Client.min.js"])
.pipe(jshint())
.pipe(jshint.reporter("default"));
diff --git a/js/package.json b/js/package.json
index 942e694bf46..040491aa750 100644
--- a/js/package.json
+++ b/js/package.json
@@ -15,27 +15,33 @@
],
"main": "src/ice.js",
"devDependencies": {
- "bower": "^1.4.1",
- "del": "^2.2.0",
- "esprima": "^2.2.0",
- "gulp": "^3.9.0",
- "gulp-concat": "^2.5.2",
+ "babel-cli": "^6.11.4",
+ "babel-plugin-transform-builtin-extend": "^1.1.0",
+ "babel-polyfill": "^6.13.0",
+ "babel-preset-es2015-script": "^1.0.0",
+ "bower": "^1.7.9",
+ "del": "^2.2.1",
+ "esprima": "^2.7.2",
+ "gulp": "^3.9.1",
+ "gulp-babel": "^6.1.2",
+ "gulp-concat": "^2.6.0",
"gulp-ext-replace": "^0.3.0",
"gulp-gzip": "^1.4.0",
"gulp-ice-builder": "^1.0.3",
- "gulp-jshint": "^2.0.0",
- "gulp-minify-css": "^1.2.3",
- "gulp-newer": "^1.1.0",
+ "gulp-jshint": "^2.0.1",
+ "gulp-clean-css": "^2.0.12",
+ "gulp-newer": "^1.2.0",
"gulp-open": "^2.0.0",
- "gulp-sourcemaps": "^1.5.2",
- "gulp-uglify": "^1.5.1",
- "gulp-util": "^3.0.5",
- "gulp-watch": "^4.2.4",
+ "gulp-sourcemaps": "^1.6.0",
+ "gulp-uglify": "^2.0.0",
+ "gulp-util": "^3.0.7",
+ "gulp-watch": "^4.3.9",
"hogan.js": "^3.0.2",
- "http-proxy": "^1.11.1",
- "jshint": "^2.8.0",
- "source-map": "^0.5.3",
- "through2": "^2.0.0",
+ "http-proxy": "^1.14.0",
+ "jshint": "^2.9.2",
+ "regenerator": "^0.8.46",
+ "source-map": "^0.5.6",
+ "through2": "^2.0.1",
"vinyl-paths": "^2.1.0"
},
"scripts": {
diff --git a/js/src/Ice/ACM.js b/js/src/Ice/ACM.js
index 2182e82b366..32a69d0d75e 100644
--- a/js/src/Ice/ACM.js
+++ b/js/src/Ice/ACM.js
@@ -7,14 +7,14 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/Debug", "../Ice/Connection", "../Ice/Debug"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/Debug", "../Ice/Connection"]);
-var Class = Ice.Class;
-var Debug = Ice.Debug;
+const Debug = Ice.Debug;
-var ACMConfig = Class({
- __init__: function(p, l, prefix, dflt)
+class ACMConfig
+{
+ constructor(p, l, prefix, dflt)
{
if(p === undefined)
{
@@ -24,7 +24,7 @@ var ACMConfig = Class({
return;
}
- var timeoutProperty;
+ let timeoutProperty;
if((prefix == "Ice.ACM.Client" || prefix == "Ice.ACM.Server") &&
p.getProperty(prefix + ".Timeout").length === 0)
{
@@ -37,7 +37,7 @@ var ACMConfig = Class({
this.timeout = p.getPropertyAsIntWithDefault(timeoutProperty, dflt.timeout / 1000) * 1000; // To ms
- var hb = p.getPropertyAsIntWithDefault(prefix + ".Heartbeat", dflt.heartbeat.value);
+ const hb = p.getPropertyAsIntWithDefault(prefix + ".Heartbeat", dflt.heartbeat.value);
if(hb >= 0 && hb <= Ice.ACMHeartbeat.maxValue)
{
this.heartbeat = Ice.ACMHeartbeat.valueOf(hb);
@@ -49,7 +49,7 @@ var ACMConfig = Class({
this.heartbeat = dflt.heartbeat;
}
- var cl = p.getPropertyAsIntWithDefault(prefix + ".Close", dflt.close.value);
+ const cl = p.getPropertyAsIntWithDefault(prefix + ".Close", dflt.close.value);
if(cl >= 0 && cl <= Ice.ACMClose.maxValue)
{
this.close = Ice.ACMClose.valueOf(cl);
@@ -61,42 +61,50 @@ var ACMConfig = Class({
this.close = dflt.close;
}
}
-});
+}
-var ACMMonitor = Class({
- add: function(con)
+class ACMMonitor
+{
+ add(con)
{
- Debug.assert(false); // Absract
- },
- remove: function(con)
+ Debug.assert(false); // Abstract
+ }
+
+ remove(con)
{
- Debug.assert(false); // Absract
- },
- reap: function(con)
+ Debug.assert(false); // Abstract
+ }
+
+ reap(con)
{
- Debug.assert(false); // Absract
- },
- acm: function(timeout)
+ Debug.assert(false); // Abstract
+ }
+
+ acm(timeout)
{
- Debug.assert(false); // Absract
+ Debug.assert(false); // Abstract
return null;
- },
- getACM: function()
+ }
+
+ getACM()
{
- Debug.assert(false); // Absract
+ Debug.assert(false); // Abstract
return 0;
}
-});
+}
-var FactoryACMMonitor = Class(ACMMonitor, {
- __init__: function(instance, config)
+class FactoryACMMonitor extends ACMMonitor
+{
+ constructor(instance, config)
{
+ super();
this._instance = instance;
this._config = config;
this._reapedConnections = [];
this._connections = [];
- },
- destroy: function()
+ }
+
+ destroy()
{
if(this._instance === null)
{
@@ -104,8 +112,9 @@ var FactoryACMMonitor = Class(ACMMonitor, {
}
this._instance = null;
this._connections = null;
- },
- add: function(connection)
+ }
+
+ add(connection)
{
if(this._config.timeout === 0)
{
@@ -115,40 +124,37 @@ var FactoryACMMonitor = Class(ACMMonitor, {
this._connections.push(connection);
if(this._connections.length == 1)
{
- var self = this;
this._timerToken = this._instance.timer().scheduleRepeated(
- function()
- {
- self.runTimerTask();
- },
- this._config.timeout / 2);
+ () => this.runTimerTask(), this._config.timeout / 2);
}
- },
- remove: function(connection)
+ }
+
+ remove(connection)
{
if(this._config.timeout === 0)
{
return;
}
- var i = this._connections.indexOf(connection);
+ let i = this._connections.indexOf(connection);
Debug.assert(i >= 0);
this._connections.splice(i, 1);
if(this._connections.length === 0)
{
this._instance.timer().cancel(this._timerToken);
- return;
}
- },
- reap: function(connection)
+ }
+
+ reap(connection)
{
this._reapedConnections.push(connection);
- },
- acm: function(timeout, close, heartbeat)
+ }
+
+ acm(timeout, close, heartbeat)
{
Debug.assert(this._instance !== null);
- var config = new ACMConfig();
+ let config = new ACMConfig();
config.timeout = this._config.timeout;
config.close = this._config.close;
config.heartbeat = this._config.heartbeat;
@@ -165,22 +171,25 @@ var FactoryACMMonitor = Class(ACMMonitor, {
config.heartbeat = heartbeat;
}
return new ConnectionACMMonitor(this, this._instance.timer(), config);
- },
- getACM: function()
+ }
+
+ getACM()
{
return new Ice.ACM(this._config.timeout / 1000, this._config.close, this._config.heartbeat);
- },
- swapReapedConnections: function()
+ }
+
+ swapReapedConnections()
{
if(this._reapedConnections.length === 0)
{
return null;
}
- var connections = this._reapedConnections;
+ let connections = this._reapedConnections;
this._reapedConnections = [];
return connections;
- },
- runTimerTask: function()
+ }
+
+ runTimerTask()
{
if(this._instance === null)
{
@@ -191,20 +200,22 @@ var FactoryACMMonitor = Class(ACMMonitor, {
// Monitor connections outside the thread synchronization, so
// that connections can be added or removed during monitoring.
//
- var now = Date.now();
- for(var i = 0; i < this._connections.length; i++)
- {
- try
- {
- this._connections[i].monitor(now, this._config);
- }
- catch(ex)
+ let now = Date.now();
+
+ this._connections.forEach(connection =>
{
- this.handleException(ex);
- }
- }
- },
- handleException: function(ex)
+ try
+ {
+ connection.monitor(now, this._config);
+ }
+ catch(ex)
+ {
+ this.handleException(ex);
+ }
+ });
+ }
+
+ handleException(ex)
{
if(this._instance === null)
{
@@ -212,28 +223,30 @@ var FactoryACMMonitor = Class(ACMMonitor, {
}
this._instance.initializationData().logger.error("exception in connection monitor:\n" + ex);
}
-});
+}
-var ConnectionACMMonitor = Class(ACMMonitor, {
- __init__: function(parent, timer, config)
+class ConnectionACMMonitor extends ACMMonitor
+{
+ constructor(parent, timer, config)
{
+ super();
this._parent = parent;
this._timer = timer;
this._config = config;
this._connection = null;
- },
- add: function(connection)
+ }
+
+ add(connection)
{
Debug.assert(this._connection === null);
this._connection = connection;
if(this._config.timeout > 0)
{
- var self = this;
- this._timerToken = this._timer.scheduleRepeated(function() { self.runTimerTask(); },
- this._config.timeout / 2);
+ this._timerToken = this._timer.scheduleRepeated(() => this.runTimerTask(), this._config.timeout / 2);
}
- },
- remove: function(connection)
+ }
+
+ remove(connection)
{
Debug.assert(this._connection === connection);
this._connection = null;
@@ -241,20 +254,24 @@ var ConnectionACMMonitor = Class(ACMMonitor, {
{
this._timer.cancel(this._timerToken);
}
- },
- reap: function(connection)
+ }
+
+ reap(connection)
{
this._parent.reap(connection);
- },
- acm: function(timeout, close, heartbeat)
+ }
+
+ acm(timeout, close, heartbeat)
{
return this._parent.acm(timeout, close, heartbeat);
- },
- getACM: function()
+ }
+
+ getACM()
{
return new Ice.ACM(this._config.timeout / 1000, this._config.close, this._config.heartbeat);
- },
- runTimerTask: function()
+ }
+
+ runTimerTask()
{
try
{
@@ -265,7 +282,7 @@ var ConnectionACMMonitor = Class(ACMMonitor, {
this._parent.handleException(ex);
}
}
-});
+}
Ice.FactoryACMMonitor = FactoryACMMonitor;
Ice.ACMConfig = ACMConfig;
diff --git a/js/src/Ice/Address.js b/js/src/Ice/Address.js
index d891a83bced..32377436131 100644
--- a/js/src/Ice/Address.js
+++ b/js/src/Ice/Address.js
@@ -8,10 +8,16 @@
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.Address = function(host, port)
+const Ice = require("../Ice/ModuleRegistry").Ice;
+
+class Address
{
- this.host = host;
- this.port = port;
-};
+ constructor(host, port)
+ {
+ this.host = host;
+ this.port = port;
+ }
+}
+
+Ice.Address = Address;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ArrayUtil.js b/js/src/Ice/ArrayUtil.js
index 16cc1ad79a1..d2e8b56b287 100644
--- a/js/src/Ice/ArrayUtil.js
+++ b/js/src/Ice/ArrayUtil.js
@@ -7,11 +7,11 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-var __M = Ice.__M;
-var Slice = Ice.Slice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
+const __M = Ice.__M;
+const Slice = Ice.Slice;
-var eq = function(e1, e2)
+const eq = function(e1, e2)
{
if(e1 === e2)
{
@@ -36,9 +36,9 @@ var eq = function(e1, e2)
return false;
};
-var ArrayUtil =
+class ArrayUtil
{
- clone: function(arr)
+ static clone(arr)
{
if(arr === undefined)
{
@@ -52,16 +52,17 @@ var ArrayUtil =
{
return arr.slice();
}
- },
- equals: function(v1, v2, valuesEqual)
+ }
+
+ static equals(v1, v2, valuesEqual)
{
if(v1.length != v2.length)
{
return false;
}
- var i, length, equalFn = valuesEqual || eq;
- for(i = 0, length = v1.length; i < length; ++i)
+ const equalFn = valuesEqual || eq;
+ for(let i = 0; i < v1.length; ++i)
{
if(!equalFn.call(equalFn, v1[i], v2[i]))
{
@@ -70,69 +71,36 @@ var ArrayUtil =
}
return true;
- },
- shuffle: function(arr)
+ }
+
+ static shuffle(arr)
{
- for(var i = arr.length; i > 1; --i)
+ for(let i = arr.length; i > 1; --i)
{
- var e = arr[i - 1];
- var rand = Math.floor(Math.random() * i);
+ let e = arr[i - 1];
+ let rand = Math.floor(Math.random() * i);
arr[i - 1] = arr[rand];
arr[rand] = e;
}
- },
- indexOf: function(arr, elem, equalFn)
- {
- if(equalFn !== undefined && equalFn !== null)
- {
- for(var i = 0; i < arr.length; ++i)
- {
- if(equalFn.call(equalFn, arr[i], elem))
- {
- return i;
- }
- }
- }
- else
- {
- return arr.indexOf(elem);
- }
-
- return -1;
- },
- filter: function(arr, includeFn, obj)
- {
- obj = obj === undefined ? includeFn : obj;
- var result = [];
- for(var i = 0; i < arr.length; ++i)
- {
- if(includeFn.call(obj, arr[i], i, arr))
- {
- result.push(arr[i]);
- }
- }
- return result;
}
-};
+}
ArrayUtil.eq = eq;
Slice.defineSequence = function(module, name, valueHelper, fixed, elementType)
{
- var helper = null;
+ let helper = null;
Object.defineProperty(module, name,
- {
- get: function()
- {
- if(helper === null)
+ {
+ get: function()
{
- /*jshint -W061 */
- helper = Ice.StreamHelpers.generateSeqHelper(__M.type(valueHelper), fixed, __M.type(elementType));
- /*jshint +W061 */
+ if(helper === null)
+ {
+ helper = Ice.StreamHelpers.generateSeqHelper(__M.type(valueHelper), fixed, __M.type(elementType));
+ }
+ return helper;
}
- return helper;
- }
- });
+ });
};
Ice.ArrayUtil = ArrayUtil;
diff --git a/js/src/Ice/AsyncResult.js b/js/src/Ice/AsyncResult.js
index 226148eb00d..489837740fd 100644
--- a/js/src/Ice/AsyncResult.js
+++ b/js/src/Ice/AsyncResult.js
@@ -7,69 +7,64 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/AsyncResultBase",
"../Ice/Debug",
- "../Ice/Promise",
"../Ice/Protocol",
"../Ice/Exception",
"../Ice/Stream"
]);
-var AsyncResultBase = Ice.AsyncResultBase;
-var Debug = Ice.Debug;
-var Promise = Ice.Promise;
-var Protocol = Ice.Protocol;
-var UserException = Ice.UserException;
-var OutputStream = Ice.OutputStream;
-
-var AsyncResult = Ice.Class(AsyncResultBase, {
- __init__: function(com, op, connection, proxy, adapter, completedFn)
- {
- //
- // AsyncResult can be constructed by a sub-type's prototype, in which case the
- // arguments are undefined.
- //
- AsyncResultBase.call(this, com, op, connection, proxy, adapter);
- if(com === undefined)
- {
- return;
- }
+const AsyncResultBase = Ice.AsyncResultBase;
+const Debug = Ice.Debug;
+const Protocol = Ice.Protocol;
+const UserException = Ice.UserException;
+const OutputStream = Ice.OutputStream;
+class AsyncResult extends AsyncResultBase
+{
+ constructor(com, op, connection, proxy, adapter, completedFn)
+ {
+ super(com, op, connection, proxy, adapter);
this._completed = completedFn;
this._is = null;
this._os = com !== null ? new OutputStream(this._instance, Protocol.currentProtocolEncoding) : null;
this._state = 0;
this._exception = null;
this._sentSynchronously = false;
- },
- cancel: function()
+ }
+
+ cancel()
{
this.__cancel(new Ice.InvocationCanceledException());
- },
- isCompleted: function()
+ }
+
+ isCompleted()
{
return (this._state & AsyncResult.Done) > 0;
- },
- isSent: function()
+ }
+
+ isSent()
{
return (this._state & AsyncResult.Sent) > 0;
- },
- throwLocalException: function()
+ }
+
+ throwLocalException()
{
if(this._exception !== null)
{
throw this._exception;
}
- },
- sentSynchronously: function()
+ }
+
+ sentSynchronously()
{
return this._sentSynchronously;
- },
- __markSent: function(done)
+ }
+
+ __markSent(done)
{
Debug.assert((this._state & AsyncResult.Done) === 0);
this._state |= AsyncResult.Sent;
@@ -77,10 +72,11 @@ var AsyncResult = Ice.Class(AsyncResultBase, {
{
this._state |= AsyncResult.Done | AsyncResult.OK;
this._cancellationHandler = null;
- this.succeed(this);
+ this.resolve();
}
- },
- __markFinished: function(ok, completed)
+ }
+
+ __markFinished(ok, completed)
{
Debug.assert((this._state & AsyncResult.Done) === 0);
this._state |= AsyncResult.Done;
@@ -95,26 +91,29 @@ var AsyncResult = Ice.Class(AsyncResultBase, {
}
else
{
- this.succeed(this);
+ this.resolve();
}
- },
- __markFinishedEx: function(ex)
+ }
+
+ __markFinishedEx(ex)
{
Debug.assert((this._state & AsyncResult.Done) === 0);
this._exception = ex;
this._state |= AsyncResult.Done;
this._cancellationHandler = null;
- this.fail(ex, this);
- },
- __cancel: function(ex)
+ this.reject(ex);
+ }
+
+ __cancel(ex)
{
this._cancellationException = ex;
if(this._cancellationHandler)
{
this._cancellationHandler.asyncRequestCanceled(this, ex);
}
- },
- __cancelable: function(handler)
+ }
+
+ __cancelable(handler)
{
if(this._cancellationException)
{
@@ -128,33 +127,40 @@ var AsyncResult = Ice.Class(AsyncResultBase, {
}
}
this._cancellationHandler = handler;
- },
- __os: function()
+ }
+
+ __os()
{
return this._os;
- },
- __is: function()
+ }
+
+ __is()
{
return this._is;
- },
- __startReadParams: function()
+ }
+
+ __startReadParams()
{
this._is.startEncapsulation();
return this._is;
- },
- __endReadParams: function()
+ }
+
+ __endReadParams()
{
this._is.endEncapsulation();
- },
- __readEmptyParams: function()
+ }
+
+ __readEmptyParams()
{
this._is.skipEmptyEncapsulation();
- },
- __readParamEncaps: function()
+ }
+
+ __readParamEncaps()
{
return this._is.readEncapsulation(null);
- },
- __throwUserException: function()
+ }
+
+ __throwUserException()
{
Debug.assert((this._state & AsyncResult.Done) !== 0);
if((this._state & AsyncResult.OK) === 0)
@@ -173,8 +179,9 @@ var AsyncResult = Ice.Class(AsyncResultBase, {
throw ex;
}
}
- },
-});
+ }
+
+}
AsyncResult.OK = 0x1;
AsyncResult.Done = 0x2;
diff --git a/js/src/Ice/AsyncResultBase.js b/js/src/Ice/AsyncResultBase.js
index 214578a93b7..d792f95fd8c 100644
--- a/js/src/Ice/AsyncResultBase.js
+++ b/js/src/Ice/AsyncResultBase.js
@@ -7,53 +7,46 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/Debug", "../Ice/Promise", "../Ice/Exception"]);
+const Ice = require("../Ice/Promise").Ice;
-var Promise = Ice.Promise;
-
-var AsyncResultBase = Ice.Class(Promise, {
- __init__: function(communicator, op, connection, proxy, adapter)
+class AsyncResultBase extends Ice.Promise
+{
+ constructor(communicator, op, connection, proxy, adapter)
{
- //
- // AsyncResultBase can be constructed by a sub-type's prototype, in which case the
- // arguments are undefined.
- //
- Promise.call(this);
- if(communicator !== undefined)
- {
- this._communicator = communicator;
- this._instance = communicator !== null ? communicator.instance : null;
- this._operation = op;
- this._connection = connection;
- this._proxy = proxy;
- this._adapter = adapter;
- }
+ super();
+ this._communicator = communicator;
+ this._instance = communicator !== null ? communicator.instance : null;
+ this._operation = op;
+ this._connection = connection;
+ this._proxy = proxy;
+ this._adapter = adapter;
}
-});
-
-var prototype = AsyncResultBase.prototype;
-var defineProperty = Object.defineProperty;
-defineProperty(prototype, "communicator", {
- get: function() { return this._communicator; }
-});
+ get communicator()
+ {
+ return this._communicator;
+ }
-defineProperty(prototype, "connection", {
- get: function() { return this._connection; }
-});
+ get connection()
+ {
+ return this._connection;
+ }
-defineProperty(prototype, "proxy", {
- get: function() { return this._proxy; }
-});
+ get proxy()
+ {
+ return this._proxy;
+ }
-defineProperty(prototype, "adapter", {
- get: function() { return this._adapter; }
-});
+ get adapter()
+ {
+ return this._adapter;
+ }
-defineProperty(prototype, "operation", {
- get: function() { return this._operation; }
-});
+ get operation()
+ {
+ return this._operation;
+ }
+}
Ice.AsyncResultBase = AsyncResultBase;
diff --git a/js/src/Ice/AsyncStatus.js b/js/src/Ice/AsyncStatus.js
index 6c1b397a8c3..4b970e48f1a 100644
--- a/js/src/Ice/AsyncStatus.js
+++ b/js/src/Ice/AsyncStatus.js
@@ -7,6 +7,6 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.AsyncStatus = {Queued: 0, Sent: 1};
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.AsyncStatus = { Queued: 0, Sent: 1 };
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Base64.js b/js/src/Ice/Base64.js
index 6211fd2c08d..1442ac5b371 100644
--- a/js/src/Ice/Base64.js
+++ b/js/src/Ice/Base64.js
@@ -7,265 +7,263 @@
//
// **********************************************************************
-var Ice = require("../Ice/Buffer").Ice;
+const Ice = require("../Ice/Buffer").Ice;
-var Buffer = Ice.Buffer;
+const Buffer = Ice.Buffer;
-var Base64 = {};
+const _codeA = "A".charCodeAt(0);
+const _codea = "a".charCodeAt(0);
+const _code0 = "0".charCodeAt(0);
-var _codeA = "A".charCodeAt(0);
-var _codea = "a".charCodeAt(0);
-var _code0 = "0".charCodeAt(0);
-
-Base64.encode = function(buf) // Expects native Buffer
+function encodeChar(uc)
{
- if(buf === null || buf.length === 0)
+ if(uc < 26)
{
- return "";
+ return String.fromCharCode(_codeA + uc);
}
- var base64Bytes = (((buf.length * 4) / 3) + 1);
- var newlineBytes = (((base64Bytes * 2) / 76) + 1);
- var totalBytes = base64Bytes + newlineBytes;
-
- var v = [];
-
- var by1;
- var by2;
- var by3;
- var by4;
- var by5;
- var by6;
- var by7;
-
- for(var i = 0; i < buf.length; i += 3)
+ if(uc < 52)
{
- by1 = buf[i] & 0xff;
- by2 = 0;
- by3 = 0;
-
- if((i + 1) < buf.length)
- {
- by2 = buf[i + 1] & 0xff;
- }
-
- if((i + 2) < buf.length)
- {
- by3 = buf[i + 2] & 0xff;
- }
-
- by4 = (by1 >> 2) & 0xff;
- by5 = (((by1 & 0x3) << 4) | (by2 >> 4)) & 0xff;
- by6 = (((by2 & 0xf) << 2) | (by3 >> 6)) & 0xff;
- by7 = by3 & 0x3f;
-
- v.push(encodeChar(by4));
- v.push(encodeChar(by5));
-
- if((i + 1) < buf.length)
- {
- v.push(encodeChar(by6));
- }
- else
- {
- v.push("=");
- }
-
- if((i + 2) < buf.length)
- {
- v.push(encodeChar(by7));
- }
- else
- {
- v.push("=");
- }
+ return String.fromCharCode(_codea + (uc - 26));
}
- var retval = v.join("");
- var outString = [];
- var iter = 0;
-
- while((retval.length - iter) > 76)
+ if(uc < 62)
{
- outString.push(retval.substring(iter, iter + 76));
- outString.push("\r\n");
- iter += 76;
+ return String.fromCharCode(_code0 + (uc - 52));
}
- outString.push(retval.substring(iter));
+ if(uc == 62)
+ {
+ return "+";
+ }
- return outString.join("");
-};
+ return "/";
+}
-Base64.decode = function(str) // Returns native Buffer
+function decodeChar(c)
{
- var newStr = [];
-
- for(var j = 0; j < str.length; j++)
+ if(c >= 'A' && c <= 'Z')
{
- var c = str.charAt(j);
- if(Base64.isBase64(c))
- {
- newStr.push(c);
- }
+ return c.charCodeAt(0) - _codeA;
}
- if(newStr.length === 0)
+ if(c >= 'a' && c <= 'z')
{
- return null;
+ return c.charCodeAt(0) - _codea + 26;
}
- // Note: This is how we were previously computing the size of the return
- // sequence. The method below is more efficient (and correct).
- // size_t lines = str.size() / 78;
- // size_t totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4);
-
- // Figure out how long the final sequence is going to be.
- var totalBytes = (newStr.length * 3 / 4) + 1;
-
- var retval = new Buffer();
- retval.resize(totalBytes);
-
- var by1;
- var by2;
- var by3;
- var by4;
-
- var c1;
- var c2;
- var c3;
- var c4;
-
- var off = 0;
+ if(c >= '0' && c <= '9')
+ {
+ return c.charCodeAt(0) - _code0 + 52;
+ }
- for(var i = 0; i < newStr.length; i += 4)
+ if(c == '+')
{
- c1 = "A";
- c2 = "A";
- c3 = "A";
- c4 = "A";
+ return 62;
+ }
- c1 = newStr[i];
+ return 63;
+}
- if((i + 1) < newStr.length)
+class Base64
+{
+ // Expects native Buffer
+ static encode(buf)
+ {
+ if(buf === null || buf.length === 0)
{
- c2 = newStr[i + 1];
+ return "";
}
- if((i + 2) < newStr.length)
+ let v = [];
+
+ let by1;
+ let by2;
+ let by3;
+ let by4;
+ let by5;
+ let by6;
+ let by7;
+
+ for(let i = 0; i < buf.length; i += 3)
{
- c3 = newStr[i + 2];
+ by1 = buf[i] & 0xff;
+ by2 = 0;
+ by3 = 0;
+
+ if((i + 1) < buf.length)
+ {
+ by2 = buf[i + 1] & 0xff;
+ }
+
+ if((i + 2) < buf.length)
+ {
+ by3 = buf[i + 2] & 0xff;
+ }
+
+ by4 = (by1 >> 2) & 0xff;
+ by5 = (((by1 & 0x3) << 4) | (by2 >> 4)) & 0xff;
+ by6 = (((by2 & 0xf) << 2) | (by3 >> 6)) & 0xff;
+ by7 = by3 & 0x3f;
+
+ v.push(encodeChar(by4));
+ v.push(encodeChar(by5));
+
+ if((i + 1) < buf.length)
+ {
+ v.push(encodeChar(by6));
+ }
+ else
+ {
+ v.push("=");
+ }
+
+ if((i + 2) < buf.length)
+ {
+ v.push(encodeChar(by7));
+ }
+ else
+ {
+ v.push("=");
+ }
}
- if((i + 3) < newStr.length)
+ let retval = v.join("");
+ let outString = [];
+ let iter = 0;
+
+ while((retval.length - iter) > 76)
{
- c4 = newStr[i + 3];
+ outString.push(retval.substring(iter, iter + 76));
+ outString.push("\r\n");
+ iter += 76;
}
- by1 = decodeChar(c1) & 0xff;
- by2 = decodeChar(c2) & 0xff;
- by3 = decodeChar(c3) & 0xff;
- by4 = decodeChar(c4) & 0xff;
+ outString.push(retval.substring(iter));
+
+ return outString.join("");
+ }
- retval.put((by1 << 2) | (by2 >> 4));
+ static decode(str) // Returns native Buffer
+ {
+ let newStr = [];
- if(c3 != "=")
+ for(let j = 0; j < str.length; j++)
{
- retval.put(((by2 & 0xf) << 4) | (by3 >> 2));
+ let c = str.charAt(j);
+ if(Base64.isBase64(c))
+ {
+ newStr.push(c);
+ }
}
- if(c4 != "=")
+ if(newStr.length === 0)
{
- retval.put(((by3 & 0x3) << 6) | by4);
+ return null;
}
- }
- return retval.remaining > 0 ? retval.getArrayAt(0, retval.position) : retval.getArrayAt(0);
-};
+ // Note: This is how we were previously computing the size of the return
+ // sequence. The method below is more efficient (and correct).
+ // size_t lines = str.size() / 78;
+ // size_t totalBytes = (lines * 76) + (((str.size() - (lines * 78)) * 3) / 4);
-Base64.isBase64 = function(c)
-{
- if(c >= 'A' && c <= 'Z')
- {
- return true;
- }
+ // Figure out how long the final sequence is going to be.
+ let totalBytes = (newStr.length * 3 / 4) + 1;
- if(c >= 'a' && c <= 'z')
- {
- return true;
- }
+ let retval = new Buffer();
+ retval.resize(totalBytes);
- if(c >= '0' && c <= '9')
- {
- return true;
- }
+ let by1;
+ let by2;
+ let by3;
+ let by4;
- if(c == '+')
- {
- return true;
- }
-
- if(c == '/')
- {
- return true;
- }
-
- if(c == '=')
- {
- return true;
- }
+ let c1;
+ let c2;
+ let c3;
+ let c4;
- return false;
-};
+ let off = 0;
-function encodeChar(uc)
-{
- if(uc < 26)
- {
- return String.fromCharCode(_codeA + uc);
- }
+ for(let i = 0; i < newStr.length; i += 4)
+ {
+ c1 = "A";
+ c2 = "A";
+ c3 = "A";
+ c4 = "A";
+
+ c1 = newStr[i];
+
+ if((i + 1) < newStr.length)
+ {
+ c2 = newStr[i + 1];
+ }
+
+ if((i + 2) < newStr.length)
+ {
+ c3 = newStr[i + 2];
+ }
+
+ if((i + 3) < newStr.length)
+ {
+ c4 = newStr[i + 3];
+ }
+
+ by1 = decodeChar(c1) & 0xff;
+ by2 = decodeChar(c2) & 0xff;
+ by3 = decodeChar(c3) & 0xff;
+ by4 = decodeChar(c4) & 0xff;
+
+ retval.put((by1 << 2) | (by2 >> 4));
+
+ if(c3 != "=")
+ {
+ retval.put(((by2 & 0xf) << 4) | (by3 >> 2));
+ }
+
+ if(c4 != "=")
+ {
+ retval.put(((by3 & 0x3) << 6) | by4);
+ }
+ }
- if(uc < 52)
- {
- return String.fromCharCode(_codea + (uc - 26));
+ return retval.remaining > 0 ? retval.getArrayAt(0, retval.position) : retval.getArrayAt(0);
}
- if(uc < 62)
+ static isBase64(c)
{
- return String.fromCharCode(_code0 + (uc - 52));
- }
+ if(c >= 'A' && c <= 'Z')
+ {
+ return true;
+ }
- if(uc == 62)
- {
- return "+";
- }
+ if(c >= 'a' && c <= 'z')
+ {
+ return true;
+ }
- return "/";
-}
+ if(c >= '0' && c <= '9')
+ {
+ return true;
+ }
-function decodeChar(c)
-{
- if(c >= 'A' && c <= 'Z')
- {
- return c.charCodeAt(0) - _codeA;
- }
+ if(c == '+')
+ {
+ return true;
+ }
- if(c >= 'a' && c <= 'z')
- {
- return c.charCodeAt(0) - _codea + 26;
- }
+ if(c == '/')
+ {
+ return true;
+ }
- if(c >= '0' && c <= '9')
- {
- return c.charCodeAt(0) - _code0 + 52;
- }
+ if(c == '=')
+ {
+ return true;
+ }
- if(c == '+')
- {
- return 62;
+ return false;
}
-
- return 63;
}
Ice.Base64 = Base64;
diff --git a/js/src/Ice/BatchRequestQueue.js b/js/src/Ice/BatchRequestQueue.js
index deab2209be5..cfc965763e4 100644
--- a/js/src/Ice/BatchRequestQueue.js
+++ b/js/src/Ice/BatchRequestQueue.js
@@ -7,26 +7,25 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Stream",
"../Ice/Debug",
"../Ice/ExUtil",
"../Ice/Protocol",
]);
-var OutputStream = Ice.OutputStream;
-var Debug = Ice.Debug;
-var ExUtil = Ice.ExUtil;
-var Class = Ice.Class;
-var Protocol = Ice.Protocol;
+const OutputStream = Ice.OutputStream;
+const Debug = Ice.Debug;
+const ExUtil = Ice.ExUtil;
+const Protocol = Ice.Protocol;
-var udpOverhead = 20 + 8;
+const udpOverhead = 20 + 8;
-var BatchRequestQueue = Class({
- __init__: function(instance, datagram)
+class BatchRequestQueue
+{
+ constructor(instance, datagram)
{
this._batchStreamInUse = false;
this._batchRequestNum = 0;
@@ -38,23 +37,25 @@ var BatchRequestQueue = Class({
this._maxSize = instance.batchAutoFlushSize();
if(this._maxSize > 0 && datagram)
{
- var props = instance.initializationData().properties;
- var udpSndSize = props.getPropertyAsIntWithDefault("Ice.UDP.SndSize", 65535 - udpOverhead);
+ const udpSndSize = instance.initializationData().properties.getPropertyAsIntWithDefault(
+ "Ice.UDP.SndSize", 65535 - udpOverhead);
if(udpSndSize < this._maxSize)
{
this._maxSize = udpSndSize;
}
}
- },
- prepareBatchRequest: function(os)
+ }
+
+ prepareBatchRequest(os)
{
if(this._exception)
{
throw this._exception;
}
this._batchStream.swap(os);
- },
- finishBatchRequest: function(os, proxy, operation)
+ }
+
+ finishBatchRequest(os, proxy, operation)
{
//
// No need for synchronization, no other threads are supposed
@@ -77,29 +78,31 @@ var BatchRequestQueue = Class({
{
this._batchStream.resize(this._batchMarker);
}
- },
- abortBatchRequest: function(os)
+ }
+
+ abortBatchRequest(os)
{
this._batchStream.swap(os);
this._batchStream.resize(this._batchMarker);
- },
- swap: function(os)
+ }
+
+ swap(os)
{
if(this._batchRequestNum === 0)
{
return 0;
}
- var lastRequest = null;
+ let lastRequest = null;
if(this._batchMarker < this._batchStream.size)
{
- var length = this._batchStream.size - this._batchMarker;
+ const length = this._batchStream.size - this._batchMarker;
this._batchStream.pos = this._batchMarker;
lastRequest = this._batchStream.buffer.getArray(length);
this._batchStream.resize(this._batchMarker);
}
- var requestNum = this._batchRequestNum;
+ const requestNum = this._batchRequestNum;
this._batchStream.swap(os);
//
@@ -113,16 +116,18 @@ var BatchRequestQueue = Class({
this._batchStream.writeBlob(lastRequest);
}
return requestNum;
- },
- destroy: function(ex)
+ }
+
+ destroy(ex)
{
this._exception = ex;
- },
- isEmpty: function()
+ }
+
+ isEmpty()
{
return this._batchStream.size === Protocol.requestBatchHdr.length;
}
-});
+}
Ice.BatchRequestQueue = BatchRequestQueue;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Buffer.js b/js/src/Ice/Buffer.js
index 51aa610150d..e652ea3732e 100644
--- a/js/src/Ice/Buffer.js
+++ b/js/src/Ice/Buffer.js
@@ -7,46 +7,42 @@
//
// **********************************************************************
-//
-// Ice.Buffer implementation to be used by Node.js, it uses node Buffer
-// as the store.
-//
+const Ice = require("../Ice/Long").Ice;
+const Long = Ice.Long;
+
+const __BufferOverflowException__ = "BufferOverflowException";
+const __BufferUnderflowException__ = "BufferUnderflowException";
+const __IndexOutOfBoundsException__ = "IndexOutOfBoundsException";
//
-// Define Node.Buffer as an alias to NodeJS global Buffer type,
-// that allow us to refer to Ice.Buffer as Buffer in this file.
+// Buffer implementation to be used by web browsers, it uses ArrayBuffer as
+// the store.
//
-var Node = { Buffer: global.Buffer };
-
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Long", "../Ice/Class"]);
-
-var Long = Ice.Long;
-
-var __BufferOverflowException__ = "BufferOverflowException";
-var __BufferUnderflowException__ = "BufferUnderflowException";
-var __IndexOutOfBoundsException__ = "IndexOutOfBoundsException";
-
-var Buffer = Ice.Class({
- __init__: function(buffer)
+class Buffer
+{
+ constructor(buffer)
{
if(buffer !== undefined)
{
this.b = buffer;
+ this.v = new DataView(this.b);
}
else
{
- this.b = null;
+ this.b = null; // ArrayBuffer
+ this.v = null; // DataView
}
this._position = 0;
this._limit = 0;
this._shrinkCounter = 0;
- },
- empty: function()
+ }
+
+ empty()
{
return this._limit === 0;
- },
- resize: function(n)
+ }
+
+ resize(n)
{
if(n === 0)
{
@@ -57,28 +53,32 @@ var Buffer = Ice.Class({
this.reserve(n);
}
this._limit = n;
- },
- clear: function()
+ }
+
+ clear()
{
this.b = null;
+ this.v = null;
this._position = 0;
this._limit = 0;
- },
+ }
+
//
// Call expand(n) to add room for n additional bytes. Note that expand()
// examines the current position of the buffer first; we don't want to
// expand the buffer if the caller is writing to a location that is
// already in the buffer.
//
- expand: function(n)
+ expand(n)
{
var sz = this.capacity === 0 ? n : this._position + n;
if(sz > this._limit)
{
this.resize(sz);
}
- },
- reset: function()
+ }
+
+ reset()
{
if(this._limit > 0 && this._limit * 2 < this.capacity)
{
@@ -100,331 +100,333 @@ var Buffer = Ice.Class({
}
this._limit = 0;
this._position = 0;
- },
- reserve: function(n)
+ }
+
+ reserve(n)
{
- var b, capacity;
if(n > this.capacity)
{
- capacity = Math.max(n, 2 * this.capacity);
+ var capacity = Math.max(n, 2 * this.capacity);
capacity = Math.max(1024, capacity);
- if(this.b === null)
+ if(!this.b)
{
- this.b = new Node.Buffer(capacity);
+ this.b = new ArrayBuffer(capacity);
}
else
{
- b = new Node.Buffer(capacity);
- this.b.copy(b);
- this.b = b;
+ var b = new Uint8Array(capacity);
+ b.set(new Uint8Array(this.b));
+ this.b = b.buffer;
}
+ this.v = new DataView(this.b);
}
else if(n < this.capacity)
{
this.b = this.b.slice(0, this.capacity);
+ this.v = new DataView(this.b);
}
else
{
return;
}
- },
- put: function(v)
+ }
+
+ put(v)
{
if(this._position === this._limit)
{
throw new Error(__BufferOverflowException__);
}
- this.b.writeUInt8(v, this._position, true);
+ this.v.setUint8(this._position, v);
this._position++;
- },
- putAt: function(i, v)
+ }
+
+ putAt(i, v)
{
if(i >= this._limit)
{
throw new Error(__IndexOutOfBoundsException__);
}
- this.b.writeUInt8(v, i, true);
- },
- putArray: function(v)
+ this.v.setUint8(i, v);
+ }
+
+ putArray(v)
{
- //Expects a Nodejs Buffer
- if(!Node.Buffer.isBuffer(v))
+ //Expects an Uint8Array
+ if(!(v instanceof Uint8Array))
{
- throw new TypeError("argument is not a Node.Buffer");
+ throw new TypeError('argument is not a Uint8Array');
}
- if(this._position + v.length > this._limit)
+ if(v.byteLength > 0)
{
- throw new Error(__BufferOverflowException__);
+ if(this._position + v.length > this._limit)
+ {
+ throw new Error(__BufferOverflowException__);
+ }
+ new Uint8Array(this.b, 0, this.b.byteLength).set(v, this._position);
+ this._position += v.byteLength;
}
- v.copy(this.b, this._position);
- this._position += v.length;
- },
- putShort: function(v)
+ }
+
+ putShort(v)
{
if(this._position + 2 > this._limit)
{
throw new Error(__BufferOverflowException__);
}
- this.b.writeInt16LE(v, this._position, true);
+ this.v.setInt16(this._position, v, true);
this._position += 2;
- },
- putShortAt: function(i, v)
- {
- if(i + 2 > this._limit || i < 0)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- this.b.writeInt16LE(v, i, true);
- },
- putInt: function(v)
+ }
+
+ putInt(v)
{
if(this._position + 4 > this._limit)
{
throw new Error(__BufferOverflowException__);
}
- this.b.writeInt32LE(v, this._position, true);
+ this.v.setInt32(this._position, v, true);
this._position += 4;
- },
- putIntAt: function(i, v)
+ }
+
+ putIntAt(i, v)
{
if(i + 4 > this._limit || i < 0)
{
throw new Error(__IndexOutOfBoundsException__);
}
- this.b.writeInt32LE(v, i, true);
- },
- putFloat: function(v)
+ this.v.setInt32(i, v, true);
+ }
+
+ putFloat(v)
{
if(this._position + 4 > this._limit)
{
throw new Error(__BufferOverflowException__);
}
- this.b.writeFloatLE(v, this._position, true);
+ this.v.setFloat32(this._position, v, true);
this._position += 4;
- },
- putFloatAt: function(i, v)
- {
- if(i + 4 > this._limit || i < 0)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- this.b.writeFloatLE(v, i, true);
- },
- putDouble: function(v)
+ }
+
+ putDouble(v)
{
if(this._position + 8 > this._limit)
{
throw new Error(__BufferOverflowException__);
}
- this.b.writeDoubleLE(v, this._position, true);
+ this.v.setFloat64(this._position, v, true);
this._position += 8;
- },
- putDoubleAt: function(i, v)
- {
- if(i + 8 > this._limit || i < 0)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- this.b.writeDoubleLE(v, i, true);
- },
- putLong: function(v)
+ }
+
+ putLong(v)
{
if(this._position + 8 > this._limit)
{
throw new Error(__BufferOverflowException__);
}
- this.b.writeUInt32LE(v.low, this._position, true);
+ this.v.setInt32(this._position, v.low, true);
this._position += 4;
- this.b.writeUInt32LE(v.high, this._position, true);
+ this.v.setInt32(this._position, v.high, true);
this._position += 4;
- },
- putLongAt: function(i, v)
- {
- if(i + 8 > this._limit || i < 0)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- this.b.writeUInt32LE(v.low, i, true);
- this.b.writeUInt32LE(v.high, i + 4, true);
- },
- writeString: function(stream, v)
+ }
+
+ writeString(stream, v)
{
- var sz = Node.Buffer.byteLength(v);
- stream.writeSize(sz);
- stream.expand(sz);
- this.putString(v, sz);
- },
- putString: function(v, sz)
+ //
+ // Encode the string as utf8
+ //
+ var encoded = unescape(encodeURIComponent(v));
+
+ stream.writeSize(encoded.length);
+ stream.expand(encoded.length);
+ this.putString(encoded, encoded.length);
+ }
+
+ putString(v, sz)
{
if(this._position + sz > this._limit)
{
throw new Error(__BufferOverflowException__);
}
- var bytes = this.b.write(v, this._position);
- //
- // Check all bytes were written
- //
- if(bytes < sz)
+ for(var i = 0; i < sz; ++i)
{
- throw new Error(__IndexOutOfBoundsException__);
+ this.v.setUint8(this._position, v.charCodeAt(i));
+ this._position++;
}
- this._position += sz;
- },
- get: function()
+ }
+
+ get()
{
if(this._position >= this._limit)
{
throw new Error(__BufferUnderflowException__);
}
- var v = this.b.readUInt8(this._position, true);
+ var v = this.v.getUint8(this._position);
this._position++;
return v;
- },
- getAt: function(i)
+ }
+
+ getAt(i)
{
if(i < 0 || i >= this._limit)
{
throw new Error(__IndexOutOfBoundsException__);
}
- return this.b.readUInt8(i, true);
- },
- getArray: function(length)
+ return this.v.getUint8(i);
+ }
+
+ getArray(length)
{
if(this._position + length > this._limit)
{
throw new Error(__BufferUnderflowException__);
}
- var buffer = new Node.Buffer(length);
- this.b.slice(this._position, this._position + length).copy(buffer);
+ var buffer = this.b.slice(this._position, this._position + length);
this._position += length;
- return buffer;
- },
- getArrayAt: function(position, length)
+ return new Uint8Array(buffer);
+ }
+
+ getArrayAt(position, length)
{
if(position + length > this._limit)
{
throw new Error(__BufferUnderflowException__);
}
- length = length === undefined ? (this.b.length - position) : length;
- var buffer = new Node.Buffer(length);
- this.b.slice(position, position + length).copy(buffer);
- return buffer;
- },
- getShort: function()
+ length = length === undefined ? (this.b.byteLength - position) : length;
+ return new Uint8Array(this.b.slice(position, position + length));
+ }
+
+ getShort()
{
- var v;
if(this._limit - this._position < 2)
{
throw new Error(__BufferUnderflowException__);
}
- v = this.b.readInt16LE(this._position, true);
+ var v = this.v.getInt16(this._position, true);
this._position += 2;
return v;
- },
- getInt: function()
+ }
+
+ getInt()
{
- var v;
if(this._limit - this._position < 4)
{
throw new Error(__BufferUnderflowException__);
}
- v = this.b.readInt32LE(this._position, true);
+ var v = this.v.getInt32(this._position, true);
this._position += 4;
return v;
- },
- getFloat: function()
+ }
+
+ getFloat()
{
if(this._limit - this._position < 4)
{
throw new Error(__BufferUnderflowException__);
}
- var v = this.b.readFloatLE(this._position, true);
+ var v = this.v.getFloat32(this._position, true);
this._position += 4;
return v;
- },
- getDouble: function()
+ }
+
+ getDouble()
{
if(this._limit - this._position < 8)
{
throw new Error(__BufferUnderflowException__);
}
- var v = this.b.readDoubleLE(this._position, true);
+ var v = this.v.getFloat64(this._position, true);
this._position += 8;
return v;
- },
- getLong: function()
+ }
+
+ getLong()
{
if(this._limit - this._position < 8)
{
throw new Error(__BufferUnderflowException__);
}
var v = new Long();
- v.low = this.b.readUInt32LE(this._position, true);
+ v.low = this.v.getUint32(this._position, true);
this._position += 4;
- v.high = this.b.readUInt32LE(this._position, true);
+ v.high = this.v.getUint32(this._position, true);
this._position += 4;
return v;
- },
- getString: function(length)
+ }
+
+ getString(length)
{
if(this._position + length > this._limit)
{
throw new Error(__BufferUnderflowException__);
}
- var s =this.b.toString("utf8", this._position, this._position + length);
+
+ var data = new DataView(this.b, this._position, length);
+ var s = "";
+
+ for(var i = 0; i < length; ++i)
+ {
+ s += String.fromCharCode(data.getUint8(i));
+ }
this._position += length;
+ s = decodeURIComponent(escape(s));
return s;
}
-});
-
-var prototype = Buffer.prototype;
-
-Object.defineProperty(prototype, "position", {
- get: function() { return this._position; },
- set: function(position){
- if(position >= 0 && position <= this._limit)
+
+ get position()
+ {
+ return this._position;
+ }
+
+ set position(value)
+ {
+ if(value >= 0 && value <= this._limit)
{
- this._position = position;
+ this._position = value;
}
}
-});
-
-Object.defineProperty(prototype, "limit", {
- get: function() { return this._limit; },
- set: function(limit){
- if(limit <= this.capacity)
+
+ get limit()
+ {
+ return this._limit;
+ }
+
+ set limit(value)
+ {
+ if(value <= this.capacity)
{
- this._limit = limit;
- if(this._position > limit)
+ this._limit = value;
+ if(this._position > value)
{
- this._position = limit;
+ this._position = value;
}
}
}
-});
-
-Object.defineProperty(prototype, "capacity", {
- get: function() { return this.b === null ? 0 : this.b.length; }
-});
-
-Object.defineProperty(prototype, "remaining", {
- get: function() { return this._limit - this._position; }
-});
-
-//
-// Create a native buffer from an array of bytes.
-//
-Buffer.createNative = function(data)
-{
- if(data === undefined)
+
+ get capacity()
+ {
+ return this.b === null ? 0 : this.b.byteLength;
+ }
+
+ get remaining()
{
- return new Node.Buffer(0);
+ return this._limit - this._position;
}
- else
+
+ //
+ // Create a native buffer from an array of bytes.
+ //
+ static createNative(data)
{
- return new Node.Buffer(data);
+ if(data === undefined)
+ {
+ return new Uint8Array(0);
+ }
+ else
+ {
+ return new Uint8Array(data);
+ }
}
-};
+}
Ice.Buffer = Buffer;
-module.exports.Ice = Ice;
+module.exports.Ice = Ice; \ No newline at end of file
diff --git a/js/src/Ice/Class.js b/js/src/Ice/Class.js
deleted file mode 100644
index 57a6fd819c6..00000000000
--- a/js/src/Ice/Class.js
+++ /dev/null
@@ -1,55 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-var Ice = require("../Ice/ModuleRegistry").Ice;
-
-Ice.Class = function()
-{
- var base;
- var desc;
- var constructor;
-
- if(arguments.length == 1)
- {
- desc = arguments[0];
- }
- else if(arguments.length == 2)
- {
- base = arguments[0];
- desc = arguments[1];
- }
-
- if(desc !== undefined)
- {
- constructor = desc.__init__;
- if(constructor)
- {
- delete desc.__init__;
- }
- }
-
- var o = constructor || function(){};
-
- if(base !== undefined)
- {
- o.prototype = new base();
- o.prototype.constructor = o;
- }
-
- if(desc !== undefined)
- {
- for(var key in desc)
- {
- o.prototype[key] = desc[key];
- }
- }
- return o;
-};
-
-module.exports.Ice = Ice;
diff --git a/js/src/Ice/Communicator.js b/js/src/Ice/Communicator.js
index 9d1d7ed3102..4fd7a9d91ab 100644
--- a/js/src/Ice/Communicator.js
+++ b/js/src/Ice/Communicator.js
@@ -7,82 +7,93 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Instance",
- "../Ice/Promise",
"../Ice/UUID",
"../Ice/AsyncResultBase"
]);
-var Instance = Ice.Instance;
-var Promise = Ice.Promise;
+const Instance = Ice.Instance;
//
// Ice.Communicator
//
-var Communicator = Ice.Class({
- __init__: function(initData)
+class Communicator
+{
+ constructor(initData)
{
this._instance = new Instance(initData);
- },
+ }
+
//
// Certain initialization tasks need to be completed after the
// constructor.
//
- finishSetup: function(promise)
+ finishSetup(promise)
{
this._instance.finishSetup(this, promise);
- },
- destroy: function()
+ }
+
+ destroy()
{
return this._instance.destroy();
- },
- shutdown: function()
+ }
+
+ shutdown()
{
this._instance.objectAdapterFactory().shutdown();
- },
- waitForShutdown: function()
+ }
+
+ waitForShutdown()
{
return this._instance.objectAdapterFactory().waitForShutdown();
- },
- isShutdown: function()
+ }
+
+ isShutdown()
{
return this._instance.objectAdapterFactory().isShutdown();
- },
- stringToProxy: function(s)
+ }
+
+ stringToProxy(s)
{
return this._instance.proxyFactory().stringToProxy(s);
- },
- proxyToString: function(proxy)
+ }
+
+ proxyToString(proxy)
{
return this._instance.proxyFactory().proxyToString(proxy);
- },
- propertyToProxy: function(s)
+ }
+
+ propertyToProxy(s)
{
return this._instance.proxyFactory().propertyToProxy(s);
- },
- proxyToProperty: function(proxy, prefix)
+ }
+
+ proxyToProperty(proxy, prefix)
{
return this._instance.proxyFactory().proxyToProperty(proxy, prefix);
- },
- stringToIdentity: function(s)
+ }
+
+ stringToIdentity(s)
{
return Ice.stringToIdentity(s);
- },
- identityToString: function(ident)
+ }
+
+ identityToString(ident)
{
return Ice.identityToString(ident);
- },
- createObjectAdapter: function(name)
+ }
+
+ createObjectAdapter(name)
{
- var promise = new Ice.AsyncResultBase(this, "createObjectAdapter", this, null, null);
+ const promise = new Ice.AsyncResultBase(this, "createObjectAdapter", this, null, null);
this._instance.objectAdapterFactory().createObjectAdapter(name, null, promise);
return promise;
- },
- createObjectAdapterWithEndpoints: function(name, endpoints)
+ }
+
+ createObjectAdapterWithEndpoints(name, endpoints)
{
if(name.length === 0)
{
@@ -90,80 +101,92 @@ var Communicator = Ice.Class({
}
this.getProperties().setProperty(name + ".Endpoints", endpoints);
- var promise = new Ice.AsyncResultBase(this, "createObjectAdapterWithEndpoints", this, null, null);
+ const promise = new Ice.AsyncResultBase(this, "createObjectAdapterWithEndpoints", this, null, null);
this._instance.objectAdapterFactory().createObjectAdapter(name, null, promise);
return promise;
- },
- createObjectAdapterWithRouter: function(name, router)
+ }
+
+ createObjectAdapterWithRouter(name, router)
{
if(name.length === 0)
{
name = Ice.generateUUID();
}
- var promise = new Ice.AsyncResultBase(this, "createObjectAdapterWithRouter", this, null, null);
+ const promise = new Ice.AsyncResultBase(this, "createObjectAdapterWithRouter", this, null, null);
//
// We set the proxy properties here, although we still use the proxy supplied.
//
- var properties = this.proxyToProperty(router, name + ".Router");
- for(var e = properties.entries; e !== null; e = e.next)
- {
- this.getProperties().setProperty(e.key, e.value);
- }
+ this.proxyToProperty(router, name + ".Router").forEach((value, key) =>
+ {
+ this.getProperties().setProperty(key, value);
+ });
this._instance.objectAdapterFactory().createObjectAdapter(name, router, promise);
return promise;
- },
- addObjectFactory: function(factory, id)
+ }
+
+ addObjectFactory(factory, id)
{
this._instance.addObjectFactory(factory, id);
- },
- findObjectFactory: function(id)
+ }
+
+ findObjectFactory(id)
{
return this._instance.findObjectFactory(id);
- },
- getValueFactoryManager: function()
+ }
+
+ getValueFactoryManager()
{
return this._instance.initializationData().valueFactoryManager;
- },
- getImplicitContext: function()
+ }
+
+ getImplicitContext()
{
return this._instance.getImplicitContext();
- },
- getProperties: function()
+ }
+
+ getProperties()
{
return this._instance.initializationData().properties;
- },
- getLogger: function()
+ }
+
+ getLogger()
{
return this._instance.initializationData().logger;
- },
- getDefaultRouter: function()
+ }
+
+ getDefaultRouter()
{
return this._instance.referenceFactory().getDefaultRouter();
- },
- setDefaultRouter: function(router)
+ }
+
+ setDefaultRouter(router)
{
this._instance.setDefaultRouter(router);
- },
- getDefaultLocator: function()
+ }
+
+ getDefaultLocator()
{
return this._instance.referenceFactory().getDefaultLocator();
- },
- setDefaultLocator: function(locator)
+ }
+
+ setDefaultLocator(locator)
{
this._instance.setDefaultLocator(locator);
- },
- flushBatchRequests: function()
+ }
+
+ flushBatchRequests()
{
return this._instance.outgoingConnectionFactory().flushAsyncBatchRequests();
}
-});
-Object.defineProperty(Communicator.prototype, "instance", {
- get: function() { return this._instance; }
-});
+ get instance()
+ {
+ return this._instance;
+ }
+}
Ice.Communicator = Communicator;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/CompactIdRegistry.js b/js/src/Ice/CompactIdRegistry.js
index 6fba08b88cb..08914b0f4be 100644
--- a/js/src/Ice/CompactIdRegistry.js
+++ b/js/src/Ice/CompactIdRegistry.js
@@ -7,6 +7,6 @@
//
// **********************************************************************
-var Ice = require("../Ice/HashMap").Ice;
-Ice.CompactIdRegistry = new Ice.HashMap();
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.CompactIdRegistry = new Map();
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ConnectRequestHandler.js b/js/src/Ice/ConnectRequestHandler.js
index 126421c726d..42b6e81f738 100644
--- a/js/src/Ice/ConnectRequestHandler.js
+++ b/js/src/Ice/ConnectRequestHandler.js
@@ -7,38 +7,27 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
- "../Ice/AsyncResult",
"../Ice/AsyncStatus",
- "../Ice/Stream",
"../Ice/ConnectionRequestHandler",
"../Ice/Debug",
- "../Ice/ExUtil",
"../Ice/RetryException",
- "../Ice/OutgoingAsync",
- "../Ice/Protocol",
"../Ice/ReferenceMode",
"../Ice/Exception",
- "../Ice/Promise"
]);
-var AsyncResult = Ice.AsyncResult;
-var AsyncStatus = Ice.AsyncStatus;
-var ConnectionRequestHandler = Ice.ConnectionRequestHandler;
-var Debug = Ice.Debug;
-var ExUtil = Ice.ExUtil;
-var RetryException = Ice.RetryException;
-var OutgoingAsync = Ice.OutgoingAsync;
-var Protocol = Ice.Protocol;
-var ReferenceMode = Ice.ReferenceMode;
-var LocalException = Ice.LocalException;
-var Promise = Ice.Promise;
+const AsyncStatus = Ice.AsyncStatus;
+const ConnectionRequestHandler = Ice.ConnectionRequestHandler;
+const Debug = Ice.Debug;
+const RetryException = Ice.RetryException;
+const ReferenceMode = Ice.ReferenceMode;
+const LocalException = Ice.LocalException;
-var ConnectRequestHandler = Ice.Class({
- __init__: function(ref, proxy)
+class ConnectRequestHandler
+{
+ constructor(ref, proxy)
{
this._reference = ref;
this._response = ref.getMode() === ReferenceMode.ModeTwoway;
@@ -50,20 +39,23 @@ var ConnectRequestHandler = Ice.Class({
this._compress = false;
this._exception = null;
this._requests = [];
- },
- connect: function(proxy)
+ }
+
+ connect(proxy)
{
if(!this.initialized())
{
this._proxies.push(proxy);
}
return this._requestHandler ? this._requestHandler : this;
- },
- update: function(previousHandler, newHandler)
+ }
+
+ update(previousHandler, newHandler)
{
return previousHandler === this ? newHandler : this;
- },
- sendAsyncRequest: function(out)
+ }
+
+ sendAsyncRequest(out)
{
if(!this._initialized)
{
@@ -76,8 +68,9 @@ var ConnectRequestHandler = Ice.Class({
return AsyncStatus.Queued;
}
return out.__invokeRemote(this._connection, this._compress, this._response);
- },
- asyncRequestCanceled: function(out, ex)
+ }
+
+ asyncRequestCanceled(out, ex)
{
if(this._exception !== null)
{
@@ -86,7 +79,7 @@ var ConnectRequestHandler = Ice.Class({
if(!this.initialized())
{
- for(var i = 0; i < this._requests.length; i++)
+ for(let i = 0; i < this._requests.length; i++)
{
if(this._requests[i] === out)
{
@@ -98,12 +91,14 @@ var ConnectRequestHandler = Ice.Class({
Debug.assert(false); // The request has to be queued if it timed out and we're not initialized yet.
}
this._connection.asyncRequestCanceled(out, ex);
- },
- getReference: function()
+ }
+
+ getReference()
{
return this._reference;
- },
- getConnection: function()
+ }
+
+ getConnection()
{
if(this._exception !== null)
{
@@ -113,37 +108,30 @@ var ConnectRequestHandler = Ice.Class({
{
return this._connection;
}
- },
+ }
+
//
// Implementation of Reference_GetConnectionCallback
//
- setConnection: function(connection, compress)
+ setConnection(values)
{
Debug.assert(this._exception === null && this._connection === null);
- this._connection = connection;
- this._compress = compress;
+ [this._connection, this._compress] = values;
//
// If this proxy is for a non-local object, and we are using a router, then
// add this proxy to the router info object.
//
- var ri = this._reference.getRouterInfo();
+ let ri = this._reference.getRouterInfo();
if(ri !== null)
{
- var self = this;
- ri.addProxy(this._proxy).then(function()
- {
- //
- // The proxy was added to the router info, we're now ready to send the
- // queued requests.
- //
- self.flushRequests();
- },
- function(ex)
- {
- self.setException(ex);
- });
+ //
+ ri.addProxy(this._proxy).then(() => this.flushRequests(), // The proxy was added to the router
+ // info, we're now ready to send the
+ // queued requests.
+ //
+ ex => this.setException(ex));
return; // The request handler will be initialized once addProxy completes.
}
@@ -151,8 +139,9 @@ var ConnectRequestHandler = Ice.Class({
// We can now send the queued requests.
//
this.flushRequests();
- },
- setException: function(ex)
+ }
+
+ setException(ex)
{
Debug.assert(!this._initialized && this._exception === null);
@@ -175,17 +164,17 @@ var ConnectRequestHandler = Ice.Class({
// Ignore
}
- for(var i = 0; i < this._requests.length; ++i)
- {
- var request = this._requests[i];
- if(request !== null)
+ this._requests.forEach(request =>
{
- request.__completedEx(this._exception);
- }
- }
+ if(request !== null)
+ {
+ request.__completedEx(this._exception);
+ }
+ });
this._requests.length = 0;
- },
- initialized: function()
+ }
+
+ initialized()
{
if(this._initialized)
{
@@ -213,47 +202,44 @@ var ConnectRequestHandler = Ice.Class({
return this._initialized;
}
}
- },
- flushRequests: function()
+ }
+
+ flushRequests()
{
Debug.assert(this._connection !== null && !this._initialized);
- var exception = null;
- for(var i = 0; i < this._requests.length; ++i)
- {
- var request = this._requests[i];
- try
- {
- request.__invokeRemote(this._connection, this._compress, this._response);
- }
- catch(ex)
+ let exception = null;
+ this._requests.forEach(request =>
{
- if(ex instanceof RetryException)
+ try
{
- exception = ex.inner;
-
- // Remove the request handler before retrying.
- this._reference.getInstance().requestHandlerFactory().removeRequestHandler(this._reference, this);
-
- request.__retryException(ex.inner);
+ request.__invokeRemote(this._connection, this._compress, this._response);
}
- else
+ catch(ex)
{
- Debug.assert(ex instanceof LocalException);
- exception = ex;
- request.out.__completedEx(ex);
+ if(ex instanceof RetryException)
+ {
+ exception = ex.inner;
+
+ // Remove the request handler before retrying.
+ this._reference.getInstance().requestHandlerFactory().removeRequestHandler(this._reference, this);
+
+ request.__retryException(ex.inner);
+ }
+ else
+ {
+ Debug.assert(ex instanceof LocalException);
+ exception = ex;
+ request.out.__completedEx(ex);
+ }
}
- }
- }
+ });
this._requests.length = 0;
if(this._reference.getCacheConnection() && exception === null)
{
this._requestHandler = new ConnectionRequestHandler(this._reference, this._connection, this._compress);
- for(var k = 0; k < this._proxies.length; ++k)
- {
- this._proxies[k].__updateRequestHandler(this, this._requestHandler);
- }
+ this._proxies.forEach(proxy => proxy.__updateRequestHandler(this, this._requestHandler));
}
Debug.assert(!this._initialized);
@@ -269,7 +255,7 @@ var ConnectRequestHandler = Ice.Class({
this._proxies.length = 0;
this._proxy = null; // Break cyclic reference count.
}
-});
+}
Ice.ConnectRequestHandler = ConnectRequestHandler;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js
index 18c5a1b3c59..a671849aecd 100644
--- a/js/src/Ice/ConnectionI.js
+++ b/js/src/Ice/ConnectionI.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/AsyncStatus",
"../Ice/Stream",
"../Ice/OutgoingAsync",
@@ -30,53 +29,53 @@ Ice.__M.require(module,
"../Ice/BatchRequestQueue",
]);
-var AsyncStatus = Ice.AsyncStatus;
-var AsyncResultBase = Ice.AsyncResultBase;
-var InputStream = Ice.InputStream;
-var OutputStream = Ice.OutputStream;
-var BatchRequestQueue = Ice.BatchRequestQueue;
-var ConnectionFlushBatch = Ice.ConnectionFlushBatch;
-var Debug = Ice.Debug;
-var ExUtil = Ice.ExUtil;
-var HashMap = Ice.HashMap;
-var IncomingAsync = Ice.IncomingAsync;
-var RetryException = Ice.RetryException;
-var Promise = Ice.Promise;
-var Protocol = Ice.Protocol;
-var SocketOperation = Ice.SocketOperation;
-var Timer = Ice.Timer;
-var TraceUtil = Ice.TraceUtil;
-var ProtocolVersion = Ice.ProtocolVersion;
-var EncodingVersion = Ice.EncodingVersion;
-var ACM = Ice.ACM;
-var ACMClose = Ice.ACMClose;
-var ACMHeartbeat = Ice.ACMHeartbeat;
-
-var StateNotInitialized = 0;
-var StateNotValidated = 1;
-var StateActive = 2;
-var StateHolding = 3;
-var StateClosing = 4;
-var StateClosed = 5;
-var StateFinished = 6;
-
-var MessageInfo = function(instance)
+const AsyncStatus = Ice.AsyncStatus;
+const AsyncResultBase = Ice.AsyncResultBase;
+const InputStream = Ice.InputStream;
+const OutputStream = Ice.OutputStream;
+const BatchRequestQueue = Ice.BatchRequestQueue;
+const ConnectionFlushBatch = Ice.ConnectionFlushBatch;
+const Debug = Ice.Debug;
+const ExUtil = Ice.ExUtil;
+const HashMap = Ice.HashMap;
+const IncomingAsync = Ice.IncomingAsync;
+const RetryException = Ice.RetryException;
+const Protocol = Ice.Protocol;
+const SocketOperation = Ice.SocketOperation;
+const Timer = Ice.Timer;
+const TraceUtil = Ice.TraceUtil;
+const ProtocolVersion = Ice.ProtocolVersion;
+const EncodingVersion = Ice.EncodingVersion;
+const ACM = Ice.ACM;
+const ACMClose = Ice.ACMClose;
+const ACMHeartbeat = Ice.ACMHeartbeat;
+
+const StateNotInitialized = 0;
+const StateNotValidated = 1;
+const StateActive = 2;
+const StateHolding = 3;
+const StateClosing = 4;
+const StateClosed = 5;
+const StateFinished = 6;
+
+class MessageInfo
{
- this.stream = new InputStream(instance, Protocol.currentProtocolEncoding);
-
- this.invokeNum = 0;
- this.requestId = 0;
- this.compress = false;
- this.servantManager = null;
- this.adapter = null;
- this.outAsync = null;
- this.heartbeatCallback = null;
-};
-
-var Class = Ice.Class;
+ constructor(instance)
+ {
+ this.stream = new InputStream(instance, Protocol.currentProtocolEncoding);
+ this.invokeNum = 0;
+ this.requestId = 0;
+ this.compress = false;
+ this.servantManager = null;
+ this.adapter = null;
+ this.outAsync = null;
+ this.heartbeatCallback = null;
+ }
+}
-var ConnectionI = Class({
- __init__: function(communicator, instance, monitor, transceiver, endpoint, incoming, adapter)
+class ConnectionI
+{
+ constructor(communicator, instance, monitor, transceiver, endpoint, incoming, adapter)
{
this._communicator = communicator;
this._instance = instance;
@@ -87,7 +86,7 @@ var ConnectionI = Class({
this._endpoint = endpoint;
this._incoming = incoming;
this._adapter = adapter;
- var initData = instance.initializationData();
+ const initData = instance.initializationData();
this._logger = initData.logger; // Cached for better performance.
this._traceLevels = instance.traceLevels(); // Cached for better performance.
this._timer = instance.timer();
@@ -143,8 +142,9 @@ var ConnectionI = Class({
}
this._closeCallback = null;
this._heartbeatCallback = null;
- },
- start: function()
+ }
+
+ start()
{
Debug.assert(this._startPromise === null);
@@ -154,15 +154,14 @@ var ConnectionI = Class({
if(this._state >= StateClosed)
{
Debug.assert(this._exception !== null);
- return new Promise().fail(this._exception);
+ return Ice.Promise.reject(this._exception);
}
- this._startPromise = new Promise();
- var self = this;
+ this._startPromise = new Ice.Promise();
this._transceiver.setCallbacks(
- function() { self.message(SocketOperation.Write); }, // connected callback
- function() { self.message(SocketOperation.Read); }, // read callback
- function() { self.message(SocketOperation.Write); } // write callback
+ () => { this.message(SocketOperation.Write); }, // connected callback
+ () => { this.message(SocketOperation.Read); }, // read callback
+ () => { this.message(SocketOperation.Write); } // write callback
);
this.initialize();
}
@@ -172,12 +171,12 @@ var ConnectionI = Class({
{
this.exception(ex);
}
- return new Promise().fail(ex);
+ return Ice.Promise.reject(ex);
}
-
return this._startPromise;
- },
- activate: function()
+ }
+
+ activate()
{
if(this._state <= StateNotValidated)
{
@@ -189,8 +188,9 @@ var ConnectionI = Class({
this._acmLastActivity = Date.now();
}
this.setState(StateActive);
- },
- hold: function()
+ }
+
+ hold()
{
if(this._state <= StateNotValidated)
{
@@ -198,8 +198,9 @@ var ConnectionI = Class({
}
this.setState(StateHolding);
- },
- destroy: function(reason)
+ }
+
+ destroy(reason)
{
switch(reason)
{
@@ -215,15 +216,16 @@ var ConnectionI = Class({
break;
}
}
- },
- close: function(force)
+ }
+
+ close(force)
{
- var __r = new AsyncResultBase(this._communicator, "close", this, null, null);
+ const __r = new AsyncResultBase(this._communicator, "close", this, null, null);
if(force)
{
this.setState(StateClosed, new Ice.ForcedCloseConnectionException());
- __r.succeed(__r);
+ __r.resolve();
}
else
{
@@ -239,8 +241,9 @@ var ConnectionI = Class({
}
return __r;
- },
- checkClose: function()
+ }
+
+ checkClose()
{
//
// If close(false) has been called, then we need to check if all
@@ -250,18 +253,17 @@ var ConnectionI = Class({
if(this._asyncRequests.size === 0 && this._closePromises.length > 0)
{
this.setState(StateClosing, new Ice.CloseConnectionException());
- for(var i = 0; i < this._closePromises.length; ++i)
- {
- this._closePromises[i].succeed(this._closePromises[i]);
- }
+ this._closePromises.forEach(p => p.resolve());
this._closePromises = [];
}
- },
- isActiveOrHolding: function()
+ }
+
+ isActiveOrHolding()
{
return this._state > StateNotValidated && this._state < StateClosing;
- },
- isFinished: function()
+ }
+
+ isFinished()
{
if(this._state !== StateFinished || this._dispatchCount !== 0)
{
@@ -270,30 +272,34 @@ var ConnectionI = Class({
Debug.assert(this._state === StateFinished);
return true;
- },
- throwException: function()
+ }
+
+ throwException()
{
if(this._exception !== null)
{
Debug.assert(this._state >= StateClosing);
throw this._exception;
}
- },
- waitUntilHolding: function()
+ }
+
+ waitUntilHolding()
{
- var promise = new Promise();
+ const promise = new Ice.Promise();
this._holdPromises.push(promise);
this.checkState();
return promise;
- },
- waitUntilFinished: function()
+ }
+
+ waitUntilFinished()
{
- var promise = new Promise();
+ const promise = new Ice.Promise();
this._finishedPromises.push(promise);
this.checkState();
return promise;
- },
- monitor: function(now, acm)
+ }
+
+ monitor(now, acm)
{
if(this._state !== StateActive)
{
@@ -314,8 +320,8 @@ var ConnectionI = Class({
// called every (timeout / 2) period.
//
if(acm.heartbeat == Ice.ACMHeartbeat.HeartbeatAlways ||
- (acm.heartbeat != Ice.ACMHeartbeat.HeartbeatOff && this._writeStream.isEmpty() &&
- now >= (this._acmLastActivity + acm.timeout / 4)))
+ (acm.heartbeat != Ice.ACMHeartbeat.HeartbeatOff && this._writeStream.isEmpty() &&
+ now >= (this._acmLastActivity + acm.timeout / 4)))
{
if(acm.heartbeat != Ice.ACMHeartbeat.HeartbeatOnInvocation || this._dispatchCount > 0)
{
@@ -337,7 +343,7 @@ var ConnectionI = Class({
if(acm.close != Ice.ACMClose.CloseOff && now >= (this._acmLastActivity + acm.timeout))
{
if(acm.close == Ice.ACMClose.CloseOnIdleForceful ||
- (acm.close != Ice.ACMClose.CloseOnIdle && this._asyncRequests.size > 0))
+ (acm.close != Ice.ACMClose.CloseOnIdle && this._asyncRequests.size > 0))
{
//
// Close the connection if we didn't receive a heartbeat in
@@ -354,11 +360,12 @@ var ConnectionI = Class({
this.setState(StateClosing, new Ice.ConnectionTimeoutException());
}
}
- },
- sendAsyncRequest: function(out, compress, response, batchRequestNum)
+ }
+
+ sendAsyncRequest(out, compress, response, batchRequestNum)
{
- var requestId = 0;
- var os = out.__os();
+ let requestId = 0;
+ const os = out.__os();
if(this._exception !== null)
{
@@ -409,7 +416,7 @@ var ConnectionI = Class({
os.writeInt(batchRequestNum);
}
- var status;
+ let status;
try
{
status = this.sendMessage(OutgoingMessage.create(out, out.__os(), compress, requestId));
@@ -437,32 +444,35 @@ var ConnectionI = Class({
}
return status;
- },
- getBatchRequestQueue: function()
+ }
+
+ getBatchRequestQueue()
{
return this._batchRequestQueue;
- },
- flushBatchRequests: function()
+ }
+
+ flushBatchRequests()
{
- var result = new ConnectionFlushBatch(this, this._communicator, "flushBatchRequests");
+ const result = new ConnectionFlushBatch(this, this._communicator, "flushBatchRequests");
result.__invoke();
return result;
- },
- setCloseCallback: function(callback)
+ }
+
+ setCloseCallback(callback)
{
if(this._state >= StateClosed)
{
if(callback !== null)
{
- var self = this;
- Timer.setImmediate(function() {
+ Timer.setImmediate(() =>
+ {
try
{
callback(this);
}
catch(ex)
{
- self._logger.error("connection callback exception:\n" + ex + '\n' + self._desc);
+ this._logger.error("connection callback exception:\n" + ex + '\n' + this._desc);
}
});
}
@@ -471,12 +481,14 @@ var ConnectionI = Class({
{
this._closeCallback = callback;
}
- },
- setHeartbeatCallback: function(callback)
+ }
+
+ setHeartbeatCallback(callback)
{
this._heartbeatCallback = callback;
- },
- setACM: function(timeout, close, heartbeat)
+ }
+
+ setACM(timeout, close, heartbeat)
{
if(this._monitor === null || this._state >= StateClosed)
{
@@ -500,17 +512,19 @@ var ConnectionI = Class({
{
this._acmLastActivity = Date.now();
}
- },
- getACM: function()
+ }
+
+ getACM()
{
return this._monitor !== null ? this._monitor.getACM() :
new ACM(0, ACMClose.CloseOff, ACMHeartbeat.HeartbeatOff);
- },
- asyncRequestCanceled: function(outAsync, ex)
+ }
+
+ asyncRequestCanceled(outAsync, ex)
{
- for(var i = 0; i < this._sendStreams.length; i++)
+ for(let i = 0; i < this._sendStreams.length; i++)
{
- var o = this._sendStreams[i];
+ let o = this._sendStreams[i];
if(o.outAsync === outAsync)
{
if(o.requestId > 0)
@@ -534,18 +548,19 @@ var ConnectionI = Class({
if(outAsync instanceof Ice.OutgoingAsync)
{
- for(var e = this._asyncRequests.entries; e !== null; e = e.next)
+ for(let [key, value] of this._asyncRequests)
{
- if(e.value === outAsync)
+ if(value === outAsync)
{
- this._asyncRequests.delete(e.key);
+ this._asyncRequests.delete(key);
outAsync.__completedEx(ex);
return; // We're done.
}
}
}
- },
- sendResponse: function(os, compressFlag)
+ }
+
+ sendResponse(os, compressFlag)
{
Debug.assert(this._state > StateNotValidated);
@@ -584,8 +599,9 @@ var ConnectionI = Class({
throw ex;
}
}
- },
- sendNoResponse: function()
+ }
+
+ sendNoResponse()
{
Debug.assert(this._state > StateNotValidated);
try
@@ -621,12 +637,14 @@ var ConnectionI = Class({
throw ex;
}
}
- },
- endpoint: function()
+ }
+
+ endpoint()
{
return this._endpoint;
- },
- setAdapter: function(adapter)
+ }
+
+ setAdapter(adapter)
{
if(this._state <= StateNotValidated || this._state >= StateClosing)
{
@@ -648,16 +666,19 @@ var ConnectionI = Class({
{
this._servantManager = null;
}
- },
- getAdapter: function()
+ }
+
+ getAdapter()
{
return this._adapter;
- },
- getEndpoint: function()
+ }
+
+ getEndpoint()
{
return this._endpoint;
- },
- createProxy: function(ident)
+ }
+
+ createProxy(ident)
{
//
// Create a reference and return a reverse proxy for this
@@ -665,8 +686,9 @@ var ConnectionI = Class({
//
return this._instance.proxyFactory().referenceToProxy(
this._instance.referenceFactory().createFixed(ident, this));
- },
- message: function(operation)
+ }
+
+ message(operation)
{
if(this._state >= StateClosed)
{
@@ -680,7 +702,7 @@ var ConnectionI = Class({
//
this._hasMoreData.value = (operation & SocketOperation.Read) !== 0;
- var info = null;
+ let info = null;
try
{
if((operation & SocketOperation.Write) !== 0 && this._writeStream.buffer.remaining > 0)
@@ -708,7 +730,7 @@ var ConnectionI = Class({
Debug.assert(this._readStream.buffer.remaining === 0);
this._readHeader = false;
- var pos = this._readStream.pos;
+ const pos = this._readStream.pos;
if(pos < Protocol.headerSize)
{
//
@@ -718,16 +740,14 @@ var ConnectionI = Class({
}
this._readStream.pos = 0;
- var magic0 = this._readStream.readByte();
- var magic1 = this._readStream.readByte();
- var magic2 = this._readStream.readByte();
- var magic3 = this._readStream.readByte();
+ const magic0 = this._readStream.readByte();
+ const magic1 = this._readStream.readByte();
+ const magic2 = this._readStream.readByte();
+ const magic3 = this._readStream.readByte();
if(magic0 !== Protocol.magic[0] || magic1 !== Protocol.magic[1] ||
- magic2 !== Protocol.magic[2] || magic3 !== Protocol.magic[3])
+ magic2 !== Protocol.magic[2] || magic3 !== Protocol.magic[3])
{
- var bme = new Ice.BadMagicException();
- bme.badMagic = Ice.Buffer.createNative([magic0, magic1, magic2, magic3]);
- throw bme;
+ throw new Ice.BadMagicException("", Ice.Buffer.createNative([magic0, magic1, magic2, magic3]));
}
this._readProtocol.__read(this._readStream);
@@ -738,7 +758,7 @@ var ConnectionI = Class({
this._readStream.readByte(); // messageType
this._readStream.readByte(); // compress
- var size = this._readStream.readInt();
+ const size = this._readStream.readInt();
if(size < Protocol.headerSize)
{
throw new Ice.IllegalMessageSizeException();
@@ -866,20 +886,21 @@ var ConnectionI = Class({
if(this._hasMoreData.value)
{
- var self = this;
- Timer.setImmediate(function() { self.message(SocketOperation.Read); }); // Don't tie up the thread.
+ Timer.setImmediate(() => { this.message(SocketOperation.Read); }); // Don't tie up the thread.
}
- },
- dispatch: function(info)
+ }
+
+ dispatch(info)
{
- var count = 0;
+ let count = 0;
//
// Notify the factory that the connection establishment and
// validation has completed.
//
if(this._startPromise !== null)
{
- this._startPromise.succeed();
+ this._startPromise.resolve();
+
this._startPromise = null;
++count;
}
@@ -951,19 +972,19 @@ var ConnectionI = Class({
this.checkState();
}
}
- },
- finish: function()
+ }
+
+ finish()
{
Debug.assert(this._state === StateClosed);
this.unscheduleTimeout(SocketOperation.Read | SocketOperation.Write | SocketOperation.Connect);
- var s;
- var traceLevels = this._instance.traceLevels();
+ const traceLevels = this._instance.traceLevels();
if(!this._initialized)
{
if(traceLevels.network >= 2)
{
- s = [];
+ let s = [];
s.push("failed to establish ");
s.push(this._endpoint.protocol());
s.push(" connection\n");
@@ -977,7 +998,7 @@ var ConnectionI = Class({
{
if(traceLevels.network >= 1)
{
- s = [];
+ let s = [];
s.push("closed ");
s.push(this._endpoint.protocol());
s.push(" connection\n");
@@ -1002,7 +1023,7 @@ var ConnectionI = Class({
if(this._startPromise !== null)
{
- this._startPromise.fail(this._exception);
+ this._startPromise.reject(this._exception);
this._startPromise = null;
}
@@ -1014,8 +1035,7 @@ var ConnectionI = Class({
// Return the stream to the outgoing call. This is important for
// retriable AMI calls which are not marshalled again.
//
- var message = this._sendStreams[0];
- this._writeStream.swap(message.stream);
+ this._writeStream.swap(this._sendStreams[0].stream);
}
//
@@ -1024,9 +1044,9 @@ var ConnectionI = Class({
// because it's either in the _requests/_asyncRequests set. This is fine, only the
// first call should be taken into account by the implementation of finished.
//
- for(var i = 0; i < this._sendStreams.length; ++i)
+ for(let i = 0; i < this._sendStreams.length; ++i)
{
- var p = this._sendStreams[i];
+ let p = this._sendStreams[i];
if(p.requestId > 0)
{
this._asyncRequests.delete(p.requestId);
@@ -1036,9 +1056,9 @@ var ConnectionI = Class({
this._sendStreams = [];
}
- for(var e = this._asyncRequests.entries; e !== null; e = e.next)
+ for(let value of this._asyncRequests.values())
{
- e.value.__completedEx(this._exception);
+ value.__completedEx(this._exception);
}
this._asyncRequests.clear();
@@ -1074,12 +1094,14 @@ var ConnectionI = Class({
this.reap();
}
this.setState(StateFinished);
- },
- toString: function()
+ }
+
+ toString()
{
return this._desc;
- },
- timedOut: function(event)
+ }
+
+ timedOut(event)
{
if(this._state <= StateNotValidated)
{
@@ -1093,42 +1115,48 @@ var ConnectionI = Class({
{
this.setState(StateClosed, new Ice.CloseTimeoutException());
}
- },
- type: function()
+ }
+
+ type()
{
return this._type;
- },
- timeout: function()
+ }
+
+ timeout()
{
return this._endpoint.timeout();
- },
- getInfo: function()
+ }
+
+ getInfo()
{
if(this._state >= StateClosed)
{
throw this._exception;
}
- var info = this._transceiver.getInfo();
- for(var p = info; p; p = p.underlying)
+ let info = this._transceiver.getInfo();
+ for(let p = info; p !== null; p = p.underlying)
{
p.adapterName = this._adapter !== null ? this._adapter.getName() : "";
p.incoming = this._incoming;
}
return info;
- },
- setBufferSize: function(rcvSize, sndSize)
+ }
+
+ setBufferSize(rcvSize, sndSize)
{
if(this._state >= StateClosed)
{
throw this._exception;
}
this._transceiver.setBufferSize(rcvSize, sndSize);
- },
- exception: function(ex)
+ }
+
+ exception(ex)
{
this.setState(StateClosed, ex);
- },
- invokeException: function(ex, invokeNum)
+ }
+
+ invokeException(ex, invokeNum)
{
//
// Fatal exception while invoking a request. Since sendResponse/sendNoResponse isn't
@@ -1151,8 +1179,9 @@ var ConnectionI = Class({
this.checkState();
}
}
- },
- setState: function(state, ex)
+ }
+
+ setState(state, ex)
{
if(ex !== undefined)
{
@@ -1326,8 +1355,8 @@ var ConnectionI = Class({
{
if(ex instanceof Ice.LocalException)
{
- var msg = "unexpected connection exception:\n " + this._desc + "\n" + ex.toString();
- this._instance.initializationData().logger.error(msg);
+ this._instance.initializationData().logger.error(
+ `unexpected connection exception:\n${this._desc}\n${ex.toString()}`);
}
else
{
@@ -1383,8 +1412,9 @@ var ConnectionI = Class({
}
this.checkState();
- },
- initiateShutdown: function()
+ }
+
+ initiateShutdown()
{
Debug.assert(this._state === StateClosing);
Debug.assert(this._dispatchCount === 0);
@@ -1396,7 +1426,7 @@ var ConnectionI = Class({
// Before we shut down, we send a close connection
// message.
//
- var os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
+ const os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
os.writeBlob(Protocol.magic);
Protocol.currentProtocol.__write(os);
Protocol.currentProtocolEncoding.__write(os);
@@ -1404,8 +1434,7 @@ var ConnectionI = Class({
os.writeByte(0); // compression status: always report 0 for CloseConnection.
os.writeInt(Protocol.headerSize); // Message size.
- var status = this.sendMessage(OutgoingMessage.createForStream(os, false, false));
- if((status & AsyncStatus.Sent) > 0)
+ if((this.sendMessage(OutgoingMessage.createForStream(os, false, false)) & AsyncStatus.Sent) > 0)
{
//
// Schedule the close timeout to wait for the peer to close the connection.
@@ -1423,14 +1452,15 @@ var ConnectionI = Class({
//
//this._transceiver.shutdownWrite();
}
- },
- heartbeat: function()
+ }
+
+ heartbeat()
{
Debug.assert(this._state === StateActive);
if(!this._endpoint.datagram())
{
- var os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
+ const os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
os.writeBlob(Protocol.magic);
Protocol.currentProtocol.__write(os);
Protocol.currentProtocolEncoding.__write(os);
@@ -1447,10 +1477,11 @@ var ConnectionI = Class({
Debug.assert(this._exception !== null);
}
}
- },
- initialize: function()
+ }
+
+ initialize()
{
- var s = this._transceiver.initialize(this._readStream.buffer, this._writeStream.buffer);
+ const s = this._transceiver.initialize(this._readStream.buffer, this._writeStream.buffer);
if(s != SocketOperation.None)
{
this.scheduleTimeout(s, this.connectTimeout());
@@ -1464,8 +1495,9 @@ var ConnectionI = Class({
this._initialized = true;
this.setState(StateNotValidated);
return true;
- },
- validate: function()
+ }
+
+ validate()
{
if(!this._endpoint.datagram()) // Datagram connections are always implicitly validated.
{
@@ -1506,13 +1538,11 @@ var ConnectionI = Class({
Debug.assert(this._readStream.pos === Protocol.headerSize);
this._readStream.pos = 0;
- var m = this._readStream.readBlob(4);
+ const m = this._readStream.readBlob(4);
if(m[0] !== Protocol.magic[0] || m[1] !== Protocol.magic[1] ||
m[2] !== Protocol.magic[2] || m[3] !== Protocol.magic[3])
{
- var bme = new Ice.BadMagicException();
- bme.badMagic = m;
- throw bme;
+ throw new Ice.BadMagicException("", m);
}
this._readProtocol.__read(this._readStream);
@@ -1521,14 +1551,13 @@ var ConnectionI = Class({
this._readProtocolEncoding.__read(this._readStream);
Protocol.checkSupportedProtocolEncoding(this._readProtocolEncoding);
- var messageType = this._readStream.readByte();
+ const messageType = this._readStream.readByte();
if(messageType !== Protocol.validateConnectionMsg)
{
throw new Ice.ConnectionNotValidatedException();
}
this._readStream.readByte(); // Ignore compression status for validate connection.
- var size = this._readStream.readInt();
- if(size !== Protocol.headerSize)
+ if( this._readStream.readInt() !== Protocol.headerSize)
{
throw new Ice.IllegalMessageSizeException();
}
@@ -1544,10 +1573,10 @@ var ConnectionI = Class({
this._readHeader = true;
this._readStream.pos = 0;
- var traceLevels = this._instance.traceLevels();
+ const traceLevels = this._instance.traceLevels();
if(traceLevels.network >= 1)
{
- var s = [];
+ let s = [];
if(this._endpoint.datagram())
{
s.push("starting to send ");
@@ -1557,7 +1586,6 @@ var ConnectionI = Class({
}
else
{
- s = [];
s.push("established ");
s.push(this._endpoint.protocol());
s.push(" connection\n");
@@ -1567,8 +1595,9 @@ var ConnectionI = Class({
}
return true;
- },
- sendNextMessage: function()
+ }
+
+ sendNextMessage()
{
if(this._sendStreams.length === 0)
{
@@ -1583,7 +1612,7 @@ var ConnectionI = Class({
//
// Notify the message that it was sent.
//
- var message = this._sendStreams.shift();
+ let message = this._sendStreams.shift();
this._writeStream.swap(message.stream);
message.sent();
@@ -1612,7 +1641,7 @@ var ConnectionI = Class({
//
message = this._sendStreams[0];
Debug.assert(!message.prepared);
- var stream = message.stream;
+ let stream = message.stream;
stream.pos = 10;
stream.writeInt(stream.size);
@@ -1657,8 +1686,9 @@ var ConnectionI = Class({
{
this.scheduleTimeout(SocketOperation.Write, this.closeTimeout());
}
- },
- sendMessage: function(message)
+ }
+
+ sendMessage(message)
{
if(this._sendStreams.length > 0)
{
@@ -1670,15 +1700,15 @@ var ConnectionI = Class({
Debug.assert(!message.prepared);
- var stream = message.stream;
+ let stream = message.stream;
stream.pos = 10;
stream.writeInt(stream.size);
stream.prepareWrite();
message.prepared = true;
- TraceUtil.traceSend(message.stream, this._logger, this._traceLevels);
+ TraceUtil.traceSend(stream, this._logger, this._traceLevels);
- if(this.write(message.stream.buffer))
+ if(this.write(stream.buffer))
{
//
// Entire buffer was written immediately.
@@ -1693,17 +1723,18 @@ var ConnectionI = Class({
}
message.doAdopt();
- this._writeStream.swap(message.stream);
+ this._writeStream.swap(stream);
this._sendStreams.push(message);
this.scheduleTimeout(SocketOperation.Write, this._endpoint.timeout());
return AsyncStatus.Queued;
- },
- parseMessage: function()
+ }
+
+ parseMessage()
{
Debug.assert(this._state > StateNotValidated && this._state < StateClosed);
- var info = new MessageInfo(this._instance);
+ let info = new MessageInfo(this._instance);
this._readStream.swap(info.stream);
this._readStream.resize(Protocol.headerSize);
@@ -1727,13 +1758,11 @@ var ConnectionI = Class({
// been done by the caller.
//
info.stream.pos = 8;
- var messageType = info.stream.readByte();
+ const messageType = info.stream.readByte();
info.compress = info.stream.readByte();
if(info.compress === 2)
{
- var ex = new Ice.FeatureNotSupportedException();
- ex.unsupportedFeature = "Cannot uncompress compressed message";
- throw ex;
+ throw new Ice.FeatureNotSupportedException("Cannot uncompress compressed message");
}
info.stream.pos = Protocol.headerSize;
@@ -1861,10 +1890,10 @@ var ConnectionI = Class({
}
return info;
- },
- invokeAll: function(stream, invokeNum, requestId, compress, servantManager, adapter)
+ }
+
+ invokeAll(stream, invokeNum, requestId, compress, servantManager, adapter)
{
- var inc = null;
try
{
while(invokeNum > 0)
@@ -1872,8 +1901,11 @@ var ConnectionI = Class({
//
// Prepare the invocation.
//
- var response = !this._endpoint.datagram() && requestId !== 0;
- inc = new IncomingAsync(this._instance, this, adapter, response, compress, requestId);
+ let inc = new IncomingAsync(this._instance, this,
+ adapter,
+ !this._endpoint.datagram() && requestId !== 0, // response
+ compress,
+ requestId);
//
// Dispatch the invocation.
@@ -1881,7 +1913,6 @@ var ConnectionI = Class({
inc.invoke(servantManager, stream);
--invokeNum;
- inc = null;
}
stream.clear();
@@ -1897,27 +1928,28 @@ var ConnectionI = Class({
throw ex;
}
}
- },
- scheduleTimeout: function(op, timeout)
+ }
+
+ scheduleTimeout(op, timeout)
{
if(timeout < 0)
{
return;
}
- var self = this;
if((op & SocketOperation.Read) !== 0)
{
- this._readTimeoutId = this._timer.schedule(function() { self.timedOut(); }, timeout);
+ this._readTimeoutId = this._timer.schedule(() => this.timedOut(), timeout);
this._readTimeoutScheduled = true;
}
if((op & (SocketOperation.Write | SocketOperation.Connect)) !== 0)
{
- this._writeTimeoutId = this._timer.schedule(function() { self.timedOut(); }, timeout);
+ this._writeTimeoutId = this._timer.schedule(() => this.timedOut(), timeout);
this._writeTimeoutScheduled = true;
}
- },
- unscheduleTimeout: function(op)
+ }
+
+ unscheduleTimeout(op)
{
if((op & SocketOperation.Read) !== 0 && this._readTimeoutScheduled)
{
@@ -1929,10 +1961,11 @@ var ConnectionI = Class({
this._timer.cancel(this._writeTimeoutId);
this._writeTimeoutScheduled = false;
}
- },
- connectTimeout: function()
+ }
+
+ connectTimeout()
{
- var defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
if(defaultsAndOverrides.overrideConnectTimeout)
{
return defaultsAndOverrides.overrideConnectTimeoutValue;
@@ -1941,10 +1974,11 @@ var ConnectionI = Class({
{
return this._endpoint.timeout();
}
- },
- closeTimeout: function()
+ }
+
+ closeTimeout()
{
- var defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
if(defaultsAndOverrides.overrideCloseTimeout)
{
return defaultsAndOverrides.overrideCloseTimeoutValue;
@@ -1953,27 +1987,22 @@ var ConnectionI = Class({
{
return this._endpoint.timeout();
}
- },
- warning: function(msg, ex)
+ }
+
+ warning(msg, ex)
{
this._logger.warning(msg + ":\n" + this._desc + "\n" + ex.toString());
- },
- checkState: function()
+ }
+
+ checkState()
{
if(this._state < StateHolding || this._dispatchCount > 0)
{
return;
}
- var i;
- if(this._holdPromises.length > 0)
- {
- for(i = 0; i < this._holdPromises.length; ++i)
- {
- this._holdPromises[i].succeed();
- }
- this._holdPromises = [];
- }
+ this._holdPromises.forEach(p => p.resolve());
+ this._holdPromises = [];
//
// We aren't finished until the state is finished and all
@@ -1987,28 +2016,26 @@ var ConnectionI = Class({
// Clear the OA. See bug 1673 for the details of why this is necessary.
//
this._adapter = null;
-
- for(i = 0; i < this._finishedPromises.length; ++i)
- {
- this._finishedPromises[i].succeed();
- }
+ this._finishedPromises.forEach(p => p.resolve());
this._finishedPromises = [];
}
- },
- reap: function()
+ }
+
+ reap()
{
if(this._monitor !== null)
{
this._monitor.reap(this);
}
- },
- read: function(buf)
+ }
+
+ read(buf)
{
- var start = buf.position;
- var ret = this._transceiver.read(buf, this._hasMoreData);
+ const start = buf.position;
+ const ret = this._transceiver.read(buf, this._hasMoreData);
if(this._instance.traceLevels().network >= 3 && buf.position != start)
{
- var s = [];
+ let s = [];
s.push("received ");
if(this._endpoint.datagram())
{
@@ -2027,14 +2054,15 @@ var ConnectionI = Class({
this._instance.initializationData().logger.trace(this._instance.traceLevels().networkCat, s.join(""));
}
return ret;
- },
- write: function(buf)
+ }
+
+ write(buf)
{
- var start = buf.position;
- var ret = this._transceiver.write(buf);
+ const start = buf.position;
+ const ret = this._transceiver.write(buf);
if(this._instance.traceLevels().network >= 3 && buf.position != start)
{
- var s = [];
+ let s = [];
s.push("sent ");
s.push(buf.position - start);
if(!this._endpoint.datagram())
@@ -2050,7 +2078,7 @@ var ConnectionI = Class({
}
return ret;
}
-});
+}
// DestructionReason.
ConnectionI.ObjectAdapterDeactivated = 0;
@@ -2058,68 +2086,73 @@ ConnectionI.CommunicatorDestroyed = 1;
Ice.ConnectionI = ConnectionI;
-var OutgoingMessage = Class({
- __init__: function()
+class OutgoingMessage
+{
+ constructor()
{
this.stream = null;
this.outAsync = null;
this.compress = false;
this.requestId = 0;
this.prepared = false;
- },
- canceled: function()
+ }
+
+ canceled()
{
Debug.assert(this.outAsync !== null);
this.outAsync = null;
- },
- doAdopt: function()
+ }
+
+ doAdopt()
{
if(this.adopt)
{
- var stream = new OutputStream(this.stream.instance, Protocol.currentProtocolEncoding);
+ const stream = new OutputStream(this.stream.instance, Protocol.currentProtocolEncoding);
stream.swap(this.stream);
this.stream = stream;
this.adopt = false;
}
- },
- sent: function()
+ }
+
+ sent()
{
if(this.outAsync !== null)
{
this.outAsync.__sent();
}
- },
- completed: function(ex)
+ }
+
+ completed(ex)
{
if(this.outAsync !== null)
{
this.outAsync.__completedEx(ex);
}
}
-});
+
+ static createForStream(stream, compress, adopt)
+ {
+ const m = new OutgoingMessage();
+ m.stream = stream;
+ m.compress = compress;
+ m.adopt = adopt;
+ m.isSent = false;
+ m.requestId = 0;
+ m.outAsync = null;
+ return m;
+ }
-OutgoingMessage.createForStream = function(stream, compress, adopt)
-{
- var m = new OutgoingMessage();
- m.stream = stream;
- m.compress = compress;
- m.adopt = adopt;
- m.isSent = false;
- m.requestId = 0;
- m.outAsync = null;
- return m;
-};
-
-OutgoingMessage.create = function(out, stream, compress, requestId)
-{
- var m = new OutgoingMessage();
- m.stream = stream;
- m.compress = compress;
- m.outAsync = out;
- m.requestId = requestId;
- m.isSent = false;
- m.adopt = false;
- return m;
-};
+ static create(out, stream, compress, requestId)
+ {
+ const m = new OutgoingMessage();
+ m.stream = stream;
+ m.compress = compress;
+ m.outAsync = out;
+ m.requestId = requestId;
+ m.isSent = false;
+ m.adopt = false;
+ return m;
+ }
+}
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ConnectionRequestHandler.js b/js/src/Ice/ConnectionRequestHandler.js
index a451621d104..afdc1b4446d 100644
--- a/js/src/Ice/ConnectionRequestHandler.js
+++ b/js/src/Ice/ConnectionRequestHandler.js
@@ -7,21 +7,20 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Promise", "../Ice/Class", "../Ice/ReferenceMode"]);
+const Ice = require("../Ice/ReferenceMode").Ice;
+const ReferenceMode = Ice.ReferenceMode;
-var Promise = Ice.Promise;
-var ReferenceMode = Ice.ReferenceMode;
-
-var ConnectionRequestHandler = Ice.Class({
- __init__: function(ref, connection, compress)
+class ConnectionRequestHandler
+{
+ constructor(ref, connection, compress)
{
this._reference = ref;
this._response = ref.getMode() == ReferenceMode.ModeTwoway;
this._connection = connection;
this._compress = compress;
- },
- update: function(previousHandler, newHandler)
+ }
+
+ update(previousHandler, newHandler)
{
try
{
@@ -44,24 +43,28 @@ var ConnectionRequestHandler = Ice.Class({
// Ignore
}
return this;
- },
- sendAsyncRequest: function(out)
+ }
+
+ sendAsyncRequest(out)
{
return out.__invokeRemote(this._connection, this._compress, this._response);
- },
- asyncRequestCanceled: function(out)
+ }
+
+ asyncRequestCanceled(out)
{
return this._connection.asyncRequestCanceled(out);
- },
- getReference: function()
+ }
+
+ getReference()
{
return this._reference;
- },
- getConnection: function()
+ }
+
+ getConnection()
{
return this._connection;
- },
-});
+ }
+}
Ice.ConnectionRequestHandler = ConnectionRequestHandler;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Debug.js b/js/src/Ice/Debug.js
index 92b968b515c..9db904ad462 100644
--- a/js/src/Ice/Debug.js
+++ b/js/src/Ice/Debug.js
@@ -7,25 +7,20 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-var fs = require("fs");
+const Ice = require("../Ice/ModuleRegistry").Ice;
+const fs = require("fs");
-function writeSync(stream, msg)
+class Debug
{
- var data = new Buffer(msg + "\n");
- fs.writeSync(stream.fd, data, 0, data.length, stream.pos);
-}
-
-Ice.Debug =
-{
- assert: function(b, msg)
+ static assert(b, msg)
{
if(!b)
{
- writeSync(process.stderr, msg === undefined ? "assertion failed" : msg);
- writeSync(process.stderr, new Error().stack);
+ fs.writeSync(process.stderr.fd, msg === undefined ? "assertion failed" : msg);
+ fs.writeSync(process.stderr.fd, new Error().stack);
process.exit(1);
}
}
-};
+}
+Ice.Debug = Debug;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/DefaultsAndOverrides.js b/js/src/Ice/DefaultsAndOverrides.js
index 8c4bdfc1af2..92a98526d6b 100644
--- a/js/src/Ice/DefaultsAndOverrides.js
+++ b/js/src/Ice/DefaultsAndOverrides.js
@@ -8,7 +8,7 @@
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
"../Ice/FormatType",
@@ -17,128 +17,131 @@ Ice.__M.require(module,
"../Ice/LocalException"
]);
-var FormatType = Ice.FormatType;
-var EndpointSelectionType = Ice.EndpointSelectionType;
-var Protocol = Ice.Protocol;
+const FormatType = Ice.FormatType;
+const EndpointSelectionType = Ice.EndpointSelectionType;
+const Protocol = Ice.Protocol;
-var DefaultsAndOverrides = function(properties, logger)
+class DefaultsAndOverrides
{
- this.defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol",
- Ice.TcpEndpointFactory !== undefined ? "tcp" : "ws");
+ constructor(properties, logger)
+ {
+ this.defaultProtocol = properties.getPropertyWithDefault("Ice.Default.Protocol",
+ Ice.TcpEndpointFactory !== undefined ? "tcp" : "ws");
- var value = properties.getProperty("Ice.Default.Host");
- this.defaultHost = value.length > 0 ? value : null;
+ let value = properties.getProperty("Ice.Default.Host");
+ this.defaultHost = value.length > 0 ? value : null;
- value = properties.getProperty("Ice.Default.SourceAddress");
- this.defaultSourceAddress = value.length > 0 ? value : null;
+ value = properties.getProperty("Ice.Default.SourceAddress");
+ this.defaultSourceAddress = value.length > 0 ? value : null;
- value = properties.getProperty("Ice.Override.Timeout");
- if(value.length > 0)
- {
- this.overrideTimeout = true;
- this.overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
- if(this.overrideTimeoutValue < 1 && this.overrideTimeoutValue !== -1)
+ value = properties.getProperty("Ice.Override.Timeout");
+ if(value.length > 0)
+ {
+ this.overrideTimeout = true;
+ this.overrideTimeoutValue = properties.getPropertyAsInt("Ice.Override.Timeout");
+ if(this.overrideTimeoutValue < 1 && this.overrideTimeoutValue !== -1)
+ {
+ this.overrideTimeoutValue = -1;
+ logger.warning("invalid value for Ice.Override.Timeout `" +
+ properties.getProperty("Ice.Override.Timeout") + "': defaulting to -1");
+ }
+ }
+ else
{
+ this.overrideTimeout = false;
this.overrideTimeoutValue = -1;
- logger.warning("invalid value for Ice.Override.Timeout `" +
- properties.getProperty("Ice.Override.Timeout") + "': defaulting to -1");
}
- }
- else
- {
- this.overrideTimeout = false;
- this.overrideTimeoutValue = -1;
- }
- value = properties.getProperty("Ice.Override.ConnectTimeout");
- if(value.length > 0)
- {
- this.overrideConnectTimeout = true;
- this.overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
- if(this.overrideConnectTimeoutValue < 1 && this.overrideConnectTimeoutValue !== -1)
+ value = properties.getProperty("Ice.Override.ConnectTimeout");
+ if(value.length > 0)
{
+ this.overrideConnectTimeout = true;
+ this.overrideConnectTimeoutValue = properties.getPropertyAsInt("Ice.Override.ConnectTimeout");
+ if(this.overrideConnectTimeoutValue < 1 && this.overrideConnectTimeoutValue !== -1)
+ {
+ this.overrideConnectTimeoutValue = -1;
+ logger.warning("invalid value for Ice.Override.ConnectTimeout `" +
+ properties.getProperty("Ice.Override.ConnectTimeout") + "': defaulting to -1");
+ }
+ }
+ else
+ {
+ this.overrideConnectTimeout = false;
this.overrideConnectTimeoutValue = -1;
- logger.warning("invalid value for Ice.Override.ConnectTimeout `" +
- properties.getProperty("Ice.Override.ConnectTimeout") + "': defaulting to -1");
}
- }
- else
- {
- this.overrideConnectTimeout = false;
- this.overrideConnectTimeoutValue = -1;
- }
- value = properties.getProperty("Ice.Override.CloseTimeout");
- if(value.length > 0)
- {
- this.overrideCloseTimeout = true;
- this.overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout");
- if(this.overrideCloseTimeoutValue < 1 && this.overrideCloseTimeoutValue !== -1)
+ value = properties.getProperty("Ice.Override.CloseTimeout");
+ if(value.length > 0)
{
+ this.overrideCloseTimeout = true;
+ this.overrideCloseTimeoutValue = properties.getPropertyAsInt("Ice.Override.CloseTimeout");
+ if(this.overrideCloseTimeoutValue < 1 && this.overrideCloseTimeoutValue !== -1)
+ {
+ this.overrideCloseTimeoutValue = -1;
+ logger.warning("invalid value for Ice.Override.CloseTimeout `" +
+ properties.getProperty("Ice.Override.CloseTimeout") + "': defaulting to -1");
+ }
+ }
+ else
+ {
+ this.overrideCloseTimeout = false;
this.overrideCloseTimeoutValue = -1;
- logger.warning("invalid value for Ice.Override.CloseTimeout `" +
- properties.getProperty("Ice.Override.CloseTimeout") + "': defaulting to -1");
}
- }
- else
- {
- this.overrideCloseTimeout = false;
- this.overrideCloseTimeoutValue = -1;
- }
- this.overrideCompress = false;
- this.overrideSecure = false;
+ this.overrideCompress = false;
+ this.overrideSecure = false;
- value = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
- if(value === "Random")
- {
- this.defaultEndpointSelection = EndpointSelectionType.Random;
- }
- else if(value === "Ordered")
- {
- this.defaultEndpointSelection = EndpointSelectionType.Ordered;
- }
- else
- {
- var ex = new Ice.EndpointSelectionTypeParseException();
- ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
- throw ex;
- }
+ value = properties.getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
+ if(value === "Random")
+ {
+ this.defaultEndpointSelection = EndpointSelectionType.Random;
+ }
+ else if(value === "Ordered")
+ {
+ this.defaultEndpointSelection = EndpointSelectionType.Ordered;
+ }
+ else
+ {
+ let ex = new Ice.EndpointSelectionTypeParseException();
+ ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
+ throw ex;
+ }
- this.defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
- if(this.defaultTimeout < 1 && this.defaultTimeout !== -1)
- {
- this.defaultTimeout = 60000;
- logger.warning("invalid value for Ice.Default.Timeout `" + properties.getProperty("Ice.Default.Timeout") +
- "': defaulting to 60000");
- }
+ this.defaultTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.Timeout", 60000);
+ if(this.defaultTimeout < 1 && this.defaultTimeout !== -1)
+ {
+ this.defaultTimeout = 60000;
+ logger.warning("invalid value for Ice.Default.Timeout `" + properties.getProperty("Ice.Default.Timeout") +
+ "': defaulting to 60000");
+ }
- this.defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
- if(this.defaultLocatorCacheTimeout < -1)
- {
- this.defaultLocatorCacheTimeout = -1;
- logger.warning("invalid value for Ice.Default.LocatorCacheTimeout `" +
- properties.getProperty("Ice.Default.LocatorCacheTimeout") + "': defaulting to -1");
- }
+ this.defaultLocatorCacheTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
+ if(this.defaultLocatorCacheTimeout < -1)
+ {
+ this.defaultLocatorCacheTimeout = -1;
+ logger.warning("invalid value for Ice.Default.LocatorCacheTimeout `" +
+ properties.getProperty("Ice.Default.LocatorCacheTimeout") + "': defaulting to -1");
+ }
- this.defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
- if(this.defaultInvocationTimeout < 1 && this.defaultInvocationTimeout !== -1)
- {
- this.defaultInvocationTimeout = -1;
- logger.warning("invalid value for Ice.Default.InvocationTimeout `" +
- properties.getProperty("Ice.Default.InvocationTimeout") + "': defaulting to -1");
- }
+ this.defaultInvocationTimeout = properties.getPropertyAsIntWithDefault("Ice.Default.InvocationTimeout", -1);
+ if(this.defaultInvocationTimeout < 1 && this.defaultInvocationTimeout !== -1)
+ {
+ this.defaultInvocationTimeout = -1;
+ logger.warning("invalid value for Ice.Default.InvocationTimeout `" +
+ properties.getProperty("Ice.Default.InvocationTimeout") + "': defaulting to -1");
+ }
- this.defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
+ this.defaultPreferSecure = properties.getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
- value = properties.getPropertyWithDefault("Ice.Default.EncodingVersion",
- Ice.encodingVersionToString(Protocol.currentEncoding));
- this.defaultEncoding = Ice.stringToEncodingVersion(value);
- Protocol.checkSupportedEncoding(this.defaultEncoding);
+ value = properties.getPropertyWithDefault("Ice.Default.EncodingVersion",
+ Ice.encodingVersionToString(Protocol.currentEncoding));
+ this.defaultEncoding = Ice.stringToEncodingVersion(value);
+ Protocol.checkSupportedEncoding(this.defaultEncoding);
- var slicedFormat = properties.getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
- this.defaultFormat = slicedFormat ? FormatType.SlicedFormat : FormatType.CompactFormat;
-};
+ const slicedFormat = properties.getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
+ this.defaultFormat = slicedFormat ? FormatType.SlicedFormat : FormatType.CompactFormat;
+ }
+}
Ice.DefaultsAndOverrides = DefaultsAndOverrides;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/DispatchStatus.js b/js/src/Ice/DispatchStatus.js
index 6525d77fafd..9f0f5b217e9 100644
--- a/js/src/Ice/DispatchStatus.js
+++ b/js/src/Ice/DispatchStatus.js
@@ -7,6 +7,6 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.DispatchStatus = {DispatchOK: 0, DispatchUserException: 1, DispatchAsync: 2};
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.DispatchStatus = { DispatchOK: 0, DispatchUserException: 1, DispatchAsync: 2 };
module.exports.Ice = Ice;
diff --git a/js/src/Ice/EndpointFactoryManager.js b/js/src/Ice/EndpointFactoryManager.js
index 6c6692ee19f..8570d8a757c 100644
--- a/js/src/Ice/EndpointFactoryManager.js
+++ b/js/src/Ice/EndpointFactoryManager.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/StringUtil",
"../Ice/Stream",
"../Ice/Debug",
@@ -22,67 +21,59 @@ Ice.__M.require(module,
//
// Local aliases.
//
-var Debug = Ice.Debug;
-var InputStream = Ice.InputStream;
-var OutputStream = Ice.OutputStream;
-var EndpointParseException = Ice.EndpointParseException;
-var OpaqueEndpointI = Ice.OpaqueEndpointI;
-var Protocol = Ice.Protocol;
-var StringUtil = Ice.StringUtil;
+const Debug = Ice.Debug;
+const InputStream = Ice.InputStream;
+const OutputStream = Ice.OutputStream;
+const EndpointParseException = Ice.EndpointParseException;
+const OpaqueEndpointI = Ice.OpaqueEndpointI;
+const Protocol = Ice.Protocol;
+const StringUtil = Ice.StringUtil;
-var EndpointFactoryManager = Ice.Class({
- __init__: function(instance)
+class EndpointFactoryManager
+{
+ constructor(instance)
{
this._instance = instance;
this._factories = [];
- },
- add: function(factory)
- {
- for(var i = 0; i < this._factories.length; ++i)
- {
- Debug.assert(this._factories[i].type() != factory.type());
- }
+ }
+ add(factory)
+ {
+ Debug.assert(this._factories.find(f => factory.type() == f.type()) === undefined);
this._factories.push(factory);
- },
- get: function(type)
+ }
+
+ get(type)
{
- for(var i = 0; i < this._factories.length; ++i)
- {
- if(this._factories[i].type() === type)
- {
- return this._factories[i];
- }
- }
- return null;
- },
- create: function(str, oaEndpoint)
+ return this._factories.find(f => type == f.type()) || null;
+ }
+
+ create(str, oaEndpoint)
{
- var s = str.trim();
+ const s = str.trim();
if(s.length === 0)
{
throw new EndpointParseException("value has no non-whitespace characters");
}
- var arr = StringUtil.splitString(s, " \t\n\r");
+ const arr = StringUtil.splitString(s, " \t\n\r");
if(arr.length === 0)
{
throw new EndpointParseException("value has no non-whitespace characters");
}
- var protocol = arr[0];
+ let protocol = arr[0];
arr.splice(0, 1);
if(protocol === "default")
{
protocol = this._instance.defaultsAndOverrides().defaultProtocol;
}
-
- for(var i = 0, length = this._factories.length; i < length; ++i)
+ for(let i = 0, length = this._factories.length; i < length; ++i)
{
if(this._factories[i].protocol() === protocol)
{
- var e = this._factories[i].create(arr, oaEndpoint);
+ const e = this._factories[i].create(arr, oaEndpoint);
if(arr.length > 0)
{
throw new EndpointParseException("unrecognized argument `" + arr[0] + "' in endpoint `" +
@@ -98,14 +89,14 @@ var EndpointFactoryManager = Ice.Class({
//
if(protocol === "opaque")
{
- var ue = new OpaqueEndpointI();
+ const ue = new OpaqueEndpointI();
ue.initWithOptions(arr);
if(arr.length > 0)
{
throw new EndpointParseException("unrecognized argument `" + arr[0] + "' in endpoint `" + str + "'");
}
- for(i = 0, length = this._factories.length; i < length; ++i)
+ for(let i = 0, length = this._factories.length; i < length; ++i)
{
if(this._factories[i].type() == ue.type())
{
@@ -114,14 +105,14 @@ var EndpointFactoryManager = Ice.Class({
// and ask the factory to read the endpoint data from that stream to create
// the actual endpoint.
//
- var os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
+ const os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
os.writeShort(ue.type());
ue.streamWrite(os);
- var is = new InputStream(this._instance, Protocol.currentProtocolEncoding, os.buffer);
+ const is = new InputStream(this._instance, Protocol.currentProtocolEncoding, os.buffer);
is.pos = 0;
is.readShort(); // type
is.startEncapsulation();
- var e = this._factories[i].read(is);
+ const e = this._factories[i].read(is);
is.endEncapsulation();
return e;
}
@@ -130,36 +121,34 @@ var EndpointFactoryManager = Ice.Class({
}
return null;
- },
- read: function(s)
+ }
+
+ read(s)
{
- var e;
- var type = s.readShort();
- for(var i = 0; i < this._factories.length; ++i)
+ const type = s.readShort();
+ for(let i = 0; i < this._factories.length; ++i)
{
if(this._factories[i].type() == type)
{
s.startEncapsulation();
- e = this._factories[i].read(s);
+ const e = this._factories[i].read(s);
s.endEncapsulation();
return e;
}
}
s.startEncapsulation();
- e = new OpaqueEndpointI(type);
+ const e = new OpaqueEndpointI(type);
e.initWithStream(s);
s.endEncapsulation();
return e;
- },
- destroy: function()
+ }
+
+ destroy()
{
- for(var i = 0; i < this._factories.length; ++i)
- {
- this._factories[i].destroy();
- }
+ this._factories.forEach(factory => factory.destroy());
this._factories = [];
}
-});
+}
Ice.EndpointFactoryManager = EndpointFactoryManager;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/EndpointI.js b/js/src/Ice/EndpointI.js
index 29352ec172a..34b0ceffb01 100644
--- a/js/src/Ice/EndpointI.js
+++ b/js/src/Ice/EndpointI.js
@@ -7,17 +7,11 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module,
- [
- "../Ice/Class",
- "../Ice/Endpoint",
- ]);
+const Ice = require("../Ice/Endpoint").Ice;
-var Class = Ice.Class;
-
-var EndpointI = Class(Ice.Endpoint, {
- toString: function()
+class EndpointI extends Ice.Endpoint
+{
+ toString()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
@@ -27,14 +21,14 @@ var EndpointI = Class(Ice.Endpoint, {
// format of proxyToString() before changing this and related code.
//
return this.protocol() + this.options();
- },
- initWithOptions: function(args)
+ }
+
+ initWithOptions(args)
{
- var unknown = [];
+ const unknown = [];
- var i;
- var str = "`" + this.protocol();
- for(i = 0; i < args.length; ++i)
+ let str = "`" + this.protocol();
+ for(let i = 0; i < args.length; ++i)
{
if(args[i].search(/[ \t\n\r]+/) !== -1)
{
@@ -47,17 +41,16 @@ var EndpointI = Class(Ice.Endpoint, {
}
str += "'";
- i = 0;
- while(i < args.length)
+ for(let i = 0; i < args.length;)
{
- var option = args[i++];
+ let option = args[i++];
if(option.length < 2 || option.charAt(0) != '-')
{
unknown.push(option);
continue;
}
- var argument = null;
+ let argument = null;
if(i < args.length && args[i].charAt(0) != '-')
{
argument = args[i++];
@@ -74,27 +67,28 @@ var EndpointI = Class(Ice.Endpoint, {
}
args.length = 0;
- for(i = 0; i < unknown.length; i++)
+ for(let i = 0; i < unknown.length; i++)
{
args.push(unknown[i]);
}
- },
+ }
//
// Compare endpoints for sorting purposes
//
- equals: function(p)
+ equals(p)
{
if(!(p instanceof EndpointI))
{
return false;
}
return this.compareTo(p) === 0;
- },
- checkOption: function()
+ }
+
+ checkOption()
{
return false;
}
-});
+}
Ice.EndpointI = EndpointI;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/EnumBase.js b/js/src/Ice/EnumBase.js
index 56c6de335cd..8cc6cb1b616 100644
--- a/js/src/Ice/EnumBase.js
+++ b/js/src/Ice/EnumBase.js
@@ -7,98 +7,105 @@
//
// **********************************************************************
-var Ice = require("../Ice/Class").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
//
// Ice.EnumBase
//
-var EnumBase = Ice.Class({
- __init__: function(name, value)
+class EnumBase
+{
+ constructor(name, value)
{
this._name = name;
this._value = value;
- },
- equals: function(rhs)
+ }
+
+ equals(rhs)
{
if(this === rhs)
{
return true;
}
- var proto = Object.getPrototypeOf(this);
- if(!(rhs instanceof proto.constructor))
+ if(!(rhs instanceof Object.getPrototypeOf(this).constructor))
{
return false;
}
return this._value == rhs._value;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
return this._value;
- },
- toString: function()
+ }
+
+ toString()
{
return this._name;
}
-});
+
+ get name()
+ {
+ return this._name;
+ }
+
+ get value()
+ {
+ return this._value;
+ }
+}
Ice.EnumBase = EnumBase;
-var prototype = EnumBase.prototype;
-
-Object.defineProperty(prototype, 'name', {
- enumerable: true,
- get: function() { return this._name; }
-});
-
-Object.defineProperty(prototype, 'value', {
- enumerable: true,
- get: function() { return this._value; }
-});
-
-var EnumHelper = Ice.Class({
- __init__: function(enumType)
+class EnumHelper
+{
+ constructor(enumType)
{
this._enumType = enumType;
- },
- write: function(os, v)
+ }
+
+ write(os, v)
{
this._enumType.__write(os, v);
- },
- writeOptional: function(os, tag, v)
+ }
+
+ writeOptional(os, tag, v)
{
this._enumType.__writeOpt(os, tag, v);
- },
- read: function(is)
+ }
+
+ read(is)
{
return this._enumType.__read(is);
- },
- readOptional: function(is, tag)
+ }
+
+ readOptional(is, tag)
{
return this._enumType.__readOpt(is, tag);
}
-});
+}
Ice.EnumHelper = EnumHelper;
-var Slice = Ice.Slice;
+const Slice = Ice.Slice;
Slice.defineEnum = function(enumerators)
{
- var type = function(n, v)
+ const type = class extends EnumBase
{
- EnumBase.call(this, n, v);
+ constructor(n, v)
+ {
+ super(n, v);
+ }
};
- type.prototype = new EnumBase();
- type.prototype.constructor = type;
-
- var enums = [];
- var maxValue = 0;
- var firstEnum = null;
- for(var idx in enumerators)
+ const enums = [];
+ let maxValue = 0;
+ let firstEnum = null;
+
+ for(let idx in enumerators)
{
- var e = enumerators[idx][0], value = enumerators[idx][1];
- var enumerator = new type(e, value);
+ let e = enumerators[idx][0], value = enumerators[idx][1];
+ let enumerator = new type(e, value);
enums[value] = enumerator;
if(!firstEnum)
{
diff --git a/js/src/Ice/ExUtil.js b/js/src/Ice/ExUtil.js
index b514a7dfe4c..125f14acce0 100644
--- a/js/src/Ice/ExUtil.js
+++ b/js/src/Ice/ExUtil.js
@@ -7,13 +7,13 @@
//
// **********************************************************************
-var Ice = require("../Ice/LocalException").Ice;
+const Ice = require("../Ice/LocalException").Ice;
//
// Local aliases.
//
-var UnexpectedObjectException = Ice.UnexpectedObjectException;
-var MemoryLimitException = Ice.MemoryLimitException;
+const UnexpectedObjectException = Ice.UnexpectedObjectException;
+const MemoryLimitException = Ice.MemoryLimitException;
//
// Exception utilities
@@ -23,7 +23,7 @@ Ice.ExUtil =
{
throwUOE: function(expectedType, v)
{
- var type = v.ice_id();
+ const type = v.ice_id();
throw new UnexpectedObjectException("expected element of type `" + expectedType + "' but received '" +
type, type, expectedType);
},
diff --git a/js/src/Ice/Exception.js b/js/src/Ice/Exception.js
index 3b21ad75662..973c4ff7436 100644
--- a/js/src/Ice/Exception.js
+++ b/js/src/Ice/Exception.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/Class").Ice;
-var Class = Ice.Class;
+const Ice = require("../Ice/ModuleRegistry").Ice;
-var toString = function(key, object, objectTable, ident)
+const toString = function(key, object, objectTable, ident)
{
ident += " ";
if(object === null)
@@ -35,8 +34,8 @@ var toString = function(key, object, objectTable, ident)
}
objectTable.push(object);
- var s = "\n" + ident + key + ":";
- for(var k in object)
+ let s = "\n" + ident + key + ":";
+ for(let k in object)
{
if(key.indexOf("_") === 0)
{
@@ -55,19 +54,23 @@ var toString = function(key, object, objectTable, ident)
//
// Ice.Exception
//
-var Exception = Class(Error, {
- __init__: function(cause)
+class Exception extends Error
+{
+ constructor(cause)
{
+ super();
if(cause)
{
this.ice_cause = cause;
}
- },
- ice_name: function()
+ }
+
+ ice_name()
{
return "Ice::Exception";
- },
- toString: function()
+ }
+
+ toString()
{
//
// We have a guard here to prevent being re-entered. With some browsers (IE), accessing
@@ -80,8 +83,8 @@ var Exception = Class(Error, {
}
this._inToStringAlready = true;
- var s = this.ice_name();
- for(var key in this)
+ let s = this.ice_name();
+ for(let key in this)
{
if(key != "_inToStringAlready")
{
@@ -96,94 +99,96 @@ var Exception = Class(Error, {
this._inToStringAlready = false;
return s;
}
-});
-
-Exception.captureStackTrace = function(object)
-{
- var stack = new Error().stack;
- //
- // In IE 10 and greater the stack will be filled once the Error is throw
- // we don't need to do anything.
- //
- if(stack !== undefined)
+
+ static captureStackTrace(object)
{
- Object.defineProperty(object, "stack", {
- get: function(){
- return stack;
- }
- });
+ const stack = new Error().stack;
+ //
+ // In IE 10 and greater the stack will be filled once the Error is throw
+ // we don't need to do anything.
+ //
+ if(stack !== undefined)
+ {
+ Object.defineProperty(object, "stack", {
+ get: function()
+ {
+ return stack;
+ }
+ });
+ }
}
-};
+}
Ice.Exception = Exception;
//
// Ice.LocalException
//
-var LocalException = Class(Exception, {
- __init__: function(cause)
+class LocalException extends Exception
+{
+ constructor(cause)
{
- Exception.call(this, cause);
+ super(cause);
Exception.captureStackTrace(this);
- },
- ice_name: function()
+ }
+
+ ice_name()
{
return "Ice::LocalException";
}
-});
+}
Ice.LocalException = LocalException;
-var Slice = Ice.Slice;
-Slice.defineLocalException = function(constructor, base, name)
-{
- var ex = constructor;
- ex.prototype = new base();
- ex.prototype.constructor = ex;
- ex.prototype.ice_name = function()
- {
- return name;
- };
- return ex;
-};
+const Slice = Ice.Slice;
//
// Ice.UserException
//
-var UserException = Class(Exception, {
- __init__: function(cause)
+class UserException extends Exception
+{
+ constructor(cause)
{
- Exception.call(this, cause);
+ super(cause);
Exception.captureStackTrace(this);
- },
- ice_name: function()
+ }
+
+ ice_name()
{
return "Ice::UserException";
- },
- __write: function(os)
+ }
+
+ __write(os)
{
os.startException(null);
__writeImpl(this, os, this.__mostDerivedType());
os.endException();
- },
- __read: function(is)
+ }
+
+ __read(is)
{
is.startException();
__readImpl(this, is, this.__mostDerivedType());
is.endException(false);
- },
- __usesClasses: function()
+ }
+
+ __usesClasses()
{
return false;
}
-});
+
+ __mostDerivedType()
+ {
+ return Ice.UserException;
+ }
+}
Ice.UserException = UserException;
//
// Private methods
//
-var __writeImpl = function(obj, os, type)
+const __writeImpl = function(obj, os, type)
{
//
// The __writeImpl method is a recursive method that goes down the
@@ -205,7 +210,7 @@ var __writeImpl = function(obj, os, type)
__writeImpl(obj, os, type.__parent);
};
-var __readImpl = function(obj, is, type)
+const __readImpl = function(obj, is, type)
{
//
// The __readImpl method is a recursive method that goes down the
@@ -227,7 +232,7 @@ var __readImpl = function(obj, is, type)
__readImpl(obj, is, type.__parent);
};
-var __writePreserved = function(os)
+const __writePreserved = function(os)
{
//
// For Slice exceptions which are marked "preserved", the implementation of this method
@@ -238,7 +243,7 @@ var __writePreserved = function(os)
os.endException();
};
-var __readPreserved = function(is)
+const __readPreserved = function(is)
{
//
// For Slice exceptions which are marked "preserved", the implementation of this method
@@ -249,35 +254,10 @@ var __readPreserved = function(is)
this.__slicedData = is.endException(true);
};
-Slice.defineUserException = function(constructor, base, name, writeImpl, readImpl, preserved, usesClasses)
+Slice.PreservedUserException = function(ex)
{
- var ex = constructor;
- ex.__parent = base;
- ex.prototype = new base();
- ex.__id = "::" + name;
- ex.prototype.ice_name = function()
- {
- return name;
- };
-
- ex.prototype.constructor = ex;
- ex.prototype.__mostDerivedType = function() { return ex; };
- if(preserved)
- {
- ex.prototype.__write = __writePreserved;
- ex.prototype.__read = __readPreserved;
- }
- ex.prototype.__writeMemberImpl = writeImpl;
- ex.prototype.__readMemberImpl = readImpl;
-
- if(usesClasses)
- {
- ex.prototype.__usesClasses = function()
- {
- return true;
- };
- }
-
- return ex;
+ ex.prototype.__write = __writePreserved;
+ ex.prototype.__read = __readPreserved;
};
+
module.exports.Ice = Ice;
diff --git a/js/src/Ice/FormatType.js b/js/src/Ice/FormatType.js
index 4972b2b1d92..b12547a8a19 100644
--- a/js/src/Ice/FormatType.js
+++ b/js/src/Ice/FormatType.js
@@ -7,6 +7,6 @@
//
// **********************************************************************
-var Ice = require("../Ice/EnumBase").Ice;
+const Ice = require("../Ice/EnumBase").Ice;
Ice.FormatType = Ice.Slice.defineEnum([['DefaultFormat', 0], ['CompactFormat',1], ['SlicedFormat',2]]);
module.exports.Ice = Ice;
diff --git a/js/src/Ice/HashMap.js b/js/src/Ice/HashMap.js
index 20be20ebf26..b7a223bc777 100644
--- a/js/src/Ice/HashMap.js
+++ b/js/src/Ice/HashMap.js
@@ -7,17 +7,17 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-var __M = Ice.__M;
-__M.require(module, ["../Ice/Class", "../Ice/StringUtil", "../Ice/UUID"]);
-var StringUtil = Ice.StringUtil;
+const Ice = require("../Ice/ModuleRegistry").Ice;
+const __M = Ice.__M;
+__M.require(module, ["../Ice/StringUtil", "../Ice/UUID"]);
+const StringUtil = Ice.StringUtil;
function setInternal(map, key, value, hash, index)
{
//
// Search for an entry with the same key.
//
- for(var e = map._table[index]; e !== null; e = e._nextInBucket)
+ for(let e = map._table[index]; e !== null; e = e._nextInBucket)
{
if(e._hash === hash && map.keysEqual(key, e._key))
{
@@ -54,16 +54,15 @@ function compareIdentity(v1, v2)
return v1 === v2;
}
-var HashMap = Ice.Class({
- __init__: function(arg1, arg2)
+class HashMap
+{
+ constructor(arg1, arg2)
{
//
// The first argument can be a HashMap or the keyComparator, the second
// argument if present is always the value comparator.
//
- var args = arguments;
-
- var h, keyComparator, valueComparator;
+ let h, keyComparator, valueComparator;
if(typeof arg1 == "function")
{
@@ -86,13 +85,11 @@ var HashMap = Ice.Class({
this._keyComparator = (typeof keyComparator == "function") ? keyComparator : compareIdentity;
this._valueComparator = (typeof valueComparator == "function") ? valueComparator : compareIdentity;
- var i, length;
if(h instanceof HashMap && h._size > 0)
{
this._threshold = h._threshold;
- length = h._table.length;
- this._table.length = length;
- for(i = 0; i < length; i++)
+ this._table.length = h._table.length;
+ for(let i = 0; i < h._table.length; i++)
{
this._table[i] = null;
}
@@ -101,42 +98,46 @@ var HashMap = Ice.Class({
else
{
this._threshold = this._initialCapacity * this._loadFactor;
- for(i = 0; i < this._initialCapacity; i++)
+ for(let i = 0; i < this._initialCapacity; i++)
{
this._table[i] = null;
}
}
- },
- set: function(key, value)
+ }
+
+ set(key, value)
{
- var r = this.computeHash(key); // Returns an object with key,hash members.
+ const r = this.computeHash(key); // Returns an object with key,hash members.
- var index = this.hashIndex(r.hash, this._table.length);
+ const index = this.hashIndex(r.hash, this._table.length);
return setInternal(this, r.key, value, r.hash, index);
- },
- get: function(key)
+ }
+
+ get(key)
{
- var r = this.computeHash(key); // Returns an object with key,hash members.
- var e = this.findEntry(r.key, r.hash);
+ const r = this.computeHash(key); // Returns an object with key,hash members.
+ const e = this.findEntry(r.key, r.hash);
return e !== undefined ? e._value : undefined;
- },
- has: function(key)
+ }
+
+ has(key)
{
- var r = this.computeHash(key); // Returns an object with key,hash members.
+ const r = this.computeHash(key); // Returns an object with key,hash members.
return this.findEntry(r.key, r.hash) !== undefined;
- },
- delete: function(key)
+ }
+
+ delete(key)
{
- var r = this.computeHash(key); // Returns an object with key,hash members.
+ const r = this.computeHash(key); // Returns an object with key,hash members.
- var index = this.hashIndex(r.hash, this._table.length);
+ const index = this.hashIndex(r.hash, this._table.length);
//
// Search for an entry with the same key.
//
- var prev = null;
- for(var e = this._table[index]; e !== null; e = e._nextInBucket)
+ let prev = null;
+ for(let e = this._table[index]; e !== null; e = e._nextInBucket)
{
if(e._hash === r.hash && this.keysEqual(r.key, e._key))
{
@@ -181,85 +182,88 @@ var HashMap = Ice.Class({
}
return undefined;
- },
- clear: function()
+ }
+
+ clear()
{
- for(var i = 0; i < this._table.length; ++i)
+ for(let i = 0; i < this._table.length; ++i)
{
this._table[i] = null;
}
this._head = null;
this._size = 0;
- },
- forEach: function(fn, obj)
+ }
+
+ forEach(fn, obj)
{
obj = obj === undefined ? fn : obj;
- for(var e = this._head; e !== null; e = e._next)
+ for(let e = this._head; e !== null; e = e._next)
+ {
+ fn.call(obj, e._value, e._key);
+ }
+ }
+
+ *entries()
+ {
+ for(let e = this._head; e !== null; e = e._next)
{
- fn.call(obj, e._key, e._value);
+ yield [e._key, e._value];
}
- },
- keys: function()
+ }
+
+ *keys()
{
- var k = [];
- var i = 0;
- for(var e = this._head; e !== null; e = e._next)
+ for(let e = this._head; e !== null; e = e._next)
{
- k[i++] = e._key;
+ yield e._key;
}
- return k;
- },
- values: function()
+ }
+
+ *values()
{
- var v = [];
- var i = 0;
- for(var e = this._head; e !== null; e = e._next)
+ for(let e = this._head; e !== null; e = e._next)
{
- v[i++] = e._value;
+ yield e._value;
}
- return v;
- },
- equals: function(other, valuesEqual)
+ }
+
+ equals(other, valuesEqual)
{
if(other === null || !(other instanceof HashMap) || this._size !== other._size)
{
return false;
}
- var self = this;
- var eq = valuesEqual || function(v1, v2)
+ const eq = valuesEqual || ((v1, v2) =>
{
- return self._valueComparator.call(self._valueComparator, v1, v2);
- };
+ return this._valueComparator.call(this._valueComparator, v1, v2);
+ });
- for(var e = this._head; e !== null; e = e._next)
+ for(let e = this._head; e !== null; e = e._next)
{
- var oe = other.findEntry(e._key, e._hash);
+ const oe = other.findEntry(e._key, e._hash);
if(oe === undefined || !eq(e._value, oe._value))
{
return false;
}
}
-
return true;
- },
- clone: function()
- {
- return new HashMap(this);
- },
- merge: function(from)
+ }
+
+ merge(from)
{
- for(var e = from._head; e !== null; e = e._next)
+ for(let e = from._head; e !== null; e = e._next)
{
setInternal(this, e._key, e._value, e._hash, this.hashIndex(e._hash, this._table.length));
}
- },
- add: function(key, value, hash, index)
+ }
+
+ add(key, value, hash, index)
{
//
// Create a new table entry.
//
- var e = Object.create(null, {
+ let e = Object.create(null, {
"key": {
enumerable: true,
get: function() { return this._key; }
@@ -318,37 +322,33 @@ var HashMap = Ice.Class({
{
this.resize(this._table.length * 2);
}
- },
- resize: function(capacity)
- {
- var oldTable = this._table;
+ }
- var newTable = [];
- for(var i = 0; i < capacity; i++)
- {
- newTable[i] = null;
- }
+ resize(capacity)
+ {
+ const newTable = new Array(capacity).fill(null);
//
// Re-assign all entries to buckets.
//
- for(var e = this._head; e !== null; e = e._next)
+ for(let e = this._head; e !== null; e = e._next)
{
- var index = this.hashIndex(e._hash, capacity);
+ let index = this.hashIndex(e._hash, capacity);
e._nextInBucket = newTable[index];
newTable[index] = e;
}
this._table = newTable;
this._threshold = (capacity * this._loadFactor);
- },
- findEntry: function(key, hash)
+ }
+
+ findEntry(key, hash)
{
- var index = this.hashIndex(hash, this._table.length);
+ let index = this.hashIndex(hash, this._table.length);
//
// Search for an entry with the same key.
//
- for(var e = this._table[index]; e !== null; e = e._nextInBucket)
+ for(let e = this._table[index]; e !== null; e = e._nextInBucket)
{
if(e._hash === hash && this.keysEqual(key, e._key))
{
@@ -357,14 +357,15 @@ var HashMap = Ice.Class({
}
return undefined;
- },
- hashIndex: function(hash, len)
+ }
+
+ hashIndex(hash, len)
{
return hash & (len - 1);
- },
- computeHash: function(v)
+ }
+
+ computeHash(v)
{
- var uuid;
if(v === 0 || v === -0)
{
return {key:0, hash:0};
@@ -374,7 +375,7 @@ var HashMap = Ice.Class({
{
if(HashMap._null === null)
{
- uuid = Ice.generateUUID();
+ let uuid = Ice.generateUUID();
HashMap._null = {key:uuid, hash:StringUtil.hashCode(uuid)};
}
return HashMap._null;
@@ -390,7 +391,7 @@ var HashMap = Ice.Class({
return {key:v, hash:v.hashCode()};
}
- var type = typeof(v);
+ const type = typeof(v);
if(type === "string" || v instanceof String)
{
return {key:v, hash:StringUtil.hashCode(v)};
@@ -401,7 +402,7 @@ var HashMap = Ice.Class({
{
if(HashMap._nan === null)
{
- uuid = Ice.generateUUID();
+ let uuid = Ice.generateUUID();
HashMap._nan = {key:uuid, hash:StringUtil.hashCode(uuid)};
}
return HashMap._nan;
@@ -414,12 +415,21 @@ var HashMap = Ice.Class({
}
throw new Error("cannot compute hash for value of type " + type);
- },
- keysEqual: function(k1, k2)
+ }
+
+ keysEqual(k1, k2)
{
return this._keyComparator.call(this._keyComparator, k1, k2);
}
-});
+
+ get size()
+ {
+ return this._size;
+ }
+}
+
+HashMap.prototype[Symbol.iterator] = HashMap.prototype.entries;
+
Ice.HashMap = HashMap;
HashMap.compareEquals = compareEquals;
@@ -427,20 +437,15 @@ HashMap.compareIdentity = compareIdentity;
HashMap._null = null;
HashMap._nan = null;
-var prototype = HashMap.prototype;
-
-Object.defineProperty(prototype, "size", {
- get: function() { return this._size; }
-});
-
-Object.defineProperty(prototype, "entries", {
- get: function() { return this._head; }
-});
+const Slice = Ice.Slice;
-var Slice = Ice.Slice;
-Slice.defineDictionary = function(module, name, helperName, keyHelper, valueHelper, fixed, keysEqual, valueType, valuesEqual)
+Slice.defineDictionary = function(module, name, helperName, keyHelper, valueHelper, fixed, keysEqual, valueType)
{
- if(keysEqual !== undefined || valuesEqual !== undefined)
+ if(keysEqual === undefined)
+ {
+ module[name] = Map;
+ }
+ else
{
//
// Define a constructor function for a dictionary whose key type requires
@@ -449,28 +454,25 @@ Slice.defineDictionary = function(module, name, helperName, keyHelper, valueHelp
//
module[name] = function(h)
{
- return new HashMap(h || keysEqual, valuesEqual);
+ return new HashMap(h || keysEqual);
};
}
- else
- {
- module[name] = HashMap;
- }
-
- var helper = null;
+
+ let helper = null;
Object.defineProperty(module, helperName,
{
get: function()
+ {
+ if(helper === null)
{
- if(helper === null)
- {
- /*jshint -W061 */
- helper = Ice.StreamHelpers.generateDictHelper(__M.type(keyHelper), __M.type(valueHelper), fixed,
- __M.type(valueType), module[name]);
- /*jshint +W061 */
- }
- return helper;
+ helper = Ice.StreamHelpers.generateDictHelper(__M.type(keyHelper),
+ __M.type(valueHelper),
+ fixed,
+ __M.type(valueType),
+ module[name]);
}
+ return helper;
+ }
});
};
module.exports.Ice = Ice;
diff --git a/js/src/Ice/HashUtil.js b/js/src/Ice/HashUtil.js
index c593278ae5f..fa0e61fd067 100644
--- a/js/src/Ice/HashUtil.js
+++ b/js/src/Ice/HashUtil.js
@@ -7,45 +7,51 @@
//
// **********************************************************************
-var Ice = require("../Ice/StringUtil").Ice;
-var StringUtil = Ice.StringUtil;
+const Ice = require("../Ice/StringUtil").Ice;
+const StringUtil = Ice.StringUtil;
-Ice.HashUtil =
+class HashUtil
{
- addBoolean: function(h, b)
+ static addBoolean(h, b)
{
return ((h << 5) + h) ^ (b ? 0 : 1);
- },
- addString: function(h, str)
+ }
+
+ static addString(h, str)
{
if(str !== undefined && str !== null)
{
h = ((h << 5) + h) ^ StringUtil.hashCode(str);
}
return h;
- },
- addNumber: function(h, num)
+ }
+
+ static addNumber(h, num)
{
return ((h << 5) + h) ^ num;
- },
- addHashable: function(h, obj)
+ }
+
+ static addHashable(h, obj)
{
if(obj !== undefined && obj !== null)
{
h = ((h << 5) + h) ^ obj.hashCode();
}
return h;
- },
- addArray: function(h, arr, hashCode)
+ }
+
+ static addArray(h, arr, hashCode)
{
if(arr !== undefined && arr !== null)
{
- for(var i = 0; i < arr.length; ++i)
+ for(let i = 0; i < arr.length; ++i)
{
h = hashCode(h, arr[i]);
}
}
return h;
}
-};
+}
+
+Ice.HashUtil = HashUtil;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/IPEndpointI.js b/js/src/Ice/IPEndpointI.js
index d27c73c0806..cc268eb2949 100644
--- a/js/src/Ice/IPEndpointI.js
+++ b/js/src/Ice/IPEndpointI.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Address",
"../Ice/HashUtil",
"../Ice/StringUtil",
@@ -18,65 +17,73 @@ Ice.__M.require(module,
"../Ice/LocalException"
]);
-var Address = Ice.Address;
-var HashUtil = Ice.HashUtil;
-var StringUtil = Ice.StringUtil;
-var Class = Ice.Class;
-var EndpointParseException = Ice.EndpointParseException;
+const Address = Ice.Address;
+const HashUtil = Ice.HashUtil;
+const StringUtil = Ice.StringUtil;
+const EndpointParseException = Ice.EndpointParseException;
-var IPEndpointI = Class(Ice.EndpointI, {
- __init__: function(instance, ho, po, sa, conId)
+class IPEndpointI extends Ice.EndpointI
+{
+ constructor(instance, ho, po, sa, conId)
{
+ super();
this._instance = instance;
this._host = ho === undefined ? null : ho;
this._port = po === undefined ? null : po;
this._sourceAddr = sa === undefined ? null : sa;
this._connectionId = conId === undefined ? "" : conId;
- },
+ }
+
//
// Marshal the endpoint
//
- streamWrite: function(s)
+ streamWrite(s)
{
s.startEncapsulation();
this.streamWriteImpl(s);
s.endEncapsulation();
- },
- getInfo: function()
+ }
+
+ getInfo()
{
- var info = new Ice.IPEndpointInfo();
+ const info = new Ice.IPEndpointInfo();
this.fillEndpointInfo(info);
return info;
- },
+ }
+
//
// Return the endpoint type
//
- type: function()
+ type()
{
return this._instance.type();
- },
+ }
+
//
// Return the protocol string
//
- protocol: function()
+ protocol()
{
return this._instance.protocol();
- },
+ }
+
//
// Return true if the endpoint is secure.
//
- secure: function()
+ secure()
{
return this._instance.secure();
- },
- connectionId: function()
+ }
+
+ connectionId()
{
return this._connectionId;
- },
+ }
+
//
// Return a new endpoint with a different connection id.
//
- changeConnectionId: function(connectionId)
+ changeConnectionId(connectionId)
{
if(connectionId === this._connectionId)
{
@@ -86,19 +93,21 @@ var IPEndpointI = Class(Ice.EndpointI, {
{
return this.createEndpoint(this._host, this._port, connectionId);
}
- },
+ }
+
//
// Return the endpoint information.
//
- hashCode: function()
+ hashCode()
{
if(this._hashCode === undefined)
{
this._hashCode = this.hashInit(5381);
}
return this._hashCode;
- },
- options: function()
+ }
+
+ options()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
@@ -107,12 +116,12 @@ var IPEndpointI = Class(Ice.EndpointI, {
// these features. Please review for all features that depend on the
// format of proxyToString() before changing this and related code.
//
- var s = "";
+ let s = "";
if(this._host !== null && this._host.length > 0)
{
s += " -h ";
- var addQuote = this._host.indexOf(':') != -1;
+ const addQuote = this._host.indexOf(':') != -1;
if(addQuote)
{
s += "\"";
@@ -131,8 +140,9 @@ var IPEndpointI = Class(Ice.EndpointI, {
s += " --sourceAddr " + this._sourceAddr;
}
return s;
- },
- compareTo: function(p)
+ }
+
+ compareTo(p)
{
if(this === p)
{
@@ -174,24 +184,28 @@ var IPEndpointI = Class(Ice.EndpointI, {
}
return 0;
- },
- getAddress: function()
+ }
+
+ getAddress()
{
return new Address(this._host, this._port);
- },
+ }
+
//
// Convert the endpoint to its Connector string form
//
- toConnectorString: function()
+ toConnectorString()
{
return this._host + ":" + this._port;
- },
- streamWriteImpl: function(s)
+ }
+
+ streamWriteImpl(s)
{
s.writeString(this._host);
s.writeInt(this._port);
- },
- hashInit: function(h)
+ }
+
+ hashInit(h)
{
h = HashUtil.addNumber(h, this.type());
h = HashUtil.addString(h, this._host);
@@ -199,20 +213,21 @@ var IPEndpointI = Class(Ice.EndpointI, {
h = HashUtil.addString(h, this._sourceAddr);
h = HashUtil.addString(h, this._connectionId);
return h;
- },
- fillEndpointInfo: function(info)
+ }
+
+ fillEndpointInfo(info)
{
- var self = this;
- info.type = function() { return self.type(); };
- info.datagram = function() { return self.datagram(); };
- info.secure = function() { return self.secure(); };
+ info.type = () => this.type();
+ info.datagram = () => this.datagram();
+ info.secure = () => this.secure();
info.host = this._host;
info.port = this._port;
info.sourceAddress = this._sourceAddr;
- },
- initWithOptions: function(args, oaEndpoint)
+ }
+
+ initWithOptions(args, oaEndpoint)
{
- Ice.EndpointI.prototype.initWithOptions.call(this, args);
+ super.initWithOptions(args);
if(this._host === null || this._host.length === 0)
{
@@ -246,13 +261,15 @@ var IPEndpointI = Class(Ice.EndpointI, {
{
throw new EndpointParseException("`--sourceAddress not valid for object adapter endpoint `" + this + "'");
}
- },
- initWithStream: function(s)
+ }
+
+ initWithStream(s)
{
this._host = s.readString();
this._port = s.readInt();
- },
- checkOption: function(option, argument, str)
+ }
+
+ checkOption(option, argument, str)
{
if(option === "-h")
{
@@ -299,8 +316,7 @@ var IPEndpointI = Class(Ice.EndpointI, {
}
return true;
}
-});
+}
Ice.IPEndpointI = IPEndpointI;
module.exports.Ice = Ice;
-
diff --git a/js/src/Ice/Ice.js b/js/src/Ice/Ice.js
index e5565859db5..05b9e8d3aa5 100644
--- a/js/src/Ice/Ice.js
+++ b/js/src/Ice/Ice.js
@@ -8,7 +8,7 @@
// **********************************************************************
-var __M = require("../Ice/ModuleRegistry").Ice.__M;
+const __M = require("../Ice/ModuleRegistry").Ice.__M;
module.exports.Ice = __M.require(module,
[
@@ -38,7 +38,8 @@ module.exports.Ice = __M.require(module,
"../Ice/Buffer",
"../Ice/ArrayUtil",
"../Ice/UnknownSlicedValue",
- "../Ice/Process"
+ "../Ice/Process",
+ "../Ice/MapUtil"
]).Ice;
module.exports.IceMX = require("../Ice/Metrics").IceMX;
diff --git a/js/src/Ice/IdentityUtil.js b/js/src/Ice/IdentityUtil.js
index 87ee2c1b55e..1d5b79a4a51 100644
--- a/js/src/Ice/IdentityUtil.js
+++ b/js/src/Ice/IdentityUtil.js
@@ -7,12 +7,12 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module, [ "../Ice/StringUtil", "../Ice/Identity", "../Ice/LocalException"]);
-var StringUtil = Ice.StringUtil;
-var Identity = Ice.Identity;
-var IdentityParseException = Ice.IdentityParseException;
+const StringUtil = Ice.StringUtil;
+const Identity = Ice.Identity;
+const IdentityParseException = Ice.IdentityParseException;
/**
* Converts a string to an object identity.
@@ -23,17 +23,17 @@ var IdentityParseException = Ice.IdentityParseException;
**/
Ice.stringToIdentity = function(s)
{
- var ident = new Identity();
+ const ident = new Identity();
//
// Find unescaped separator; note that the string may contain an escaped
// backslash before the separator.
//
- var slash = -1;
- var pos = 0;
+ let slash = -1;
+ let pos = 0;
while((pos = s.indexOf('/', pos)) !== -1)
{
- var escapes = 0;
+ let escapes = 0;
while(pos - escapes > 0 && s.charAt(pos - escapes - 1) == '\\')
{
escapes++;
@@ -53,9 +53,7 @@ Ice.stringToIdentity = function(s)
//
// Extra unescaped slash found.
//
- var ex = new IdentityParseException();
- ex.str = "unescaped backslash in identity `" + s + "'";
- throw ex;
+ throw new IdentityParseException(`unescaped backslash in identity \`${s}'`);
}
}
pos++;
@@ -70,9 +68,7 @@ Ice.stringToIdentity = function(s)
}
catch(e)
{
- var ex = new IdentityParseException();
- ex.str = "invalid identity name `" + s + "': " + ex.toString();
- throw ex;
+ throw new IdentityParseException(`invalid identity name \`${s}': ${e.toString()}`);
}
}
else
@@ -83,9 +79,7 @@ Ice.stringToIdentity = function(s)
}
catch(e)
{
- var ex = new IdentityParseException();
- ex.str = "invalid category in identity `" + s + "': " + ex.toString();
- throw ex;
+ throw new IdentityParseException(`invalid category in identity \`${s}': ${e.toString()}`);
}
if(slash + 1 < s.length)
{
@@ -95,9 +89,7 @@ Ice.stringToIdentity = function(s)
}
catch(e)
{
- var ex = new IdentityParseException();
- ex.str = "invalid name in identity `" + s + "': " + ex.toString();
- throw ex;
+ throw new IdentityParseException(`invalid name in identity \`${s}': ${e.toString()}`);
}
}
else
@@ -157,14 +149,10 @@ Ice.proxyIdentityCompare = function(lhs, rhs)
}
else
{
- var lhsIdentity = lhs.ice_getIdentity();
- var rhsIdentity = rhs.ice_getIdentity();
- var n;
- if((n = lhsIdentity.name.localeCompare(rhsIdentity.name)) !== 0)
- {
- return n;
- }
- return lhsIdentity.category.localeCompare(rhsIdentity.category);
+ const lhsIdentity = lhs.ice_getIdentity();
+ const rhsIdentity = rhs.ice_getIdentity();
+ const n = lhsIdentity.name.localeCompare(rhsIdentity.name);
+ return (n !== 0) ? n : lhsIdentity.category.localeCompare(rhsIdentity.category);
}
};
@@ -197,20 +185,21 @@ Ice.proxyIdentityAndFacetCompare = function(lhs, rhs)
}
else
{
- var lhsIdentity = lhs.ice_getIdentity();
- var rhsIdentity = rhs.ice_getIdentity();
- var n;
- if((n = lhsIdentity.name.localeCompare(rhsIdentity.name)) !== 0)
+ const lhsIdentity = lhs.ice_getIdentity();
+ const rhsIdentity = rhs.ice_getIdentity();
+ let n = lhsIdentity.name.localeCompare(rhsIdentity.name);
+ if(n !== 0)
{
return n;
}
- if((n = lhsIdentity.category.localeCompare(rhsIdentity.category)) !== 0)
+ n = lhsIdentity.category.localeCompare(rhsIdentity.category);
+ if(n !== 0)
{
return n;
}
- var lhsFacet = lhs.ice_getFacet();
- var rhsFacet = rhs.ice_getFacet();
+ const lhsFacet = lhs.ice_getFacet();
+ const rhsFacet = rhs.ice_getFacet();
if(lhsFacet === null && rhsFacet === null)
{
return 0;
diff --git a/js/src/Ice/ImplicitContextI.js b/js/src/Ice/ImplicitContextI.js
index d1a01526288..b5cf0a640b3 100644
--- a/js/src/Ice/ImplicitContextI.js
+++ b/js/src/Ice/ImplicitContextI.js
@@ -7,25 +7,28 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/LocalException", "../Ice/Current", "../Ice/Class"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/LocalException", "../Ice/Current"]);
-var Context = Ice.Context;
-var InitializationException = Ice.InitializationException;
+const Context = Ice.Context;
+const InitializationException = Ice.InitializationException;
//
// The base class for all ImplicitContext implementations
//
-var ImplicitContextI = Ice.Class({
- __init__: function()
+class ImplicitContextI
+{
+ constructor()
{
this._context = new Context();
- },
- getContext: function()
+ }
+
+ getContext()
{
return new Context(this._context);
- },
- setContext: function(context)
+ }
+
+ setContext(context)
{
if(context !== null && context.size > 0)
{
@@ -35,8 +38,9 @@ var ImplicitContextI = Ice.Class({
{
this._context.clear();
}
- },
- containsKey: function(key)
+ }
+
+ containsKey(key)
{
if(key === null)
{
@@ -44,23 +48,25 @@ var ImplicitContextI = Ice.Class({
}
return this._context.has(key);
- },
- get: function(key)
+ }
+
+ get(key)
{
if(key === null)
{
key = "";
}
- var val = this._context.get(key);
+ let val = this._context.get(key);
if(val === null)
{
val = "";
}
return val;
- },
- put: function(key, value)
+ }
+
+ put(key, value)
{
if(key === null)
{
@@ -71,7 +77,7 @@ var ImplicitContextI = Ice.Class({
value = "";
}
- var oldVal = this._context.get(key);
+ let oldVal = this._context.get(key);
if(oldVal === null)
{
oldVal = "";
@@ -80,15 +86,16 @@ var ImplicitContextI = Ice.Class({
this._context.set(key, value);
return oldVal;
- },
- remove: function(key)
+ }
+
+ remove(key)
{
if(key === null)
{
key = "";
}
- var val = this._context.get(key);
+ let val = this._context.get(key);
this._context.delete(key);
if(val === null)
@@ -96,8 +103,9 @@ var ImplicitContextI = Ice.Class({
val = "";
}
return val;
- },
- write: function(prxContext, os)
+ }
+
+ write(prxContext, os)
{
if(prxContext.size === 0)
{
@@ -105,7 +113,7 @@ var ImplicitContextI = Ice.Class({
}
else
{
- var ctx = null;
+ let ctx = null;
if(this._context.size === 0)
{
ctx = prxContext;
@@ -113,27 +121,31 @@ var ImplicitContextI = Ice.Class({
else
{
ctx = new Context(this._context);
- ctx.merge(prxContext);
+ for(let [key, value] of prxContext)
+ {
+ ctx.set(key, value);
+ }
}
Ice.ContextHelper.write(os, ctx);
}
}
-});
-
-ImplicitContextI.create = function(kind)
-{
- if(kind.length === 0 || kind === "None")
- {
- return null;
- }
- else if(kind === "Shared")
+
+ static create(kind)
{
- return new ImplicitContextI();
- }
- else
- {
- throw new InitializationException("'" + kind + "' is not a valid value for Ice.ImplicitContext");
+ if(kind.length === 0 || kind === "None")
+ {
+ return null;
+ }
+ else if(kind === "Shared")
+ {
+ return new ImplicitContextI();
+ }
+ else
+ {
+ throw new InitializationException("'" + kind + "' is not a valid value for Ice.ImplicitContext");
+ }
}
-};
+}
+
Ice.ImplicitContextI = ImplicitContextI;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/IncomingAsync.js b/js/src/Ice/IncomingAsync.js
index 619ffd70892..30453faabc3 100644
--- a/js/src/Ice/IncomingAsync.js
+++ b/js/src/Ice/IncomingAsync.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Stream",
"../Ice/BuiltinSequences",
"../Ice/Connection",
@@ -24,17 +23,18 @@ Ice.__M.require(module,
"../Ice/StringUtil"
]);
-var OutputStream = Ice.OutputStream;
-var Current = Ice.Current;
-var Debug = Ice.Debug;
-var FormatType = Ice.FormatType;
-var Context = Ice.Context;
-var Identity = Ice.Identity;
-var Protocol = Ice.Protocol;
-var StringUtil = Ice.StringUtil;
-
-var IncomingAsync = Ice.Class({
- __init__: function(instance, connection, adapter, response, compress, requestId)
+const OutputStream = Ice.OutputStream;
+const Current = Ice.Current;
+const Debug = Ice.Debug;
+const FormatType = Ice.FormatType;
+const Context = Ice.Context;
+const Identity = Ice.Identity;
+const Protocol = Ice.Protocol;
+const StringUtil = Ice.StringUtil;
+
+class IncomingAsync
+{
+ constructor(instance, connection, adapter, response, compress, requestId)
{
this._instance = instance;
this._response = response;
@@ -72,8 +72,9 @@ var IncomingAsync = Ice.Class({
this._cb = null;
this._active = true;
- },
- __startWriteParams: function(format)
+ }
+
+ __startWriteParams(format)
{
if(!this._response)
{
@@ -85,19 +86,21 @@ var IncomingAsync = Ice.Class({
this._os.writeByte(0);
this._os.startEncapsulation(this._current.encoding, format);
return this._os;
- },
- __endWriteParams: function(ok)
+ }
+
+ __endWriteParams(ok)
{
if(this._response)
{
- var save = this._os.pos;
+ const save = this._os.pos;
this._os.pos = Protocol.headerSize + 4; // Reply status position.
this._os.writeByte(ok ? Protocol.replyOK : Protocol.replyUserException);
this._os.pos = save;
this._os.endEncapsulation();
}
- },
- __writeEmptyParams: function()
+ }
+
+ __writeEmptyParams()
{
if(this._response)
{
@@ -106,8 +109,9 @@ var IncomingAsync = Ice.Class({
this._os.writeByte(Protocol.replyOK);
this._os.writeEmptyEncapsulation(this._current.encoding);
}
- },
- __writeParamEncaps: function(v, ok)
+ }
+
+ __writeParamEncaps(v, ok)
{
if(this._response)
{
@@ -123,25 +127,27 @@ var IncomingAsync = Ice.Class({
this._os.writeEncapsulation(v);
}
}
- },
- __writeUserException: function(ex, format)
+ }
+
+ __writeUserException(ex, format)
{
- var os = this.__startWriteParams(format);
+ const os = this.__startWriteParams(format);
os.writeUserException(ex);
this.__endWriteParams(false);
- },
- __warning: function(ex)
+ }
+
+ __warning(ex)
{
Debug.assert(this._instance !== null);
- var s = [];
+ const s = [];
s.push("dispatch exception:");
s.push("\nidentity: " + Ice.identityToString(this._current.id));
s.push("\nfacet: " + StringUtil.escapeString(this._current.facet, ""));
s.push("\noperation: " + this._current.operation);
if(this._connection !== null)
{
- for(var p = this._connection.getInfo(); p; p = p.underlying)
+ for(let p = this._connection.getInfo(); p; p = p.underlying)
{
if(p instanceof Ice.IPConnectionInfo)
{
@@ -155,8 +161,9 @@ var IncomingAsync = Ice.Class({
s.push(ex.stack);
}
this._instance.initializationData().logger.warning(s.join(""));
- },
- __servantLocatorFinished: function()
+ }
+
+ __servantLocatorFinished()
{
Debug.assert(this._locator !== null && this._servant !== null);
try
@@ -195,13 +202,13 @@ var IncomingAsync = Ice.Class({
}
return false;
}
- },
- __handleException: function(ex)
+ }
+
+ __handleException(ex)
{
Debug.assert(this._connection !== null);
- var props = this._instance.initializationData().properties;
- var s;
+ const props = this._instance.initializationData().properties;
if(ex instanceof Ice.RequestFailedException)
{
if(ex.id === null)
@@ -335,7 +342,7 @@ var IncomingAsync = Ice.Class({
this._os.resize(Protocol.headerSize + 4); // Reply status position.
this._os.writeByte(Protocol.replyUnknownLocalException);
//this._os.writeString(ex.toString());
- s = [ ex.ice_name() ];
+ let s = [ ex.ice_name() ];
if(ex.stack)
{
s.push("\n");
@@ -361,7 +368,7 @@ var IncomingAsync = Ice.Class({
this._os.resize(Protocol.headerSize + 4); // Reply status position.
this._os.writeByte(Protocol.replyUnknownUserException);
//this._os.writeString(ex.toString());
- s = [ ex.ice_name() ];
+ let s = [ ex.ice_name() ];
if(ex.stack)
{
s.push("\n");
@@ -397,13 +404,12 @@ var IncomingAsync = Ice.Class({
}
this._connection = null;
- },
- invoke: function(servantManager, stream)
+ }
+
+ invoke(servantManager, stream)
{
this._is = stream;
- var start = this._is.pos;
-
//
// Read the current.
//
@@ -412,7 +418,7 @@ var IncomingAsync = Ice.Class({
//
// For compatibility with the old FacetPath.
//
- var facetPath = Ice.StringSeqHelper.read(this._is);
+ const facetPath = Ice.StringSeqHelper.read(this._is);
if(facetPath.length > 0)
{
if(facetPath.length > 1)
@@ -429,12 +435,10 @@ var IncomingAsync = Ice.Class({
this._current.operation = this._is.readString();
this._current.mode = Ice.OperationMode.valueOf(this._is.readByte());
this._current.ctx = new Context();
- var sz = this._is.readSize();
+ let sz = this._is.readSize();
while(sz-- > 0)
{
- var first = this._is.readString();
- var second = this._is.readString();
- this._current.ctx.set(first, second);
+ this._current.ctx.set(this._is.readString(), this._is.readString());
}
//
@@ -442,7 +446,6 @@ var IncomingAsync = Ice.Class({
// in the code above are considered fatal, and must propagate to
// the caller of this operation.
//
-
if(servantManager !== null)
{
this._servant = servantManager.findServant(this._current.id, this._current.facet);
@@ -464,8 +467,7 @@ var IncomingAsync = Ice.Class({
{
if(ex instanceof Ice.UserException)
{
- var encoding = this._is.skipEncapsulation(); // Required for batch requests.
-
+ const encoding = this._is.skipEncapsulation(); // Required for batch requests.
if(this._response)
{
this._os.writeByte(Protocol.replyUserException);
@@ -525,12 +527,12 @@ var IncomingAsync = Ice.Class({
if(servantManager !== null && servantManager.hasServant(this._current.id))
{
throw new Ice.FacetNotExistException(this._current.id, this._current.facet,
- this._current.operation);
+ this._current.operation);
}
else
{
throw new Ice.ObjectNotExistException(this._current.id, this._current.facet,
- this._current.operation);
+ this._current.operation);
}
}
}
@@ -562,8 +564,9 @@ var IncomingAsync = Ice.Class({
}
this._connection = null;
- },
- startReadParams: function()
+ }
+
+ startReadParams()
{
//
// Remember the encoding used by the input parameters, we'll
@@ -571,21 +574,25 @@ var IncomingAsync = Ice.Class({
//
this._current.encoding = this._is.startEncapsulation();
return this._is;
- },
- endReadParams: function()
+ }
+
+ endReadParams()
{
this._is.endEncapsulation();
- },
- readEmptyParams: function()
+ }
+
+ readEmptyParams()
{
this._current.encoding = this._is.skipEmptyEncapsulation();
- },
- readParamEncaps: function()
+ }
+
+ readParamEncaps()
{
this._current.encoding = new Ice.EncodingVersion();
return this._is.readEncapsulation(this._current.encoding);
- },
- __response: function()
+ }
+
+ __response()
{
try
{
@@ -611,8 +618,9 @@ var IncomingAsync = Ice.Class({
{
this._connection.invokeException(ex, 1);
}
- },
- __exception: function(exc)
+ }
+
+ __exception(exc)
{
try
{
@@ -627,8 +635,9 @@ var IncomingAsync = Ice.Class({
{
this._connection.invokeException(ex, 1);
}
- },
- __validateResponse: function(ok)
+ }
+
+ __validateResponse(ok)
{
if(!this._active)
{
@@ -636,8 +645,9 @@ var IncomingAsync = Ice.Class({
}
this._active = false;
return true;
- },
- ice_exception: function(ex)
+ }
+
+ ice_exception(ex)
{
if(!this._active)
{
@@ -660,7 +670,7 @@ var IncomingAsync = Ice.Class({
}
}
}
-});
+}
Ice.IncomingAsync = IncomingAsync;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Initialize.js b/js/src/Ice/Initialize.js
index 0f0ef6490a9..6ff5e1ce8ad 100644
--- a/js/src/Ice/Initialize.js
+++ b/js/src/Ice/Initialize.js
@@ -7,7 +7,7 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
"../Ice/Protocol",
@@ -16,7 +16,7 @@ Ice.__M.require(module,
"../Ice/Properties"
]);
-var Protocol = Ice.Protocol;
+const Protocol = Ice.Protocol;
//
// Ice.InitializationData
@@ -30,7 +30,7 @@ Ice.InitializationData = function()
Ice.InitializationData.prototype.clone = function()
{
- var r = new Ice.InitializationData();
+ const r = new Ice.InitializationData();
r.properties = this.properties;
r.logger = this.logger;
r.valueFactoryManager = this.valueFactoryManager;
@@ -42,8 +42,8 @@ Ice.InitializationData.prototype.clone = function()
//
Ice.initialize = function(arg1, arg2)
{
- var args = null;
- var initData = null;
+ let args = null;
+ let initData = null;
if(arg1 instanceof Array)
{
@@ -80,7 +80,7 @@ Ice.initialize = function(arg1, arg2)
}
initData.properties = Ice.createProperties(args, initData.properties);
- var result = new Ice.Communicator(initData);
+ const result = new Ice.Communicator(initData);
result.finishSetup(null);
return result;
};
diff --git a/js/src/Ice/Instance.js b/js/src/Ice/Instance.js
index c094704f27f..df3a67a8947 100644
--- a/js/src/Ice/Instance.js
+++ b/js/src/Ice/Instance.js
@@ -7,15 +7,13 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/AsyncResultBase",
"../Ice/Debug",
"../Ice/DefaultsAndOverrides",
"../Ice/EndpointFactoryManager",
- "../Ice/HashMap",
"../Ice/ImplicitContextI",
"../Ice/IdentityUtil",
"../Ice/LocatorManager",
@@ -41,39 +39,38 @@ Ice.__M.require(module,
"../Ice/ACM"
]);
-var IceSSL = Ice.__M.require(module, ["../Ice/EndpointInfo"]).IceSSL;
-
-var AsyncResultBase = Ice.AsyncResultBase;
-var Debug = Ice.Debug;
-var DefaultsAndOverrides = Ice.DefaultsAndOverrides;
-var EndpointFactoryManager = Ice.EndpointFactoryManager;
-var HashMap = Ice.HashMap;
-var ImplicitContextI = Ice.ImplicitContextI;
-var LocatorManager = Ice.LocatorManager;
-var Logger = Ice.Logger;
-var ObjectAdapterFactory = Ice.ObjectAdapterFactory;
-var ValueFactoryManagerI = Ice.ValueFactoryManagerI;
-var OutgoingConnectionFactory = Ice.OutgoingConnectionFactory;
-var Promise = Ice.Promise;
-var Properties = Ice.Properties;
-var ProxyFactory = Ice.ProxyFactory;
-var RetryQueue = Ice.RetryQueue;
-var RouterManager = Ice.RouterManager;
-var Timer = Ice.Timer;
-var TraceLevels = Ice.TraceLevels;
-var ReferenceFactory = Ice.ReferenceFactory;
-var RequestHandlerFactory = Ice.RequestHandlerFactory;
-var ACMConfig = Ice.ACMConfig;
-
-var StateActive = 0;
-var StateDestroyInProgress = 1;
-var StateDestroyed = 2;
+const IceSSL = Ice.__M.require(module, ["../Ice/EndpointInfo"]).IceSSL;
+
+const AsyncResultBase = Ice.AsyncResultBase;
+const Debug = Ice.Debug;
+const DefaultsAndOverrides = Ice.DefaultsAndOverrides;
+const EndpointFactoryManager = Ice.EndpointFactoryManager;
+const ImplicitContextI = Ice.ImplicitContextI;
+const LocatorManager = Ice.LocatorManager;
+const Logger = Ice.Logger;
+const ObjectAdapterFactory = Ice.ObjectAdapterFactory;
+const ValueFactoryManagerI = Ice.ValueFactoryManagerI;
+const OutgoingConnectionFactory = Ice.OutgoingConnectionFactory;
+const Properties = Ice.Properties;
+const ProxyFactory = Ice.ProxyFactory;
+const RetryQueue = Ice.RetryQueue;
+const RouterManager = Ice.RouterManager;
+const Timer = Ice.Timer;
+const TraceLevels = Ice.TraceLevels;
+const ReferenceFactory = Ice.ReferenceFactory;
+const RequestHandlerFactory = Ice.RequestHandlerFactory;
+const ACMConfig = Ice.ACMConfig;
+
+const StateActive = 0;
+const StateDestroyInProgress = 1;
+const StateDestroyed = 2;
//
// Instance - only for use by Communicator
//
-var Instance = Ice.Class({
- __init__: function(initData)
+class Instance
+{
+ constructor(initData)
{
this._state = StateActive;
this._initData = initData;
@@ -95,8 +92,9 @@ var Instance = Ice.Class({
this._endpointHostResolver = null;
this._endpointFactoryManager = null;
this._objectFactoryMap = null;
- },
- initializationData: function()
+ }
+
+ initializationData()
{
//
// No check for destruction. It must be possible to access the
@@ -105,20 +103,23 @@ var Instance = Ice.Class({
// This value is immutable.
//
return this._initData;
- },
- traceLevels: function()
+ }
+
+ traceLevels()
{
// This value is immutable.
Debug.assert(this._traceLevels !== null);
return this._traceLevels;
- },
- defaultsAndOverrides: function()
+ }
+
+ defaultsAndOverrides()
{
// This value is immutable.
Debug.assert(this._defaultsAndOverrides !== null);
return this._defaultsAndOverrides;
- },
- routerManager: function()
+ }
+
+ routerManager()
{
if(this._state === StateDestroyed)
{
@@ -127,8 +128,9 @@ var Instance = Ice.Class({
Debug.assert(this._routerManager !== null);
return this._routerManager;
- },
- locatorManager: function()
+ }
+
+ locatorManager()
{
if(this._state === StateDestroyed)
{
@@ -137,8 +139,9 @@ var Instance = Ice.Class({
Debug.assert(this._locatorManager !== null);
return this._locatorManager;
- },
- referenceFactory: function()
+ }
+
+ referenceFactory()
{
if(this._state === StateDestroyed)
{
@@ -147,8 +150,9 @@ var Instance = Ice.Class({
Debug.assert(this._referenceFactory !== null);
return this._referenceFactory;
- },
- requestHandlerFactory: function()
+ }
+
+ requestHandlerFactory()
{
if(this._state === StateDestroyed)
{
@@ -157,8 +161,9 @@ var Instance = Ice.Class({
Debug.assert(this._requestHandlerFactory !== null);
return this._requestHandlerFactory;
- },
- proxyFactory: function()
+ }
+
+ proxyFactory()
{
if(this._state === StateDestroyed)
{
@@ -167,8 +172,9 @@ var Instance = Ice.Class({
Debug.assert(this._proxyFactory !== null);
return this._proxyFactory;
- },
- outgoingConnectionFactory: function()
+ }
+
+ outgoingConnectionFactory()
{
if(this._state === StateDestroyed)
{
@@ -177,8 +183,9 @@ var Instance = Ice.Class({
Debug.assert(this._outgoingConnectionFactory !== null);
return this._outgoingConnectionFactory;
- },
- objectAdapterFactory: function()
+ }
+
+ objectAdapterFactory()
{
if(this._state === StateDestroyed)
{
@@ -187,8 +194,9 @@ var Instance = Ice.Class({
Debug.assert(this._objectAdapterFactory !== null);
return this._objectAdapterFactory;
- },
- retryQueue: function()
+ }
+
+ retryQueue()
{
if(this._state === StateDestroyed)
{
@@ -197,8 +205,9 @@ var Instance = Ice.Class({
Debug.assert(this._retryQueue !== null);
return this._retryQueue;
- },
- timer: function()
+ }
+
+ timer()
{
if(this._state === StateDestroyed)
{
@@ -207,8 +216,9 @@ var Instance = Ice.Class({
Debug.assert(this._timer !== null);
return this._timer;
- },
- endpointFactoryManager: function()
+ }
+
+ endpointFactoryManager()
{
if(this._state === StateDestroyed)
{
@@ -217,27 +227,32 @@ var Instance = Ice.Class({
Debug.assert(this._endpointFactoryManager !== null);
return this._endpointFactoryManager;
- },
- messageSizeMax: function()
+ }
+
+ messageSizeMax()
{
// This value is immutable.
return this._messageSizeMax;
- },
- batchAutoFlushSize: function()
+ }
+
+ batchAutoFlushSize()
{
// This value is immutable.
return this._batchAutoFlushSize;
- },
- clientACM: function()
+ }
+
+ clientACM()
{
// This value is immutable.
return this._clientACM;
- },
- getImplicitContext: function()
+ }
+
+ getImplicitContext()
{
return this._implicitContext;
- },
- setDefaultLocator: function(locator)
+ }
+
+ setDefaultLocator(locator)
{
if(this._state == StateDestroyed)
{
@@ -245,8 +260,9 @@ var Instance = Ice.Class({
}
this._referenceFactory = this._referenceFactory.setDefaultLocator(locator);
- },
- setDefaultRouter: function(router)
+ }
+
+ setDefaultRouter(router)
{
if(this._state == StateDestroyed)
{
@@ -254,18 +270,19 @@ var Instance = Ice.Class({
}
this._referenceFactory = this._referenceFactory.setDefaultRouter(router);
- },
- setLogger: function(logger)
+ }
+
+ setLogger(logger)
{
this._initData.logger = logger;
- },
- finishSetup: function(communicator, promise)
+ }
+
+ finishSetup(communicator, promise)
{
//
// If promise == null, it means the caller is requesting a synchronous setup.
// Otherwise, we resolve the promise after all initialization is complete.
//
-
try
{
if(this._initData.properties === null)
@@ -290,8 +307,8 @@ var Instance = Ice.Class({
this._defaultsAndOverrides = new DefaultsAndOverrides(this._initData.properties, this._initData.logger);
- var defMessageSizeMax = 1024;
- var num = this._initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defMessageSizeMax);
+ const defMessageSizeMax = 1024;
+ let num = this._initData.properties.getPropertyAsIntWithDefault("Ice.MessageSizeMax", defMessageSizeMax);
if(num < 1 || num > 0x7fffffff / 1024)
{
this._messageSizeMax = 0x7fffffff;
@@ -345,20 +362,20 @@ var Instance = Ice.Class({
this._endpointFactoryManager = new EndpointFactoryManager(this);
- var tcpInstance = new Ice.ProtocolInstance(this, Ice.TCPEndpointType, "tcp", false);
- var tcpEndpointFactory = new Ice.TcpEndpointFactory(tcpInstance);
+ const tcpInstance = new Ice.ProtocolInstance(this, Ice.TCPEndpointType, "tcp", false);
+ const tcpEndpointFactory = new Ice.TcpEndpointFactory(tcpInstance);
this._endpointFactoryManager.add(tcpEndpointFactory);
- var wsInstance = new Ice.ProtocolInstance(this, Ice.WSEndpointType, "ws", false);
- var wsEndpointFactory = new Ice.WSEndpointFactory(wsInstance, tcpEndpointFactory.clone(wsInstance));
+ const wsInstance = new Ice.ProtocolInstance(this, Ice.WSEndpointType, "ws", false);
+ const wsEndpointFactory = new Ice.WSEndpointFactory(wsInstance, tcpEndpointFactory.clone(wsInstance));
this._endpointFactoryManager.add(wsEndpointFactory);
- var sslInstance = new Ice.ProtocolInstance(this, Ice.SSLEndpointType, "ssl", true);
- var sslEndpointFactory = new Ice.TcpEndpointFactory(sslInstance);
+ const sslInstance = new Ice.ProtocolInstance(this, Ice.SSLEndpointType, "ssl", true);
+ const sslEndpointFactory = new Ice.TcpEndpointFactory(sslInstance);
this._endpointFactoryManager.add(sslEndpointFactory);
- var wssInstance = new Ice.ProtocolInstance(this, Ice.WSSEndpointType, "wss", true);
- var wssEndpointFactory = new Ice.WSEndpointFactory(wssInstance, sslEndpointFactory.clone(wssInstance));
+ const wssInstance = new Ice.ProtocolInstance(this, Ice.WSSEndpointType, "wss", true);
+ const wssEndpointFactory = new Ice.WSEndpointFactory(wssInstance, sslEndpointFactory.clone(wssInstance));
this._endpointFactoryManager.add(wssEndpointFactory);
this._outgoingConnectionFactory = new OutgoingConnectionFactory(communicator, this);
@@ -373,13 +390,13 @@ var Instance = Ice.Class({
this._retryQueue = new RetryQueue(this);
this._timer = new Timer(this._initData.logger);
- var router = Ice.RouterPrx.uncheckedCast(this._proxyFactory.propertyToProxy("Ice.Default.Router"));
+ const router = Ice.RouterPrx.uncheckedCast(this._proxyFactory.propertyToProxy("Ice.Default.Router"));
if(router !== null)
{
this._referenceFactory = this._referenceFactory.setDefaultRouter(router);
}
- var loc = Ice.LocatorPrx.uncheckedCast(this._proxyFactory.propertyToProxy("Ice.Default.Locator"));
+ const loc = Ice.LocatorPrx.uncheckedCast(this._proxyFactory.propertyToProxy("Ice.Default.Locator"));
if(loc !== null)
{
this._referenceFactory = this._referenceFactory.setDefaultLocator(loc);
@@ -387,7 +404,7 @@ var Instance = Ice.Class({
if(promise !== null)
{
- promise.succeed(communicator);
+ promise.resolve(communicator);
}
}
catch(ex)
@@ -396,14 +413,11 @@ var Instance = Ice.Class({
{
if(ex instanceof Ice.LocalException)
{
- this.destroy().finally(function()
- {
- promise.fail(ex);
- });
+ this.destroy().finally(() => promise.reject(ex));
}
else
{
- promise.fail(ex);
+ promise.reject(ex);
}
}
else
@@ -415,13 +429,14 @@ var Instance = Ice.Class({
throw ex;
}
}
- },
+ }
+
//
// Only for use by Ice.CommunicatorI
//
- destroy: function()
+ destroy()
{
- var promise = new AsyncResultBase(null, "destroy", null, this, null);
+ const promise = new AsyncResultBase(null, "destroy", null, this, null);
//
// If destroy is in progress, wait for it to be done. This is
@@ -443,153 +458,131 @@ var Instance = Ice.Class({
// Shutdown and destroy all the incoming and outgoing Ice
// connections and wait for the connections to be finished.
//
- var self = this;
- Ice.Promise.try(
- function()
+ Ice.Promise.try(() =>
{
- if(self._objectAdapterFactory)
+ if(this._objectAdapterFactory)
{
- return self._objectAdapterFactory.shutdown();
+ return this._objectAdapterFactory.shutdown();
}
}
- ).then(
- function()
+ ).then(() =>
{
- if(self._outgoingConnectionFactory !== null)
+ if(this._outgoingConnectionFactory !== null)
{
- self._outgoingConnectionFactory.destroy();
+ this._outgoingConnectionFactory.destroy();
}
- if(self._objectAdapterFactory !== null)
+ if(this._objectAdapterFactory !== null)
{
- return self._objectAdapterFactory.destroy();
+ return this._objectAdapterFactory.destroy();
}
}
- ).then(
- function()
+ ).then(() =>
{
- if(self._outgoingConnectionFactory !== null)
+ if(this._outgoingConnectionFactory !== null)
{
- return self._outgoingConnectionFactory.waitUntilFinished();
+ return this._outgoingConnectionFactory.waitUntilFinished();
}
}
- ).then(
- function()
+ ).then(() =>
{
- if(self._retryQueue)
+ if(this._retryQueue)
{
- self._retryQueue.destroy();
+ this._retryQueue.destroy();
}
- if(self._timer)
+ if(this._timer)
{
- self._timer.destroy();
+ this._timer.destroy();
}
- if(self._objectFactoryMap !== null)
+ if(this._objectFactoryMap !== null)
{
- self._objectFactoryMap.forEach(function(arg, id, factory)
- {
- factory.destroy();
- });
- self._objectFactoryMap.clear();
+ this._objectFactoryMap.forEach(factory => factory.destroy());
+ this._objectFactoryMap.clear();
}
- if(self._routerManager)
+ if(this._routerManager)
{
- self._routerManager.destroy();
+ this._routerManager.destroy();
}
- if(self._locatorManager)
+ if(this._locatorManager)
{
- self._locatorManager.destroy();
+ this._locatorManager.destroy();
}
- if(self._endpointFactoryManager)
+ if(this._endpointFactoryManager)
{
- self._endpointFactoryManager.destroy();
+ this._endpointFactoryManager.destroy();
}
- var i;
- if(self._initData.properties.getPropertyAsInt("Ice.Warn.UnusedProperties") > 0)
+ if(this._initData.properties.getPropertyAsInt("Ice.Warn.UnusedProperties") > 0)
{
- var unusedProperties = self._initData.properties.getUnusedProperties();
+ const unusedProperties = this._initData.properties.getUnusedProperties();
if(unusedProperties.length > 0)
{
- var message = [];
+ const message = [];
message.push("The following properties were set but never read:");
- for(i = 0; i < unusedProperties.length; ++i)
- {
- message.push("\n ");
- message.push(unusedProperties[i]);
- }
- self._initData.logger.warning(message.join(""));
+ unusedProperties.forEach(p => message.push("\n ", p));
+ this._initData.logger.warning(message.join(""));
}
}
- self._objectAdapterFactory = null;
- self._outgoingConnectionFactory = null;
- self._retryQueue = null;
- self._timer = null;
+ this._objectAdapterFactory = null;
+ this._outgoingConnectionFactory = null;
+ this._retryQueue = null;
+ this._timer = null;
- self._referenceFactory = null;
- self._requestHandlerFactory = null;
- self._proxyFactory = null;
- self._routerManager = null;
- self._locatorManager = null;
- self._endpointFactoryManager = null;
+ this._referenceFactory = null;
+ this._requestHandlerFactory = null;
+ this._proxyFactory = null;
+ this._routerManager = null;
+ this._locatorManager = null;
+ this._endpointFactoryManager = null;
- self._state = StateDestroyed;
+ this._state = StateDestroyed;
if(this._destroyPromises)
{
- for(i = 0; i < this._destroyPromises.length; ++i)
- {
- this._destroyPromises[i].succeed(this._destroyPromises[i]);
- }
+ this._destroyPromises.forEach(p => p.resolve());
}
- promise.succeed(promise);
+ promise.resolve();
}
- ).exception(
- function(ex)
+ ).catch(ex =>
{
if(this._destroyPromises)
{
- for(var i = 0; i < this._destroyPromises.length; ++i)
- {
- this._destroyPromises[i].fail(ex, this._destroyPromises[i]);
- }
+ this._destroyPromises.forEach(p => p.reject(ex));
}
- promise.fail(ex, promise);
- }
- );
+ promise.reject(ex);
+ });
return promise;
- },
- addObjectFactory: function(factory, id)
+ }
+
+ addObjectFactory(factory, id)
{
//
// Create a ValueFactory wrapper around the given ObjectFactory and register the wrapper
// with the value factory manager. This may raise AlreadyRegisteredException.
//
- this._initData.valueFactoryManager.add(function(typeId)
- {
- return factory.create(typeId);
- }, id);
+ this._initData.valueFactoryManager.add(typeId => factory.create(typeId), id);
if(this._objectFactoryMap === null)
{
- this._objectFactoryMap = new HashMap();
+ this._objectFactoryMap = new Map();
}
this._objectFactoryMap.set(id, factory);
- },
- findObjectFactory: function(id)
+ }
+
+ findObjectFactory(id)
{
- var factory = null;
+ let factory = null;
if(this._objectFactoryMap !== null)
{
factory = this._objectFactoryMap.get(id);
}
return factory !== undefined ? factory : null;
}
-});
+}
Ice.Instance = Instance;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/LocatorInfo.js b/js/src/Ice/LocatorInfo.js
index 1624727fca9..deeed68660a 100644
--- a/js/src/Ice/LocatorInfo.js
+++ b/js/src/Ice/LocatorInfo.js
@@ -7,44 +7,44 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
- "../Ice/HashMap",
"../Ice/Promise",
"../Ice/Protocol",
"../Ice/Locator",
"../Ice/LocalException",
- "../Ice/Exception"
+ "../Ice/Exception",
+ "../Ice/HashMap",
+ "../Ice/IdentityUtil"
]);
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var Promise = Ice.Promise;
-var Protocol = Ice.Protocol;
-var LocatorRegistryPrx = Ice.LocatorRegisterPrx;
+const Debug = Ice.Debug;
+const Protocol = Ice.Protocol;
+const LocatorRegistryPrx = Ice.LocatorRegisterPrx;
+const HashMap = Ice.HashMap;
-var Class = Ice.Class;
-
-var LocatorInfo = Class({
- __init__: function(locator, table, background)
+class LocatorInfo
+{
+ constructor(locator, table, background)
{
this._locator = locator;
this._locatorRegistry = null;
this._table = table;
this._background = background;
- this._adapterRequests = new HashMap(); // Map<String, Request>
+ this._adapterRequests = new Map(); // Map<String, Request>
this._objectRequests = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, Request>
- },
- destroy: function()
+ }
+
+ destroy()
{
this._locatorRegistry = null;
this._table.clear();
- },
- equals: function(rhs)
+ }
+
+ equals(rhs)
{
if(this === rhs)
{
@@ -57,43 +57,45 @@ var LocatorInfo = Class({
}
return false;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
return this._locator.hashCode();
- },
- getLocator: function()
+ }
+
+ getLocator()
{
return this._locator;
- },
- getLocatorRegistry: function()
+ }
+
+ getLocatorRegistry()
{
if(this._locatorRegistry !== null)
{
- return new Promise().succeed(this._locatorRegistry);
+ return Ice.Promise.resolve(this._locatorRegistry);
}
- var self = this;
- return this._locator.getRegistry().then(
- function(reg)
+ return this._locator.getRegistry().then(reg =>
{
//
// The locator registry can't be located. We use ordered
// endpoint selection in case the locator returned a proxy
// with some endpoints which are prefered to be tried first.
//
- self._locatorRegistry = LocatorRegistryPrx.uncheckedCast(reg.ice_locator(null).ice_endpointSelection(
+ this._locatorRegistry = LocatorRegistryPrx.uncheckedCast(reg.ice_locator(null).ice_endpointSelection(
Ice.EndpointSelectionType.Ordered));
- return self._locatorRegistry;
+ return this._locatorRegistry;
});
- },
- getEndpoints: function(ref, wellKnownRef, ttl, p)
+ }
+
+ getEndpoints(ref, wellKnownRef, ttl, p)
{
- var promise = p || new Promise(); // success callback receives (endpoints, cached)
+ const promise = p || new Ice.Promise(); // success callback receives (endpoints, cached)
Debug.assert(ref.isIndirect());
- var endpoints = null;
- var cached = { value: false };
+ let endpoints = null;
+ const cached = { value: false };
if(!ref.isWellKnown())
{
endpoints = this._table.getAdapterEndpoints(ref.getAdapterId(), ttl, cached);
@@ -112,7 +114,7 @@ var LocatorInfo = Class({
}
else
{
- var r = this._table.getObjectReference(ref.getIdentity(), ttl, cached);
+ const r = this._table.getObjectReference(ref.getIdentity(), ttl, cached);
if(!cached.value)
{
if(this._background && r !== null)
@@ -142,17 +144,18 @@ var LocatorInfo = Class({
{
this.getEndpointsTrace(ref, endpoints, true);
}
- promise.succeed(endpoints, true);
+ promise.resolve([endpoints, true]);
return promise;
- },
- clearCache: function(ref)
+ }
+
+ clearCache(ref)
{
Debug.assert(ref.isIndirect());
if(!ref.isWellKnown())
{
- var endpoints = this._table.removeAdapterEndpoints(ref.getAdapterId());
+ const endpoints = this._table.removeAdapterEndpoints(ref.getAdapterId());
if(endpoints !== null && ref.getInstance().traceLevels().location >= 2)
{
@@ -161,7 +164,7 @@ var LocatorInfo = Class({
}
else
{
- var r = this._table.removeObjectReference(ref.getIdentity());
+ const r = this._table.removeObjectReference(ref.getIdentity());
if(r !== null)
{
if(!r.isIndirect())
@@ -177,12 +180,13 @@ var LocatorInfo = Class({
}
}
}
- },
- trace: function(msg, ref, endpoints)
+ }
+
+ trace(msg, ref, endpoints)
{
Debug.assert(ref.isIndirect());
- var s = [];
+ const s = [];
s.push(msg);
s.push("\n");
if(!ref.isWellKnown())
@@ -199,23 +203,15 @@ var LocatorInfo = Class({
}
s.push("endpoints = ");
- for(var i = 0; i < endpoints.length; i++)
- {
- s.push(endpoints[i].toString());
- if(i + 1 < endpoints.length)
- {
- s.push(":");
- }
- }
-
+ s.push(endpoints.map(e => e.toString()).join(":"));
ref.getInstance().initializationData().logger.trace(ref.getInstance().traceLevels().locationCat, s.join(""));
- },
- getEndpointsException: function(ref, exc)
+ }
+
+ getEndpointsException(ref, exc)
{
Debug.assert(ref.isIndirect());
- var instance = ref.getInstance();
- var s, e;
+ const instance = ref.getInstance();
try
{
throw exc;
@@ -226,14 +222,14 @@ var LocatorInfo = Class({
{
if(instance.traceLevels().location >= 1)
{
- s = [];
+ const s = [];
s.push("adapter not found\n");
s.push("adapter = ");
s.push(ref.getAdapterId());
instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.join(""));
}
- e = new Ice.NotRegisteredException();
+ const e = new Ice.NotRegisteredException();
e.kindOfObject = "object adapter";
e.id = ref.getAdapterId();
throw e;
@@ -242,14 +238,14 @@ var LocatorInfo = Class({
{
if(instance.traceLevels().location >= 1)
{
- s = [];
+ const s = [];
s.push("object not found\n");
s.push("object = ");
s.push(Ice.identityToString(ref.getIdentity()));
instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.join(""));
}
- e = new Ice.NotRegisteredException();
+ const e = new Ice.NotRegisteredException();
e.kindOfObject = "object";
e.id = Ice.identityToString(ref.getIdentity());
throw e;
@@ -262,7 +258,7 @@ var LocatorInfo = Class({
{
if(instance.traceLevels().location >= 1)
{
- s = [];
+ const s = [];
s.push("couldn't contact the locator to retrieve adapter endpoints\n");
if(ref.getAdapterId().length > 0)
{
@@ -286,8 +282,9 @@ var LocatorInfo = Class({
Debug.assert(false);
}
}
- },
- getEndpointsTrace: function(ref, endpoints, cached)
+ }
+
+ getEndpointsTrace(ref, endpoints, cached)
{
if(endpoints !== null && endpoints.length > 0)
{
@@ -302,8 +299,8 @@ var LocatorInfo = Class({
}
else
{
- var instance = ref.getInstance();
- var s = [];
+ const instance = ref.getInstance();
+ const s = [];
s.push("no endpoints configured for ");
if(ref.getAdapterId().length > 0)
{
@@ -321,20 +318,21 @@ var LocatorInfo = Class({
}
instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.join(""));
}
- },
- getAdapterRequest: function(ref)
+ }
+
+ getAdapterRequest(ref)
{
if(ref.getInstance().traceLevels().location >= 1)
{
- var instance = ref.getInstance();
- var s = [];
+ const instance = ref.getInstance();
+ const s = [];
s.push("searching for adapter by id\n");
s.push("adapter = ");
s.push(ref.getAdapterId());
instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.join(""));
}
- var request = this._adapterRequests.get(ref.getAdapterId());
+ let request = this._adapterRequests.get(ref.getAdapterId());
if(request !== undefined)
{
return request;
@@ -342,20 +340,21 @@ var LocatorInfo = Class({
request = new AdapterRequest(this, ref);
this._adapterRequests.set(ref.getAdapterId(), request);
return request;
- },
- getObjectRequest: function(ref)
+ }
+
+ getObjectRequest(ref)
{
if(ref.getInstance().traceLevels().location >= 1)
{
- var instance = ref.getInstance();
- var s = [];
+ const instance = ref.getInstance();
+ const s = [];
s.push("searching for object by id\n");
s.push("object = ");
s.push(Ice.identityToString(ref.getIdentity()));
instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.join(""));
}
- var request = this._objectRequests.get(ref.getIdentity());
+ let request = this._objectRequests.get(ref.getIdentity());
if(request !== undefined)
{
return request;
@@ -363,8 +362,9 @@ var LocatorInfo = Class({
request = new ObjectRequest(this, ref);
this._objectRequests.set(ref.getIdentity(), request);
return request;
- },
- finishRequest: function(ref, wellKnownRefs, proxy, notRegistered)
+ }
+
+ finishRequest(ref, wellKnownRefs, proxy, notRegistered)
{
if(proxy === null || proxy.__reference().isIndirect())
{
@@ -372,7 +372,7 @@ var LocatorInfo = Class({
// Remove the cached references of well-known objects for which we tried
// to resolved the endpoints if these endpoints are empty.
//
- for(var i = 0; i < wellKnownRefs.length; ++i)
+ for(let i = 0; i < wellKnownRefs.length; ++i)
{
this._table.removeObjectReference(wellKnownRefs[i].getIdentity());
}
@@ -409,23 +409,25 @@ var LocatorInfo = Class({
this._objectRequests.delete(ref.getIdentity());
}
}
-});
+}
Ice.LocatorInfo = LocatorInfo;
-var RequestCallback = Class({
- __init__: function(ref, ttl, promise)
+class RequestCallback
+{
+ constructor(ref, ttl, promise)
{
this._ref = ref;
this._ttl = ttl;
this._promise = promise;
- },
- response: function(locatorInfo, proxy)
+ }
+
+ response(locatorInfo, proxy)
{
- var endpoints = null;
+ let endpoints = null;
if(proxy !== null)
{
- var r = proxy.__reference();
+ let r = proxy.__reference();
if(this._ref.isWellKnown() && !Protocol.isSupported(this._ref.getEncoding(), r.getEncoding()))
{
//
@@ -445,20 +447,19 @@ var RequestCallback = Class({
// by the locator is an indirect proxy. We now need to resolve the endpoints
// of this indirect proxy.
//
- var self = this;
locatorInfo.getEndpoints(r, this._ref, this._ttl).then(
- function(endpts, b)
+ values =>
{
- if(self._promise !== null)
+ if(this._promise !== null)
{
- self._promise.succeed(endpts, b);
+ this._promise.resolve(values);
}
},
- function(ex)
+ ex =>
{
- if(self._promise !== null)
+ if(this._promise !== null)
{
- self._promise.fail(ex);
+ this._promise.reject(ex);
}
});
return;
@@ -472,10 +473,11 @@ var RequestCallback = Class({
if(this._promise !== null)
{
- this._promise.succeed(endpoints === null ? [] : endpoints, false);
+ this._promise.resolve(endpoints === null ? [[], false] : [endpoints, false]);
}
- },
- exception: function(locatorInfo, exc)
+ }
+
+ exception(locatorInfo, exc)
{
try
{
@@ -485,14 +487,15 @@ var RequestCallback = Class({
{
if(this._promise !== null)
{
- this._promise.fail(ex);
+ this._promise.reject(ex);
}
}
}
-});
+}
-var Request = Class({
- __init__: function(locatorInfo, ref)
+class Request
+{
+ constructor(locatorInfo, ref)
{
this._locatorInfo = locatorInfo;
this._ref = ref;
@@ -503,10 +506,11 @@ var Request = Class({
this._response = false;
this._proxy = null;
this._exception = null;
- },
- addCallback: function(ref, wellKnownRef, ttl, promise)
+ }
+
+ addCallback(ref, wellKnownRef, ttl, promise)
{
- var callback = new RequestCallback(ref, ttl, promise);
+ const callback = new RequestCallback(ref, ttl, promise);
if(this._response)
{
callback.response(this._locatorInfo, this._proxy);
@@ -528,82 +532,74 @@ var Request = Class({
this.send();
}
}
- },
- response: function(proxy)
+ }
+
+ response(proxy)
{
this._locatorInfo.finishRequest(this._ref, this._wellKnownRefs, proxy, false);
this._response = true;
this._proxy = proxy;
- for(var i = 0; i < this._callbacks.length; ++i)
+ for(let i = 0; i < this._callbacks.length; ++i)
{
this._callbacks[i].response(this._locatorInfo, proxy);
}
- },
- exception: function(ex)
+ }
+
+ exception(ex)
{
this._locatorInfo.finishRequest(this._ref, this._wellKnownRefs, null, ex instanceof Ice.UserException);
this._exception = ex;
- for(var i = 0; i < this._callbacks.length; ++i)
+ for(let i = 0; i < this._callbacks.length; ++i)
{
this._callbacks[i].exception(this._locatorInfo, ex);
}
}
-});
+}
-var ObjectRequest = Class(Request, {
- __init__: function(locatorInfo, reference)
+class ObjectRequest extends Request
+{
+ constructor(locatorInfo, reference)
{
- Request.call(this, locatorInfo, reference);
+ super(locatorInfo, reference);
Debug.assert(reference.isWellKnown());
- },
- send: function()
+ }
+
+ send()
{
try
{
- var self = this;
this._locatorInfo.getLocator().findObjectById(this._ref.getIdentity()).then(
- function(proxy)
- {
- self.response(proxy);
- },
- function(ex)
- {
- self.exception(ex);
- });
+ proxy => this.response(proxy),
+ ex => this.exception(ex));
}
catch(ex)
{
this.exception(ex);
}
}
-});
+}
-var AdapterRequest = Class(Request, {
- __init__: function(locatorInfo, reference)
+class AdapterRequest extends Request
+{
+ constructor(locatorInfo, reference)
{
- Request.call(this, locatorInfo, reference);
+ super(locatorInfo, reference);
Debug.assert(reference.isIndirect());
- },
- send: function()
+ }
+
+ send()
{
try
{
- var self = this;
this._locatorInfo.getLocator().findAdapterById(this._ref.getAdapterId()).then(
- function(proxy)
- {
- self.response(proxy);
- },
- function(ex)
- {
- self.exception(ex);
- });
+ proxy => this.response(proxy),
+ ex => this.exception(ex));
}
catch(ex)
{
this.exception(ex);
}
}
-});
+}
module.exports.Ice = Ice;
diff --git a/js/src/Ice/LocatorManager.js b/js/src/Ice/LocatorManager.js
index ddd356939c4..53ee66670ec 100644
--- a/js/src/Ice/LocatorManager.js
+++ b/js/src/Ice/LocatorManager.js
@@ -7,43 +7,44 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/HashMap",
"../Ice/LocatorInfo",
"../Ice/LocatorTable",
"../Ice/Locator"
]);
-var HashMap = Ice.HashMap;
-var LocatorInfo = Ice.LocatorInfo;
-var LocatorTable = Ice.LocatorTable;
-var LocatorPrx = Ice.LocatorPrx;
+const HashMap = Ice.HashMap;
+const LocatorInfo = Ice.LocatorInfo;
+const LocatorTable = Ice.LocatorTable;
+const LocatorPrx = Ice.LocatorPrx;
-var LocatorManager = Ice.Class({
- __init__: function(properties)
+class LocatorManager
+{
+ constructor(properties)
{
this._background = properties.getPropertyAsInt("Ice.BackgroundLocatorCacheUpdates") > 0;
-
this._table = new HashMap(HashMap.compareEquals); // Map<Ice.LocatorPrx, LocatorInfo>
this._locatorTables = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, LocatorTable>
- },
- destroy: function()
+ }
+
+ destroy()
{
- for(var e = this._table.entries; e !== null; e = e.next)
+ for(let locator of this._table.values())
{
- e.value.destroy();
+ locator.destroy();
}
this._table.clear();
this._locatorTables.clear();
- },
+ }
+
//
// Returns locator info for a given locator. Automatically creates
// the locator info if it doesn't exist yet.
//
- find: function(loc)
+ find(loc)
{
if(loc === null)
{
@@ -53,13 +54,12 @@ var LocatorManager = Ice.Class({
//
// The locator can't be located.
//
- var locator = LocatorPrx.uncheckedCast(loc.ice_locator(null));
+ const locator = LocatorPrx.uncheckedCast(loc.ice_locator(null));
//
// TODO: reap unused locator info objects?
//
-
- var info = this._table.get(locator);
+ let info = this._table.get(locator);
if(info === undefined)
{
//
@@ -67,7 +67,7 @@ var LocatorManager = Ice.Class({
// have only one table per locator (not one per locator
// proxy).
//
- var table = this._locatorTables.get(locator.ice_getIdentity());
+ let table = this._locatorTables.get(locator.ice_getIdentity());
if(table === undefined)
{
table = new LocatorTable();
@@ -80,7 +80,7 @@ var LocatorManager = Ice.Class({
return info;
}
-});
+}
Ice.LocatorManager = LocatorManager;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/LocatorTable.js b/js/src/Ice/LocatorTable.js
index 5130a13b3ca..be29ec34528 100644
--- a/js/src/Ice/LocatorTable.js
+++ b/js/src/Ice/LocatorTable.js
@@ -7,24 +7,45 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/HashMap", "../Ice/Debug"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/HashMap", "../Ice/Debug", "../Ice/IdentityUtil"]);
-var HashMap = Ice.HashMap;
-var Debug = Ice.Debug;
+const HashMap = Ice.HashMap;
+const Debug = Ice.Debug;
-var LocatorTable = Ice.Class({
- __init__: function()
+class EndpointTableEntry
+{
+ constructor(time, endpoints)
+ {
+ this.time = time;
+ this.endpoints = endpoints;
+ }
+}
+
+class ReferenceTableEntry
+{
+ constructor(time, reference)
+ {
+ this.time = time;
+ this.reference = reference;
+ }
+}
+
+class LocatorTable
+{
+ constructor()
{
- this._adapterEndpointsTable = new HashMap(); // Map<String, EndpointTableEntry>
+ this._adapterEndpointsTable = new Map(); // Map<String, EndpointTableEntry>
this._objectTable = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, ReferenceTableEntry>
- },
- clear: function()
+ }
+
+ clear()
{
this._adapterEndpointsTable.clear();
this._objectTable.clear();
- },
- getAdapterEndpoints: function(adapter, ttl, cached)
+ }
+
+ getAdapterEndpoints(adapter, ttl, cached)
{
if(ttl === 0) // Locator cache disabled.
{
@@ -32,7 +53,7 @@ var LocatorTable = Ice.Class({
return null;
}
- var entry = this._adapterEndpointsTable.get(adapter);
+ const entry = this._adapterEndpointsTable.get(adapter);
if(entry !== undefined)
{
cached.value = this.checkTTL(entry.time, ttl);
@@ -40,18 +61,21 @@ var LocatorTable = Ice.Class({
}
cached.value = false;
return null;
- },
- addAdapterEndpoints: function(adapter, endpoints)
+ }
+
+ addAdapterEndpoints(adapter, endpoints)
{
this._adapterEndpointsTable.set(adapter, new EndpointTableEntry(Date.now(), endpoints));
- },
- removeAdapterEndpoints: function(adapter)
+ }
+
+ removeAdapterEndpoints(adapter)
{
- var entry = this._adapterEndpointsTable.get(adapter);
+ const entry = this._adapterEndpointsTable.get(adapter);
this._adapterEndpointsTable.delete(adapter);
return entry !== undefined ? entry.endpoints : null;
- },
- getObjectReference: function(id, ttl, cached)
+ }
+
+ getObjectReference(id, ttl, cached)
{
if(ttl === 0) // Locator cache disabled.
{
@@ -59,7 +83,7 @@ var LocatorTable = Ice.Class({
return null;
}
- var entry = this._objectTable.get(id);
+ const entry = this._objectTable.get(id);
if(entry !== undefined)
{
cached.value = this.checkTTL(entry.time, ttl);
@@ -67,18 +91,21 @@ var LocatorTable = Ice.Class({
}
cached.value = false;
return null;
- },
- addObjectReference: function(id, ref)
+ }
+
+ addObjectReference(id, ref)
{
this._objectTable.set(id, new ReferenceTableEntry(Date.now(), ref));
- },
- removeObjectReference: function(id)
+ }
+
+ removeObjectReference(id)
{
- var entry = this._objectTable.get(id);
+ const entry = this._objectTable.get(id);
this._objectTable.delete(id);
return entry !== undefined ? entry.reference : null;
- },
- checkTTL: function(time, ttl)
+ }
+
+ checkTTL(time, ttl)
{
Debug.assert(ttl !== 0);
if(ttl < 0) // TTL = infinite
@@ -90,19 +117,8 @@ var LocatorTable = Ice.Class({
return Date.now() - time <= (ttl * 1000);
}
}
-});
+}
Ice.LocatorTable = LocatorTable;
module.exports.Ice = Ice;
-var EndpointTableEntry = function(time, endpoints)
-{
- this.time = time;
- this.endpoints = endpoints;
-};
-
-var ReferenceTableEntry = function(time, reference)
-{
- this.time = time;
- this.reference = reference;
-};
diff --git a/js/src/Ice/Logger.js b/js/src/Ice/Logger.js
index db230df6568..d6601386b8d 100644
--- a/js/src/Ice/Logger.js
+++ b/js/src/Ice/Logger.js
@@ -7,10 +7,11 @@
//
// **********************************************************************
-var Ice = require("../Ice/Class").Ice;
-
-var Logger = Ice.Class({
- __init__: function(prefix)
+const Ice = require("../Ice/ModuleRegistry").Ice;
+
+class Logger
+{
+ constructor(prefix)
{
if(prefix !== undefined && prefix.length > 0)
{
@@ -20,6 +21,7 @@ var Logger = Ice.Class({
{
this._prefix = "";
}
+
this._dateformat =
{
year: 'numeric',
@@ -30,15 +32,17 @@ var Logger = Ice.Class({
second: 'numeric',
hour12: false
};
- },
- print: function(message)
+ }
+
+ print(message)
{
this.write(message, false);
- },
- trace: function(category, message)
+ }
+
+ trace(category, message)
{
- var s = [];
- var d = new Date();
+ const s = [];
+ const d = new Date();
s.push("-- ");
s.push(this.timestamp());
s.push(' ');
@@ -47,11 +51,12 @@ var Logger = Ice.Class({
s.push(": ");
s.push(message);
this.write(s.join(""), true);
- },
- warning: function(message)
+ }
+
+ warning(message)
{
- var s = [];
- var d = new Date();
+ const s = [];
+ const d = new Date();
s.push("-! ");
s.push(this.timestamp());
s.push(' ');
@@ -59,11 +64,12 @@ var Logger = Ice.Class({
s.push("warning: ");
s.push(message);
this.write(s.join(""), true);
- },
- error: function(message)
+ }
+
+ error(message)
{
- var s = [];
- var d = new Date();
+ const s = [];
+ const d = new Date();
s.push("!! ");
s.push(this.timestamp());
s.push(' ');
@@ -71,12 +77,14 @@ var Logger = Ice.Class({
s.push("error: ");
s.push(message);
this.write(s.join(""), true);
- },
- cloneWithPrefix: function(prefix)
+ }
+
+ cloneWithPrefix(prefix)
{
return new Logger(prefix);
- },
- write: function(message, indent)
+ }
+
+ write(message, indent)
{
if(indent)
{
@@ -84,12 +92,14 @@ var Logger = Ice.Class({
}
console.log(message);
- },
- timestamp: function()
+ }
+
+ timestamp()
{
- var d = new Date();
+ const d = new Date();
return d.toLocaleString("en-US", this._dateformat) + "." + d.getMilliseconds();
}
-});
+}
+
Ice.Logger = Logger;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Long.js b/js/src/Ice/Long.js
index 04d93dc15d4..3d4225633a6 100644
--- a/js/src/Ice/Long.js
+++ b/js/src/Ice/Long.js
@@ -7,15 +7,15 @@
//
// **********************************************************************
-var Ice = require("../Ice/Class").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
//
// The Long type represents a signed 64-bit integer as two 32-bit values
// corresponding to the high and low words.
//
-
-var Long = Ice.Class({
- __init__: function(high, low)
+class Long
+{
+ constructor(high, low)
{
if(low < 0 || low > Long.MAX_UINT32)
{
@@ -28,12 +28,14 @@ var Long = Ice.Class({
this.high = high;
this.low = low;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
return this.low;
- },
- equals: function(rhs)
+ }
+
+ equals(rhs)
{
if(this === rhs)
{
@@ -44,12 +46,14 @@ var Long = Ice.Class({
return false;
}
return this.high === rhs.high && this.low === rhs.low;
- },
- toString: function()
+ }
+
+ toString()
{
return this.high + ":" + this.low;
- },
- toNumber: function()
+ }
+
+ toNumber()
{
if((this.high & Long.SIGN_MASK) !== 0)
@@ -59,7 +63,7 @@ var Long = Ice.Class({
return -(~this.low + 1);
}
- var high = ~this.high + 1;
+ const high = ~this.high + 1;
if(high > Long.HIGH_MAX)
{
@@ -77,7 +81,7 @@ var Long = Ice.Class({
return (this.high * Long.HIGH_MASK) + this.low;
}
}
-});
+}
//
// 2^32
diff --git a/js/src/Ice/MapUtil.js b/js/src/Ice/MapUtil.js
new file mode 100644
index 00000000000..d8511839085
--- /dev/null
+++ b/js/src/Ice/MapUtil.js
@@ -0,0 +1,51 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+const Ice = require("../Ice/ModuleRegistry").Ice;
+
+class MapUtil
+{
+ static equals(m1, m2)
+ {
+ if(m1 === m2)
+ {
+ return true;
+ }
+ else if(m1.size != m2.size)
+ {
+ return false;
+ }
+ else
+ {
+ for(let [key, value] of m1)
+ {
+ if(value === undefined)
+ {
+ if(!m2.has(key))
+ {
+ return false;
+ }
+ else if(m2.get(key) !== value)
+ {
+ return false;
+ }
+ }
+ else if(m2.get(key) !== value)
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
+
+Ice.MapUtil = MapUtil;
+
+module.exports.Ice = Ice;
diff --git a/js/src/Ice/ModuleRegistry.js b/js/src/Ice/ModuleRegistry.js
index 8452a06a900..2ca8f955850 100644
--- a/js/src/Ice/ModuleRegistry.js
+++ b/js/src/Ice/ModuleRegistry.js
@@ -7,39 +7,42 @@
//
// **********************************************************************
-var __modules__ = {};
+const __modules__ = {};
-var __M =
+class __M
{
- module: function(name)
+ static module(name)
{
- var m = __modules__[name];
+ let m = __modules__[name];
if(m === undefined)
{
m = {};
__modules__[name] = m;
}
return m;
- },
- require: function(m, paths)
+ }
+
+ static require(m, paths)
{
- var i = 0, length = paths.length, o;
- for(; i < length; ++i)
- {
- o = m.require(paths[i]);
- }
+ let o;
+ paths.forEach(path =>
+ {
+ o = m.require(path);
+ });
return o;
- },
- type: function(scoped)
+ }
+
+ static type(scoped)
{
if(scoped === undefined)
{
return undefined;
}
- var components = scoped.split(".");
- var T = __modules__;
- for(var i = 0, length = components.length; i < length; ++i)
+ const components = scoped.split(".");
+ let T = __modules__;
+
+ for(let i = 0; i < components.length; ++i)
{
T = T[components[i]];
if(T === undefined)
@@ -49,9 +52,9 @@ var __M =
}
return T;
}
-};
+}
-var Ice = __M.module("Ice");
+const Ice = __M.module("Ice");
Ice.Slice = Ice.Slice || {};
Ice.__M = __M;
exports.Ice = Ice;
diff --git a/js/src/Ice/Object.js b/js/src/Ice/Object.js
index f3bb34f9a84..6758e2f09af 100644
--- a/js/src/Ice/Object.js
+++ b/js/src/Ice/Object.js
@@ -12,10 +12,9 @@
//
// Using IceObject in this file to avoid collisions with the native Object.
//
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/DispatchStatus",
"../Ice/Exception",
"../Ice/FormatType",
@@ -23,58 +22,70 @@ Ice.__M.require(module,
"../Ice/OptionalFormat"
]);
-var Class = Ice.Class;
+let nextAddress = 0;
-var nextAddress = 0;
+const Ice_Object_ids__ = ["::Ice::Object"];
-var IceObject = Class({
- __init__: function()
+Ice.Object = class
+{
+ constructor()
{
// Fake Address used as the hashCode for this object instance.
this.__address = nextAddress++;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
return this.__address;
- },
- ice_isA: function(s, current)
+ }
+
+ ice_isA(s, current)
{
return this.__mostDerivedType().__ids.indexOf(s) >= 0;
- },
- ice_ping: function(current)
+ }
+
+ ice_ping(current)
{
- },
- ice_ids: function(current)
+ }
+
+ ice_ids(current)
{
return this.__mostDerivedType().__ids;
- },
- ice_id: function(current)
+ }
+
+ ice_id(current)
{
return this.__mostDerivedType().__id;
- },
- toString: function()
+ }
+
+ toString()
{
return "[object " + this.ice_id() + "]";
- },
- ice_preMarshal: function()
+ }
+
+ ice_preMarshal()
{
- },
- ice_postUnmarshal: function()
+ }
+
+ ice_postUnmarshal()
{
- },
- __write: function(os)
+ }
+
+ __write(os)
{
os.startValue(null);
__writeImpl(this, os, this.__mostDerivedType());
os.endValue();
- },
- __read: function(is)
+ }
+
+ __read(is)
{
is.startValue();
__readImpl(this, is, this.__mostDerivedType());
is.endValue(false);
- },
- ice_instanceof: function(T)
+ }
+
+ ice_instanceof(T)
{
if(T)
{
@@ -85,7 +96,8 @@ var IceObject = Class({
return this.__mostDerivedType().__instanceof(T);
}
return false;
- },
+ }
+
//
// __mostDerivedType returns the the most derived Ice generated class. This is
// necessary because the user might extend Slice generated classes. The user
@@ -97,83 +109,91 @@ var IceObject = Class({
// The __mostDerivedType is overriden by each Slice generated class, see the
// Slice.defineObject method implementation for details.
//
- __mostDerivedType: function()
+ __mostDerivedType()
{
- return IceObject;
- },
+ return Ice.Object;
+ }
+
//
// The default implementation of equals compare references.
//
- equals: function(other)
+ equals(other)
{
return this === other;
}
-});
-
-//
-// These methods are used for object parameters.
-//
-IceObject.write = function(os, v)
-{
- os.writeValue(v);
-};
-
-IceObject.writeOptional = function(os, tag, v)
-{
- os.writeOptionalValue(tag, v);
-};
+
+ //
+ // These methods are used for object parameters.
+ //
+ static write(os, v)
+ {
+ os.writeValue(v);
+ }
-IceObject.read = function(is)
-{
- var v = { value: null };
- is.readValue(function(o) { v.value = o; }, IceObject);
- return v;
-};
+ static writeOptional(os, tag, v)
+ {
+ os.writeOptionalValue(tag, v);
+ }
-IceObject.readOptional = function(is, tag)
-{
- var v = { value: undefined };
- is.readOptionalValue(tag, function(o) { v.value = o; }, IceObject);
- return v;
-};
+ static read(is)
+ {
+ const v = { value: null };
+ is.readValue(o => v.value = o, this);
+ return v;
+ }
-IceObject.ice_staticId = function()
-{
- return IceObject.__id;
-};
+ static readOptional(is, tag)
+ {
+ const v = { value: undefined };
+ is.readOptionalValue(tag, o => v.value = o, this);
+ return v;
+ }
-IceObject.__instanceof = function(T)
-{
- if(T === this)
+ static ice_staticId()
{
- return true;
+ return this.__id;
}
- for(var i in this.__implements)
+ static __instanceof(T)
{
- if(this.__implements[i].__instanceof(T))
+ if(T === this)
+ {
+ return true;
+ }
+
+ if(this.__implements.some(i => i.__instanceof(T)))
{
return true;
}
+
+ if(this.__parent)
+ {
+ return this.__parent.__instanceof(T);
+ }
+ return false;
}
- if(this.__parent)
+ static get __ids()
{
- return this.__parent.__instanceof(T);
+ return Ice_Object_ids__;
+ }
+
+ static get __id()
+ {
+ return Ice_Object_ids__[0];
}
- return false;
-};
-IceObject.__ids = ["::Ice::Object"];
-IceObject.__id = IceObject.__ids[0];
-IceObject.__compactId = -1;
-IceObject.__preserved = false;
+ static get __implements()
+ {
+ return [];
+ }
+};
//
// Private methods
//
-var __writeImpl = function(obj, os, type)
+const __writeImpl = function(obj, os, type)
{
//
// The __writeImpl method is a recursive method that goes down the
@@ -181,12 +201,14 @@ var __writeImpl = function(obj, os, type)
// generated __writeMemberImpl method.
//
- if(type === undefined || type === IceObject)
+ if(type === undefined || type === Ice.Object)
{
- return; // Don't marshal anything for IceObject
+ return; // Don't marshal anything for Ice.Object
}
- os.startSlice(type.__id, type.__compactId, type.__parent === IceObject);
+ os.startSlice(type.__id,
+ Object.prototype.hasOwnProperty.call(type, '__compactId') ? type.__compactId : -1 ,
+ type.__parent === Ice.Object);
if(type.prototype.__writeMemberImpl)
{
type.prototype.__writeMemberImpl.call(obj, os);
@@ -195,7 +217,7 @@ var __writeImpl = function(obj, os, type)
__writeImpl(obj, os, type.__parent);
};
-var __readImpl = function(obj, is, type)
+const __readImpl = function(obj, is, type)
{
//
// The __readImpl method is a recursive method that goes down the
@@ -203,9 +225,9 @@ var __readImpl = function(obj, is, type)
// generated __readMemberImpl method.
//
- if(type === undefined || type === IceObject)
+ if(type === undefined || type === Ice.Object)
{
- return; // Don't marshal anything for IceObject
+ return; // Don't marshal anything for Ice.Object
}
is.startSlice();
@@ -217,7 +239,7 @@ var __readImpl = function(obj, is, type)
__readImpl(obj, is, type.__parent);
};
-var __writePreserved = function(os)
+const __writePreserved = function(os)
{
//
// For Slice classes which are marked "preserved", the implementation of this method
@@ -228,7 +250,7 @@ var __writePreserved = function(os)
os.endValue();
};
-var __readPreserved = function(is)
+const __readPreserved = function(is)
{
//
// For Slice classes which are marked "preserved", the implementation of this method
@@ -239,74 +261,13 @@ var __readPreserved = function(is)
this.__slicedData = is.endValue(true);
};
-Ice.Object = IceObject;
-var Slice = Ice.Slice;
-Slice.defineLocalObject = function(constructor, base)
-{
- var obj = constructor || function(){};
+const Slice = Ice.Slice;
- if(base !== undefined)
- {
- obj.prototype = new base();
- obj.__parent = base;
- obj.prototype.constructor = constructor;
- }
-
- return obj;
-};
-
-Slice.defineObject = function(constructor, base, intfs, scope, ids, compactId, writeImpl, readImpl, preserved)
+Slice.PreservedObject = function(obj)
{
- var obj = constructor || function(){};
-
- obj.prototype = new base();
- obj.__parent = base;
- obj.__ids = ids;
- obj.__id = ids[scope];
- obj.__compactId = compactId;
- obj.__instanceof = IceObject.__instanceof;
- obj.__implements = intfs;
-
- //
- // These methods are used for object parameters.
- //
- obj.write = function(os, v)
- {
- os.writeValue(v);
- };
- obj.writeOptional = function(os, tag, v)
- {
- os.writeOptionalValue(tag, v);
- };
- obj.read = function(is)
- {
- var v = { value: null };
- is.readValue(function(o) { v.value = o; }, obj);
- return v;
- };
- obj.readOptional = function(is, tag)
- {
- var v = { value: undefined };
- is.readOptionalValue(tag, function(o) { v.value = o; }, obj);
- return v;
- };
-
- obj.ice_staticId = function()
- {
- return ids[scope];
- };
-
- obj.prototype.constructor = obj;
- obj.prototype.__mostDerivedType = function() { return obj; };
- if(preserved)
- {
- obj.prototype.__write = __writePreserved;
- obj.prototype.__read = __readPreserved;
- }
- obj.prototype.__writeMemberImpl = writeImpl;
- obj.prototype.__readMemberImpl = readImpl;
-
- return obj;
+ obj.prototype.__write = __writePreserved;
+ obj.prototype.__read = __readPreserved;
};
+
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ObjectAdapterFactory.js b/js/src/Ice/ObjectAdapterFactory.js
index 89de4ba3d96..619396bf716 100644
--- a/js/src/Ice/ObjectAdapterFactory.js
+++ b/js/src/Ice/ObjectAdapterFactory.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/AsyncResultBase",
"../Ice/LocalException",
"../Ice/ObjectAdapterI",
@@ -18,23 +17,25 @@ Ice.__M.require(module,
"../Ice/UUID"
]);
-var AsyncResultBase = Ice.AsyncResultBase;
-var ObjectAdapterI = Ice.ObjectAdapterI;
-var Promise = Ice.Promise;
+const AsyncResultBase = Ice.AsyncResultBase;
+const ObjectAdapterI = Ice.ObjectAdapterI;
+const _Promise = Ice.Promise;
//
// Only for use by Instance.
//
-var ObjectAdapterFactory = Ice.Class({
- __init__: function(instance, communicator)
+class ObjectAdapterFactory
+{
+ constructor(instance, communicator)
{
this._instance = instance;
this._communicator = communicator;
this._adapters = [];
this._adapterNamesInUse = [];
- this._shutdownPromise = new Promise();
- },
- shutdown: function()
+ this._shutdownPromise = new _Promise();
+ }
+
+ shutdown()
{
//
// Ignore shutdown requests if the object adapter factory has
@@ -47,55 +48,39 @@ var ObjectAdapterFactory = Ice.Class({
this._instance = null;
this._communicator = null;
- this._shutdownPromise = Promise.all(
- this._adapters.map(function(adapter)
- {
- return adapter.deactivate();
- }));
+ this._shutdownPromise = _Promise.all(this._adapters.map(adapter => adapter.deactivate()));
return this._shutdownPromise;
- },
- waitForShutdown: function()
+ }
+
+ waitForShutdown()
{
- var self = this;
- return this._shutdownPromise.then(
- function()
- {
- return Promise.all(self._adapters.map(function(adapter)
- {
- return adapter.waitForDeactivate();
- }));
- });
- },
- isShutdown: function()
+ return this._shutdownPromise.then(() => _Promise.all(this._adapters.map(adapter => adapter.waitForDeactivate())));
+ }
+
+ isShutdown()
{
return this._instance === null;
- },
- destroy: function()
+ }
+
+ destroy()
{
- var self = this;
- return this.waitForShutdown().then(
- function()
- {
- return Promise.all(self._adapters.map(function(adapter)
- {
- return adapter.destroy();
- }));
- });
- },
- createObjectAdapter: function(name, router, promise)
+ return this.waitForShutdown().then(() => _Promise.all(this._adapters.map(adapter => adapter.destroy())));
+ }
+
+ createObjectAdapter(name, router, promise)
{
if(this._instance === null)
{
throw new Ice.ObjectAdapterDeactivatedException();
}
- var adapter = null;
+ let adapter = null;
try
{
if(name.length === 0)
{
- var uuid = Ice.generateUUID();
- adapter = new ObjectAdapterI(this._instance, this._communicator, this, uuid, null, true, promise);
+ adapter = new ObjectAdapterI(this._instance, this._communicator, this, Ice.generateUUID(), null, true,
+ promise);
}
else
{
@@ -110,17 +95,18 @@ var ObjectAdapterFactory = Ice.Class({
}
catch(ex)
{
- promise.fail(ex, promise);
+ promise.reject(ex);
}
- },
- removeObjectAdapter: function(adapter)
+ }
+
+ removeObjectAdapter(adapter)
{
if(this._instance === null)
{
return;
}
- var n = this._adapters.indexOf(adapter);
+ let n = this._adapters.indexOf(adapter);
if(n !== -1)
{
this._adapters.splice(n, 1);
@@ -132,7 +118,7 @@ var ObjectAdapterFactory = Ice.Class({
this._adapterNamesInUse.splice(n, 1);
}
}
-});
+}
Ice.ObjectAdapterFactory = ObjectAdapterFactory;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ObjectAdapterI.js b/js/src/Ice/ObjectAdapterI.js
index 3d556a51235..4db04bf214a 100644
--- a/js/src/Ice/ObjectAdapterI.js
+++ b/js/src/Ice/ObjectAdapterI.js
@@ -7,15 +7,13 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/AsyncResultBase",
"../Ice/Debug",
"../Ice/Identity",
"../Ice/LocalException",
- "../Ice/Promise",
"../Ice/PropertyNames",
"../Ice/Router",
"../Ice/ServantManager",
@@ -23,15 +21,14 @@ Ice.__M.require(module,
"../Ice/UUID"
]);
-var AsyncResultBase = Ice.AsyncResultBase;
-var Debug = Ice.Debug;
-var Identity = Ice.Identity;
-var Promise = Ice.Promise;
-var PropertyNames = Ice.PropertyNames;
-var ServantManager = Ice.ServantManager;
-var StringUtil = Ice.StringUtil;
+const AsyncResultBase = Ice.AsyncResultBase;
+const Debug = Ice.Debug;
+const Identity = Ice.Identity;
+const PropertyNames = Ice.PropertyNames;
+const ServantManager = Ice.ServantManager;
+const StringUtil = Ice.StringUtil;
-var _suffixes =
+const _suffixes =
[
"ACM",
"AdapterId",
@@ -69,19 +66,20 @@ var _suffixes =
"ThreadPool.Serialize"
];
-var StateUninitialized = 0; // Just constructed.
-//var StateHeld = 1;
-//var StateWaitActivate = 2;
-//var StateActive = 3;
-//var StateDeactivating = 4;
-var StateDeactivated = 5;
-var StateDestroyed = 6;
+const StateUninitialized = 0; // Just constructed.
+//const StateHeld = 1;
+//const StateWaitActivate = 2;
+//const StateActive = 3;
+//const StateDeactivating = 4;
+const StateDeactivated = 5;
+const StateDestroyed = 6;
//
// Only for use by IceInternal.ObjectAdapterFactory
//
-var ObjectAdapterI = Ice.Class({
- __init__: function(instance, communicator, objectAdapterFactory, name, router, noConfig, promise)
+class ObjectAdapterI
+{
+ constructor(instance, communicator, objectAdapterFactory, name, router, noConfig, promise)
{
this._instance = instance;
this._communicator = communicator;
@@ -97,24 +95,21 @@ var ObjectAdapterI = Ice.Class({
{
this._reference = this._instance.referenceFactory().createFromString("dummy -t", "");
this._messageSizeMax = this._instance.messageSizeMax();
- promise.succeed(this, promise);
+ promise.resolve(this);
return;
}
- var properties = this._instance.initializationData().properties;
- var unknownProps = [];
- var noProps = this.filterProperties(unknownProps);
+ const properties = this._instance.initializationData().properties;
+ const unknownProps = [];
+ const noProps = this.filterProperties(unknownProps);
//
// Warn about unknown object adapter properties.
//
if(unknownProps.length !== 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0)
{
- var message = ["found unknown properties for object adapter `" + name + "':"];
- for(var i = 0; i < unknownProps.length; ++i)
- {
- message.push("\n " + unknownProps[i]);
- }
+ const message = ["found unknown properties for object adapter `" + name + "':"];
+ unknownProps.forEach(unknownProp => message.push("\n " + unknownProp));
this._instance.initializationData().logger.warning(message.join(""));
}
@@ -123,16 +118,14 @@ var ObjectAdapterI = Ice.Class({
//
if(router === null && noProps)
{
- var ex = new Ice.InitializationException();
- ex.reason = "object adapter `" + this._name + "' requires configuration";
- throw ex;
+ throw new Ice.InitializationException(`object adapter \`${this._name}' requires configuration`);
}
//
// Setup a reference to be used to get the default proxy options
// when creating new proxies. By default, create twoway proxies.
//
- var proxyOptions = properties.getPropertyWithDefault(this._name + ".ProxyOptions", "-t");
+ const proxyOptions = properties.getPropertyWithDefault(this._name + ".ProxyOptions", "-t");
try
{
this._reference = this._instance.referenceFactory().createFromString("dummy " + proxyOptions, "");
@@ -141,9 +134,8 @@ var ObjectAdapterI = Ice.Class({
{
if(e instanceof Ice.ProxyParseException)
{
- var ex = new Ice.InitializationException();
- ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + name + "'";
- throw ex;
+ throw new Ice.InitializationException(
+ `invalid proxy options \`${proxyOptions}' for object adapter \`${name}'`);
}
else
{
@@ -152,8 +144,8 @@ var ObjectAdapterI = Ice.Class({
}
{
- var defaultMessageSizeMax = this._instance.messageSizeMax() / 1024;
- var num = properties.getPropertyAsIntWithDefault(this._name + ".MessageSizeMax", defaultMessageSizeMax);
+ const defaultMessageSizeMax = this._instance.messageSizeMax() / 1024;
+ const num = properties.getPropertyAsIntWithDefault(this._name + ".MessageSizeMax", defaultMessageSizeMax);
if(num < 1 || num > 0x7fffffff / 1024)
{
this._messageSizeMax = 0x7fffffff;
@@ -191,33 +183,21 @@ var ObjectAdapterI = Ice.Class({
// Add the router's server proxy endpoints to this object
// adapter.
//
- var self = this;
this._routerInfo.getServerEndpoints().then(
- function(endpoints)
+ (endpoints) =>
{
- var i;
-
- for(i = 0; i < endpoints.length; ++i)
- {
- self._routerEndpoints.push(endpoints[i]);
- }
- self._routerEndpoints.sort( // Must be sorted.
- function(e1, e2)
- {
- return e1.compareTo(e2);
- });
+ endpoints.forEach(endpoint => this._routerEndpoints.push(endpoint));
+ this._routerEndpoints.sort((e1, e2) => e1.compareTo(e2)); // Must be sorted.
//
// Remove duplicate endpoints, so we have a list of unique
// endpoints.
//
- for(i = 0; i < self._routerEndpoints.length - 1;)
+ for(let i = 0; i < this._routerEndpoints.length - 1;)
{
- var e1 = self._routerEndpoints[i];
- var e2 = self._routerEndpoints[i + 1];
- if(e1.equals(e2))
+ if(this._routerEndpoints[i].equals(this._routerEndpoints[i + 1]))
{
- self._routerEndpoints.splice(i, 1);
+ this._routerEndpoints.splice(i, 1);
}
else
{
@@ -230,33 +210,25 @@ var ObjectAdapterI = Ice.Class({
// new outgoing connections to the router's client proxy will
// use this object adapter for callbacks.
//
- self._routerInfo.setAdapter(self);
+ this._routerInfo.setAdapter(this);
//
// Also modify all existing outgoing connections to the
// router's client proxy to use this object adapter for
// callbacks.
//
- return self._instance.outgoingConnectionFactory().setRouterInfo(self._routerInfo);
+ return this._instance.outgoingConnectionFactory().setRouterInfo(this._routerInfo);
}
- ).then(
- function()
- {
- promise.succeed(self, promise);
- },
- function(ex)
- {
- promise.fail(ex, promise);
- });
+ ).then(() => promise.resolve(this), promise.reject);
}
else
{
- var endpoints = properties.getProperty(this._name + ".Endpoints");
+ const endpoints = properties.getProperty(this._name + ".Endpoints");
if(endpoints.length > 0)
{
throw new Ice.FeatureNotSupportedException("object adapter endpoints not supported");
}
- promise.succeed(this, promise);
+ promise.resolve(this);
}
}
catch(ex)
@@ -264,75 +236,81 @@ var ObjectAdapterI = Ice.Class({
this.destroy();
throw ex;
}
- },
- getName: function()
+ }
+
+ getName()
{
//
// No mutex lock necessary, _name is immutable.
//
return this._noConfig ? "" : this._name;
- },
- getCommunicator: function()
+ }
+
+ getCommunicator()
{
return this._communicator;
- },
- activate: function()
+ }
+
+ activate()
{
- },
- hold: function()
+ }
+
+ hold()
{
this.checkForDeactivation();
- },
- waitForHold: function()
+ }
+
+ waitForHold()
{
- var promise = new AsyncResultBase(this._communicator, "waitForHold", null, null, this);
- if(this.checkForDeactivation(promise))
- {
- return promise;
- }
- return promise.succeed(promise);
- },
- deactivate: function()
+ const promise = new AsyncResultBase(this._communicator, "waitForHold", null, null, this);
+ return this.checkForDeactivation(promise) ? promise : promise.resolve();
+ }
+
+ deactivate()
{
- var promise = new AsyncResultBase(this._communicator, "deactivate", null, null, this);
+ const promise = new AsyncResultBase(this._communicator, "deactivate", null, null, this);
if(this._state < StateDeactivated)
{
this._state = StateDeactivated;
this._instance.outgoingConnectionFactory().removeAdapter(this);
}
- return promise.succeed(promise);
- },
- waitForDeactivate: function()
+ promise.resolve();
+ return promise;
+ }
+
+ waitForDeactivate()
{
- var promise = new AsyncResultBase(this._communicator, "deactivate", null, null, this);
- return promise.succeed(promise);
- },
- isDeactivated: function()
+ return new AsyncResultBase(this._communicator, "deactivate", null, null, this).resolve();
+ }
+
+ isDeactivated()
{
return this._state >= StateDeactivated;
- },
- destroy: function()
+ }
+
+ destroy()
{
- var promise = new AsyncResultBase(this._communicator, "destroy", null, null, this);
- var self = this;
- var destroyInternal = function()
+ const promise = new AsyncResultBase(this._communicator, "destroy", null, null, this);
+ const destroyInternal = () =>
{
- if(self._state < StateDestroyed)
+ if(this._state < StateDestroyed)
{
- self._state = StateDestroyed;
- self._servantManager.destroy();
- self._objectAdapterFactory.removeObjectAdapter(self);
+ this._state = StateDestroyed;
+ this._servantManager.destroy();
+ this._objectAdapterFactory.removeObjectAdapter(this);
}
- return promise.succeed(promise);
+ return promise.resolve();
};
return this._state < StateDeactivated ? this.deactivate().then(destroyInternal) : destroyInternal();
- },
- add: function(object, ident)
+ }
+
+ add(object, ident)
{
return this.addFacet(object, ident, "");
- },
- addFacet: function(object, ident, facet)
+ }
+
+ addFacet(object, ident, facet)
{
this.checkForDeactivation();
this.checkIdentity(ident);
@@ -342,172 +320,184 @@ var ObjectAdapterI = Ice.Class({
// Create a copy of the Identity argument, in case the caller
// reuses it.
//
- var id = ident.clone();
+ const id = ident.clone();
this._servantManager.addServant(object, id, facet);
return this.newProxy(id, facet);
- },
- addWithUUID: function(object)
+ }
+
+ addWithUUID(object)
{
return this.addFacetWithUUID(object, "");
- },
- addFacetWithUUID: function(object, facet)
+ }
+
+ addFacetWithUUID(object, facet)
{
return this.addFacet(object, new Identity(Ice.generateUUID(), ""), facet);
- },
- addDefaultServant: function(servant, category)
+ }
+
+ addDefaultServant(servant, category)
{
this.checkServant(servant);
this.checkForDeactivation();
this._servantManager.addDefaultServant(servant, category);
- },
- remove: function(ident)
+ }
+
+ remove(ident)
{
return this.removeFacet(ident, "");
- },
- removeFacet: function(ident, facet)
+ }
+
+ removeFacet(ident, facet)
{
this.checkForDeactivation();
this.checkIdentity(ident);
return this._servantManager.removeServant(ident, facet);
- },
- removeAllFacets: function(ident)
+ }
+
+ removeAllFacets(ident)
{
this.checkForDeactivation();
this.checkIdentity(ident);
return this._servantManager.removeAllFacets(ident);
- },
- removeDefaultServant: function(category)
+ }
+
+ removeDefaultServant(category)
{
this.checkForDeactivation();
return this._servantManager.removeDefaultServant(category);
- },
- find: function(ident)
+ }
+
+ find(ident)
{
return this.findFacet(ident, "");
- },
- findFacet: function(ident, facet)
+ }
+
+ findFacet(ident, facet)
{
this.checkForDeactivation();
this.checkIdentity(ident);
-
return this._servantManager.findServant(ident, facet);
- },
- findAllFacets: function(ident)
+ }
+
+ findAllFacets(ident)
{
this.checkForDeactivation();
this.checkIdentity(ident);
-
return this._servantManager.findAllFacets(ident);
- },
- findByProxy: function(proxy)
+ }
+
+ findByProxy(proxy)
{
this.checkForDeactivation();
-
- var ref = proxy.__reference();
+ const ref = proxy.__reference();
return this.findFacet(ref.getIdentity(), ref.getFacet());
- },
- findDefaultServant: function(category)
+ }
+
+ findDefaultServant(category)
{
this.checkForDeactivation();
-
return this._servantManager.findDefaultServant(category);
- },
- addServantLocator: function(locator, prefix)
+ }
+
+ addServantLocator(locator, prefix)
{
this.checkForDeactivation();
-
this._servantManager.addServantLocator(locator, prefix);
- },
- removeServantLocator: function(prefix)
+ }
+
+ removeServantLocator(prefix)
{
this.checkForDeactivation();
-
return this._servantManager.removeServantLocator(prefix);
- },
- findServantLocator: function(prefix)
+ }
+
+ findServantLocator(prefix)
{
this.checkForDeactivation();
-
return this._servantManager.findServantLocator(prefix);
- },
- createProxy: function(ident)
+ }
+
+ createProxy(ident)
{
this.checkForDeactivation();
this.checkIdentity(ident);
-
return this.newProxy(ident, "");
- },
- createDirectProxy: function(ident)
+ }
+
+ createDirectProxy(ident)
{
return this.createProxy(ident);
- },
- createIndirectProxy: function(ident)
+ }
+
+ createIndirectProxy(ident)
{
- throw new Ice.FeatureNotSupportedException("setLocator not supported");
- },
- setLocator: function(locator)
+ throw new Ice.FeatureNotSupportedException("createIndirectProxy not supported");
+ }
+
+ setLocator(locator)
{
throw new Ice.FeatureNotSupportedException("setLocator not supported");
- },
- refreshPublishedEndpoints: function()
+ }
+
+ refreshPublishedEndpoints()
{
throw new Ice.FeatureNotSupportedException("refreshPublishedEndpoints not supported");
- },
- getEndpoints: function()
+ }
+
+ getEndpoints()
{
return [];
- },
- getPublishedEndpoints: function()
+ }
+
+ getPublishedEndpoints()
{
return [];
- },
- getServantManager: function()
+ }
+
+ getServantManager()
{
//
// _servantManager is immutable.
//
return this._servantManager;
- },
- messageSizeMax: function()
+ }
+
+ messageSizeMax()
{
return this._messageSizeMax;
- },
- newProxy: function(ident, facet)
- {
- var endpoints = [];
+ }
+ newProxy(ident, facet)
+ {
//
// Now we also add the endpoints of the router's server proxy, if
// any. This way, object references created by this object adapter
// will also point to the router's server proxy endpoints.
//
- for(var i = 0; i < this._routerEndpoints.length; ++i)
- {
- endpoints.push(this._routerEndpoints[i]);
- }
-
//
// Create a reference and return a proxy for this reference.
//
- var ref = this._instance.referenceFactory().create(ident, facet, this._reference, endpoints);
- return this._instance.proxyFactory().referenceToProxy(ref);
- },
- checkForDeactivation: function(promise)
+ return this._instance.proxyFactory().referenceToProxy(
+ this._instance.referenceFactory().create(ident, facet, this._reference,
+ Array.from(this._routerEndpoints)));
+ }
+
+ checkForDeactivation(promise)
{
if(this._state >= StateDeactivated)
{
- var ex = new Ice.ObjectAdapterDeactivatedException();
+ const ex = new Ice.ObjectAdapterDeactivatedException();
ex.name = this.getName();
if(promise !== undefined)
{
- promise.fail(ex, promise);
+ promise.reject(ex);
return true;
}
else
@@ -517,8 +507,9 @@ var ObjectAdapterI = Ice.Class({
}
return false;
- },
- checkIdentity: function(ident)
+ }
+
+ checkIdentity(ident)
{
if(ident.name === undefined || ident.name === null || ident.name.length === 0)
{
@@ -529,22 +520,24 @@ var ObjectAdapterI = Ice.Class({
{
ident.category = "";
}
- },
- checkServant: function(servant)
+ }
+
+ checkServant(servant)
{
if(servant === undefined || servant === null)
{
throw new Ice.IllegalServantException("cannot add null servant to Object Adapter");
}
- },
- filterProperties: function(unknownProps)
+ }
+
+ filterProperties(unknownProps)
{
//
// Do not create unknown properties list if Ice prefix, i.e., Ice, Glacier2, etc.
//
- var addUnknown = true, i;
- var prefix = this._name + ".";
- for(i = 0; i < PropertyNames.clPropNames.length; ++i)
+ let addUnknown = true;
+ const prefix = this._name + ".";
+ for(let i = 0; i < PropertyNames.clPropNames.length; ++i)
{
if(prefix.indexOf(PropertyNames.clPropNames[i] + ".") === 0)
{
@@ -553,14 +546,14 @@ var ObjectAdapterI = Ice.Class({
}
}
- var noProps = true;
- var props = this._instance.initializationData().properties.getPropertiesForPrefix(prefix);
- for(var e = props.entries; e !== null; e = e.next)
+ let noProps = true;
+ let props = this._instance.initializationData().properties.getPropertiesForPrefix(prefix);
+ for(let [key, value] of props)
{
- var valid = false;
- for(i = 0; i < _suffixes.length; ++i)
+ let valid = false;
+ for(let i = 0; i < _suffixes.length; ++i)
{
- if(e.key === prefix + _suffixes[i])
+ if(key === prefix + _suffixes[i])
{
noProps = false;
valid = true;
@@ -570,13 +563,13 @@ var ObjectAdapterI = Ice.Class({
if(!valid && addUnknown)
{
- unknownProps.push(e.key);
+ unknownProps.push(key);
}
}
return noProps;
}
-});
+}
Ice.ObjectAdapterI = ObjectAdapterI;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ObjectFactory.js b/js/src/Ice/ObjectFactory.js
index ad372d599de..0287a74cfc9 100644
--- a/js/src/Ice/ObjectFactory.js
+++ b/js/src/Ice/ObjectFactory.js
@@ -7,15 +7,20 @@
//
// **********************************************************************
-var Ice = require("../Ice/Class").Ice;
-Ice.ObjectFactory = Ice.Class({
- create: function(type)
+const Ice = require("../Ice/ModuleRegistry").Ice;
+
+class ObjectFactory
+{
+ create(type)
{
throw new Error("not implemented");
- },
- destroy: function()
+ }
+
+ destroy()
{
throw new Error("not implemented");
}
-});
+}
+
+Ice.ObjectFactory = ObjectFactory;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ObjectPrx.js b/js/src/Ice/ObjectPrx.js
index cc915234377..eca66655764 100644
--- a/js/src/Ice/ObjectPrx.js
+++ b/js/src/Ice/ObjectPrx.js
@@ -7,15 +7,13 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/ArrayUtil",
"../Ice/AsyncResult",
"../Ice/Debug",
"../Ice/FormatType",
- "../Ice/HashMap",
"../Ice/OutgoingAsync",
"../Ice/ReferenceMode",
"../Ice/Current",
@@ -25,44 +23,49 @@ Ice.__M.require(module,
"../Ice/Object"
]);
-var ArrayUtil = Ice.ArrayUtil;
-var AsyncResultBase = Ice.AsyncResultBase;
-var AsyncResult = Ice.AsyncResult;
-var Debug = Ice.Debug;
-var FormatType = Ice.FormatType;
-var HashMap = Ice.HashMap;
-var OutgoingAsync = Ice.OutgoingAsync;
-var ProxyFlushBatch = Ice.ProxyFlushBatch;
-var ProxyGetConnection = Ice.ProxyGetConnection;
-var RefMode = Ice.ReferenceMode;
-var OperationMode = Ice.OperationMode;
+const ArrayUtil = Ice.ArrayUtil;
+const AsyncResultBase = Ice.AsyncResultBase;
+const AsyncResult = Ice.AsyncResult;
+const Debug = Ice.Debug;
+const FormatType = Ice.FormatType;
+const OutgoingAsync = Ice.OutgoingAsync;
+const ProxyFlushBatch = Ice.ProxyFlushBatch;
+const ProxyGetConnection = Ice.ProxyGetConnection;
+const RefMode = Ice.ReferenceMode;
+const OperationMode = Ice.OperationMode;
//
// Ice.ObjectPrx
//
-var ObjectPrx = Ice.Class({
- __init__: function()
+class ObjectPrx
+{
+ constructor()
{
this._reference = null;
this._requestHandler = null;
- },
- hashCode: function(r)
+ }
+
+ hashCode(r)
{
return this._reference.hashCode();
- },
- ice_getCommunicator: function()
+ }
+
+ ice_getCommunicator()
{
return this._reference.getCommunicator();
- },
- toString: function()
+ }
+
+ toString()
{
return this._reference.toString();
- },
- ice_getIdentity: function()
+ }
+
+ ice_getIdentity()
{
return this._reference.getIdentity().clone();
- },
- ice_identity: function(newIdentity)
+ }
+
+ ice_identity(newIdentity)
{
if(newIdentity === undefined || newIdentity === null || newIdentity.name.length === 0)
{
@@ -74,24 +77,28 @@ var ObjectPrx = Ice.Class({
}
else
{
- var proxy = new ObjectPrx();
+ const proxy = new ObjectPrx();
proxy.__setup(this._reference.changeIdentity(newIdentity));
return proxy;
}
- },
- ice_getContext: function()
+ }
+
+ ice_getContext()
{
- return new HashMap(this._reference.getContext());
- },
- ice_context: function(newContext)
+ return new Map(this._reference.getContext());
+ }
+
+ ice_context(newContext)
{
return this.__newInstance(this._reference.changeContext(newContext));
- },
- ice_getFacet: function()
+ }
+
+ ice_getFacet()
{
return this._reference.getFacet();
- },
- ice_facet: function(newFacet)
+ }
+
+ ice_facet(newFacet)
{
if(newFacet === undefined || newFacet === null)
{
@@ -104,16 +111,18 @@ var ObjectPrx = Ice.Class({
}
else
{
- var proxy = new ObjectPrx();
+ const proxy = new ObjectPrx();
proxy.__setup(this._reference.changeFacet(newFacet));
return proxy;
}
- },
- ice_getAdapterId: function()
+ }
+
+ ice_getAdapterId()
{
return this._reference.getAdapterId();
- },
- ice_adapterId: function(newAdapterId)
+ }
+
+ ice_adapterId(newAdapterId)
{
if(newAdapterId === undefined || newAdapterId === null)
{
@@ -128,12 +137,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeAdapterId(newAdapterId));
}
- },
- ice_getEndpoints: function()
+ }
+
+ ice_getEndpoints()
{
return ArrayUtil.clone(this._reference.getEndpoints());
- },
- ice_endpoints: function(newEndpoints)
+ }
+
+ ice_endpoints(newEndpoints)
{
if(newEndpoints === undefined || newEndpoints === null)
{
@@ -148,12 +159,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeEndpoints(newEndpoints));
}
- },
- ice_getLocatorCacheTimeout: function()
+ }
+
+ ice_getLocatorCacheTimeout()
{
return this._reference.getLocatorCacheTimeout();
- },
- ice_locatorCacheTimeout: function(newTimeout)
+ }
+
+ ice_locatorCacheTimeout(newTimeout)
{
if(newTimeout < -1)
{
@@ -167,12 +180,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeLocatorCacheTimeout(newTimeout));
}
- },
- ice_getInvocationTimeout: function()
+ }
+
+ ice_getInvocationTimeout()
{
return this._reference.getInvocationTimeout();
- },
- ice_invocationTimeout: function(newTimeout)
+ }
+
+ ice_invocationTimeout(newTimeout)
{
if(newTimeout < 1 && newTimeout !== -1)
{
@@ -186,12 +201,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeInvocationTimeout(newTimeout));
}
- },
- ice_isConnectionCached: function()
+ }
+
+ ice_isConnectionCached()
{
return this._reference.getCacheConnection();
- },
- ice_connectionCached: function(newCache)
+ }
+
+ ice_connectionCached(newCache)
{
if(newCache === this._reference.getCacheConnection())
{
@@ -201,12 +218,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeCacheConnection(newCache));
}
- },
- ice_getEndpointSelection: function()
+ }
+
+ ice_getEndpointSelection()
{
return this._reference.getEndpointSelection();
- },
- ice_endpointSelection: function(newType)
+ }
+
+ ice_endpointSelection(newType)
{
if(newType === this._reference.getEndpointSelection())
{
@@ -216,12 +235,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeEndpointSelection(newType));
}
- },
- ice_isSecure: function()
+ }
+
+ ice_isSecure()
{
return this._reference.getSecure();
- },
- ice_secure: function(b)
+ }
+
+ ice_secure(b)
{
if(b === this._reference.getSecure())
{
@@ -231,12 +252,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeSecure(b));
}
- },
- ice_getEncodingVersion: function()
+ }
+
+ ice_getEncodingVersion()
{
return this._reference.getEncoding().clone();
- },
- ice_encodingVersion: function(e)
+ }
+
+ ice_encodingVersion(e)
{
if(e.equals(this._reference.getEncoding()))
{
@@ -246,12 +269,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeEncoding(e));
}
- },
- ice_isPreferSecure: function()
+ }
+
+ ice_isPreferSecure()
{
return this._reference.getPreferSecure();
- },
- ice_preferSecure: function(b)
+ }
+
+ ice_preferSecure(b)
{
if(b === this._reference.getPreferSecure())
{
@@ -261,15 +286,17 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changePreferSecure(b));
}
- },
- ice_getRouter: function()
+ }
+
+ ice_getRouter()
{
- var ri = this._reference.getRouterInfo();
+ const ri = this._reference.getRouterInfo();
return ri !== null ? ri.getRouter() : null;
- },
- ice_router: function(router)
+ }
+
+ ice_router(router)
{
- var ref = this._reference.changeRouter(router);
+ const ref = this._reference.changeRouter(router);
if(ref.equals(this._reference))
{
return this;
@@ -278,15 +305,17 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(ref);
}
- },
- ice_getLocator: function()
+ }
+
+ ice_getLocator()
{
- var ri = this._reference.getLocatorInfo();
+ const ri = this._reference.getLocatorInfo();
return ri !== null ? ri.getLocator() : null;
- },
- ice_locator: function(locator)
+ }
+
+ ice_locator(locator)
{
- var ref = this._reference.changeLocator(locator);
+ const ref = this._reference.changeLocator(locator);
if(ref.equals(this._reference))
{
return this;
@@ -295,12 +324,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(ref);
}
- },
- ice_isTwoway: function()
+ }
+
+ ice_isTwoway()
{
return this._reference.getMode() === RefMode.ModeTwoway;
- },
- ice_twoway: function()
+ }
+
+ ice_twoway()
{
if(this._reference.getMode() === RefMode.ModeTwoway)
{
@@ -310,12 +341,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeMode(RefMode.ModeTwoway));
}
- },
- ice_isOneway: function()
+ }
+
+ ice_isOneway()
{
return this._reference.getMode() === RefMode.ModeOneway;
- },
- ice_oneway: function()
+ }
+
+ ice_oneway()
{
if(this._reference.getMode() === RefMode.ModeOneway)
{
@@ -325,12 +358,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeMode(RefMode.ModeOneway));
}
- },
- ice_isBatchOneway: function()
+ }
+
+ ice_isBatchOneway()
{
return this._reference.getMode() === RefMode.ModeBatchOneway;
- },
- ice_batchOneway: function()
+ }
+
+ ice_batchOneway()
{
if(this._reference.getMode() === RefMode.ModeBatchOneway)
{
@@ -340,12 +375,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeMode(RefMode.ModeBatchOneway));
}
- },
- ice_isDatagram: function()
+ }
+
+ ice_isDatagram()
{
return this._reference.getMode() === RefMode.ModeDatagram;
- },
- ice_datagram: function()
+ }
+
+ ice_datagram()
{
if(this._reference.getMode() === RefMode.ModeDatagram)
{
@@ -355,12 +392,14 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeMode(RefMode.ModeDatagram));
}
- },
- ice_isBatchDatagram: function()
+ }
+
+ ice_isBatchDatagram()
{
return this._reference.getMode() === RefMode.ModeBatchDatagram;
- },
- ice_batchDatagram: function()
+ }
+
+ ice_batchDatagram()
{
if(this._reference.getMode() === RefMode.ModeBatchDatagram)
{
@@ -370,10 +409,11 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(this._reference.changeMode(RefMode.ModeBatchDatagram));
}
- },
- ice_compress: function(co)
+ }
+
+ ice_compress(co)
{
- var ref = this._reference.changeCompress(co);
+ const ref = this._reference.changeCompress(co);
if(ref.equals(this._reference))
{
return this;
@@ -382,14 +422,15 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(ref);
}
- },
- ice_timeout: function(t)
+ }
+
+ ice_timeout(t)
{
if(t < 1 && t !== -1)
{
throw new Error("invalid value passed to ice_timeout: " + t);
}
- var ref = this._reference.changeTimeout(t);
+ const ref = this._reference.changeTimeout(t);
if(ref.equals(this._reference))
{
return this;
@@ -398,14 +439,16 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(ref);
}
- },
- ice_getConnectionId: function()
+ }
+
+ ice_getConnectionId()
{
return this._reference.getConnectionId();
- },
- ice_connectionId: function(id)
+ }
+
+ ice_connectionId(id)
{
- var ref = this._reference.changeConnectionId(id);
+ const ref = this._reference.changeConnectionId(id);
if(ref.equals(this._reference))
{
return this;
@@ -414,10 +457,11 @@ var ObjectPrx = Ice.Class({
{
return this.__newInstance(ref);
}
- },
- ice_getConnection: function()
+ }
+
+ ice_getConnection()
{
- var r = new ProxyGetConnection(this, "ice_getConnection");
+ const r = new ProxyGetConnection(this, "ice_getConnection");
try
{
r.__invoke();
@@ -427,14 +471,16 @@ var ObjectPrx = Ice.Class({
r.__abort(ex);
}
return r;
- },
- ice_getCachedConnection: function()
+ }
+
+ ice_getCachedConnection()
{
return this._requestHandler ? this._requestHandler.getConnection() : null;
- },
- ice_flushBatchRequests: function()
+ }
+
+ ice_flushBatchRequests()
{
- var r = new ProxyFlushBatch(this, "ice_flushBatchRequests");
+ const r = new ProxyFlushBatch(this, "ice_flushBatchRequests");
try
{
r.__invoke();
@@ -444,8 +490,9 @@ var ObjectPrx = Ice.Class({
r.__abort(ex);
}
return r;
- },
- equals: function(r)
+ }
+
+ equals(r)
{
if(this === r)
{
@@ -458,25 +505,29 @@ var ObjectPrx = Ice.Class({
}
return false;
- },
- __write: function(os)
+ }
+
+ __write(os)
{
this._reference.getIdentity().__write(os);
this._reference.streamWrite(os);
- },
- __reference: function()
+ }
+
+ __reference()
{
return this._reference;
- },
- __copyFrom: function(from)
+ }
+
+ __copyFrom(from)
{
Debug.assert(this._reference === null);
Debug.assert(this._requestHandler === null);
this._reference = from._reference;
this._requestHandler = from._requestHandler;
- },
- __handleException: function(ex, handler, mode, sent, sleep, cnt)
+ }
+
+ __handleException(ex, handler, mode, sent, sleep, cnt)
{
this.__updateRequestHandler(handler, null); // Clear the request handler
@@ -526,15 +577,17 @@ var ObjectPrx = Ice.Class({
{
throw ex;
}
- },
- __checkAsyncTwowayOnly: function(name)
+ }
+
+ __checkAsyncTwowayOnly(name)
{
if(!this.ice_isTwoway())
{
throw new Error("`" + name + "' can only be called with a twoway proxy");
}
- },
- __getRequestHandler: function()
+ }
+
+ __getRequestHandler()
{
if(this._reference.getCacheConnection())
{
@@ -544,16 +597,18 @@ var ObjectPrx = Ice.Class({
}
}
return this._reference.getRequestHandler(this);
- },
- __getBatchRequestQueue: function()
+ }
+
+ __getBatchRequestQueue()
{
if(!this._batchRequestQueue)
{
this._batchRequestQueue = this._reference.getBatchRequestQueue();
}
return this._batchRequestQueue;
- },
- __setRequestHandler: function(handler)
+ }
+
+ __setRequestHandler(handler)
{
if(this._reference.getCacheConnection())
{
@@ -564,8 +619,9 @@ var ObjectPrx = Ice.Class({
return this._requestHandler;
}
return handler;
- },
- __updateRequestHandler: function(previous, handler)
+ }
+
+ __updateRequestHandler(previous, handler)
{
if(this._reference.getCacheConnection() && previous !== null)
{
@@ -574,23 +630,26 @@ var ObjectPrx = Ice.Class({
this._requestHandler = this._requestHandler.update(previous, handler);
}
}
- },
+ }
+
//
// Only for use by IceInternal.ProxyFactory
//
- __setup: function(ref)
+ __setup(ref)
{
Debug.assert(this._reference === null);
this._reference = ref;
- },
- __newInstance: function(ref)
+ }
+
+ __newInstance(ref)
{
- var proxy = new this.constructor();
+ const proxy = new this.constructor();
proxy.__setup(ref);
return proxy;
- },
- ice_instanceof: function(T)
+ }
+
+ ice_instanceof(T)
{
if(T)
{
@@ -602,347 +661,313 @@ var ObjectPrx = Ice.Class({
}
return false;
}
-});
-
-//
-// Generic invocation for operations that have input parameters.
-//
-ObjectPrx.__invoke = function(p, name, mode, fmt, ctx, marshalFn, unmarshalFn, userEx, args)
-{
- if(unmarshalFn !== null || userEx.length > 0)
+
+ //
+ // Generic invocation for operations that have input parameters.
+ //
+ static __invoke(p, name, mode, fmt, ctx, marshalFn, unmarshalFn, userEx, args)
{
- p.__checkAsyncTwowayOnly(name);
- }
-
- var __r = new OutgoingAsync(p, name,
- function(__res)
+ if(unmarshalFn !== null || userEx.length > 0)
{
- ObjectPrx.__completed(__res, unmarshalFn, userEx);
- });
+ p.__checkAsyncTwowayOnly(name);
+ }
- try
- {
- __r.__prepare(name, mode, ctx);
- if(marshalFn === null)
+ const __r = new OutgoingAsync(p, name,
+ __res =>
+ {
+ this.__completed(__res, unmarshalFn, userEx);
+ });
+
+ try
{
- __r.__writeEmptyParams();
+ __r.__prepare(name, mode, ctx);
+ if(marshalFn === null)
+ {
+ __r.__writeEmptyParams();
+ }
+ else
+ {
+ const __os = __r.__startWriteParams(fmt);
+ marshalFn.call(null, __os, args);
+ __r.__endWriteParams();
+ }
+ __r.__invoke();
}
- else
+ catch(ex)
{
- var __os = __r.__startWriteParams(fmt);
- marshalFn.call(null, __os, args);
- __r.__endWriteParams();
+ __r.__abort(ex);
}
- __r.__invoke();
- }
- catch(ex)
- {
- __r.__abort(ex);
+ return __r;
}
- return __r;
-};
-//
-// Handles the completion of an invocation.
-//
-ObjectPrx.__completed = function(__r, unmarshalFn, userEx)
-{
- if(!ObjectPrx.__check(__r, userEx))
+ //
+ // Handles the completion of an invocation.
+ //
+ static __completed(__r, unmarshalFn, userEx)
{
- return;
- }
+ if(!this.__check(__r, userEx))
+ {
+ return;
+ }
- try
- {
- if(unmarshalFn === null)
+ try
{
- __r.__readEmptyParams();
- __r.succeed(__r);
+ if(unmarshalFn === null)
+ {
+ __r.__readEmptyParams();
+ __r.resolve();
+ }
+ else
+ {
+ __r.resolve(unmarshalFn(__r));
+ }
}
- else
+ catch(ex)
{
- var results = unmarshalFn(__r);
- __r.succeed.apply(__r, results);
+ this.__dispatchLocalException(__r, ex);
+ return;
}
}
- catch(ex)
+
+ //
+ // Unmarshal callback for operations that return a bool as the only result.
+ //
+ static __returns_bool(__is, __results)
{
- ObjectPrx.__dispatchLocalException(__r, ex);
- return;
+ __results.push(__is.readBool());
}
-};
-//
-// Unmarshal callback for operations that return a bool as the only result.
-//
-ObjectPrx.__returns_bool = function(__is, __results)
-{
- __results.push(__is.readBool());
-};
-
-//
-// Unmarshal callback for operations that return a byte as the only result.
-//
-ObjectPrx.__returns_byte = function(__is, __results)
-{
- __results.push(__is.readByte());
-};
-
-//
-// Unmarshal callback for operations that return a short as the only result.
-//
-ObjectPrx.__returns_short = function(__is, __results)
-{
- __results.push(__is.readShort());
-};
+ //
+ // Unmarshal callback for operations that return a byte as the only result.
+ //
+ static __returns_byte(__is, __results)
+ {
+ __results.push(__is.readByte());
+ }
-//
-// Unmarshal callback for operations that return an int as the only result.
-//
-ObjectPrx.__returns_int = function(__is, __results)
-{
- __results.push(__is.readInt());
-};
+ //
+ // Unmarshal callback for operations that return a short as the only result.
+ //
+ static __returns_short(__is, __results)
+ {
+ __results.push(__is.readShort());
+ }
-//
-// Unmarshal callback for operations that return a long as the only result.
-//
-ObjectPrx.__returns_long = function(__is, __results)
-{
- __results.push(__is.readLong());
-};
+ //
+ // Unmarshal callback for operations that return an int as the only result.
+ //
+ static __returns_int(__is, __results)
+ {
+ __results.push(__is.readInt());
+ }
-//
-// Unmarshal callback for operations that return a float as the only result.
-//
-ObjectPrx.__returns_float = function(__is, __results)
-{
- __results.push(__is.readFloat());
-};
+ //
+ // Unmarshal callback for operations that return a long as the only result.
+ //
+ static __returns_long(__is, __results)
+ {
+ __results.push(__is.readLong());
+ }
-//
-// Unmarshal callback for operations that return a double as the only result.
-//
-ObjectPrx.__returns_double = function(__is, __results)
-{
- __results.push(__is.readDouble());
-};
+ //
+ // Unmarshal callback for operations that return a float as the only result.
+ //
+ static __returns_float(__is, __results)
+ {
+ __results.push(__is.readFloat());
+ }
-//
-// Unmarshal callback for operations that return a string as the only result.
-//
-ObjectPrx.__returns_string = function(__is, __results)
-{
- __results.push(__is.readString());
-};
+ //
+ // Unmarshal callback for operations that return a double as the only result.
+ //
+ static __returns_double(__is, __results)
+ {
+ __results.push(__is.readDouble());
+ }
-//
-// Unmarshal callback for operations that return a proxy as the only result.
-//
-ObjectPrx.__returns_ObjectPrx = function(__is, __results)
-{
- __results.push(__is.readProxy());
-};
+ //
+ // Unmarshal callback for operations that return a string as the only result.
+ //
+ static __returns_string(__is, __results)
+ {
+ __results.push(__is.readString());
+ }
-//
-// Unmarshal callback for operations that return an object as the only result.
-//
-ObjectPrx.__returns_Object = function(__is, __results)
-{
- __is.readValue(function(obj){ __results.push(obj); }, Ice.Object);
- __is.readPendingValues();
-};
+ //
+ // Unmarshal callback for operations that return a proxy as the only result.
+ //
+ static __returns_ObjectPrx(__is, __results)
+ {
+ __results.push(__is.readProxy());
+ }
-//
-// Handles user exceptions.
-//
-ObjectPrx.__check = function(__r, __uex)
-{
//
- // If __uex is non-null, it must be an array of exception types.
+ // Unmarshal callback for operations that return an object as the only result.
//
- try
+ static __returns_Object(__is, __results)
{
- __r.__throwUserException();
+ __is.readValue(obj => __results.push(obj), Ice.Object);
+ __is.readPendingValues();
}
- catch(ex)
+
+ //
+ // Handles user exceptions.
+ //
+ static __check(__r, __uex)
{
- if(ex instanceof Ice.UserException)
+ //
+ // If __uex is non-null, it must be an array of exception types.
+ //
+ try
+ {
+ __r.__throwUserException();
+ }
+ catch(ex)
{
- if(__uex !== null)
+ if(ex instanceof Ice.UserException)
{
- for(var i = 0; i < __uex.length; ++i)
+ if(__uex !== null)
{
- if(ex instanceof __uex[i])
+ for(let i = 0; i < __uex.length; ++i)
{
- __r.fail(ex, __r);
- return false;
+ if(ex instanceof __uex[i])
+ {
+ __r.reject(ex);
+ return false;
+ }
}
}
+ __r.reject(new Ice.UnknownUserException(ex.ice_name()));
+ return false;
+ }
+ else
+ {
+ __r.reject(ex);
+ return false;
}
- __r.fail(new Ice.UnknownUserException(ex.ice_name()), __r);
- return false;
- }
- else
- {
- __r.fail(ex, __r);
- return false;
}
- }
-
- return true;
-};
-
-ObjectPrx.__dispatchLocalException = function(__r, __ex)
-{
- __r.fail(__ex, __r);
-};
-ObjectPrx.ice_staticId = Ice.Object.ice_staticId;
-
-ObjectPrx.checkedCast = function(prx, facet, ctx)
-{
- var __r = null;
+ return true;
+ }
- if(prx === undefined || prx === null)
+ static __dispatchLocalException(__r, __ex)
{
- __r = new AsyncResultBase(null, "checkedCast", null, null, null);
- __r.succeed(null, __r);
+ __r.reject(__ex);
}
- else
+
+ static checkedCast(prx, facet, ctx)
{
- if(facet !== undefined)
+ let __r = null;
+
+ if(prx === undefined || prx === null)
{
- prx = prx.ice_facet(facet);
+ __r = new AsyncResultBase(null, "checkedCast", null, null, null);
+ __r.resolve(null);
}
-
- var self = this;
- __r = new AsyncResultBase(prx.ice_getCommunicator(), "checkedCast", null, prx, null);
- prx.ice_isA(this.ice_staticId(), ctx).then(
- function(__res, __ret)
+ else
+ {
+ if(facet !== undefined)
{
- if(__ret)
- {
- var __h = new self();
- __h.__copyFrom(prx);
- __r.succeed(__h, __r);
- }
- else
- {
- __r.succeed(null, __r);
- }
- }).exception(
- function(__ex)
+ prx = prx.ice_facet(facet);
+ }
+ __r = new AsyncResultBase(prx.ice_getCommunicator(), "checkedCast", null, prx, null);
+ prx.ice_isA(this.ice_staticId(), ctx).then(
+ __ret =>
{
- if(__ex instanceof Ice.FacetNotExistException)
+ if(__ret)
{
- __r.succeed(null, __r);
+ const __h = new this();
+ __h.__copyFrom(prx);
+ __r.resolve(__h);
}
else
{
- __r.fail(__ex, __r);
+ __r.resolve(null);
}
- });
+ }).catch(
+ __ex =>
+ {
+ if(__ex instanceof Ice.FacetNotExistException)
+ {
+ __r.resolve(null);
+ }
+ else
+ {
+ __r.reject(__ex);
+ }
+ });
+ }
+
+ return __r;
}
- return __r;
-};
-
-ObjectPrx.uncheckedCast = function(prx, facet)
-{
- var r = null;
- if(prx !== undefined && prx !== null)
+ static uncheckedCast(prx, facet)
{
- r = new this();
- if(facet !== undefined)
+ let r = null;
+ if(prx !== undefined && prx !== null)
{
- prx = prx.ice_facet(facet);
+ r = new this();
+ if(facet !== undefined)
+ {
+ prx = prx.ice_facet(facet);
+ }
+ r.__copyFrom(prx);
}
- r.__copyFrom(prx);
+ return r;
}
- return r;
-};
-
-Object.defineProperty(ObjectPrx, "minWireSize", {
- get: function(){ return 2; }
-});
-
-ObjectPrx.write = function(os, v)
-{
- os.writeProxy(v);
-};
-ObjectPrx.read = function(is)
-{
- return is.readProxy(this);
-};
-
-ObjectPrx.writeOptional = function(os, tag, v)
-{
- os.writeOptionalProxy(tag, v);
-};
-
-ObjectPrx.readOptional = function(is, tag)
-{
- return is.readOptionalProxy(tag, this);
-};
-
-ObjectPrx.__instanceof = function(T)
-{
- if(T === this)
+ static get minWireSize()
{
- return true;
+ return 2;
}
- for(var i in this.__implements)
+ static write(os, v)
{
- if(this.__implements[i].__instanceof(T))
- {
- return true;
- }
+ os.writeProxy(v);
}
- if(this.__parent)
+ static read(is)
{
- return this.__parent.__instanceof(T);
+ return is.readProxy(this);
}
- return false;
-};
-var Slice = Ice.Slice;
-Slice.defineProxy = function(base, staticId, prxInterfaces)
-{
- var prx = function()
+ static writeOptional(os, tag, v)
{
- base.call(this);
- };
- prx.__parent = base;
- prx.__implements = prxInterfaces;
-
- // All generated proxies inherit from ObjectPrx
- prx.prototype = new base();
- prx.prototype.constructor = prx;
-
- // Static methods
- prx.ice_staticId = staticId;
+ os.writeOptionalProxy(tag, v);
+ }
- // Copy static methods inherited from ObjectPrx
- prx.checkedCast = ObjectPrx.checkedCast;
- prx.uncheckedCast = ObjectPrx.uncheckedCast;
- prx.write = ObjectPrx.write;
- prx.writeOptional = ObjectPrx.writeOptional;
- prx.read = ObjectPrx.read;
- prx.readOptional = ObjectPrx.readOptional;
+ static readOptional(is, tag)
+ {
+ return is.readOptionalProxy(tag, this);
+ }
- prx.__instanceof = ObjectPrx.__instanceof;
+ static __instanceof(T)
+ {
+ if(T === this)
+ {
+ return true;
+ }
- // Static properties
- Object.defineProperty(prx, "minWireSize", {
- get: function(){ return 2; }
- });
+ for(let i in this.__implements)
+ {
+ if(this.__implements[i].__instanceof(T))
+ {
+ return true;
+ }
+ }
- return prx;
-};
+ if(this.__parent)
+ {
+ return this.__parent.__instanceof(T);
+ }
+ return false;
+ }
+
+ static ice_staticId()
+ {
+ return "::Ice::Object";
+ }
+}
Ice.ObjectPrx = ObjectPrx;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/OpaqueEndpointI.js b/js/src/Ice/OpaqueEndpointI.js
index a176adc1bff..3c63c13bd56 100644
--- a/js/src/Ice/OpaqueEndpointI.js
+++ b/js/src/Ice/OpaqueEndpointI.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Base64",
"../Ice/Debug",
"../Ice/FormatType",
@@ -21,111 +20,124 @@ Ice.__M.require(module,
"../Ice/LocalException"
]);
-var Base64 = Ice.Base64;
-var Debug = Ice.Debug;
-var HashUtil = Ice.HashUtil;
-var Protocol = Ice.Protocol;
-var StringUtil = Ice.StringUtil;
-var EndpointParseException = Ice.EndpointParseException;
+const Base64 = Ice.Base64;
+const Debug = Ice.Debug;
+const HashUtil = Ice.HashUtil;
+const Protocol = Ice.Protocol;
+const StringUtil = Ice.StringUtil;
+const EndpointParseException = Ice.EndpointParseException;
-var Class = Ice.Class;
-
-var OpaqueEndpointI = Class(Ice.EndpointI, {
- __init__: function(type)
+class OpaqueEndpointI extends Ice.EndpointI
+{
+ constructor(type)
{
+ super();
this._rawEncoding = Ice.Encoding_1_0;
this._type = type === undefined ? -1 : type;
this._rawBytes = null;
- },
+ }
+
//
// Marshal the endpoint
//
- streamWrite: function(s)
+ streamWrite(s)
{
s.startEncapsulation(this._rawEncoding, Ice.FormatType.DefaultFormat);
s.writeBlob(this._rawBytes);
s.endEncapsulation();
- },
+ }
+
//
// Return the endpoint information.
//
- getInfo: function()
+ getInfo()
{
return new OpaqueEndpointInfoI(null, -1, false, this._rawEncoding, this._rawBytes, this._type);
- },
+ }
+
//
// Return the endpoint type
//
- type: function()
+ type()
{
return this._type;
- },
- protocol: function()
+ }
+
+ protocol()
{
return "opaque";
- },
+ }
+
//
// Return the timeout for the endpoint in milliseconds. 0 means
// non-blocking, -1 means no timeout.
//
- timeout: function()
+ timeout()
{
return -1;
- },
+ }
+
//
// Return a new endpoint with a different timeout value, provided
// that timeouts are supported by the endpoint. Otherwise the same
// endpoint is returned.
//
- changeTimeout: function(t)
+ changeTimeout(t)
{
return this;
- },
+ }
+
//
// Return a new endpoint with a different connection id.
//
- changeConnectionId: function(connectionId)
+ changeConnectionId(connectionId)
{
return this;
- },
+ }
+
//
// Return true if the endpoints support bzip2 compress, or false
// otherwise.
//
- compress: function()
+ compress()
{
return false;
- },
+ }
+
//
// Return a new endpoint with a different compression value,
// provided that compression is supported by the
// endpoint. Otherwise the same endpoint is returned.
//
- changeCompress: function(compress)
+ changeCompress(compress)
{
return this;
- },
+ }
+
//
// Return true if the endpoint is datagram-based.
//
- datagram: function()
+ datagram()
{
return false;
- },
+ }
+
//
// Return true if the endpoint is secure.
//
- secure: function()
+ secure()
{
return false;
- },
+ }
+
//
// Get the encoded endpoint.
//
- rawBytes: function()
+ rawBytes()
{
return this._rawBytes; // Returns a Uint8Array
- },
+ }
+
//
// Return a server side transceiver for this endpoint, or null if a
// transceiver can only be created by an acceptor. In case a
@@ -133,11 +145,12 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
// "effective" endpoint, which might differ from this endpoint,
// for example, if a dynamic port number is assigned.
//
- transceiver: function(endpoint)
+ transceiver(endpoint)
{
endpoint.value = null;
return null;
- },
+ }
+
//
// Return an acceptor for this endpoint, or null if no acceptors
// is available. In case an acceptor is created, this operation
@@ -145,39 +158,43 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
// from this endpoint, for example, if a dynamic port number is
// assigned.
//
- acceptor: function(endpoint, adapterName)
+ acceptor(endpoint, adapterName)
{
endpoint.value = this;
return null;
- },
- connect: function()
+ }
+
+ connect()
{
return null;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
if(this._hashCode === undefined)
{
- var h = 5381;
+ let h = 5381;
h = HashUtil.addNumber(h, this._type);
h = HashUtil.addHashable(h, this._rawEncoding);
h = HashUtil.addArray(h, this._rawBytes, HashUtil.addNumber);
this._hashCode = h;
}
return this._hashCode;
- },
- options: function()
+ }
+
+ options()
{
- var s = "";
- s+= " -t " + this._type;
+ let s = "";
+ s += " -t " + this._type;
s += " -e " + Ice.encodingVersionToString(this._rawEncoding);
s += " -v " + Base64.encode(this._rawBytes);
return s;
- },
+ }
+
//
// Compare endpoints for sorting purposes
//
- equals: function(p)
+ equals(p)
{
if(!(p instanceof OpaqueEndpointI))
{
@@ -203,7 +220,7 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
{
return false;
}
- for(var i = 0; i < this._rawBytes.length; i++)
+ for(let i = 0; i < this._rawBytes.length; i++)
{
if(this._rawBytes[i] !== p._rawBytes[i])
{
@@ -212,8 +229,9 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
}
return true;
- },
- compareTo: function(p)
+ }
+
+ compareTo(p)
{
if(this === p)
{
@@ -265,7 +283,7 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
{
return 1;
}
- for(var i = 0; i < this._rawBytes.length; i++)
+ for(let i = 0; i < this._rawBytes.length; i++)
{
if(this._rawBytes[i] < p._rawBytes[i])
{
@@ -278,8 +296,9 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
}
return 0;
- },
- checkOption: function(option, argument, endpoint)
+ }
+
+ checkOption(option, argument, endpoint)
{
switch(option.charAt(1))
{
@@ -294,7 +313,7 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
throw new EndpointParseException("no argument provided for -t option in endpoint " + endpoint);
}
- var type;
+ let type;
try
{
@@ -325,13 +344,13 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
{
throw new EndpointParseException("no argument provided for -v option in endpoint " + endpoint);
}
- for(var j = 0; j < argument.length; ++j)
+ for(let i = 0; i < argument.length; ++i)
{
- if(!Base64.isBase64(argument.charAt(j)))
+ if(!Base64.isBase64(argument.charAt(i)))
{
- throw new EndpointParseException("invalid base64 character `" + argument.charAt(j) +
- "' (ordinal " + argument.charCodeAt(j) +
- ") in endpoint " + endpoint);
+ throw new EndpointParseException("invalid base64 character `" + argument.charAt(i) +
+ "' (ordinal " + argument.charCodeAt(i) +
+ ") in endpoint " + endpoint);
}
}
this._rawBytes = Base64.decode(argument);
@@ -361,10 +380,11 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
return false;
}
}
- },
- initWithOptions: function(args)
+ }
+
+ initWithOptions(args)
{
- Ice.EndpointI.prototype.initWithOptions.call(this, args);
+ super.initWithOptions(args);
Debug.assert(this._rawEncoding);
if(this._type < 0)
@@ -375,34 +395,38 @@ var OpaqueEndpointI = Class(Ice.EndpointI, {
{
throw new EndpointParseException("no -v option in endpoint `" + this + "'");
}
- },
- initWithStream: function(s)
+ }
+
+ initWithStream(s)
{
this._rawEncoding = s.getEncoding();
- var sz = s.getEncapsulationSize();
- this._rawBytes = s.readBlob(sz);
+ this._rawBytes = s.readBlob(s.getEncapsulationSize());
}
-});
+}
-var OpaqueEndpointInfoI = Class(Ice.OpaqueEndpointInfo, {
- __init__: function(timeout, compress, rawEncoding, rawBytes, type)
+class OpaqueEndpointInfoI extends Ice.OpaqueEndpointInfo
+{
+ constructor(timeout, compress, rawEncoding, rawBytes, type)
{
- Ice.OpaqueEndpointInfo.call(this, -1, false, rawEncoding, rawBytes);
+ super(-1, false, rawEncoding, rawBytes);
this._type = type;
- },
- type: function()
+ }
+
+ type()
{
return this._type;
- },
- datagram: function()
+ }
+
+ datagram()
{
return false;
- },
- secure: function()
+ }
+
+ secure()
{
return false;
}
-});
+}
Ice.OpaqueEndpointI = OpaqueEndpointI;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Operation.js b/js/src/Ice/Operation.js
index bc115ba8c0e..c79af7f8721 100644
--- a/js/src/Ice/Operation.js
+++ b/js/src/Ice/Operation.js
@@ -8,11 +8,10 @@
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-var __M = Ice.__M;
+const Ice = require("../Ice/ModuleRegistry").Ice;
+const __M = Ice.__M;
__M.require(module,
[
- "../Ice/Class",
"../Ice/Current",
"../Ice/DispatchStatus",
"../Ice/Exception",
@@ -23,9 +22,7 @@ __M.require(module,
"../Ice/StreamHelpers"
]);
-var Class = Ice.Class;
-
-var builtinHelpers =
+const builtinHelpers =
[
Ice.ByteHelper,
Ice.BoolHelper,
@@ -41,17 +38,15 @@ var builtinHelpers =
function parseParam(p)
{
- var type = p[0];
- var t = typeof(type);
+ let type = p[0];
+ const t = typeof(type);
if(t === 'number')
{
type = builtinHelpers[p[0]];
}
else if(t === 'string')
{
- /*jshint -W061 */
type = __M.type(type);
- /*jshint +W061 */
}
return {
@@ -80,9 +75,7 @@ function parseParam(p)
//
function parseOperation(name, arr)
{
- var r = {};
- var i;
- var p;
+ const r = {};
r.name = name;
r.mode = arr[1] ? Ice.OperationMode.valueOf(arr[1]) : Ice.OperationMode.Normal;
@@ -99,7 +92,7 @@ function parseOperation(name, arr)
r.servantMethod = arr[0] ? arr[0] : name;
}
- var ret;
+ let ret;
if(arr[5])
{
ret = parseParam(arr[5]);
@@ -107,13 +100,13 @@ function parseOperation(name, arr)
}
r.returns = ret;
- var inParams = [];
- var inParamsOpt = [];
+ const inParams = [];
+ const inParamsOpt = [];
if(arr[6])
{
- for(i = 0; i < arr[6].length; ++i)
+ for(let i = 0; i < arr[6].length; ++i)
{
- p = parseParam(arr[6][i]);
+ let p = parseParam(arr[6][i]);
p.pos = i;
inParams.push(p);
if(p.tag)
@@ -126,14 +119,14 @@ function parseOperation(name, arr)
r.inParams = inParams;
r.inParamsOpt = inParamsOpt;
- var outParams = [];
- var outParamsOpt = [];
+ const outParams = [];
+ const outParamsOpt = [];
if(arr[7])
{
- var offs = ret ? 1 : 0;
- for(i = 0; i < arr[7].length; ++i)
+ const offs = ret ? 1 : 0;
+ for(let i = 0; i < arr[7].length; ++i)
{
- p = parseParam(arr[7][i]);
+ let p = parseParam(arr[7][i]);
p.pos = i + offs;
outParams.push(p);
if(p.tag)
@@ -150,10 +143,10 @@ function parseOperation(name, arr)
r.outParams = outParams;
r.outParamsOpt = outParamsOpt;
- var exceptions = [];
+ const exceptions = [];
if(arr[8])
{
- for(i = 0; i < arr[8].length; ++i)
+ for(let i = 0; i < arr[8].length; ++i)
{
exceptions.push(arr[8][i]);
}
@@ -166,18 +159,20 @@ function parseOperation(name, arr)
return r;
}
-var OpTable = Class({
- __init__: function(ops)
+class OpTable
+{
+ constructor(ops)
{
this.raw = ops;
this.parsed = {};
- },
- find: function(name)
+ }
+
+ find(name)
{
//
// Check if we've already parsed the operation.
//
- var op = this.parsed[name];
+ let op = this.parsed[name];
if(op === undefined && this.raw[name] !== undefined)
{
//
@@ -188,20 +183,19 @@ var OpTable = Class({
}
return op;
}
-});
+}
function unmarshalParams(is, retvalInfo, allParamInfo, optParamInfo, usesClasses, params, offset)
{
- var i, p, v;
//
// First read all required params.
//
- for(i = 0; i < allParamInfo.length; ++i)
+ for(let i = 0; i < allParamInfo.length; ++i)
{
- p = allParamInfo[i];
+ let p = allParamInfo[i];
if(!p.tag)
{
- v = p.type.read(is);
+ let v = p.type.read(is);
params[p.pos + offset] = v;
}
}
@@ -211,17 +205,17 @@ function unmarshalParams(is, retvalInfo, allParamInfo, optParamInfo, usesClasses
//
if(retvalInfo)
{
- v = retvalInfo.type.read(is);
+ let v = retvalInfo.type.read(is);
params[retvalInfo.pos + offset] = v;
}
//
// Then read all optional params.
//
- for(i = 0; i < optParamInfo.length; ++i)
+ for(let i = 0; i < optParamInfo.length; ++i)
{
- p = optParamInfo[i];
- v = p.type.readOptional(is, p.tag);
+ let p = optParamInfo[i];
+ let v = p.type.readOptional(is, p.tag);
params[p.pos + offset] = v;
}
@@ -233,14 +227,12 @@ function unmarshalParams(is, retvalInfo, allParamInfo, optParamInfo, usesClasses
function marshalParams(os, params, retvalInfo, paramInfo, optParamInfo, usesClasses)
{
- var i, p;
-
//
// Write the required params.
//
- for(i = 0; i < paramInfo.length; ++i)
+ for(let i = 0; i < paramInfo.length; ++i)
{
- p = paramInfo[i];
+ let p = paramInfo[i];
if(!p.tag)
{
p.type.write(os, params[p.pos]);
@@ -258,9 +250,9 @@ function marshalParams(os, params, retvalInfo, paramInfo, optParamInfo, usesClas
//
// Write the optional params.
//
- for(i = 0; i < optParamInfo.length; ++i)
+ for(let i = 0; i < optParamInfo.length; ++i)
{
- p = optParamInfo[i];
+ let p = optParamInfo[i];
p.type.writeOptional(os, p.tag, params[p.pos]);
}
@@ -270,21 +262,21 @@ function marshalParams(os, params, retvalInfo, paramInfo, optParamInfo, usesClas
}
}
-var Upcall = Class({
- __init__: function(incomingAsync, op)
+class Upcall
+{
+ constructor(incomingAsync, op)
{
this.incomingAsync = incomingAsync;
this.op = op;
- },
- ice_response: function()
- {
- var args = arguments;
+ }
+ ice_response()
+ {
if(this.incomingAsync.__validateResponse(true))
{
try
{
- this.__sendResponse(args);
+ this.__sendResponse(arguments);
this.incomingAsync.__response();
}
catch(ex)
@@ -292,8 +284,9 @@ var Upcall = Class({
this.incomingAsync.__exception(ex);
}
}
- },
- ice_exception: function(ex)
+ }
+
+ ice_exception(ex)
{
if(this.__checkException(ex))
{
@@ -307,8 +300,9 @@ var Upcall = Class({
{
this.incomingAsync.ice_exception(ex);
}
- },
- __sendResponse: function(results)
+ }
+
+ __sendResponse(results)
{
if(this.op.returns === undefined && this.op.outParams.length === 0)
{
@@ -326,8 +320,8 @@ var Upcall = Class({
}
else
{
- var __os = this.incomingAsync.__startWriteParams(this.op.format);
- var retvalInfo;
+ const __os = this.incomingAsync.__startWriteParams(this.op.format);
+ let retvalInfo;
if(this.op.returns && !this.op.returns.tag)
{
retvalInfo = this.op.returns;
@@ -336,14 +330,15 @@ var Upcall = Class({
this.op.returnsClasses);
this.incomingAsync.__endWriteParams(true);
}
- },
- __checkException: function(ex)
+ }
+
+ __checkException(ex)
{
//
// Make sure the given exception is an instance of one of the declared user exceptions
// for this operation.
//
- for(var i = 0; i < this.op.exceptions.length; ++i)
+ for(let i = 0; i < this.op.exceptions.length; ++i)
{
if(ex instanceof this.op.exceptions[i])
{
@@ -355,46 +350,44 @@ var Upcall = Class({
}
return false;
- },
- __sendException: function(ex)
+ }
+
+ __sendException(ex)
{
//
// User exception is valid, now marshal it.
//
this.incomingAsync.__writeUserException(ex, this.op.format);
}
-});
+}
-var __dispatchImpl = function(servant, op, incomingAsync, current)
+function __dispatchImpl(servant, op, incomingAsync, current)
{
//
// Check to make sure the servant implements the operation.
//
- var method = servant[op.servantMethod];
+ const method = servant[op.servantMethod];
if(method === undefined || typeof(method) !== "function")
{
- var comm = current.adapter.getCommunicator();
- var msg = "servant for identity " + Ice.identityToString(current.id) +
- " does not define operation `" + op.servantMethod + "'";
- throw new Ice.UnknownException(msg);
+ throw new Ice.UnknownException("servant for identity " + Ice.identityToString(current.id) +
+ " does not define operation `" + op.servantMethod + "'");
}
- var up = new Upcall(incomingAsync, op);
-
+ const up = new Upcall(incomingAsync, op);
try
{
//
// Unmarshal the in params (if any).
//
- var params = op.amd ? [null] : [];
+ const params = op.amd ? [null] : [];
if(op.inParams.length === 0)
{
incomingAsync.readEmptyParams();
}
else
{
- var __is = incomingAsync.startReadParams();
- var offset = op.amd ? 1 : 0;
+ const __is = incomingAsync.startReadParams();
+ const offset = op.amd ? 1 : 0;
unmarshalParams(__is, undefined, op.inParams, op.inParamsOpt, op.sendsClasses, params, offset);
incomingAsync.endReadParams();
@@ -406,17 +399,16 @@ var __dispatchImpl = function(servant, op, incomingAsync, current)
//
if(op.inParams.length > 0 && (op.sendsClasses || op.inParamsOpt.length > 0))
{
- for(var i = 0; i < op.inParams.length; ++i)
- {
- var p = op.inParams[i];
- //
- // Optional parameters may be undefined.
- //
- if(p.isObject && params[p.pos + offset] !== undefined)
+ op.inParams.forEach(p =>
{
- params[p.pos + offset] = params[p.pos + offset].value;
- }
- }
+ //
+ // Optional parameters may be undefined.
+ //
+ if(p.isObject && params[p.pos + offset] !== undefined)
+ {
+ params[p.pos + offset] = params[p.pos + offset].value;
+ }
+ });
}
}
@@ -440,13 +432,13 @@ var __dispatchImpl = function(servant, op, incomingAsync, current)
//
// Determine how many out parameters to expect.
//
- var numExpectedResults = op.outParams.length;
+ let numExpectedResults = op.outParams.length;
if(op.returns)
{
++numExpectedResults;
}
- var results = method.apply(servant, params);
+ let results = method.apply(servant, params);
//
// Complain if we expect more than out parameter and the servant doesn't return an array.
@@ -480,14 +472,14 @@ var __dispatchImpl = function(servant, op, incomingAsync, current)
throw ex;
}
}
-};
+}
function getServantMethodFromInterfaces(interfaces, methodName, all)
{
- var method;
- for(var i = 0; method === undefined && i < interfaces.length; ++i)
+ let method;
+ for(let i = 0; method === undefined && i < interfaces.length; ++i)
{
- var intf = interfaces[i];
+ let intf = interfaces[i];
method = intf[methodName];
if(method === undefined)
{
@@ -504,21 +496,21 @@ function getServantMethodFromInterfaces(interfaces, methodName, all)
return method;
}
-var dispatchPrefix = "__op_";
+const dispatchPrefix = "__op_";
function getServantMethod(servantType, name)
{
//
// The dispatch method is named __op_<Slice name> and is stored in the type (not the prototype).
//
- var methodName = dispatchPrefix + name;
+ const methodName = dispatchPrefix + name;
//
// First check the servant type.
//
- var method = servantType[methodName];
+ let method = servantType[methodName];
- var allInterfaces;
+ let allInterfaces;
if(method === undefined)
{
@@ -527,7 +519,7 @@ function getServantMethod(servantType, name)
//
// Now check the prototypes of the implemented interfaces.
//
- var curr = servantType;
+ let curr = servantType;
while(curr && method === undefined)
{
if(curr.__implements)
@@ -551,19 +543,19 @@ function getServantMethod(servantType, name)
//
// Next check the op table for the servant's type.
//
- var op;
+ let op;
if(servantType.__ops)
{
op = servantType.__ops.find(name);
}
- var source;
+ let source;
if(op === undefined)
{
//
// Now check the op tables of the base types.
//
- var parent = servantType.__parent;
+ let parent = servantType.__parent;
while(op === undefined && parent)
{
if(parent.__ops)
@@ -579,9 +571,9 @@ function getServantMethod(servantType, name)
//
// Now check the op tables of all base interfaces.
//
- for(var i = 0; op === undefined && i < allInterfaces.length; ++i)
+ for(let i = 0; op === undefined && i < allInterfaces.length; ++i)
{
- var intf = allInterfaces[i];
+ let intf = allInterfaces[i];
if(intf.__ops)
{
if((op = intf.__ops.find(name)) !== undefined)
@@ -619,13 +611,13 @@ function getServantMethod(servantType, name)
function addProxyOperation(proxyType, name, data)
{
- var method = data[0] ? data[0] : name;
+ let method = data[0] ? data[0] : name;
- var op = null;
+ let op = null;
proxyType.prototype[method] = function()
{
- var args = arguments;
+ let args = arguments;
//
// Parse the operation data on the first invocation of a proxy method.
@@ -635,22 +627,20 @@ function addProxyOperation(proxyType, name, data)
op = parseOperation(name, data);
}
- var ctx = args[op.inParams.length]; // The request context is the last argument (if present).
+ let ctx = args[op.inParams.length]; // The request context is the last argument (if present).
- var marshalFn = null;
+ let marshalFn = null;
if(op.inParams.length > 0)
{
marshalFn = function(os, params)
{
- var i, p, v;
-
//
// Validate the parameters.
//
- for(i = 0; i < op.inParams.length; ++i)
+ for(let i = 0; i < op.inParams.length; ++i)
{
- p = op.inParams[i];
- v = params[p.pos];
+ let p = op.inParams[i];
+ let v = params[p.pos];
if(!p.tag || v !== undefined)
{
if(typeof p.type.validate === "function")
@@ -668,7 +658,7 @@ function addProxyOperation(proxyType, name, data)
};
}
- var unmarshalFn = null;
+ let unmarshalFn = null;
if(op.returns || op.outParams.length > 0)
{
unmarshalFn = function(asyncResult)
@@ -678,11 +668,11 @@ function addProxyOperation(proxyType, name, data)
//
// [retval, out1, out2, ..., asyncResult]
//
- var results = [];
+ let results = [];
- var is = asyncResult.__startReadParams();
+ let is = asyncResult.__startReadParams();
- var retvalInfo;
+ let retvalInfo;
if(op.returns && !op.returns.tag)
{
retvalInfo = op.returns;
@@ -699,14 +689,14 @@ function addProxyOperation(proxyType, name, data)
//
if(op.returnsClasses || op.outParamsOpt.length > 0)
{
- var offset = 0; // Skip asyncResult in results.
+ let offset = 0; // Skip asyncResult in results.
if(op.returns && op.returns.isObject && results[op.returns.pos + offset] !== undefined)
{
results[op.returns.pos + offset] = results[op.returns.pos + offset].value;
}
- for(var i = 0; i < op.outParams.length; ++i)
+ for(let i = 0; i < op.outParams.length; ++i)
{
- var p = op.outParams[i];
+ let p = op.outParams[i];
//
// Optional parameters may be undefined.
//
@@ -716,17 +706,16 @@ function addProxyOperation(proxyType, name, data)
}
}
}
- results.push(asyncResult);
- return results;
+
+ return results.length == 1 ? results[0] : results;
};
}
-
- return Ice.ObjectPrx.__invoke(this, op.name, op.sendMode, op.format, ctx, marshalFn, unmarshalFn,
- op.exceptions, Array.prototype.slice.call(args));
+ return Ice.ObjectPrx.__invoke(this, op.name, op.sendMode, op.format, ctx, marshalFn, unmarshalFn,
+ op.exceptions, Array.prototype.slice.call(args));
};
}
-var Slice = Ice.Slice;
+const Slice = Ice.Slice;
Slice.defineOperations = function(classType, proxyType, ops)
{
if(ops)
@@ -739,7 +728,7 @@ Slice.defineOperations = function(classType, proxyType, ops)
//
// Retrieve the dispatch method for this operation.
//
- var method = getServantMethod(classType, current.operation);
+ const method = getServantMethod(classType, current.operation);
if(method === undefined || typeof(method) !== 'function')
{
@@ -751,7 +740,7 @@ Slice.defineOperations = function(classType, proxyType, ops)
if(ops)
{
- for(var name in ops)
+ for(let name in ops)
{
addProxyOperation(proxyType, name, ops[name]);
}
@@ -762,10 +751,10 @@ Slice.defineOperations = function(classType, proxyType, ops)
//
if(proxyType.__implements)
{
- for(var intf in proxyType.__implements)
+ for(let intf in proxyType.__implements)
{
- var proto = proxyType.__implements[intf].prototype;
- for(var f in proto)
+ let proto = proxyType.__implements[intf].prototype;
+ for(let f in proto)
{
if(typeof proto[f] == "function" && proxyType.prototype[f] === undefined)
{
diff --git a/js/src/Ice/OptionalFormat.js b/js/src/Ice/OptionalFormat.js
index 2d3c48c3dea..a5a9b22f29b 100644
--- a/js/src/Ice/OptionalFormat.js
+++ b/js/src/Ice/OptionalFormat.js
@@ -7,6 +7,6 @@
//
// **********************************************************************
-var Ice = require("../Ice/EnumBase").Ice;
+const Ice = require("../Ice/EnumBase").Ice;
Ice.OptionalFormat = Ice.Slice.defineEnum([['F1', 0], ['F2', 1], ['F4', 2], ['F8', 3], ['Size', 4], ['VSize', 5], ['FSize', 6], ['Class', 7]]);
module.exports.Ice = Ice;
diff --git a/js/src/Ice/OutgoingAsync.js b/js/src/Ice/OutgoingAsync.js
index 50cbbc6706e..8c426beb2ba 100644
--- a/js/src/Ice/OutgoingAsync.js
+++ b/js/src/Ice/OutgoingAsync.js
@@ -7,15 +7,13 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/AsyncStatus",
"../Ice/AsyncResult",
"../Ice/Stream",
"../Ice/Debug",
- "../Ice/HashMap",
"../Ice/RetryException",
"../Ice/Current",
"../Ice/Protocol",
@@ -25,62 +23,52 @@ Ice.__M.require(module,
"../Ice/Identity"
]);
-var AsyncStatus = Ice.AsyncStatus;
-var AsyncResult = Ice.AsyncResult;
-var InputStream = Ice.InputStream;
-var OutputStream = Ice.OutputStream;
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var RetryException = Ice.RetryException;
-var OperationMode = Ice.OperationMode;
-var Protocol = Ice.Protocol;
-var Identity = Ice.Identity;
-
-var OutgoingAsyncBase = Ice.Class(AsyncResult, {
- __init__ : function(communicator, operation, connection, proxy, adapter)
- {
- if(communicator !== undefined)
- {
- AsyncResult.call(this, communicator, operation, connection, proxy, adapter);
- this._os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
- }
- else
- {
- AsyncResult.call(this);
- }
- },
- __os: function()
+const AsyncStatus = Ice.AsyncStatus;
+const AsyncResult = Ice.AsyncResult;
+const InputStream = Ice.InputStream;
+const OutputStream = Ice.OutputStream;
+const Debug = Ice.Debug;
+const RetryException = Ice.RetryException;
+const OperationMode = Ice.OperationMode;
+const Protocol = Ice.Protocol;
+const Identity = Ice.Identity;
+
+class OutgoingAsyncBase extends AsyncResult
+{
+ constructor(communicator, operation, connection, proxy, adapter)
+ {
+ super(communicator, operation, connection, proxy, adapter);
+ this._os = new OutputStream(this._instance, Protocol.currentProtocolEncoding);
+ }
+
+ __os()
{
return this._os;
- },
- __sent: function()
+ }
+
+ __sent()
{
this.__markSent(true);
- },
- __completedEx: function(ex)
+ }
+
+ __completedEx(ex)
{
this.__markFinishedEx(ex);
}
-});
+}
-
-var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
- __init__ : function(prx, operation)
+class ProxyOutgoingAsyncBase extends OutgoingAsyncBase
+{
+ constructor(prx, operation)
{
- if(prx !== undefined)
- {
- OutgoingAsyncBase.call(this, prx.ice_getCommunicator(), operation, null, prx, null);
- this._mode = null;
- this._cnt = 0;
- this._sent = false;
- this._handler = null;
- }
- else
- {
- AsyncResult.call(this);
- }
- },
- __completedEx: function(ex)
+ super(prx.ice_getCommunicator(), operation, null, prx, null);
+ this._mode = null;
+ this._cnt = 0;
+ this._sent = false;
+ this._handler = null;
+ }
+
+ __completedEx(ex)
{
try
{
@@ -90,8 +78,9 @@ var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
{
this.__markFinishedEx(ex);
}
- },
- __retryException: function(ex)
+ }
+
+ __retryException(ex)
{
try
{
@@ -102,29 +91,31 @@ var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
{
this.__completedEx(ex);
}
- },
- __retry: function()
+ }
+
+ __retry()
{
this.__invokeImpl(false);
- },
- __abort: function(ex)
+ }
+
+ __abort(ex)
{
this.__markFinishedEx(ex);
- },
- __invokeImpl: function(userThread)
+ }
+
+ __invokeImpl(userThread)
{
try
{
if(userThread)
{
- var invocationTimeout = this._proxy.__reference().getInvocationTimeout();
+ const invocationTimeout = this._proxy.__reference().getInvocationTimeout();
if(invocationTimeout > 0)
{
- var self = this;
this._timeoutToken = this._instance.timer().schedule(
- function()
+ () =>
{
- self.__cancel(new Ice.InvocationTimeoutException());
+ this.__cancel(new Ice.InvocationTimeoutException());
},
invocationTimeout);
}
@@ -136,8 +127,7 @@ var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
{
this._sent = false;
this._handler = this._proxy.__getRequestHandler();
- var status = this._handler.sendAsyncRequest(this);
- if((status & AsyncStatus.Sent) > 0)
+ if((this._handler.sendAsyncRequest(this) & AsyncStatus.Sent) > 0)
{
if(userThread)
{
@@ -155,7 +145,7 @@ var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
}
else
{
- var interval = this.__handleException(ex);
+ const interval = this.__handleException(ex);
if(interval > 0)
{
this._instance.retryQueue().add(this, interval);
@@ -169,8 +159,9 @@ var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
{
this.__markFinishedEx(ex);
}
- },
- __markSent: function(done)
+ }
+
+ __markSent(done)
{
this._sent = true;
if(done)
@@ -180,43 +171,36 @@ var ProxyOutgoingAsyncBase = Ice.Class(OutgoingAsyncBase, {
this._instance.timer().cancel(this._timeoutToken);
}
}
- OutgoingAsyncBase.prototype.__markSent.call(this, done);
- },
- __markFinishedEx: function(ex)
+ super.__markSent.call(this, done);
+ }
+
+ __markFinishedEx(ex)
{
if(this._timeoutToken)
{
this._instance.timer().cancel(this._timeoutToken);
}
- OutgoingAsyncBase.prototype.__markFinishedEx.call(this, ex);
- },
- __handleException: function(ex)
+ super.__markFinishedEx.call(this, ex);
+ }
+
+ __handleException(ex)
{
- var interval = { value: 0 };
+ const interval = { value: 0 };
this._cnt = this._proxy.__handleException(ex, this._handler, this._mode, this._sent, interval, this._cnt);
return interval.value;
}
-});
+}
-var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
- __init__: function(prx, operation, completed)
+class OutgoingAsync extends ProxyOutgoingAsyncBase
+{
+ constructor(prx, operation, completed)
{
- //
- // OutgoingAsync can be constructed by a sub-type's prototype, in which case the
- // arguments are undefined.
- //
- if(prx !== undefined)
- {
- ProxyOutgoingAsyncBase.call(this, prx, operation);
- this._encoding = Protocol.getCompatibleEncoding(this._proxy.__reference().getEncoding());
- this._completed = completed;
- }
- else
- {
- ProxyOutgoingAsyncBase.call(this);
- }
- },
- __prepare: function(op, mode, ctx)
+ super(prx, operation);
+ this._encoding = Protocol.getCompatibleEncoding(this._proxy.__reference().getEncoding());
+ this._completed = completed;
+ }
+
+ __prepare(op, mode, ctx)
{
Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(this._proxy.__reference().getProtocol()));
@@ -235,14 +219,14 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
this._os.writeBlob(Protocol.requestHdr);
}
- var ref = this._proxy.__reference();
+ const ref = this._proxy.__reference();
ref.getIdentity().__write(this._os);
//
// For compatibility with the old FacetPath.
//
- var facet = ref.getFacet();
+ const facet = ref.getFacet();
if(facet === null || facet.length === 0)
{
Ice.StringSeqHelper.write(this._os, null);
@@ -258,9 +242,9 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
if(ctx !== undefined)
{
- if(ctx !== null && !(ctx instanceof HashMap))
+ if(ctx !== null && !(ctx instanceof Map))
{
- throw new Error("illegal context value, expecting null or HashMap");
+ throw new Error("illegal context value, expecting null or Map");
}
//
@@ -273,8 +257,8 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
//
// Implicit context
//
- var implicitContext = ref.getInstance().getImplicitContext();
- var prxContext = ref.getContext();
+ const implicitContext = ref.getInstance().getImplicitContext();
+ const prxContext = ref.getContext();
if(implicitContext === null)
{
@@ -285,24 +269,28 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
implicitContext.write(prxContext, this._os);
}
}
- },
- __sent: function()
+ }
+
+ __sent()
{
this.__markSent(!this._proxy.ice_isTwoway());
- },
- __invokeRemote: function(connection, compress, response)
+ }
+
+ __invokeRemote(connection, compress, response)
{
return connection.sendAsyncRequest(this, compress, response, 0);
- },
- __abort: function(ex)
+ }
+
+ __abort(ex)
{
if(this._proxy.ice_isBatchOneway() || this._proxy.ice_isBatchDatagram())
{
this._proxy.__getBatchRequestQueue().abortBatchRequest(this._os);
}
- ProxyOutgoingAsyncBase.prototype.__abort.call(this, ex);
- },
- __invoke: function()
+ super.__abort(ex);
+ }
+
+ __invoke()
{
if(this._proxy.ice_isBatchOneway() || this._proxy.ice_isBatchDatagram())
{
@@ -318,12 +306,13 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
// exception.
//
this.__invokeImpl(true); // userThread = true
- },
- __completed: function(istr)
+ }
+
+ __completed(istr)
{
Debug.assert(this._proxy.ice_isTwoway()); // Can only be called for twoways.
- var replyStatus;
+ let replyStatus;
try
{
if(this._is === null) // _is can already be initialized if the invocation is retried
@@ -345,14 +334,14 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
case Protocol.replyFacetNotExist:
case Protocol.replyOperationNotExist:
{
- var id = new Identity();
+ const id = new Identity();
id.__read(this._is);
//
// For compatibility with the old FacetPath.
//
- var facetPath = Ice.StringSeqHelper.read(this._is);
- var facet;
+ const facetPath = Ice.StringSeqHelper.read(this._is);
+ let facet;
if(facetPath.length > 0)
{
if(facetPath.length > 1)
@@ -366,9 +355,9 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
facet = "";
}
- var operation = this._is.readString();
+ const operation = this._is.readString();
- var rfe = null;
+ let rfe = null;
switch(replyStatus)
{
case Protocol.replyObjectNotExist:
@@ -406,9 +395,9 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
case Protocol.replyUnknownLocalException:
case Protocol.replyUnknownUserException:
{
- var unknown = this._is.readString();
+ const unknown = this._is.readString();
- var ue = null;
+ let ue = null;
switch(replyStatus)
{
case Protocol.replyUnknownException:
@@ -452,21 +441,25 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
{
this.__completedEx(ex);
}
- },
- __startWriteParams: function(format)
+ }
+
+ __startWriteParams(format)
{
this._os.startEncapsulation(this._encoding, format);
return this._os;
- },
- __endWriteParams: function()
+ }
+
+ __endWriteParams()
{
this._os.endEncapsulation();
- },
- __writeEmptyParams: function()
+ }
+
+ __writeEmptyParams()
{
this._os.writeEmptyEncapsulation(this._encoding);
- },
- __writeParamEncaps: function(encaps)
+ }
+
+ __writeParamEncaps(encaps)
{
if(encaps === null || encaps.length === 0)
{
@@ -476,29 +469,35 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
{
this._os.writeEncapsulation(encaps);
}
- },
- __is: function()
+ }
+
+ __is()
{
return this._is;
- },
- __startReadParams: function()
+ }
+
+ __startReadParams()
{
this._is.startEncapsulation();
return this._is;
- },
- __endReadParams: function()
+ }
+
+ __endReadParams()
{
this._is.endEncapsulation();
- },
- __readEmptyParams: function()
+ }
+
+ __readEmptyParams()
{
this._is.skipEmptyEncapsulation();
- },
- __readParamEncaps: function()
+ }
+
+ __readParamEncaps()
{
return this._is.readEncapsulation(null);
- },
- __throwUserException: function()
+ }
+
+ __throwUserException()
{
Debug.assert((this._state & AsyncResult.Done) !== 0);
if((this._state & AsyncResult.OK) === 0)
@@ -517,17 +516,20 @@ var OutgoingAsync = Ice.Class(ProxyOutgoingAsyncBase, {
throw ex;
}
}
- },
-});
-OutgoingAsync._emptyContext = new HashMap();
+ }
+}
+
+OutgoingAsync._emptyContext = new Map(); // Map<string, string>
-var ProxyFlushBatch = Ice.Class(ProxyOutgoingAsyncBase, {
- __init__ : function(prx, operation)
+class ProxyFlushBatch extends ProxyOutgoingAsyncBase
+{
+ constructor(prx, operation)
{
- ProxyOutgoingAsyncBase.call(this, prx, operation);
+ super(prx, operation);
this._batchRequestNum = prx.__getBatchRequestQueue().swap(this._os);
- },
- __invokeRemote: function(connection, compress, response)
+ }
+
+ __invokeRemote(connection, compress, response)
{
if(this._batchRequestNum === 0)
{
@@ -535,45 +537,47 @@ var ProxyFlushBatch = Ice.Class(ProxyOutgoingAsyncBase, {
return AsyncStatus.Sent;
}
return connection.sendAsyncRequest(this, compress, response, this._batchRequestNum);
- },
- __invoke: function()
+ }
+
+ __invoke()
{
Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(this._proxy.__reference().getProtocol()));
this.__invokeImpl(true); // userThread = true
- },
-});
+ }
+}
-var ProxyGetConnection = Ice.Class(ProxyOutgoingAsyncBase, {
- __init__ : function(prx, operation)
+class ProxyGetConnection extends ProxyOutgoingAsyncBase
+{
+ constructor(prx, operation)
{
- ProxyOutgoingAsyncBase.call(this, prx, operation);
- },
- __invokeRemote: function(connection, compress, response)
+ super(prx, operation);
+ }
+
+ __invokeRemote(connection, compress, response)
{
- this.__markFinished(true,
- function(r)
- {
- r.succeed(connection);
- });
+ this.__markFinished(true, r => r.resolve(connection));
return AsyncStatus.Sent;
- },
- __invoke: function()
+ }
+
+ __invoke()
{
this.__invokeImpl(true); // userThread = true
}
-});
+}
-var ConnectionFlushBatch = Ice.Class(OutgoingAsyncBase, {
- __init__: function(con, communicator, operation)
+class ConnectionFlushBatch extends OutgoingAsyncBase
+{
+ constructor(con, communicator, operation)
{
- OutgoingAsyncBase.call(this, communicator, operation, con, null, null);
- },
- __invoke: function()
+ super(communicator, operation, con, null, null);
+ }
+
+ __invoke()
{
try
{
- var batchRequestNum = this._connection.getBatchRequestQueue().swap(this._os);
- var status;
+ const batchRequestNum = this._connection.getBatchRequestQueue().swap(this._os);
+ let status;
if(batchRequestNum === 0)
{
this.__sent();
@@ -594,7 +598,7 @@ var ConnectionFlushBatch = Ice.Class(OutgoingAsyncBase, {
this.__completedEx(ex);
}
}
-});
+}
Ice.OutgoingAsync = OutgoingAsync;
Ice.ProxyFlushBatch = ProxyFlushBatch;
diff --git a/js/src/Ice/OutgoingConnectionFactory.js b/js/src/Ice/OutgoingConnectionFactory.js
index d0f8a74e5b8..d31c301fff9 100644
--- a/js/src/Ice/OutgoingConnectionFactory.js
+++ b/js/src/Ice/OutgoingConnectionFactory.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/ArrayUtil",
"../Ice/AsyncResultBase",
"../Ice/ConnectionI",
@@ -23,22 +22,21 @@ Ice.__M.require(module,
"../Ice/ACM"
]);
-var ArrayUtil = Ice.ArrayUtil;
-var AsyncResultBase = Ice.AsyncResultBase;
-var ConnectionI = Ice.ConnectionI;
-var ConnectionReaper = Ice.ConnectionReaper;
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var Promise = Ice.Promise;
-var EndpointSelectionType = Ice.EndpointSelectionType;
-var FactoryACMMonitor = Ice.FactoryACMMonitor;
-var Class = Ice.Class;
+const ArrayUtil = Ice.ArrayUtil;
+const AsyncResultBase = Ice.AsyncResultBase;
+const ConnectionI = Ice.ConnectionI;
+const ConnectionReaper = Ice.ConnectionReaper;
+const Debug = Ice.Debug;
+const HashMap = Ice.HashMap;
+const EndpointSelectionType = Ice.EndpointSelectionType;
+const FactoryACMMonitor = Ice.FactoryACMMonitor;
//
// Only for use by Instance.
//
-var OutgoingConnectionFactory = Class({
- __init__: function(communicator, instance)
+class OutgoingConnectionFactory
+{
+ constructor(communicator, instance)
{
this._communicator = communicator;
this._instance = instance;
@@ -51,75 +49,73 @@ var OutgoingConnectionFactory = Class({
this._pendingConnectCount = 0;
this._waitPromise = null;
- },
- destroy: function()
+ }
+
+ destroy()
{
if(this._destroyed)
{
return;
}
- this._connectionsByEndpoint.forEach(function(connection)
- {
- connection.destroy(ConnectionI.CommunicatorDestroyed);
- });
+ this._connectionsByEndpoint.forEach(connection => connection.destroy(ConnectionI.CommunicatorDestroyed));
this._destroyed = true;
this._communicator = null;
this.checkFinished();
- },
- waitUntilFinished: function()
+ }
+
+ waitUntilFinished()
{
- this._waitPromise = new Promise();
+ this._waitPromise = new Ice.Promise();
this.checkFinished();
return this._waitPromise;
- },
+ }
+
//
// Returns a promise, success callback receives (connection, compress)
//
- create: function(endpts, hasMore, selType)
+ create(endpts, hasMore, selType)
{
Debug.assert(endpts.length > 0);
//
// Apply the overrides.
//
- var endpoints = this.applyOverrides(endpts);
+ const endpoints = this.applyOverrides(endpts);
//
// Try to find a connection to one of the given endpoints.
//
try
{
- var compress = { value: false };
- var connection = this.findConnectionByEndpoint(endpoints, compress);
+ const compress = { value: false };
+ const connection = this.findConnectionByEndpoint(endpoints, compress);
if(connection !== null)
{
- return new Promise().succeed(connection, compress.value);
+ return Ice.Promise.resolve([connection, compress.value]);
}
}
catch(ex)
{
- return new Promise().fail(ex);
+ return Ice.Promise.reject(ex);
}
- var cb = new ConnectCallback(this, endpoints, hasMore, selType);
- return cb.start();
- },
- setRouterInfo: function(routerInfo)
+ return new ConnectCallback(this, endpoints, hasMore, selType).start();
+ }
+
+ setRouterInfo(routerInfo)
{
- var self = this;
- return Ice.Promise.try(
- function()
+ return Ice.Promise.try(() =>
{
- if(self._destroyed)
+ if(this._destroyed)
{
throw new Ice.CommunicatorDestroyedException();
}
return routerInfo.getClientEndpoints();
}
).then(
- function(endpoints)
+ endpoints =>
{
//
// Search for connections to the router's client proxy
@@ -127,12 +123,10 @@ var OutgoingConnectionFactory = Class({
// connections, so that callbacks from the router can be
// received over such connections.
//
- var adapter = routerInfo.getAdapter();
- var defaultsAndOverrides = self._instance.defaultsAndOverrides();
- for(var i = 0; i < endpoints.length; ++i)
+ const adapter = routerInfo.getAdapter();
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ endpoints.forEach(endpoint =>
{
- var endpoint = endpoints[i];
-
//
// Modify endpoints with overrides.
//
@@ -152,48 +146,49 @@ var OutgoingConnectionFactory = Class({
//
endpoint = endpoint.changeCompress(false);
- self._connectionsByEndpoint.forEach(function(connection)
+ this._connectionsByEndpoint.forEach(connection =>
{
if(connection.endpoint().equals(endpoint))
{
connection.setAdapter(adapter);
}
});
- }
- }
- );
- },
- removeAdapter: function(adapter)
+ });
+ });
+ }
+
+ removeAdapter(adapter)
{
if(this._destroyed)
{
return;
}
- this._connectionsByEndpoint.forEach(function(connection)
+ this._connectionsByEndpoint.forEach(connection =>
{
if(connection.getAdapter() === adapter)
{
connection.setAdapter(null);
}
});
- },
- flushAsyncBatchRequests: function()
+ }
+
+ flushAsyncBatchRequests()
{
- var promise = new AsyncResultBase(this._communicator, "flushBatchRequests", null, null, null);
+ const promise = new AsyncResultBase(this._communicator, "flushBatchRequests", null, null, null);
if(this._destroyed)
{
- promise.succeed();
+ promise.resolve();
return;
}
- Promise.all(
+ Ice.Promise.all(
this._connectionsByEndpoint.map(
- function(connection)
+ connection =>
{
if(connection.isActiveOrHolding())
{
- return connection.flushBatchRequests().exception(
- function(ex)
+ return connection.flushBatchRequests().catch(
+ ex =>
{
if(ex instanceof Ice.LocalException)
{
@@ -205,68 +200,49 @@ var OutgoingConnectionFactory = Class({
}
});
}
- })
- ).then(
- function()
- {
- promise.succeed(promise);
- },
- function(ex)
- {
- promise.fail(ex, promise);
- }
- );
+ })).then(promise.resolve, promise.reject);
return promise;
- },
- applyOverrides: function(endpts)
- {
- var defaultsAndOverrides = this._instance.defaultsAndOverrides();
- var endpoints = [];
- for(var i = 0; i < endpts.length; ++i)
- {
- var endpoint = endpts[i];
+ }
- //
- // Modify endpoints with overrides.
- //
- if(defaultsAndOverrides.overrideTimeout)
- {
- endpoints.push(endpoint.changeTimeout(defaultsAndOverrides.overrideTimeoutValue));
- }
- else
+ applyOverrides(endpts)
+ {
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ return endpts.map(endpoint =>
{
- endpoints.push(endpoint);
- }
- }
+ //
+ // Modify endpoints with overrides.
+ //
+ return defaultsAndOverrides.overrideTimeout ?
+ endpoint.changeTimeout(defaultsAndOverrides.overrideTimeoutValue) : endpoint;
+ });
+ }
- return endpoints;
- },
- findConnectionByEndpoint: function(endpoints, compress)
+ findConnectionByEndpoint(endpoints, compress)
{
if(this._destroyed)
{
throw new Ice.CommunicatorDestroyedException();
}
- var defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
Debug.assert(endpoints.length > 0);
- for(var i = 0; i < endpoints.length; ++i)
+ for(let i = 0; i < endpoints.length; ++i)
{
- var endpoint = endpoints[i];
+ const endpoint = endpoints[i];
if(this._pending.has(endpoint))
{
continue;
}
- var connectionList = this._connectionsByEndpoint.get(endpoint);
+ const connectionList = this._connectionsByEndpoint.get(endpoint);
if(connectionList === undefined)
{
continue;
}
- for(var j = 0; j < connectionList.length; ++j)
+ for(let j = 0; j < connectionList.length; ++j)
{
if(connectionList[j].isActiveOrHolding()) // Don't return destroyed or un-validated connections
{
@@ -284,8 +260,9 @@ var OutgoingConnectionFactory = Class({
}
return null;
- },
- incPendingConnectCount: function()
+ }
+
+ incPendingConnectCount()
{
//
// Keep track of the number of pending connects. The outgoing connection factory
@@ -300,8 +277,9 @@ var OutgoingConnectionFactory = Class({
throw new Ice.CommunicatorDestroyedException();
}
++this._pendingConnectCount;
- },
- decPendingConnectCount: function()
+ }
+
+ decPendingConnectCount()
{
--this._pendingConnectCount;
Debug.assert(this._pendingConnectCount >= 0);
@@ -309,8 +287,9 @@ var OutgoingConnectionFactory = Class({
{
this.checkFinished();
}
- },
- getConnection: function(endpoints, cb, compress)
+ }
+
+ getConnection(endpoints, cb, compress)
{
if(this._destroyed)
{
@@ -320,15 +299,14 @@ var OutgoingConnectionFactory = Class({
//
// Reap closed connections
//
- var cons = this._monitor.swapReapedConnections();
+ const cons = this._monitor.swapReapedConnections();
if(cons !== null)
{
- for(var i = 0; i < cons.length; ++i)
- {
- var c = cons[i];
- this._connectionsByEndpoint.removeConnection(c.endpoint(), c);
- this._connectionsByEndpoint.removeConnection(c.endpoint().changeCompress(true), c);
- }
+ cons.forEach(c =>
+ {
+ this._connectionsByEndpoint.removeConnection(c.endpoint(), c);
+ this._connectionsByEndpoint.removeConnection(c.endpoint().changeCompress(true), c);
+ });
}
//
@@ -344,7 +322,7 @@ var OutgoingConnectionFactory = Class({
//
// Search for a matching connection. If we find one, we're done.
//
- var connection = this.findConnectionByEndpoint(endpoints, compress);
+ const connection = this.findConnectionByEndpoint(endpoints, compress);
if(connection !== null)
{
return connection;
@@ -377,8 +355,9 @@ var OutgoingConnectionFactory = Class({
cb.nextEndpoint();
return null;
- },
- createConnection: function(transceiver, endpoint)
+ }
+
+ createConnection(transceiver, endpoint)
{
Debug.assert(this._pending.has(endpoint) && transceiver !== null);
@@ -387,7 +366,7 @@ var OutgoingConnectionFactory = Class({
// is necessary to support the interruption of the connection initialization and validation
// in case the communicator is destroyed.
//
- var connection = null;
+ let connection = null;
try
{
if(this._destroyed)
@@ -396,7 +375,7 @@ var OutgoingConnectionFactory = Class({
}
connection = new ConnectionI(this._communicator, this._instance, this._monitor, transceiver,
- endpoint.changeCompress(false), false, null);
+ endpoint.changeCompress(false), false, null);
}
catch(ex)
{
@@ -417,172 +396,136 @@ var OutgoingConnectionFactory = Class({
this._connectionsByEndpoint.set(connection.endpoint(), connection);
this._connectionsByEndpoint.set(connection.endpoint().changeCompress(true), connection);
return connection;
- },
- finishGetConnection: function(endpoints, endpoint, connection, cb)
+ }
+
+ finishGetConnection(endpoints, endpoint, connection, cb)
{
// cb is-a ConnectCallback
- var connectionCallbacks = [];
+ const connectionCallbacks = [];
if(cb !== null)
{
connectionCallbacks.push(cb);
}
- var i;
- var cc;
- var callbacks = [];
- for(i = 0; i < endpoints.length; ++i)
- {
- var endpt = endpoints[i];
- var cbs = this._pending.get(endpt);
- if(cbs !== undefined)
+ let callbacks = [];
+ endpoints.forEach(endpt =>
{
- this._pending.delete(endpt);
- for(var j = 0; j < cbs.length; ++j)
+ let cbs = this._pending.get(endpt);
+ if(cbs !== undefined)
{
- cc = cbs[j];
- if(cc.hasEndpoint(endpoint))
- {
- if(connectionCallbacks.indexOf(cc) === -1)
+ this._pending.delete(endpt);
+ cbs.forEach(cc =>
{
- connectionCallbacks.push(cc);
- }
- }
- else
- {
- if(callbacks.indexOf(cc) === -1)
- {
- callbacks.push(cc);
- }
- }
+ if(cc.hasEndpoint(endpoint))
+ {
+ if(connectionCallbacks.indexOf(cc) === -1)
+ {
+ connectionCallbacks.push(cc);
+ }
+ }
+ else
+ {
+ if(callbacks.indexOf(cc) === -1)
+ {
+ callbacks.push(cc);
+ }
+ }
+ });
}
- }
- }
+ });
- for(i = 0; i < connectionCallbacks.length; ++i)
- {
- cc = connectionCallbacks[i];
- cc.removeFromPending();
- var idx = callbacks.indexOf(cc);
- if(idx !== -1)
+ connectionCallbacks.forEach(cc =>
{
- callbacks.splice(idx, 1);
- }
- }
- for(i = 0; i < callbacks.length; ++i)
- {
- cc = callbacks[i];
- cc.removeFromPending();
- }
+ cc.removeFromPending();
+ let idx = callbacks.indexOf(cc);
+ if(idx !== -1)
+ {
+ callbacks.splice(idx, 1);
+ }
+ });
- var compress;
- var defaultsAndOverrides = this._instance.defaultsAndOverrides();
- if(defaultsAndOverrides.overrideCompress)
- {
- compress = defaultsAndOverrides.overrideCompressValue;
- }
- else
- {
- compress = endpoint.compress();
- }
+ callbacks.forEach(cc => cc.removeFromPending());
- for(i = 0; i < callbacks.length; ++i)
- {
- cc = callbacks[i];
- cc.getConnection();
- }
- for(i = 0; i < connectionCallbacks.length; ++i)
- {
- cc = connectionCallbacks[i];
- cc.setConnection(connection, compress);
- }
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ const compress = defaultsAndOverrides.overrideCompress ? defaultsAndOverrides.overrideCompressValue :
+ endpoint.compress();
+
+ callbacks.forEach(cc => cc.getConnection());
+ connectionCallbacks.forEach(cc => cc.setConnection(connection, compress));
this.checkFinished();
- },
- finishGetConnectionEx: function(endpoints, ex, cb)
+ }
+
+ finishGetConnectionEx(endpoints, ex, cb)
{
// cb is-a ConnectCallback
- var failedCallbacks = [];
+ const failedCallbacks = [];
if(cb !== null)
{
failedCallbacks.push(cb);
}
- var i;
- var cc;
- var callbacks = [];
- for(i = 0; i < endpoints.length; ++i)
- {
- var endpt = endpoints[i];
- var cbs = this._pending.get(endpt);
- if(cbs !== undefined)
+
+ const callbacks = [];
+ endpoints.forEach(endpt =>
{
- this._pending.delete(endpt);
- for(var j = 0; j < cbs.length; ++j)
+ const cbs = this._pending.get(endpt);
+ if(cbs !== undefined)
{
- cc = cbs[j];
- if(cc.removeEndpoints(endpoints))
- {
- if(failedCallbacks.indexOf(cc) === -1)
- {
- failedCallbacks.push(cc);
- }
- }
- else
- {
- if(callbacks.indexOf(cc) === -1)
+ this._pending.delete(endpt);
+ cbs.forEach(cc =>
{
- callbacks.push(cc);
- }
- }
+ if(cc.removeEndpoints(endpoints))
+ {
+ if(failedCallbacks.indexOf(cc) === -1)
+ {
+ failedCallbacks.push(cc);
+ }
+ }
+ else
+ {
+ if(callbacks.indexOf(cc) === -1)
+ {
+ callbacks.push(cc);
+ }
+ }
+ });
}
- }
- }
+ });
- for(i = 0; i < callbacks.length; ++i)
- {
- cc = callbacks[i];
- Debug.assert(failedCallbacks.indexOf(cc) === -1);
- cc.removeFromPending();
- }
+ callbacks.forEach(cc =>
+ {
+ Debug.assert(failedCallbacks.indexOf(cc) === -1);
+ cc.removeFromPending();
+ });
this.checkFinished();
+ callbacks.forEach(cc => cc.getConnection());
+ failedCallbacks.forEach(cc => cc.setException(ex));
+ }
- for(i = 0; i < callbacks.length; ++i)
- {
- cc = callbacks[i];
- cc.getConnection();
- }
- for(i = 0; i < failedCallbacks.length; ++i)
- {
- cc = failedCallbacks[i];
- cc.setException(ex);
- }
- },
- addToPending: function(cb, endpoints)
+ addToPending(cb, endpoints)
{
// cb is-a ConnectCallback
//
// Add the callback to each pending list.
//
- var found = false;
- var p;
- var i;
+ let found = false;
if(cb !== null)
{
- for(i = 0; i < endpoints.length; ++i)
- {
- p = endpoints[i];
- var cbs = this._pending.get(p);
- if(cbs !== undefined)
+ endpoints.forEach(p =>
{
- found = true;
- if(cbs.indexOf(cb) === -1)
+ const cbs = this._pending.get(p);
+ if(cbs !== undefined)
{
- cbs.push(cb); // Add the callback to each pending endpoint.
+ found = true;
+ if(cbs.indexOf(cb) === -1)
+ {
+ cbs.push(cb); // Add the callback to each pending endpoint.
+ }
}
- }
- }
+ });
}
if(found)
@@ -595,41 +538,40 @@ var OutgoingConnectionFactory = Class({
// responsible for its establishment. We add empty pending lists,
// other callbacks to the same endpoints will be queued.
//
- for(i = 0; i < endpoints.length; ++i)
- {
- p = endpoints[i];
- if(!this._pending.has(p))
+ endpoints.forEach(p =>
{
- this._pending.set(p, []);
- }
- }
+ if(!this._pending.has(p))
+ {
+ this._pending.set(p, []);
+ }
+ });
return false;
- },
- removeFromPending: function(cb, endpoints)
+ }
+
+ removeFromPending(cb, endpoints)
{
// cb is-a ConnectCallback
-
- for(var i = 0; i < endpoints.length; ++i)
- {
- var p = endpoints[i];
- var cbs = this._pending.get(p);
- if(cbs !== undefined)
+ endpoints.forEach(p =>
{
- var idx = cbs.indexOf(cb);
- if(idx !== -1)
+ const cbs = this._pending.get(p);
+ if(cbs !== undefined)
{
- cbs.splice(idx, 1);
+ const idx = cbs.indexOf(cb);
+ if(idx !== -1)
+ {
+ cbs.splice(idx, 1);
+ }
}
- }
- }
- },
- handleConnectionException: function(ex, hasMore)
+ });
+ }
+
+ handleConnectionException(ex, hasMore)
{
- var traceLevels = this._instance.traceLevels();
+ const traceLevels = this._instance.traceLevels();
if(traceLevels.retry >= 2)
{
- var s = [];
+ const s = [];
s.push("connection to endpoint failed");
if(ex instanceof Ice.CommunicatorDestroyedException)
{
@@ -649,13 +591,14 @@ var OutgoingConnectionFactory = Class({
s.push(ex.toString());
this._instance.initializationData().logger.trace(traceLevels.retryCat, s.join(""));
}
- },
- handleException: function(ex, hasMore)
+ }
+
+ handleException(ex, hasMore)
{
- var traceLevels = this._instance.traceLevels();
+ const traceLevels = this._instance.traceLevels();
if(traceLevels.retry >= 2)
{
- var s = [];
+ const s = [];
s.push("couldn't resolve endpoint host");
if(ex instanceof Ice.CommunicatorDestroyedException)
{
@@ -675,8 +618,9 @@ var OutgoingConnectionFactory = Class({
s.push(ex.toString());
this._instance.initializationData().logger.trace(traceLevels.retryCat, s.join(""));
}
- },
- checkFinished: function()
+ }
+
+ checkFinished()
{
//
// Can't continue until the factory is destroyed and there are no pending connections.
@@ -686,50 +630,40 @@ var OutgoingConnectionFactory = Class({
return;
}
- var self = this;
- Promise.all(
- self._connectionsByEndpoint.map(
- function(connection)
- {
- return connection.waitUntilFinished().exception(function(ex)
- {
- Debug.assert(false);
- });
- }
- )
+ Ice.Promise.all(
+ this._connectionsByEndpoint.map(
+ connection => connection.waitUntilFinished().catch(ex => Debug.assert(false)))
).then(
- function()
+ () =>
{
- var cons = self._monitor.swapReapedConnections();
+ const cons = this._monitor.swapReapedConnections();
if(cons !== null)
{
- var arr = [];
- for(var e = self._connectionsByEndpoint.entries; e !== null; e = e.next)
+ const arr = [];
+ for(let connections of this._connectionsByEndpoint.values())
{
- var connectionList = e.value;
- for(var i = 0; i < connectionList.length; ++i)
- {
- if(arr.indexOf(connectionList[i]) === -1)
+ connections.forEach(connection =>
{
- arr.push(connectionList[i]);
- }
- }
+ if(arr.indexOf(connection) === -1)
+ {
+ arr.push(connection);
+ }
+ });
}
Debug.assert(cons.length === arr.length);
- self._connectionsByEndpoint.clear();
+ this._connectionsByEndpoint.clear();
}
else
{
- Debug.assert(self._connectionsByEndpoint.size === 0);
+ Debug.assert(this._connectionsByEndpoint.size === 0);
}
- Debug.assert(self._waitPromise !== null);
- self._waitPromise.succeed();
- self._monitor.destroy();
- }
- );
+ Debug.assert(this._waitPromise !== null);
+ this._waitPromise.resolve();
+ this._monitor.destroy();
+ });
}
-});
+}
Ice.OutgoingConnectionFactory = OutgoingConnectionFactory;
module.exports.Ice = Ice;
@@ -737,130 +671,135 @@ module.exports.Ice = Ice;
//
// Value is a Vector<Ice.ConnectionI>
//
-var ConnectionListMap = Class(HashMap, {
- __init__: function(h)
+class ConnectionListMap extends HashMap
+{
+ constructor(h)
{
- HashMap.call(this, h || HashMap.compareEquals);
- },
- set: function(key, value)
+ super(h || HashMap.compareEquals);
+ }
+
+ set(key, value)
{
- var list = this.get(key);
+ let list = this.get(key);
if(list === undefined)
{
list = [];
- HashMap.prototype.set.call(this, key, list);
+ super.set(key, list);
}
Debug.assert(value instanceof ConnectionI);
list.push(value);
return undefined;
- },
- removeConnection: function(key, conn)
+ }
+
+ removeConnection(key, conn)
{
- var list = this.get(key);
+ const list = this.get(key);
Debug.assert(list !== null);
- var idx = list.indexOf(conn);
+ const idx = list.indexOf(conn);
Debug.assert(idx !== -1);
list.splice(idx, 1);
if(list.length === 0)
{
this.delete(key);
}
- },
- map: function(fn)
+ }
+
+ map(fn)
{
- var arr = [];
- this.forEach(function(c) { arr.push(fn(c)); });
+ const arr = [];
+ this.forEach(c => arr.push(fn(c)));
return arr;
- },
- forEach: function(fn)
+ }
+
+ forEach(fn)
{
- for(var e = this._head; e !== null; e = e._next)
+ for(let connections of this.values())
{
- for(var i = 0; i < e.value.length; ++i)
- {
- fn(e.value[i]);
- }
+ connections.forEach(fn);
}
}
-});
+}
-var ConnectCallback = Class({
- __init__: function(f, endpoints, more, selType)
+class ConnectCallback
+{
+ constructor(f, endpoints, more, selType)
{
this._factory = f;
this._endpoints = endpoints;
this._hasMore = more;
this._selType = selType;
- this._promise = new Promise();
+ this._promise = new Ice.Promise();
this._index = 0;
this._current = null;
- },
+ }
+
//
// Methods from ConnectionI_StartCallback
//
- connectionStartCompleted: function(connection)
+ connectionStartCompleted(connection)
{
connection.activate();
this._factory.finishGetConnection(this._endpoints, this._current, connection, this);
- },
- connectionStartFailed: function(connection, ex)
+ }
+
+ connectionStartFailed(connection, ex)
{
Debug.assert(this._current !== null);
if(this.connectionStartFailedImpl(ex))
{
this.nextEndpoint();
}
- },
- setConnection: function(connection, compress)
+ }
+
+ setConnection(connection, compress)
{
//
// Callback from the factory: the connection to one of the callback
// connectors has been established.
//
- this._promise.succeed(connection, compress);
+ this._promise.resolve([connection, compress]);
this._factory.decPendingConnectCount(); // Must be called last.
- },
- setException: function(ex)
+ }
+
+ setException(ex)
{
//
// Callback from the factory: connection establishment failed.
//
- this._promise.fail(ex);
+ this._promise.reject(ex);
this._factory.decPendingConnectCount(); // Must be called last.
- },
- hasEndpoint: function(endpt)
+ }
+
+ hasEndpoint(endpoint)
{
- return this.findEndpoint(endpt) !== -1;
- },
- findEndpoint: function(endpt)
+ return this.findEndpoint(endpoint) !== -1;
+ }
+
+ findEndpoint(endpoint)
{
- for(var index = 0; index < this._endpoints.length; ++index)
- {
- if(endpt.equals(this._endpoints[index]))
- {
- return index;
- }
- }
- return -1;
- },
- removeEndpoints: function(endpoints)
+ return this._endpoints.findIndex(value => endpoint.equals(value));
+ }
+
+ removeEndpoints(endpoints)
{
- for(var i = 0; i < endpoints.length; ++i)
- {
- var idx = this.findEndpoint(endpoints[i]);
- if(idx !== -1)
+ endpoints.forEach(endpoint =>
{
- this._endpoints.splice(idx, 1);
- }
- }
+ let idx = this.findEndpoint(endpoint);
+ if(idx !== -1)
+ {
+ this._endpoints.splice(idx, 1);
+ }
+ });
this._index = 0;
return this._endpoints.length === 0;
- },
- removeFromPending: function()
+ }
+
+ removeFromPending()
{
this._factory.removeFromPending(this, this._endpoints);
- },
- start: function()
+ }
+
+ start()
{
try
{
@@ -873,22 +812,23 @@ var ConnectCallback = Class({
}
catch(ex)
{
- this._promise.fail(ex);
+ this._promise.reject(ex);
return;
}
this.getConnection();
return this._promise;
- },
- getConnection: function()
+ }
+
+ getConnection()
{
try
{
//
// Ask the factory to get a connection.
//
- var compress = { value: false };
- var connection = this._factory.getConnection(this._endpoints, this, compress);
+ const compress = { value: false };
+ const connection = this._factory.getConnection(this._endpoints, this, compress);
if(connection === null)
{
//
@@ -900,20 +840,21 @@ var ConnectCallback = Class({
return;
}
- this._promise.succeed(connection, compress.value);
+ this._promise.resolve([connection, compress.value]);
this._factory.decPendingConnectCount(); // Must be called last.
}
catch(ex)
{
- this._promise.fail(ex);
+ this._promise.reject(ex);
this._factory.decPendingConnectCount(); // Must be called last.
}
- },
- nextEndpoint: function()
+ }
+
+ nextEndpoint()
{
while(true)
{
- var traceLevels = this._factory._instance.traceLevels();
+ const traceLevels = this._factory._instance.traceLevels();
try
{
Debug.assert(this._index < this._endpoints.length);
@@ -921,7 +862,7 @@ var ConnectCallback = Class({
if(traceLevels.network >= 2)
{
- var s = [];
+ let s = [];
s.push("trying to establish ");
s.push(this._current.protocol());
s.push(" connection to ");
@@ -929,23 +870,22 @@ var ConnectCallback = Class({
this._factory._instance.initializationData().logger.trace(traceLevels.networkCat, s.join(""));
}
- var connection = this._factory.createConnection(this._current.connect(), this._current);
- var self = this;
+ const connection = this._factory.createConnection(this._current.connect(), this._current);
connection.start().then(
- function()
+ () =>
{
- self.connectionStartCompleted(connection);
+ this.connectionStartCompleted(connection);
},
- function(ex)
+ ex =>
{
- self.connectionStartFailed(connection, ex);
+ this.connectionStartFailed(connection, ex);
});
}
catch(ex)
{
if(traceLevels.network >= 2)
{
- var s = [];
+ let s = [];
s.push("failed to establish ");
s.push(this._current.protocol());
s.push(" connection to ");
@@ -962,8 +902,9 @@ var ConnectCallback = Class({
}
break;
}
- },
- connectionStartFailedImpl: function(ex)
+ }
+
+ connectionStartFailedImpl(ex)
{
if(ex instanceof Ice.LocalException)
{
@@ -987,4 +928,4 @@ var ConnectCallback = Class({
}
return false;
}
-});
+}
diff --git a/js/src/Ice/ProcessLogger.js b/js/src/Ice/ProcessLogger.js
index 70882bfaa4c..4d7f65febcc 100644
--- a/js/src/Ice/ProcessLogger.js
+++ b/js/src/Ice/ProcessLogger.js
@@ -8,10 +8,10 @@
//
// **********************************************************************
-var Ice = require("../Ice/Logger").Ice;
-var Logger = Ice.Logger;
+const Ice = require("../Ice/Logger").Ice;
+const Logger = Ice.Logger;
-var processLogger = null;
+let processLogger = null;
Ice.getProcessLogger = function()
{
diff --git a/js/src/Ice/Promise.js b/js/src/Ice/Promise.js
index ec61f0dcdef..464bbad5470 100644
--- a/js/src/Ice/Promise.js
+++ b/js/src/Ice/Promise.js
@@ -7,291 +7,58 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module,
- [
- "../Ice/Class",
- "../Ice/TimerUtil"
- ]);
+const Ice = require("../Ice/Timer").Ice;
+const Timer = Ice.Timer;
-var Timer = Ice.Timer;
-
-//
-// Promise State
-//
-var State = {Pending: 0, Success: 1, Failed: 2};
-
-var resolveImp = function(self, listener)
+class P extends Promise
{
- var callback = self.__state === State.Success ? listener.onResponse : listener.onException;
- try
+ constructor(cb)
{
- if(typeof callback !== "function")
- {
- listener.promise.setState(self.__state, self._args);
- }
- else
- {
- var result = callback.apply(null, self._args);
-
- //
- // Callback can return a new promise.
- //
- if(result && typeof result.then == "function")
+ let res, rej;
+ super((resolve, reject) =>
{
- result.then(
- function()
- {
- var args = arguments;
- listener.promise.succeed.apply(listener.promise, args);
- },
- function()
- {
- var args = arguments;
- listener.promise.fail.apply(listener.promise, args);
- });
- }
- else
- {
- listener.promise.succeed(result);
- }
- }
- }
- catch(e)
- {
- listener.promise.fail.call(listener.promise, e);
- }
-};
+ res = resolve;
+ rej = reject;
-var Promise = Ice.Class({
- __init__: function()
- {
- this.__state = State.Pending;
- this.__listeners = [];
- },
- then: function(onResponse, onException)
- {
- var promise = new Promise();
- var self = this;
- //
- // Use setImmediate so the listeners are not resolved until the call stack is empty.
- //
- Timer.setImmediate(
- function()
- {
- self.__listeners.push(
- {
- promise:promise,
- onResponse:onResponse,
- onException:onException
- });
- self.resolve();
- });
- return promise;
- },
- exception: function(onException)
- {
- return this.then(null, onException);
- },
- finally: function(cb)
- {
- var p = new Promise();
- var self = this;
-
- var finallyHandler = function(method)
- {
- return function()
- {
- var args = arguments;
- try
- {
- var result = cb.apply(null, args);
- if(result && typeof result.then == "function")
- {
- var handler = function(){ method.apply(p, args); };
- result.then(handler).exception(handler);
- }
- else
- {
- method.apply(p, args);
- }
- }
- catch(e)
+ if(cb !== undefined)
{
- method.apply(p, args);
+ cb(resolve, reject);
}
- };
- };
-
- Timer.setImmediate(
- function(){
- self.then(finallyHandler(p.succeed), finallyHandler(p.fail));
});
- return p;
- },
- delay: function(ms)
- {
- var p = new Promise();
-
- var self = this;
-
- var delayHandler = function(promise, method)
- {
- return function()
- {
- var args = arguments;
- Timer.setTimeout(
- function()
- {
- method.apply(promise, args);
- },
- ms);
- };
- };
-
- Timer.setImmediate(function()
- {
- self.then(delayHandler(p, p.succeed), delayHandler(p, p.fail));
- });
- return p;
- },
- resolve: function()
- {
- if(this.__state === State.Pending)
- {
- return;
- }
- var obj;
- while((obj = this.__listeners.pop()))
- {
- //
- // We use a separate function here to capture the listeners
- // in the loop.
- //
- resolveImp(this, obj);
- }
- },
- setState: function(state, args)
- {
- if(this.__state === State.Pending && state !== State.Pending)
- {
- this.__state = state;
- this._args = args;
- //
- // Use setImmediate so the listeners are not resolved until the call stack is empty.
- //
- var self = this;
- Timer.setImmediate(function(){ self.resolve(); });
- }
- },
- succeed: function()
- {
- var args = arguments;
- this.setState(State.Success, args);
- return this;
- },
- fail: function()
- {
- var args = arguments;
- this.setState(State.Failed, args);
- return this;
- },
- succeeded: function()
- {
- return this.__state === State.Success;
- },
- failed: function()
- {
- return this.__state === State.Failed;
- },
- completed: function()
- {
- return this.__state !== State.Pending;
+ this.resolve = res;
+ this.reject = rej;
}
-});
-
-//
-// Create a new promise object that is fulfilled when all the promise arguments
-// are fulfilled or is rejected when one of the promises is rejected.
-//
-Promise.all = function()
-{
- // If only one argument is provided, check if the argument is an array
- if(arguments.length === 1 && arguments[0] instanceof Array)
+
+ finally(cb)
{
- return Promise.all.apply(this, arguments[0]);
+ return this.then(
+ (value) => P.resolve(cb()).then(() => value),
+ (reason) => P.resolve(cb()).then(() => { throw reason; }));
}
- var promise = new Promise();
- var promises = Array.prototype.slice.call(arguments);
- var results = new Array(arguments.length);
-
- var pending = promises.length;
- if(pending === 0)
+ delay(ms)
{
- promise.succeed.apply(promise, results);
+ return this.then(
+ value => new P((resolve, reject) => Timer.setTimeout(() => resolve(value), ms)),
+ reason => new P((resolve, reject) => Timer.setTiemout(() => reject(reason), ms)));
}
- for(var i = 0; i < promises.length; ++i)
+
+ static get [Symbol.species]()
{
- //
- // Create an anonymous function to capture the loop index
- //
-
- /*jshint -W083 */
- (function(j)
- {
- if(promises[j] && typeof promises[j].then == "function")
- {
- promises[j].then(
- function()
- {
- results[j] = arguments;
- pending--;
- if(pending === 0)
- {
- promise.succeed.apply(promise, results);
- }
- },
- function()
- {
- promise.fail.apply(promise, arguments);
- });
- }
- else
- {
- results[j] = promises[j];
- pending--;
- if(pending === 0)
- {
- promise.succeed.apply(promise, results);
- }
- }
- }(i));
- /*jshint +W083 */
+ return P;
}
- return promise;
-};
-
-Promise.try = function(onResponse)
-{
- return new Promise().succeed().then(onResponse);
-};
-Promise.delay = function(ms)
-{
- if(arguments.length > 1)
+ static delay(ms, value)
{
- var p = new Promise();
- var args = Array.prototype.slice.call(arguments);
- ms = args.pop();
- return p.succeed.apply(p, args).delay(ms);
+ return new P(resolve => Timer.setTimeout(() => resolve(value), ms));
}
- else
+
+ static try(cb)
{
- return new Promise().succeed().delay(ms);
+ return P.resolve().then(cb);
}
-};
+}
-Ice.Promise = Promise;
+Ice.Promise = P;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Properties.js b/js/src/Ice/Properties.js
index 66545ee8c56..79d877f5f43 100644
--- a/js/src/Ice/Properties.js
+++ b/js/src/Ice/Properties.js
@@ -8,13 +8,10 @@
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/StringUtil",
- "../Ice/HashMap",
- "../Ice/Promise",
"../Ice/PropertyNames",
"../Ice/Debug",
"../Ice/ProcessLogger",
@@ -22,24 +19,23 @@ Ice.__M.require(module,
"../Ice/LocalException"
]);
-var StringUtil = Ice.StringUtil;
-var HashMap = Ice.HashMap;
-var Promise = Ice.Promise;
-var PropertyNames = Ice.PropertyNames;
-var Debug = Ice.Debug;
-var ProcessLogger = Ice.ProcessLogger;
-var getProcessLogger = Ice.getProcessLogger;
-var InitializationException = Ice.InitializationException;
-
-var ParseStateKey = 0;
-var ParseStateValue = 1;
+const StringUtil = Ice.StringUtil;
+const PropertyNames = Ice.PropertyNames;
+const Debug = Ice.Debug;
+const ProcessLogger = Ice.ProcessLogger;
+const getProcessLogger = Ice.getProcessLogger;
+const InitializationException = Ice.InitializationException;
+
+const ParseStateKey = 0;
+const ParseStateValue = 1;
//
// Ice.Properties
//
-var Properties = Ice.Class({
- __init__: function(args, defaults)
+class Properties
+{
+ constructor(args, defaults)
{
- this._properties = new HashMap();
+ this._properties = new Map();
if(defaults !== undefined && defaults !== null)
{
@@ -47,30 +43,32 @@ var Properties = Ice.Class({
// NOTE: we can't just do a shallow copy of the map as the map values
// would otherwise be shared between the two PropertiesI object.
//
- //_properties = new HashMap(pi._properties);
- for(var e = defaults._properties.entries; e !== null; e = e.next)
+ //_properties = new Map(pi._properties);
+ for(let [key, property] of defaults._properties)
{
- this._properties.set(e.key, { 'value': e.value.value, 'used': false });
+ this._properties.set(key, { 'value': property.value, 'used': false });
}
}
if(args !== undefined && args !== null)
{
- var v = this.parseIceCommandLineOptions(args);
+ let v = this.parseIceCommandLineOptions(args);
args.length = 0;
- for(var i = 0; i < v.length; ++i)
+ for(let i = 0; i < v.length; ++i)
{
args.push(v[i]);
}
}
- },
- getProperty: function(key)
+ }
+
+ getProperty(key)
{
return this.getPropertyWithDefault(key, "");
- },
- getPropertyWithDefault: function(key, value)
+ }
+
+ getPropertyWithDefault(key, value)
{
- var pv = this._properties.get(key);
+ const pv = this._properties.get(key);
if(pv !== undefined)
{
pv.used = true;
@@ -80,14 +78,16 @@ var Properties = Ice.Class({
{
return value;
}
- },
- getPropertyAsInt: function(key)
+ }
+
+ getPropertyAsInt(key)
{
return this.getPropertyAsIntWithDefault(key, 0);
- },
- getPropertyAsIntWithDefault: function(key, value)
+ }
+
+ getPropertyAsIntWithDefault(key, value)
{
- var pv = this._properties.get(key);
+ const pv = this._properties.get(key);
if(pv !== undefined)
{
pv.used = true;
@@ -97,24 +97,26 @@ var Properties = Ice.Class({
{
return value;
}
- },
- getPropertyAsList: function(key)
+ }
+
+ getPropertyAsList(key)
{
return this.getPropertyAsListWithDefault(key, 0);
- },
- getPropertyAsListWithDefault: function(key, value)
+ }
+
+ getPropertyAsListWithDefault(key, value)
{
if(value === undefined || value === null)
{
value = [];
}
- var pv = this._properties.get(key);
+ const pv = this._properties.get(key);
if(pv !== undefined)
{
pv.used = true;
- var result = StringUtil.splitString(pv.value, ", \t\r\n");
+ let result = StringUtil.splitString(pv.value, ", \t\r\n");
if(result === null)
{
getProcessLogger().warning("mismatched quotes in property " + key + "'s value, returning default value");
@@ -130,26 +132,28 @@ var Properties = Ice.Class({
{
return value;
}
- },
- getPropertiesForPrefix: function(prefix)
+ }
+
+ getPropertiesForPrefix(prefix = "")
{
- var result = new HashMap();
- for(var e = this._properties.entries; e !== null; e = e.next)
- {
- if(prefix === undefined || prefix === null || e.key.indexOf(prefix) === 0)
+ const result = new Map();
+ this._properties.forEach((property, key) =>
{
- e.value.used = true;
- result.set(e.key, e.value.value);
- }
- }
+ if(key.indexOf(prefix) === 0)
+ {
+ property.used = true;
+ result.set(key, property.value);
+ }
+ });
return result;
- },
- setProperty: function(key, value)
+ }
+
+ setProperty(key = "", value = "")
{
//
// Trim whitespace
//
- if(key !== null && key !== undefined)
+ if(key !== null)
{
key = key.trim();
}
@@ -157,38 +161,37 @@ var Properties = Ice.Class({
//
// Check if the property is legal.
//
- var logger = getProcessLogger();
- if(key === null || key === undefined || key.length === 0)
+ const logger = getProcessLogger();
+ if(key === null || key.length === 0)
{
throw new InitializationException("Attempt to set property with empty key");
}
- var dotPos = key.indexOf(".");
+ let dotPos = key.indexOf(".");
if(dotPos !== -1)
{
- var prefix = key.substr(0, dotPos);
- for(var i = 0; i < PropertyNames.validProps.length; ++i)
+ const prefix = key.substr(0, dotPos);
+ for(let i = 0; i < PropertyNames.validProps.length; ++i)
{
- var pattern = PropertyNames.validProps[i][0].pattern;
+ let pattern = PropertyNames.validProps[i][0].pattern;
dotPos = pattern.indexOf(".");
//
// Each top level prefix describes a non-empty namespace. Having a string without a
// prefix followed by a dot is an error.
//
Debug.assert(dotPos != -1);
- var propPrefix = pattern.substring(0, dotPos - 1);
- if(propPrefix != prefix)
+ if(pattern.substring(0, dotPos - 1) != prefix)
{
continue;
}
- var found = false;
- var mismatchCase = false;
- var otherKey;
- for(var j = 0; j < PropertyNames.validProps[i][j].length && !found; ++j)
+ let found = false;
+ let mismatchCase = false;
+ let otherKey;
+ for(let j = 0; j < PropertyNames.validProps[i][j].length && !found; ++j)
{
pattern = PropertyNames.validProps[i][j].pattern();
- var pComp = new RegExp(pattern);
+ let pComp = new RegExp(pattern);
found = pComp.test(key);
if(found && PropertyNames.validProps[i][j].deprecated)
@@ -233,9 +236,9 @@ var Properties = Ice.Class({
//
// Set or clear the property.
//
- if(value !== undefined && value !== null && value.length > 0)
+ if(value !== null && value.length > 0)
{
- var pv = this._properties.get(key);
+ let pv = this._properties.get(key);
if(pv !== undefined)
{
pv.value = value;
@@ -249,17 +252,19 @@ var Properties = Ice.Class({
{
this._properties.delete(key);
}
- },
- getCommandLineOptions: function()
+ }
+
+ getCommandLineOptions()
{
- var result = [];
- for(var e = this._properties.entries; e !== null; e = e.next)
- {
- result.push("--" + e.key + "=" + e.pv.value);
- }
+ const result = [];
+ this._properties.forEach((property, key) =>
+ {
+ result.push("--" + key + "=" + property.value);
+ });
return result;
- },
- parseCommandLineOptions: function(pfx, options)
+ }
+
+ parseCommandLineOptions(pfx, options)
{
if(pfx.length > 0 && pfx.charAt(pfx.length - 1) != ".")
{
@@ -267,11 +272,9 @@ var Properties = Ice.Class({
}
pfx = "--" + pfx;
- var result = [];
+ const result = [];
- var self = this;
- options.forEach(
- function(opt)
+ options.forEach(opt =>
{
if(opt.indexOf(pfx) === 0)
{
@@ -280,7 +283,7 @@ var Properties = Ice.Class({
opt += "=1";
}
- self.parseLine(opt.substring(2));
+ this.parseLine(opt.substring(2));
}
else
{
@@ -288,41 +291,37 @@ var Properties = Ice.Class({
}
});
return result;
- },
- parseIceCommandLineOptions: function(options)
+ }
+
+ parseIceCommandLineOptions(options)
{
- var args = options.slice();
- for(var i = 0; i < PropertyNames.clPropNames.length; ++i)
+ let args = options.slice();
+ for(let i = 0; i < PropertyNames.clPropNames.length; ++i)
{
args = this.parseCommandLineOptions(PropertyNames.clPropNames[i], args);
}
return args;
- },
- parse: function(data)
+ }
+
+ parse(data)
{
- var lines = data.match(/[^\r\n]+/g);
-
- var line;
-
- while((line = lines.shift()))
- {
- this.parseLine(line);
- }
- },
- parseLine: function(line)
+ data.match(/[^\r\n]+/g).forEach(line => this.parseLine(line));
+ }
+
+ parseLine(line)
{
- var key = "";
- var value = "";
+ let key = "";
+ let value = "";
- var state = ParseStateKey;
+ let state = ParseStateKey;
- var whitespace = "";
- var escapedspace = "";
- var finished = false;
+ let whitespace = "";
+ let escapedspace = "";
+ let finished = false;
- for(var i = 0; i < line.length; ++i)
+ for(let i = 0; i < line.length; ++i)
{
- var c = line.charAt(i);
+ let c = line.charAt(i);
switch(state)
{
case ParseStateKey:
@@ -465,7 +464,7 @@ var Properties = Ice.Class({
value += escapedspace;
if((state === ParseStateKey && key.length !== 0) ||
- (state == ParseStateValue && key.length === 0))
+ (state == ParseStateValue && key.length === 0))
{
getProcessLogger().warning("invalid config file entry: \"" + line + "\"");
return;
@@ -476,29 +475,31 @@ var Properties = Ice.Class({
}
this.setProperty(key, value);
- },
- clone: function()
+ }
+
+ clone()
{
return new Properties(null, this);
- },
- getUnusedProperties: function()
+ }
+
+ getUnusedProperties()
{
- var unused = [];
- for(var e = this._properties.entries; e !== null; e = e.next)
- {
- if(!e.pv.used)
+ const unused = [];
+ this._properties.forEach((property, key) =>
{
- unused.push(e.key);
- }
- }
+ if(!property.used)
+ {
+ unused.push(key);
+ }
+ });
return unused;
}
-});
-
-Properties.createProperties = function(args, defaults)
-{
- return new Properties(args, defaults);
-};
+
+ static createProperties(args, defaults)
+ {
+ return new Properties(args, defaults);
+ }
+}
Ice.Properties = Properties;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Property.js b/js/src/Ice/Property.js
index 23671086900..10d26f90c30 100644
--- a/js/src/Ice/Property.js
+++ b/js/src/Ice/Property.js
@@ -7,25 +7,31 @@
//
// **********************************************************************
-var Property = function Property(pattern, deprecated, deprecatedBy)
-{
- this._pattern = pattern;
- this._deprecated = deprecated;
- this._deprecatedBy = deprecatedBy;
-};
+const Ice = require("../Ice/ModuleRegistry").Ice;
-Object.defineProperty(Property.prototype, "pattern",{
- get: function() { return this._pattern; }
-});
+Ice.Property = class
+{
+ constructor(pattern, deprecated, deprecatedBy)
+ {
+ this._pattern = pattern;
+ this._deprecated = deprecated;
+ this._deprecatedBy = deprecatedBy;
+ }
+
+ get pattern()
+ {
+ return this._pattern;
+ }
-Object.defineProperty(Property.prototype, "deprecated",{
- get: function() { return this._deprecated; }
-});
+ get deprecated()
+ {
+ return this._deprecated;
+ }
-Object.defineProperty(Property.prototype, "deprecatedBy",{
- get: function() { return this._deprecatedBy; }
-});
+ get deprecatedBy()
+ {
+ return this._deprecatedBy;
+ }
+};
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.Property = Property;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/PropertyNames.js b/js/src/Ice/PropertyNames.js
index 32844b5c68f..fa40b320b5a 100644
--- a/js/src/Ice/PropertyNames.js
+++ b/js/src/Ice/PropertyNames.js
@@ -6,13 +6,13 @@
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
-// Generated by makeprops.py from file ..\config\PropertyNames.xml, Fri Jul 15 14:02:34 2016
+// Generated by makeprops.py from file ./config/PropertyNames.xml, Thu Aug 18 20:28:56 2016
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
-var Ice = require("../Ice/Property").Ice;
-var PropertyNames = {};
-var Property = Ice.Property;
+const Ice = require("../Ice/Property").Ice;
+const PropertyNames = {};
+const Property = Ice.Property;
/* jshint -W044*/
PropertyNames.IceProps =
diff --git a/js/src/Ice/Protocol.js b/js/src/Ice/Protocol.js
index 8f1d35dd0d3..2efd0ac3559 100644
--- a/js/src/Ice/Protocol.js
+++ b/js/src/Ice/Protocol.js
@@ -7,7 +7,7 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
"../Ice/StringUtil",
@@ -16,9 +16,9 @@ Ice.__M.require(module,
"../Ice/Buffer"
]);
-var StringUtil = Ice.StringUtil;
+const StringUtil = Ice.StringUtil;
-var Protocol = {};
+const Protocol = {};
Ice.Encoding_1_0 = new Ice.EncodingVersion(1, 0);
Ice.Encoding_1_1 = new Ice.EncodingVersion(1, 1);
@@ -267,56 +267,48 @@ module.exports.Ice = Ice;
function stringToMajor(str)
{
- var pos = str.indexOf('.');
+ const pos = str.indexOf('.');
if(pos === -1)
{
throw new Ice.VersionParseException("malformed version value `" + str + "'");
}
-
- var majStr = str.substring(0, pos);
- var majVersion;
+
try
{
- majVersion = StringUtil.toInt(majStr);
+ const majVersion = StringUtil.toInt(str.substring(0, pos));
+ if(majVersion < 1 || majVersion > 255)
+ {
+ throw new Ice.VersionParseException("range error in version `" + str + "'");
+ }
+ return majVersion;
}
catch(ex)
{
throw new Ice.VersionParseException("invalid version value `" + str + "'");
}
-
- if(majVersion < 1 || majVersion > 255)
- {
- throw new Ice.VersionParseException("range error in version `" + str + "'");
- }
-
- return majVersion;
}
function stringToMinor(str)
{
- var pos = str.indexOf('.');
+ const pos = str.indexOf('.');
if(pos === -1)
{
throw new Ice.VersionParseException("malformed version value `" + str + "'");
}
-
- var minStr = str.substring(pos + 1);
- var minVersion;
+
try
{
- minVersion = StringUtil.toInt(minStr);
+ const minVersion = StringUtil.toInt(str.substring(pos + 1));
+ if(minVersion < 0 || minVersion > 255)
+ {
+ throw new Ice.VersionParseException("range error in version `" + str + "'");
+ }
+ return minVersion;
}
catch(ex)
{
throw new Ice.VersionParseException("invalid version value `" + str + "'");
}
-
- if(minVersion < 0 || minVersion > 255)
- {
- throw new Ice.VersionParseException("range error in version `" + str + "'");
- }
-
- return minVersion;
}
function majorMinorToString(major, minor)
diff --git a/js/src/Ice/ProtocolInstance.js b/js/src/Ice/ProtocolInstance.js
index 5cf964e8e23..6d42e03c165 100644
--- a/js/src/Ice/ProtocolInstance.js
+++ b/js/src/Ice/ProtocolInstance.js
@@ -7,8 +7,7 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
//
// NOTE: the protocol instance class is a bit different from other
@@ -23,8 +22,9 @@ Ice.__M.require(module, ["../Ice/Class"]);
// endpoint and suppress the secure member of the protocol instance
// class bellow.
//
-var ProtocolInstance = Ice.Class({
- __init__: function(instance, type, protocol, secure)
+class ProtocolInstance
+{
+ constructor(instance, type, protocol, secure)
{
this._instance = instance;
this._traceLevel = instance.traceLevels().network;
@@ -34,58 +34,68 @@ var ProtocolInstance = Ice.Class({
this._type = type;
this._protocol = protocol;
this._secure = secure;
- },
- traceLevel: function()
+ }
+
+ traceLevel()
{
return this._traceLevel;
- },
- traceCategory: function()
+ }
+
+ traceCategory()
{
return this._traceCategory;
- },
- logger: function()
+ }
+
+ logger()
{
return this._logger;
- },
- protocol: function()
+ }
+
+ protocol()
{
return this._protocol;
- },
- type: function()
+ }
+
+ type()
{
return this._type;
- },
- secure: function()
+ }
+
+ secure()
{
return this._secure;
- },
- properties: function()
+ }
+
+ properties()
{
return this._properties;
- },
- defaultHost: function()
+ }
+
+ defaultHost()
{
return this._instance.defaultsAndOverrides().defaultHost;
- },
- defaultSourceAddress: function()
+ }
+
+ defaultSourceAddress()
{
return this._instance.defaultsAndOverrides().defaultSourceAddress;
- },
- defaultEncoding: function()
+ }
+
+ defaultEncoding()
{
return this._instance.defaultsAndOverrides().defaultEncoding;
- },
- defaultTimeout: function()
+ }
+
+ defaultTimeout()
{
return this._instance.defaultsAndOverrides().defaultTimeout;
- },
- messageSizeMax: function()
+ }
+
+ messageSizeMax()
{
return this._instance.messageSizeMax();
}
-});
+}
Ice.ProtocolInstance = ProtocolInstance;
module.exports.Ice = Ice;
-
-
diff --git a/js/src/Ice/ProxyFactory.js b/js/src/Ice/ProxyFactory.js
index b0bc6e25aac..6cb6e921ea8 100644
--- a/js/src/Ice/ProxyFactory.js
+++ b/js/src/Ice/ProxyFactory.js
@@ -7,12 +7,10 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
- "../Ice/HashMap",
"../Ice/ObjectPrx",
"../Ice/StringUtil",
"../Ice/Identity",
@@ -20,29 +18,29 @@ Ice.__M.require(module,
"../Ice/LocalException"
]);
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var ObjectPrx = Ice.ObjectPrx;
-var StringUtil = Ice.StringUtil;
-var Identity = Ice.Identity;
+const Debug = Ice.Debug;
+const ObjectPrx = Ice.ObjectPrx;
+const StringUtil = Ice.StringUtil;
+const Identity = Ice.Identity;
//
// Only for use by Instance.
//
-var ProxyFactory = Ice.Class({
- __init__: function(instance)
+class ProxyFactory
+{
+ constructor(instance)
{
this._instance = instance;
- var arr = this._instance.initializationData().properties.getPropertyAsList("Ice.RetryIntervals");
+ const arr = this._instance.initializationData().properties.getPropertyAsList("Ice.RetryIntervals");
if(arr.length > 0)
{
this._retryIntervals = [];
- for(var i = 0; i < arr.length; i++)
+ for(let i = 0; i < arr.length; i++)
{
- var v;
+ let v;
try
{
@@ -68,53 +66,42 @@ var ProxyFactory = Ice.Class({
{
this._retryIntervals = [ 0 ];
}
- },
- stringToProxy: function(str)
+ }
+
+ stringToProxy(str)
{
- var ref = this._instance.referenceFactory().createFromString(str, null);
- return this.referenceToProxy(ref);
- },
- proxyToString: function(proxy)
+ return this.referenceToProxy(this._instance.referenceFactory().createFromString(str, null));
+ }
+
+ proxyToString(proxy)
{
- if(proxy !== null)
- {
- return proxy.__reference().toString();
- }
- else
- {
- return "";
- }
- },
- propertyToProxy: function(prefix)
+ return proxy === null ? "" : proxy.__reference().toString();
+ }
+
+ propertyToProxy(prefix)
{
- var proxy = this._instance.initializationData().properties.getProperty(prefix);
- var ref = this._instance.referenceFactory().createFromString(proxy, prefix);
+ const proxy = this._instance.initializationData().properties.getProperty(prefix);
+ const ref = this._instance.referenceFactory().createFromString(proxy, prefix);
return this.referenceToProxy(ref);
- },
- proxyToProperty: function(proxy, prefix)
+ }
+
+ proxyToProperty(proxy, prefix)
{
- if(proxy !== null)
- {
- return proxy.__reference().toProperty(prefix);
- }
- else
- {
- return new HashMap();
- }
- },
- streamToProxy: function(s, type)
+ return proxy === null ? new Map() : proxy.__reference().toProperty(prefix);
+ }
+
+ streamToProxy(s, type)
{
- var ident = new Identity();
+ const ident = new Identity();
ident.__read(s);
+ return this.referenceToProxy(this._instance.referenceFactory().createFromStream(ident, s), type);
+ }
- var ref = this._instance.referenceFactory().createFromStream(ident, s);
- return this.referenceToProxy(ref, type);
- },
- referenceToProxy: function(ref, type)
+ referenceToProxy(ref, type)
{
if(ref !== null)
{
- var proxy = type ? new type() : new ObjectPrx();
+ const proxy = type ? new type() : new ObjectPrx();
proxy.__setup(ref);
return proxy;
}
@@ -122,11 +109,12 @@ var ProxyFactory = Ice.Class({
{
return null;
}
- },
- checkRetryAfterException: function(ex, ref, sleepInterval, cnt)
+ }
+
+ checkRetryAfterException(ex, ref, sleepInterval, cnt)
{
- var traceLevels = this._instance.traceLevels();
- var logger = this._instance.initializationData().logger;
+ const traceLevels = this._instance.traceLevels();
+ const logger = this._instance.initializationData().logger;
//
// We don't retry batch requests because the exception might have caused
@@ -140,9 +128,7 @@ var ProxyFactory = Ice.Class({
if(ex instanceof Ice.ObjectNotExistException)
{
- var one = ex;
-
- if(ref.getRouterInfo() !== null && one.operation === "ice_add_proxy")
+ if(ref.getRouterInfo() !== null && ex.operation === "ice_add_proxy")
{
//
// If we have a router, an ObjectNotExistException with an
@@ -176,7 +162,7 @@ var ProxyFactory = Ice.Class({
if(ref.isWellKnown())
{
- var li = ref.getLocatorInfo();
+ const li = ref.getLocatorInfo();
if(li !== null)
{
li.clearCache(ref);
@@ -246,7 +232,7 @@ var ProxyFactory = Ice.Class({
++cnt;
Debug.assert(cnt > 0);
- var interval;
+ let interval;
if(cnt === (this._retryIntervals.length + 1) && ex instanceof Ice.CloseConnectionException)
{
//
@@ -271,7 +257,7 @@ var ProxyFactory = Ice.Class({
if(traceLevels.retry >= 1)
{
- var msg = "retrying operation call";
+ let msg = "retrying operation call";
if(interval > 0)
{
msg += " in " + interval + "ms";
@@ -285,7 +271,7 @@ var ProxyFactory = Ice.Class({
return cnt;
}
-});
+}
Ice.ProxyFactory = ProxyFactory;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/Reference.js b/js/src/Ice/Reference.js
index 1234387099d..0bda489e771 100644
--- a/js/src/Ice/Reference.js
+++ b/js/src/Ice/Reference.js
@@ -7,14 +7,12 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/ArrayUtil",
"../Ice/BatchRequestQueue",
"../Ice/Debug",
- "../Ice/HashMap",
"../Ice/HashUtil",
"../Ice/OpaqueEndpointI",
"../Ice/Promise",
@@ -30,29 +28,27 @@ Ice.__M.require(module,
"../Ice/Version",
"../Ice/PropertyNames",
"../Ice/ConnectionRequestHandler",
+ "../Ice/MapUtil"
]);
-var ArrayUtil = Ice.ArrayUtil;
-var Debug = Ice.Debug;
-var BatchRequestQueue = Ice.BatchRequestQueue;
-var HashMap = Ice.HashMap;
-var HashUtil = Ice.HashUtil;
-var OpaqueEndpointI = Ice.OpaqueEndpointI;
-var Promise = Ice.Promise;
-var Protocol = Ice.Protocol;
-var RefMode = Ice.ReferenceMode;
-var StringUtil = Ice.StringUtil;
-var StringSeqHelper = Ice.StringSeqHelper;
-var EndpointSelectionType = Ice.EndpointSelectionType;
-var Identity = Ice.Identity;
-var RouterPrx = Ice.RouterPrx;
-var LocatorPrx = Ice.LocatorPrx;
-var PropertyNames = Ice.PropertyNames;
-var ConnectionRequestHandler = Ice.ConnectionRequestHandler;
-
-var Class = Ice.Class;
-
-var suffixes =
+const ArrayUtil = Ice.ArrayUtil;
+const Debug = Ice.Debug;
+const BatchRequestQueue = Ice.BatchRequestQueue;
+const HashUtil = Ice.HashUtil;
+const OpaqueEndpointI = Ice.OpaqueEndpointI;
+const Protocol = Ice.Protocol;
+const RefMode = Ice.ReferenceMode;
+const StringUtil = Ice.StringUtil;
+const StringSeqHelper = Ice.StringSeqHelper;
+const EndpointSelectionType = Ice.EndpointSelectionType;
+const Identity = Ice.Identity;
+const RouterPrx = Ice.RouterPrx;
+const LocatorPrx = Ice.LocatorPrx;
+const PropertyNames = Ice.PropertyNames;
+const ConnectionRequestHandler = Ice.ConnectionRequestHandler;
+const MapUtil = Ice.MapUtil;
+
+const suffixes =
[
"EndpointSelection",
"ConnectionCached",
@@ -68,15 +64,17 @@ var suffixes =
//
// Only for use by Instance
//
-var ReferenceFactory = Class({
- __init__: function(instance, communicator)
+class ReferenceFactory
+{
+ constructor(instance, communicator)
{
this._instance = instance;
this._communicator = communicator;
this._defaultRouter = null;
this._defaultLocator = null;
- },
- create: function(ident, facet, tmpl, endpoints)
+ }
+
+ create(ident, facet, tmpl, endpoints)
{
if(ident.name.length === 0 && ident.category.length === 0)
{
@@ -84,9 +82,10 @@ var ReferenceFactory = Class({
}
return this.createImpl(ident, facet, tmpl.getMode(), tmpl.getSecure(), tmpl.getProtocol(), tmpl.getEncoding(),
- endpoints, null, null);
- },
- createWithAdapterId: function(ident, facet, tmpl, adapterId)
+ endpoints, null, null);
+ }
+
+ createWithAdapterId(ident, facet, tmpl, adapterId)
{
if(ident.name.length === 0 && ident.category.length === 0)
{
@@ -94,9 +93,10 @@ var ReferenceFactory = Class({
}
return this.createImpl(ident, facet, tmpl.getMode(), tmpl.getSecure(), tmpl.getProtocol(), tmpl.getEncoding(),
- null, adapterId, null);
- },
- createFixed: function(ident, fixedConnection)
+ null, adapterId, null);
+ }
+
+ createFixed(ident, fixedConnection)
{
if(ident.name.length === 0 && ident.category.length === 0)
{
@@ -106,7 +106,7 @@ var ReferenceFactory = Class({
//
// Create new reference
//
- var ref = new FixedReference(
+ return new FixedReference(
this._instance,
this._communicator,
ident,
@@ -115,30 +115,29 @@ var ReferenceFactory = Class({
fixedConnection.endpoint().secure(),
this._instance.defaultsAndOverrides().defaultEncoding,
fixedConnection);
- return ref;
- },
- copy: function(r)
+ }
+
+ copy(r)
{
- var ident = r.getIdentity();
+ const ident = r.getIdentity();
if(ident.name.length === 0 && ident.category.length === 0)
{
return null;
}
return r.clone();
- },
- createFromString: function(s, propertyPrefix)
+ }
+
+ createFromString(s, propertyPrefix)
{
if(s === undefined || s === null || s.length === 0)
{
return null;
}
- var delim = " \t\n\r";
-
- var beg;
- var end = 0;
+ const delim = " \t\n\r";
- beg = StringUtil.findFirstNotOf(s, delim, end);
+ let end = 0;
+ let beg = StringUtil.findFirstNotOf(s, delim, end);
if(beg == -1)
{
throw new Ice.ProxyParseException("no non-whitespace characters found in `" + s + "'");
@@ -148,7 +147,7 @@ var ReferenceFactory = Class({
// Extract the identity, which may be enclosed in single
// or double quotation marks.
//
- var idstr = null;
+ let idstr = null;
end = StringUtil.checkQuote(s, beg);
if(end === -1)
{
@@ -178,7 +177,7 @@ var ReferenceFactory = Class({
//
// Parsing the identity may raise IdentityParseException.
//
- var ident = Ice.stringToIdentity(idstr);
+ const ident = Ice.stringToIdentity(idstr);
if(ident.name.length === 0)
{
@@ -206,12 +205,12 @@ var ReferenceFactory = Class({
}
}
- var facet = "";
- var mode = RefMode.ModeTwoway;
- var secure = false;
- var encoding = this._instance.defaultsAndOverrides().defaultEncoding;
- var protocol = Ice.Protocol_1_0;
- var adapter = "";
+ let facet = "";
+ let mode = RefMode.ModeTwoway;
+ let secure = false;
+ let encoding = this._instance.defaultsAndOverrides().defaultEncoding;
+ let protocol = Ice.Protocol_1_0;
+ let adapter = "";
while(true)
{
@@ -237,7 +236,7 @@ var ReferenceFactory = Class({
break;
}
- var option = s.substring(beg, end);
+ const option = s.substring(beg, end);
if(option.length != 2 || option.charAt(0) != '-')
{
throw new Ice.ProxyParseException("expected a proxy option but found `" + option + "' in `" + s + "'");
@@ -248,11 +247,11 @@ var ReferenceFactory = Class({
// argument may be enclosed in single or double
// quotation marks.
//
- var argument = null;
- var argumentBeg = StringUtil.findFirstNotOf(s, delim, end);
+ let argument = null;
+ let argumentBeg = StringUtil.findFirstNotOf(s, delim, end);
if(argumentBeg != -1)
{
- var ch = s.charAt(argumentBeg);
+ let ch = s.charAt(argumentBeg);
if(ch != "@" && ch != ":" && ch != "-")
{
beg = argumentBeg;
@@ -260,7 +259,7 @@ var ReferenceFactory = Class({
if(end == -1)
{
throw new Ice.ProxyParseException("mismatched quotes around value for " + option +
- " option in `" + s + "'");
+ " option in `" + s + "'");
}
else if(end === 0)
{
@@ -310,7 +309,7 @@ var ReferenceFactory = Class({
if(argument !== null)
{
throw new Ice.ProxyParseException("unexpected argument `" + argument +
- "' provided for -t option in `" + s + "'");
+ "' provided for -t option in `" + s + "'");
}
mode = RefMode.ModeTwoway;
break;
@@ -321,7 +320,7 @@ var ReferenceFactory = Class({
if(argument !== null)
{
throw new Ice.ProxyParseException("unexpected argument `" + argument +
- "' provided for -o option in `" + s + "'");
+ "' provided for -o option in `" + s + "'");
}
mode = RefMode.ModeOneway;
break;
@@ -332,7 +331,7 @@ var ReferenceFactory = Class({
if(argument !== null)
{
throw new Ice.ProxyParseException("unexpected argument `" + argument +
- "' provided for -O option in `" + s + "'");
+ "' provided for -O option in `" + s + "'");
}
mode = RefMode.ModeBatchOneway;
break;
@@ -343,7 +342,7 @@ var ReferenceFactory = Class({
if(argument !== null)
{
throw new Ice.ProxyParseException("unexpected argument `" + argument +
- "' provided for -d option in `" + s + "'");
+ "' provided for -d option in `" + s + "'");
}
mode = RefMode.ModeDatagram;
break;
@@ -354,7 +353,7 @@ var ReferenceFactory = Class({
if(argument !== null)
{
throw new Ice.ProxyParseException("unexpected argument `" + argument +
- "' provided for -D option in `" + s + "'");
+ "' provided for -D option in `" + s + "'");
}
mode = RefMode.ModeBatchDatagram;
break;
@@ -365,7 +364,7 @@ var ReferenceFactory = Class({
if(argument !== null)
{
throw new Ice.ProxyParseException("unexpected argument `" + argument +
- "' provided for -s option in `" + s + "'");
+ "' provided for -s option in `" + s + "'");
}
secure = true;
break;
@@ -385,7 +384,7 @@ var ReferenceFactory = Class({
catch(e) // VersionParseException
{
throw new Ice.ProxyParseException("invalid encoding version `" + argument + "' in `" + s +
- "':\n" + e.str);
+ "':\n" + e.str);
}
break;
}
@@ -404,7 +403,7 @@ var ReferenceFactory = Class({
catch(e) // VersionParseException
{
throw new Ice.ProxyParseException("invalid protocol version `" + argument + "' in `" + s +
- "':\n" + e.str);
+ "':\n" + e.str);
}
break;
}
@@ -421,11 +420,11 @@ var ReferenceFactory = Class({
return this.createImpl(ident, facet, mode, secure, protocol, encoding, null, null, propertyPrefix);
}
- var endpoints = [];
+ let endpoints = [];
if(s.charAt(beg) == ':')
{
- var unknownEndpoints = [];
+ let unknownEndpoints = [];
end = beg;
while(end < s.length && s.charAt(end) == ':')
@@ -443,8 +442,8 @@ var ReferenceFactory = Class({
}
else
{
- var quoted = false;
- var quote = beg;
+ let quoted = false;
+ let quote = beg;
while(true)
{
quote = s.indexOf("\"", quote);
@@ -475,8 +474,8 @@ var ReferenceFactory = Class({
}
}
- var es = s.substring(beg, end);
- var endp = this._instance.endpointFactoryManager().create(es, false);
+ let es = s.substring(beg, end);
+ let endp = this._instance.endpointFactoryManager().create(es, false);
if(endp !== null)
{
endpoints.push(endp);
@@ -492,16 +491,16 @@ var ReferenceFactory = Class({
throw new Ice.EndpointParseException("invalid endpoint `" + unknownEndpoints[0] + "' in `" + s + "'");
}
else if(unknownEndpoints.length !== 0 &&
- this._instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
+ this._instance.initializationData().properties.getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
{
- var msg = [];
+ const msg = [];
msg.push("Proxy contains unknown endpoints:");
- for(var i = 0; i < unknownEndpoints.length; ++i)
- {
- msg.push(" `");
- msg.push(unknownEndpoints[i]);
- msg.push("'");
- }
+ unknownEndpoints.forEach(unknownEndpoint =>
+ {
+ msg.push(" `");
+ msg.push(unknownEndpoint);
+ msg.push("'");
+ });
this._instance.initializationData().logger.warning(msg.join(""));
}
@@ -515,7 +514,7 @@ var ReferenceFactory = Class({
throw new Ice.ProxyParseException("missing adapter id in `" + s + "'");
}
- var adapterstr = null;
+ let adapterstr = null;
end = StringUtil.checkQuote(s, beg);
if(end === -1)
{
@@ -559,8 +558,9 @@ var ReferenceFactory = Class({
}
throw new Ice.ProxyParseException("malformed proxy `" + s + "'");
- },
- createFromStream: function(ident, s)
+ }
+
+ createFromStream(ident, s)
{
//
// Don't read the identity here. Operations calling this
@@ -575,8 +575,8 @@ var ReferenceFactory = Class({
//
// For compatibility with the old FacetPath.
//
- var facetPath = StringSeqHelper.read(s); // String[]
- var facet;
+ const facetPath = StringSeqHelper.read(s); // String[]
+ let facet;
if(facetPath.length > 0)
{
if(facetPath.length > 1)
@@ -590,16 +590,16 @@ var ReferenceFactory = Class({
facet = "";
}
- var mode = s.readByte();
+ const mode = s.readByte();
if(mode < 0 || mode > RefMode.ModeLast)
{
throw new Ice.ProxyUnmarshalException();
}
- var secure = s.readBool();
+ const secure = s.readBool();
- var protocol = null;
- var encoding = null;
+ let protocol = null;
+ let encoding = null;
if(!s.getEncoding().equals(Ice.Encoding_1_0))
{
protocol = new Ice.ProtocolVersion();
@@ -613,14 +613,14 @@ var ReferenceFactory = Class({
encoding = Ice.Encoding_1_0;
}
- var endpoints = null; // EndpointI[]
- var adapterId = null;
+ let endpoints = null; // EndpointI[]
+ let adapterId = null;
- var sz = s.readSize();
+ const sz = s.readSize();
if(sz > 0)
{
endpoints = [];
- for(var i = 0; i < sz; i++)
+ for(let i = 0; i < sz; i++)
{
endpoints[i] = this._instance.endpointFactoryManager().read(s);
}
@@ -631,46 +631,51 @@ var ReferenceFactory = Class({
}
return this.createImpl(ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, null);
- },
- setDefaultRouter: function(defaultRouter)
+ }
+
+ setDefaultRouter(defaultRouter)
{
if(this._defaultRouter === null ? defaultRouter === null : this._defaultRouter.equals(defaultRouter))
{
return this;
}
- var factory = new ReferenceFactory(this._instance, this._communicator);
+ const factory = new ReferenceFactory(this._instance, this._communicator);
factory._defaultLocator = this._defaultLocator;
factory._defaultRouter = defaultRouter;
return factory;
- },
- getDefaultRouter: function()
+ }
+
+ getDefaultRouter()
{
return this._defaultRouter;
- },
- setDefaultLocator: function(defaultLocator)
+ }
+
+ setDefaultLocator(defaultLocator)
{
if(this._defaultLocator === null ? defaultLocator === null : this._defaultLocator.equals(defaultLocator))
{
return this;
}
- var factory = new ReferenceFactory(this._instance, this._communicator);
+ const factory = new ReferenceFactory(this._instance, this._communicator);
factory._defaultRouter = this._defaultRouter;
factory._defaultLocator = defaultLocator;
return factory;
- },
- getDefaultLocator: function()
+ }
+
+ getDefaultLocator()
{
return this._defaultLocator;
- },
- checkForUnknownProperties: function(prefix)
+ }
+
+ checkForUnknownProperties(prefix)
{
- var unknownProps = [], i, length;
+ const unknownProps = [];
//
// Do not warn about unknown properties for Ice prefixes (Ice, Glacier2, etc.)
//
- for(i = 0; i < PropertyNames.clPropNames.length; ++i)
+ for(let i = 0; i < PropertyNames.clPropNames.length; ++i)
{
if(prefix.indexOf(PropertyNames.clPropNames[i] + ".") === 0)
{
@@ -678,47 +683,34 @@ var ReferenceFactory = Class({
}
}
- var props = this._instance.initializationData().properties.getPropertiesForPrefix(prefix + ".");
- for(var e = props.entries; e !== null; e = e.next)
+ let properties = this._instance.initializationData().properties.getPropertiesForPrefix(prefix + ".");
+ for(let key of properties.keys())
{
- var valid = false;
- for(i = 0, length = suffixes.length; i < length; ++i)
- {
- if(e.key === prefix + "." + suffixes[i])
- {
- valid = true;
- break;
- }
- }
-
- if(!valid)
+ if(!suffixes.some(suffix => key === (prefix + "." + suffix)))
{
- unknownProps.push(e.key);
+ unknownProps.push(key);
}
}
if(unknownProps.length > 0)
{
- var message = [];
+ let message = [];
message.push("found unknown properties for proxy '");
message.push(prefix);
message.push("':");
- for(i = 0, length = unknownProps.length; i < length; ++i)
- {
- message.push("\n ");
- message.push(unknownProps[i]);
- }
+ unknownProps.forEach(unknownProp => message.push("\n ", unknownProp));
this._instance.initializationData().logger.warning(message.join(""));
}
- },
- createImpl: function(ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, propertyPrefix)
+ }
+
+ createImpl(ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, propertyPrefix)
{
- var defaultsAndOverrides = this._instance.defaultsAndOverrides();
+ const defaultsAndOverrides = this._instance.defaultsAndOverrides();
//
// Default local proxy options.
//
- var locatorInfo = null;
+ let locatorInfo = null;
if(this._defaultLocator !== null)
{
if(!this._defaultLocator.__reference().getEncoding().equals(encoding))
@@ -731,19 +723,19 @@ var ReferenceFactory = Class({
locatorInfo = this._instance.locatorManager().find(this._defaultLocator);
}
}
- var routerInfo = this._instance.routerManager().find(this._defaultRouter);
- var cacheConnection = true;
- var preferSecure = defaultsAndOverrides.defaultPreferSecure;
- var endpointSelection = defaultsAndOverrides.defaultEndpointSelection;
- var locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout;
- var invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout;
+ let routerInfo = this._instance.routerManager().find(this._defaultRouter);
+ let cacheConnection = true;
+ let preferSecure = defaultsAndOverrides.defaultPreferSecure;
+ let endpointSelection = defaultsAndOverrides.defaultEndpointSelection;
+ let locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout;
+ let invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout;
//
// Override the defaults with the proxy properties if a property prefix is defined.
//
if(propertyPrefix !== null && propertyPrefix.length > 0)
{
- var properties = this._instance.initializationData().properties;
+ const properties = this._instance.initializationData().properties;
//
// Warn about unknown properties.
@@ -753,10 +745,8 @@ var ReferenceFactory = Class({
this.checkForUnknownProperties(propertyPrefix);
}
- var property;
-
- property = propertyPrefix + ".Locator";
- var locator = LocatorPrx.uncheckedCast(this._communicator.propertyToProxy(property));
+ let property = propertyPrefix + ".Locator";
+ const locator = LocatorPrx.uncheckedCast(this._communicator.propertyToProxy(property));
if(locator !== null)
{
if(!locator.__reference().getEncoding().equals(encoding))
@@ -770,15 +760,15 @@ var ReferenceFactory = Class({
}
property = propertyPrefix + ".Router";
- var router = RouterPrx.uncheckedCast(this._communicator.propertyToProxy(property));
+ const router = RouterPrx.uncheckedCast(this._communicator.propertyToProxy(property));
if(router !== null)
{
- var match = ".Router";
+ const match = ".Router";
if(propertyPrefix.lastIndexOf(match) == propertyPrefix.length - match.length)
{
- var s = "`" + property + "=" + properties.getProperty(property) +
- "': cannot set a router on a router; setting ignored";
- this._instance.initializationData().logger.warning(s);
+ this._instance.initializationData().logger.warning(
+ "`" + property + "=" + properties.getProperty(property) +
+ "': cannot set a router on a router; setting ignored");
}
else
{
@@ -795,7 +785,7 @@ var ReferenceFactory = Class({
property = propertyPrefix + ".EndpointSelection";
if(properties.getProperty(property).length > 0)
{
- var type = properties.getProperty(property);
+ const type = properties.getProperty(property);
if(type == "Random")
{
endpointSelection = EndpointSelectionType.Random;
@@ -807,12 +797,12 @@ var ReferenceFactory = Class({
else
{
throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type +
- "'; expected `Random' or `Ordered'");
+ "'; expected `Random' or `Ordered'");
}
}
property = propertyPrefix + ".LocatorCacheTimeout";
- var value = properties.getProperty(property);
+ let value = properties.getProperty(property);
if(value.length !== 0)
{
locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout);
@@ -861,12 +851,13 @@ var ReferenceFactory = Class({
locatorCacheTimeout,
invocationTimeout);
}
-});
+}
Ice.ReferenceFactory = ReferenceFactory;
-var Reference = Class({
- __init__: function(instance, communicator, identity, facet, mode, secure, protocol, encoding, invocationTimeout)
+class Reference
+{
+ constructor(instance, communicator, identity, facet, mode, secure, protocol, encoding, invocationTimeout)
{
//
// Validate string arguments.
@@ -888,271 +879,309 @@ var Reference = Class({
this._hashInitialized = false;
this._overrideCompress = false;
this._compress = false; // Only used if _overrideCompress == true
- },
- getMode: function()
+ }
+
+ getMode()
{
return this._mode;
- },
- getSecure: function()
+ }
+
+ getSecure()
{
return this._secure;
- },
- getProtocol: function()
+ }
+
+ getProtocol()
{
return this._protocol;
- },
- getEncoding: function()
+ }
+
+ getEncoding()
{
return this._encoding;
- },
- getIdentity: function()
+ }
+
+ getIdentity()
{
return this._identity;
- },
- getFacet: function()
+ }
+
+ getFacet()
{
return this._facet;
- },
- getInstance: function()
+ }
+
+ getInstance()
{
return this._instance;
- },
- getContext: function()
+ }
+
+ getContext()
{
- return this._context; // HashMap
- },
- getInvocationTimeout: function()
+ return this._context; // Map
+ }
+
+ getInvocationTimeout()
{
return this._invocationTimeout;
- },
- getCommunicator: function()
+ }
+
+ getCommunicator()
{
return this._communicator;
- },
- getEndpoints: function()
+ }
+
+ getEndpoints()
{
// Abstract
Debug.assert(false);
return null;
- },
- getAdapterId: function()
+ }
+
+ getAdapterId()
{
// Abstract
Debug.assert(false);
return "";
- },
- getRouterInfo: function()
+ }
+
+ getRouterInfo()
{
// Abstract
Debug.assert(false);
return null;
- },
- getLocatorInfo: function()
+ }
+
+ getLocatorInfo()
{
// Abstract
Debug.assert(false);
return null;
- },
- getCacheConnection: function()
+ }
+
+ getCacheConnection()
{
// Abstract
Debug.assert(false);
return false;
- },
- getPreferSecure: function()
+ }
+
+ getPreferSecure()
{
// Abstract
Debug.assert(false);
return false;
- },
- getEndpointSelection: function()
+ }
+
+ getEndpointSelection()
{
// Abstract
Debug.assert(false);
return null;
- },
- getLocatorCacheTimeout: function()
+ }
+
+ getLocatorCacheTimeout()
{
// Abstract
Debug.assert(false);
return 0;
- },
- getConnectionId: function()
+ }
+
+ getConnectionId()
{
// Abstract
Debug.assert(false);
return "";
- },
+ }
+
//
// The change* methods (here and in derived classes) create
// a new reference based on the existing one, with the
// corresponding value changed.
//
- changeContext: function(newContext)
+ changeContext(newContext)
{
if(newContext === undefined || newContext === null)
{
newContext = Reference._emptyContext;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
if(newContext.size === 0)
{
r._context = Reference._emptyContext;
}
else
{
- r._context = new HashMap(newContext);
+ r._context = new Map(newContext);
}
return r;
- },
- changeMode: function(newMode)
+ }
+
+ changeMode(newMode)
{
if(newMode === this._mode)
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._mode = newMode;
return r;
- },
- changeSecure: function(newSecure)
+ }
+
+ changeSecure(newSecure)
{
if(newSecure === this._secure)
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._secure = newSecure;
return r;
- },
- changeIdentity: function(newIdentity)
+ }
+
+ changeIdentity(newIdentity)
{
if(newIdentity.equals(this._identity))
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._identity = new Identity(newIdentity.name, newIdentity.category);
return r;
- },
- changeFacet: function(newFacet)
+ }
+
+ changeFacet(newFacet)
{
if(newFacet === this._facet)
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._facet = newFacet;
return r;
- },
- changeInvocationTimeout: function(newInvocationTimeout)
+ }
+
+ changeInvocationTimeout(newInvocationTimeout)
{
if(newInvocationTimeout === this._invocationTimeout)
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._invocationTimeout = newInvocationTimeout;
return r;
- },
- changeEncoding: function(newEncoding)
+ }
+
+ changeEncoding(newEncoding)
{
if(newEncoding.equals(this._encoding))
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._encoding = newEncoding;
return r;
- },
- changeCompress: function(newCompress)
+ }
+
+ changeCompress(newCompress)
{
if(this._overrideCompress && this._compress === newCompress)
{
return this;
}
- var r = this._instance.referenceFactory().copy(this);
+ const r = this._instance.referenceFactory().copy(this);
r._compress = newCompress;
r._overrideCompress = true;
return r;
- },
- changeAdapterId: function(newAdapterId)
+ }
+
+ changeAdapterId(newAdapterId)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeEndpoints: function(newEndpoints)
+ }
+
+ changeEndpoints(newEndpoints)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeLocator: function(newLocator)
+ }
+
+ changeLocator(newLocator)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeRouter: function(newRouter)
+ }
+
+ changeRouter(newRouter)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeCacheConnection: function(newCache)
+ }
+
+ changeCacheConnection(newCache)
{
// Abstract
Debug.assert(false);
return null;
- },
- changePreferSecure: function(newPreferSecure)
+ }
+
+ changePreferSecure(newPreferSecure)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeEndpointSelection: function(newType)
+ }
+
+ changeEndpointSelection(newType)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeLocatorCacheTimeout: function(newTimeout)
+ }
+
+ changeLocatorCacheTimeout(newTimeout)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeTimeout: function(newTimeout)
+ }
+
+ changeTimeout(newTimeout)
{
// Abstract
Debug.assert(false);
return null;
- },
- changeConnectionId: function(connectionId)
+ }
+
+ changeConnectionId(connectionId)
{
// Abstract
Debug.assert(false);
return null;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
if(this._hashInitialized)
{
return this._hashValue;
}
- var h = 5381;
+ let h = 5381;
h = HashUtil.addNumber(h, this._mode);
h = HashUtil.addBoolean(h, this._secure);
h = HashUtil.addHashable(h, this._identity);
if(this._context !== null && this._context !== undefined)
{
- for(var e = this._context.entries; e !== null; e = e.next)
+ for(let [key, value] of this._context)
{
- h = HashUtil.addString(h, e.key);
- h = HashUtil.addString(h, e.value);
+ h = HashUtil.addString(h, key);
+ h = HashUtil.addString(h, value);
}
}
h = HashUtil.addString(h, this._facet);
@@ -1169,26 +1198,29 @@ var Reference = Class({
this._hashInitialized = true;
return this._hashValue;
- },
+ }
+
//
// Utility methods
//
- isIndirect: function()
+ isIndirect()
{
// Abstract
Debug.assert(false);
return false;
- },
- isWellKnown: function()
+ }
+
+ isWellKnown()
{
// Abstract
Debug.assert(false);
return false;
- },
+ }
+
//
// Marshal the reference.
//
- streamWrite: function(s)
+ streamWrite(s)
{
//
// Don't write the identity here. Operations calling streamWrite
@@ -1219,11 +1251,12 @@ var Reference = Class({
}
// Derived class writes the remainder of the reference.
- },
+ }
+
//
// Convert the reference to its string form.
//
- toString: function()
+ toString()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
@@ -1232,14 +1265,14 @@ var Reference = Class({
// these features. Please review for all features that depend on the
// format of proxyToString() before changing this and related code.
//
- var s = [];
+ const s = [];
//
// If the encoded identity string contains characters which
// the reference parser uses as separators, then we enclose
// the identity string in quotes.
//
- var id = Ice.identityToString(this._identity);
+ const id = Ice.identityToString(this._identity);
if(id.search(/[ :@]/) != -1)
{
s.push('"');
@@ -1259,7 +1292,7 @@ var Reference = Class({
// the facet string in quotes.
//
s.push(" -f ");
- var fs = StringUtil.escapeString(this._facet, "");
+ const fs = StringUtil.escapeString(this._facet, "");
if(fs.search(/[ :@]/) != -1)
{
s.push('"');
@@ -1333,27 +1366,31 @@ var Reference = Class({
return s.join("");
// Derived class writes the remainder of the string.
- },
+ }
+
//
// Convert the reference to its property form.
//
- toProperty: function(prefix)
+ toProperty(prefix)
{
// Abstract
Debug.assert(false);
return null;
- },
- getRequestHandler: function(proxy)
+ }
+
+ getRequestHandler(proxy)
{
// Abstract
Debug.assert(false);
- },
- getBatchRequestQueue: function()
+ }
+
+ getBatchRequestQueue()
{
// Abstract
Debug.assert(false);
- },
- equals: function(r)
+ }
+
+ equals(r)
{
//
// Note: if(this === r) and type test are performed by each non-abstract derived class.
@@ -1374,7 +1411,7 @@ var Reference = Class({
return false;
}
- if(!this._context.equals(r._context))
+ if(!MapUtil.equals(this._context, r._context))
{
return false;
}
@@ -1386,7 +1423,7 @@ var Reference = Class({
if(this._overrideCompress !== r._overrideCompress)
{
- return false;
+ return false;
}
if(this._overrideCompress && this._compress !== r._compress)
{
@@ -1409,14 +1446,16 @@ var Reference = Class({
}
return true;
- },
- clone: function()
+ }
+
+ clone()
{
// Abstract
Debug.assert(false);
return null;
- },
- copyMembers: function(r)
+ }
+
+ copyMembers(r)
{
//
// Copy the members that are not passed to the constructor.
@@ -1425,123 +1464,150 @@ var Reference = Class({
r._overrideCompress = this._overrideCompress;
r._compress = this._compress;
}
-});
+}
-Reference._emptyContext = new HashMap();
+Reference._emptyContext = new Map();
Reference._emptyEndpoints = [];
Ice.Reference = Reference;
-var FixedReference = Class(Reference, {
- __init__: function(instance, communicator, identity, facet, mode, secure, encoding, connection)
+class FixedReference extends Reference
+{
+ constructor(instance, communicator, identity, facet, mode, secure, encoding, connection)
{
- Reference.call(this, instance, communicator, identity, facet, mode, secure, Ice.Protocol_1_0, encoding);
+ super(instance, communicator, identity, facet, mode, secure, Ice.Protocol_1_0, encoding);
this._fixedConnection = connection;
- },
- getEndpoints: function()
+ }
+
+ getEndpoints()
{
return Reference._emptyEndpoints;
- },
- getAdapterId: function()
+ }
+
+ getAdapterId()
{
return "";
- },
- getRouterInfo: function()
+ }
+
+ getRouterInfo()
{
return null;
- },
- getLocatorInfo: function()
+ }
+
+ getLocatorInfo()
{
return null;
- },
- getCacheConnection: function()
+ }
+
+ getCacheConnection()
{
return true;
- },
- getPreferSecure: function()
+ }
+
+ getPreferSecure()
{
return false;
- },
- getEndpointSelection: function()
+ }
+
+ getEndpointSelection()
{
return EndpointSelectionType.Random;
- },
- getLocatorCacheTimeout: function()
+ }
+
+ getLocatorCacheTimeout()
{
return 0;
- },
- getConnectionId: function()
+ }
+
+ getConnectionId()
{
return "";
- },
- changeAdapterId: function(newAdapterId)
+ }
+
+ changeAdapterId(newAdapterId)
{
throw new Ice.FixedProxyException();
- },
- changeEndpoints: function(newEndpoints)
+ }
+
+ changeEndpoints(newEndpoints)
{
throw new Ice.FixedProxyException();
- },
- changeLocator: function(newLocator)
+ }
+
+ changeLocato(newLocator)
{
throw new Ice.FixedProxyException();
- },
- changeRouter: function(newRouter)
+ }
+
+ changeRouter(newRouter)
{
throw new Ice.FixedProxyException();
- },
- changeCacheConnection: function(newCache)
+ }
+
+ changeCacheConnection(newCache)
{
throw new Ice.FixedProxyException();
- },
- changePreferSecure: function(prefSec)
+ }
+
+ changePreferSecure(prefSec)
{
throw new Ice.FixedProxyException();
- },
- changeEndpointSelection: function(newType)
+ }
+
+ changeEndpointSelection(newType)
{
throw new Ice.FixedProxyException();
- },
- changeLocatorCacheTimeout: function(newTimeout)
+ }
+
+ changeLocatorCacheTimeout(newTimeout)
{
throw new Ice.FixedProxyException();
- },
- changeTimeout: function(newTimeout)
+ }
+
+ changeTimeout(newTimeout)
{
throw new Ice.FixedProxyException();
- },
- changeConnectionId: function(connectionId)
+ }
+
+ changeConnectionId(connectionId)
{
throw new Ice.FixedProxyException();
- },
- isIndirect: function()
+ }
+
+ isIndirect()
{
return false;
- },
- isWellKnown: function()
+ }
+
+ isWellKnown()
{
return false;
- },
- streamWrite: function(s)
+ }
+
+ streamWrite(s)
{
throw new Ice.FixedProxyException();
- },
- toString: function()
+ }
+
+ toString()
{
throw new Ice.FixedProxyException();
- },
- toProperty: function(prefix)
+ }
+
+ toProperty(prefix)
{
throw new Ice.FixedProxyException();
- },
- clone: function()
+ }
+
+ clone()
{
- var r = new FixedReference(this.getInstance(), this.getCommunicator(), this.getIdentity(), this.getFacet(),
- this.getMode(), this.getSecure(), this.getEncoding(), this._fixedConnection);
+ const r = new FixedReference(this.getInstance(), this.getCommunicator(), this.getIdentity(), this.getFacet(),
+ this.getMode(), this.getSecure(), this.getEncoding(), this._fixedConnection);
this.copyMembers(r);
return r;
- },
- getRequestHandler: function(proxy)
+ }
+
+ getRequestHandler(proxy)
{
switch(this.getMode())
{
@@ -1571,16 +1637,8 @@ var FixedReference = Class(Reference, {
// If a secure connection is requested or secure overrides is set,
// check if the connection is secure.
//
- var secure;
- var defaultsAndOverrides = this.getInstance().defaultsAndOverrides();
- if(defaultsAndOverrides.overrideSecure)
- {
- secure = defaultsAndOverrides.overrideSecureValue;
- }
- else
- {
- secure = this.getSecure();
- }
+ const defaultsAndOverrides = this.getInstance().defaultsAndOverrides();
+ const secure = defaultsAndOverrides.overrideSecure ? defaultsAndOverrides.overrideSecureValue : this.getSecure();
if(secure && !this._fixedConnection.endpoint().secure())
{
throw new Ice.NoEndpointException("");
@@ -1588,7 +1646,7 @@ var FixedReference = Class(Reference, {
this._fixedConnection.throwException(); // Throw in case our connection is already destroyed.
- var compress;
+ let compress;
if(defaultsAndOverrides.overrideCompress)
{
compress = defaultsAndOverrides.overrideCompressValue;
@@ -1603,12 +1661,14 @@ var FixedReference = Class(Reference, {
}
return proxy.__setRequestHandler(new ConnectionRequestHandler(this, this._fixedConnection, compress));
- },
- getBatchRequestQueue: function()
+ }
+
+ getBatchRequestQueue()
{
return this._fixedConnection.getBatchRequestQueue();
- },
- equals: function(rhs)
+ }
+
+ equals(rhs)
{
if(this === rhs)
{
@@ -1618,23 +1678,23 @@ var FixedReference = Class(Reference, {
{
return false;
}
- if(!Reference.prototype.equals.call(this, rhs))
+ if(!super.equals(rhs))
{
return false;
}
return this._fixedConnection.equals(rhs._fixedConnection);
}
-});
+}
Ice.FixedReference = FixedReference;
-var RoutableReference = Class(Reference, {
- __init__: function(instance, communicator, identity, facet, mode, secure, protocol, encoding, endpoints,
- adapterId, locatorInfo, routerInfo, cacheConnection, preferSecure, endpointSelection,
- locatorCacheTimeout, invocationTimeout)
+class RoutableReference extends Reference
+{
+ constructor(instance, communicator, identity, facet, mode, secure, protocol, encoding, endpoints,
+ adapterId, locatorInfo, routerInfo, cacheConnection, preferSecure, endpointSelection,
+ locatorCacheTimeout, invocationTimeout)
{
- Reference.call(this, instance, communicator, identity, facet, mode, secure, protocol, encoding,
- invocationTimeout);
+ super(instance, communicator, identity, facet, mode, secure, protocol, encoding, invocationTimeout);
this._endpoints = endpoints;
this._adapterId = adapterId;
this._locatorInfo = locatorInfo;
@@ -1656,223 +1716,226 @@ var RoutableReference = Class(Reference, {
}
this._connectionId = "";
Debug.assert(this._adapterId.length === 0 || this._endpoints.length === 0);
- },
- getEndpoints: function()
+ }
+
+ getEndpoints()
{
return this._endpoints;
- },
- getAdapterId: function()
+ }
+
+ getAdapterId()
{
return this._adapterId;
- },
- getRouterInfo: function()
+ }
+
+ getRouterInfo()
{
return this._routerInfo;
- },
- getLocatorInfo: function()
+ }
+
+ getLocatorInfo()
{
return this._locatorInfo;
- },
- getCacheConnection: function()
+ }
+
+ getCacheConnection()
{
return this._cacheConnection;
- },
- getPreferSecure: function()
+ }
+
+ getPreferSecure()
{
return this._preferSecure;
- },
- getEndpointSelection: function()
+ }
+
+ getEndpointSelection()
{
return this._endpointSelection;
- },
- getLocatorCacheTimeout: function()
+ }
+
+ getLocatorCacheTimeout()
{
return this._locatorCacheTimeout;
- },
- getConnectionId: function()
+ }
+
+ getConnectionId()
{
return this._connectionId;
- },
- changeEncoding: function(newEncoding)
+ }
+
+ changeEncoding(newEncoding)
{
- var r = Reference.prototype.changeEncoding.call(this, newEncoding);
+ const r = super.changeEncoding(newEncoding);
if(r !== this)
{
- var locInfo = r._locatorInfo;
- if(locInfo !== null && !locInfo.getLocator().ice_getEncodingVersion().equals(newEncoding))
+ if(r._locatorInfo !== null && !r._locatorInfo.getLocator().ice_getEncodingVersion().equals(newEncoding))
{
r._locatorInfo = this.getInstance().locatorManager().find(
- locInfo.getLocator().ice_encodingVersion(newEncoding));
+ r._locatorInfo.getLocator().ice_encodingVersion(newEncoding));
}
}
return r;
- },
- changeCompress: function(newCompress)
+ }
+
+ changeCompress(newCompress)
{
- var r = Reference.prototype.changeCompress.call(this, newCompress);
+ const r = super.changeCompress(newCompress);
if(r !== this && this._endpoints.length > 0) // Also override the compress flag on the endpoints if it was updated.
{
- var newEndpoints = [];
- for(var i = 0; i < this._endpoints.length; i++)
- {
- newEndpoints[i] = this._endpoints[i].changeCompress(newCompress);
- }
- r._endpoints = newEndpoints;
+ r._endpoints = this._endpoints.map(endpoint => endpoint.changeCompress(newCompress));
}
return r;
- },
- changeAdapterId: function(newAdapterId)
+ }
+
+ changeAdapterId(newAdapterId)
{
if(this._adapterId === newAdapterId)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._adapterId = newAdapterId;
r._endpoints = Reference._emptyEndpoints;
return r;
- },
- changeEndpoints: function(newEndpoints)
+ }
+
+ changeEndpoints(newEndpoints)
{
if(ArrayUtil.equals(newEndpoints, this._endpoints, function(e1, e2) { return e1.equals(e2); }))
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._endpoints = newEndpoints;
r._adapterId = "";
r.applyOverrides(r._endpoints);
return r;
- },
- changeLocator: function(newLocator)
+ }
+
+ changeLocator(newLocator)
{
- var newLocatorInfo = this.getInstance().locatorManager().find(newLocator);
+ const newLocatorInfo = this.getInstance().locatorManager().find(newLocator);
if(newLocatorInfo !== null && this._locatorInfo !== null && newLocatorInfo.equals(this._locatorInfo))
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._locatorInfo = newLocatorInfo;
return r;
- },
- changeRouter: function(newRouter)
+ }
+
+ changeRouter(newRouter)
{
- var newRouterInfo = this.getInstance().routerManager().find(newRouter);
+ const newRouterInfo = this.getInstance().routerManager().find(newRouter);
if(newRouterInfo !== null && this._routerInfo !== null && newRouterInfo.equals(this._routerInfo))
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._routerInfo = newRouterInfo;
return r;
- },
- changeCacheConnection: function(newCache)
+ }
+
+ changeCacheConnection(newCache)
{
if(newCache === this._cacheConnection)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._cacheConnection = newCache;
return r;
- },
- changePreferSecure: function(newPreferSecure)
+ }
+
+ changePreferSecure(newPreferSecure)
{
if(newPreferSecure === this._preferSecure)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._preferSecure = newPreferSecure;
return r;
- },
- changeEndpointSelection: function(newType)
+ }
+
+ changeEndpointSelection(newType)
{
if(newType === this._endpointSelection)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._endpointSelection = newType;
return r;
- },
- changeLocatorCacheTimeout: function(newTimeout)
+ }
+
+ changeLocatorCacheTimeout(newTimeout)
{
if(this._locatorCacheTimeout === newTimeout)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._locatorCacheTimeout = newTimeout;
return r;
- },
- changeTimeout: function(newTimeout)
+ }
+
+ changeTimeout(newTimeout)
{
if(this._overrideTimeout && this._timeout === newTimeout)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._timeout = newTimeout;
r._overrideTimeout = true;
- if(this._endpoints.length > 0)
- {
- var newEndpoints = [];
- for(var i = 0; i < this._endpoints.length; i++)
- {
- newEndpoints[i] = this._endpoints[i].changeTimeout(newTimeout);
- }
- r._endpoints = newEndpoints;
- }
+ r._endpoints = this._endpoints.map(endpoint => endpoint.changeTimeout(newTimeout));
return r;
- },
- changeConnectionId: function(id)
+ }
+
+ changeConnectionId(id)
{
if(this._connectionId === id)
{
return this;
}
- var r = this.getInstance().referenceFactory().copy(this);
+ const r = this.getInstance().referenceFactory().copy(this);
r._connectionId = id;
- if(this._endpoints.length > 0)
- {
- var newEndpoints = [];
- for(var i = 0; i < this._endpoints.length; i++)
- {
- newEndpoints[i] = this._endpoints[i].changeConnectionId(id);
- }
- r._endpoints = newEndpoints;
- }
+ r._endpoints = this._endpoints.map(endpoint => endpoint.changeConnectionId(id));
return r;
- },
- isIndirect: function()
+ }
+
+ isIndirect()
{
return this._endpoints.length === 0;
- },
- isWellKnown: function()
+ }
+
+ isWellKnown()
{
return this._endpoints.length === 0 && this._adapterId.length === 0;
- },
- streamWrite: function(s)
+ }
+
+ streamWrite(s)
{
- Reference.prototype.streamWrite.call(this, s);
+ super.streamWrite(s);
s.writeSize(this._endpoints.length);
if(this._endpoints.length > 0)
{
Debug.assert(this._adapterId.length === 0);
- for(var i = 0; i < this._endpoints.length; ++i)
- {
- s.writeShort(this._endpoints[i].type());
- this._endpoints[i].streamWrite(s);
- }
+ this._endpoints.forEach(endpoint =>
+ {
+ s.writeShort(endpoint.type());
+ endpoint.streamWrite(s);
+ });
}
else
{
s.writeString(this._adapterId); // Adapter id.
}
- },
- toString: function()
+ }
+
+ toString()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
@@ -1881,19 +1944,19 @@ var RoutableReference = Class(Reference, {
// these features. Please review for all features that depend on the
// format of proxyToString() before changing this and related code.
//
- var s = [];
- s.push(Reference.prototype.toString.call(this));
+ const s = [];
+ s.push(super.toString());
if(this._endpoints.length > 0)
{
- for(var i = 0; i < this._endpoints.length; ++i)
- {
- var endp = this._endpoints[i].toString();
- if(endp !== null && endp.length > 0)
+ this._endpoints.forEach(endpoint =>
{
- s.push(':');
- s.push(endp);
- }
- }
+ const endp = endpoint.toString();
+ if(endp !== null && endp.length > 0)
+ {
+ s.push(':');
+ s.push(endp);
+ }
+ });
}
else if(this._adapterId.length > 0)
{
@@ -1904,7 +1967,7 @@ var RoutableReference = Class(Reference, {
// the reference parser uses as separators, then we enclose
// the adapter id string in quotes.
//
- var a = StringUtil.escapeString(this._adapterId, null);
+ const a = StringUtil.escapeString(this._adapterId, null);
if(a.search(/[ :@]/) != -1)
{
s.push('"');
@@ -1917,53 +1980,48 @@ var RoutableReference = Class(Reference, {
}
}
return s.join("");
- },
- toProperty: function(prefix)
+ }
+
+ toProperty(prefix)
{
- var properties = new HashMap(), e;
+ const properties = new Map();
properties.set(prefix, this.toString());
properties.set(prefix + ".CollocationOptimized", "0");
properties.set(prefix + ".ConnectionCached", this._cacheConnection ? "1" : "0");
properties.set(prefix + ".PreferSecure", this._preferSecure ? "1" : "0");
properties.set(prefix + ".EndpointSelection",
- this._endpointSelection === EndpointSelectionType.Random ? "Random" : "Ordered");
+ this._endpointSelection === EndpointSelectionType.Random ? "Random" : "Ordered");
properties.set(prefix + ".LocatorCacheTimeout", "" + this._locatorCacheTimeout);
properties.set(prefix + ".InvocationTimeout", "" + this.getInvocationTimeout());
if(this._routerInfo !== null)
{
- var h = this._routerInfo.getRouter();
- var routerProperties = h.__reference().toProperty(prefix + ".Router");
- for(e = routerProperties.entries; e !== null; e = e.next)
- {
- properties.set(e.key, e.value);
- }
+ this._routerInfo.getRouter().__reference().toProperty(prefix + ".Router").forEach(
+ (value, key) => properties.set(key, value));
}
if(this._locatorInfo !== null)
{
- var p = this._locatorInfo.getLocator();
- var locatorProperties = p.__reference().toProperty(prefix + ".Locator");
- for(e = locatorProperties.entries; e !== null; e = e.next)
- {
- properties.set(e.key, e.value);
- }
+ this._locatorInfo.getLocator().__reference().toProperty(prefix + ".Locator").forEach(
+ (value, key) => properties.set(key, value));
}
return properties;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
if(!this._hashInitialized)
{
- Reference.prototype.hashCode.call(this); // Initializes _hashValue.
+ super.hashCode(); // Initializes _hashValue.
this._hashValue = HashUtil.addString(this._hashValue, this._adapterId);
}
return this._hashValue;
- },
- equals: function(rhs)
+ }
+
+ equals(rhs)
{
if(this === rhs)
{
@@ -1974,7 +2032,7 @@ var RoutableReference = Class(Reference, {
return false;
}
- if(!Reference.prototype.equals.call(this, rhs))
+ if(!super.equals(rhs))
{
return false;
}
@@ -2024,18 +2082,21 @@ var RoutableReference = Class(Reference, {
return false;
}
return true;
- },
- getRequestHandler: function(proxy)
+ }
+
+ getRequestHandler(proxy)
{
return this._instance.requestHandlerFactory().getRequestHandler(this, proxy);
- },
- getBatchRequestQueue: function()
+ }
+
+ getBatchRequestQueue()
{
return new BatchRequestQueue(this._instance, this._mode === RefMode.ModeBatchDatagram);
- },
- getConnection: function()
+ }
+
+ getConnection()
{
- var promise = new Promise(); // success callback receives (connection, compress)
+ const p = new Ice.Promise(); // success callback receives (connection, compress)
if(this._routerInfo !== null)
{
@@ -2043,117 +2104,90 @@ var RoutableReference = Class(Reference, {
// If we route, we send everything to the router's client
// proxy endpoints.
//
- var self = this;
- this._routerInfo.getClientEndpoints().then(
- function(endpts)
+ this._routerInfo.getClientEndpoints().then(endpts =>
{
if(endpts.length > 0)
{
- self.applyOverrides(endpts);
- self.createConnection(endpts).then(
- function(connection, compress)
- {
- promise.succeed(connection, compress);
- },
- function(ex)
- {
- promise.fail(ex);
- });
+ this.applyOverrides(endpts);
+ this.createConnection(endpts).then(p.resolve, p.reject);
}
else
{
- self.getConnectionNoRouterInfo(promise);
+ this.getConnectionNoRouterInfo(p);
}
- }).exception(
- function(ex)
- {
- promise.fail(ex);
- });
+ }).catch(p.reject);
}
else
{
- this.getConnectionNoRouterInfo(promise);
+ this.getConnectionNoRouterInfo(p);
}
+ return p;
+ }
- return promise;
- },
- getConnectionNoRouterInfo: function(promise)
+ getConnectionNoRouterInfo(p)
{
if(this._endpoints.length > 0)
{
- this.createConnection(this._endpoints).then(
- function(connection, compress)
- {
- promise.succeed(connection, compress);
- }).exception(
- function(ex)
- {
- promise.fail(ex);
- });
+ this.createConnection(this._endpoints).then(p.resolve).catch(p.reject);
return;
}
- var self = this;
if(this._locatorInfo !== null)
{
this._locatorInfo.getEndpoints(this, null, this._locatorCacheTimeout).then(
- function(endpoints, cached)
+ values =>
{
+ const [endpoints, cached] = values;
if(endpoints.length === 0)
{
- promise.fail(new Ice.NoEndpointException(self.toString()));
+ p.reject(new Ice.NoEndpointException(this.toString()));
return;
}
- self.applyOverrides(endpoints);
- self.createConnection(endpoints).then(
- function(connection, compress)
- {
- promise.succeed(connection, compress);
- },
- function(ex)
+ this.applyOverrides(endpoints);
+ this.createConnection(endpoints).then(
+ p.resolve,
+ ex =>
{
if(ex instanceof Ice.NoEndpointException)
{
//
// No need to retry if there's no endpoints.
//
- promise.fail(ex);
+ p.reject(ex);
}
else
{
- Debug.assert(self._locatorInfo !== null);
- self.getLocatorInfo().clearCache(self);
+ Debug.assert(this._locatorInfo !== null);
+ this.getLocatorInfo().clearCache(this);
if(cached)
{
- var traceLevels = self.getInstance().traceLevels();
+ const traceLevels = this.getInstance().traceLevels();
if(traceLevels.retry >= 2)
{
- var s = "connection to cached endpoints failed\n" +
- "removing endpoints from cache and trying one more time\n" +
- ex.toString();
- self.getInstance().initializationData().logger.trace(traceLevels.retryCat, s);
+ this.getInstance().initializationData().logger.trace(
+ traceLevels.retryCat,
+ "connection to cached endpoints failed\n" +
+ "removing endpoints from cache and trying one more time\n" +
+ ex.toString());
}
- self.getConnectionNoRouterInfo(promise); // Retry.
+ this.getConnectionNoRouterInfo(p); // Retry.
return;
}
- promise.fail(ex);
+ p.reject(ex);
}
});
- }).exception(
- function(ex)
- {
- promise.fail(ex);
- });
+ }).catch(p.reject);
}
else
{
- promise.fail(new Ice.NoEndpointException(this.toString()));
+ p.reject(new Ice.NoEndpointException(this.toString()));
}
- },
- clone: function()
+ }
+
+ clone()
{
- var r = new RoutableReference(this.getInstance(),
+ const r = new RoutableReference(this.getInstance(),
this.getCommunicator(),
this.getIdentity(),
this.getFacet(),
@@ -2172,23 +2206,25 @@ var RoutableReference = Class(Reference, {
this._invocationTimeout);
this.copyMembers(r);
return r;
- },
- copyMembers: function(rhs)
+ }
+
+ copyMembers(rhs)
{
//
// Copy the members that are not passed to the constructor.
//
- Reference.prototype.copyMembers.call(this, rhs);
+ super.copyMembers(rhs);
rhs._overrideTimeout = this._overrideTimeout;
rhs._timeout = this._timeout;
rhs._connectionId = this._connectionId;
- },
- applyOverrides: function(endpts)
+ }
+
+ applyOverrides(endpts)
{
//
// Apply the endpoint overrides to each endpoint.
//
- for(var i = 0; i < endpts.length; ++i)
+ for(let i = 0; i < endpts.length; ++i)
{
endpts[i] = endpts[i].changeConnectionId(this._connectionId);
if(this._overrideCompress)
@@ -2200,21 +2236,14 @@ var RoutableReference = Class(Reference, {
endpts[i] = endpts[i].changeTimeout(this._timeout);
}
}
- },
- filterEndpoints: function(allEndpoints)
- {
- var endpoints = [];
+ }
+ filterEndpoints(allEndpoints)
+ {
//
// Filter out opaque endpoints or endpoints which can't connect.
//
- for(var i = 0; i < allEndpoints.length; ++i)
- {
- if(!(allEndpoints[i] instanceof OpaqueEndpointI) && allEndpoints[i].connectable())
- {
- endpoints.push(allEndpoints[i]);
- }
- }
+ let endpoints = allEndpoints.filter(e => !(e instanceof OpaqueEndpointI) && e.connectable());
//
// Filter out endpoints according to the mode of the reference.
@@ -2228,7 +2257,7 @@ var RoutableReference = Class(Reference, {
//
// Filter out datagram endpoints.
//
- endpoints = ArrayUtil.filter(endpoints, function(e, index, arr) { return !e.datagram(); });
+ endpoints = endpoints.filter(e => !e.datagram());
break;
}
@@ -2238,7 +2267,7 @@ var RoutableReference = Class(Reference, {
//
// Filter out non-datagram endpoints.
//
- endpoints = ArrayUtil.filter(endpoints, function(e, index, arr) { return e.datagram(); });
+ endpoints = endpoints.filter(e => e.datagram());
break;
}
}
@@ -2274,18 +2303,18 @@ var RoutableReference = Class(Reference, {
// make secure endpoints prefered. By default make non-secure
// endpoints preferred over secure endpoints.
//
- var overrides = this.getInstance().defaultsAndOverrides();
+ const overrides = this.getInstance().defaultsAndOverrides();
if(overrides.overrideSecure ? overrides.overrideSecureValue : this.getSecure())
{
- endpoints = ArrayUtil.filter(endpoints, function(e, index, arr) { return e.secure(); });
+ endpoints = endpoints.filter(e => e.secure());
}
else
{
- var preferSecure = this.getPreferSecure();
- var compare = function(e1, e2)
+ const preferSecure = this.getPreferSecure();
+ const compare = (e1, e2) =>
{
- var ls = e1.secure();
- var rs = e2.secure();
+ const ls = e1.secure();
+ const rs = e2.secure();
if((ls && rs) || (!ls && !rs))
{
return 0;
@@ -2302,37 +2331,30 @@ var RoutableReference = Class(Reference, {
endpoints.sort(compare);
}
return endpoints;
- },
- createConnection: function(allEndpoints)
+ }
+
+ createConnection(allEndpoints)
{
- var endpoints = this.filterEndpoints(allEndpoints);
+ const endpoints = this.filterEndpoints(allEndpoints);
if(endpoints.length === 0)
{
- return new Promise().fail(new Ice.NoEndpointException(this.toString()));
+ return Ice.Promise.reject(new Ice.NoEndpointException(this.toString()));
}
//
// Finally, create the connection.
//
- var promise = new Promise();
- var factory = this.getInstance().outgoingConnectionFactory();
- var cb;
+ const promise = new Ice.Promise();
+ const factory = this.getInstance().outgoingConnectionFactory();
if(this.getCacheConnection() || endpoints.length == 1)
{
//
// Get an existing connection or create one if there's no
// existing connection to one of the given endpoints.
//
- cb = new CreateConnectionCallback(this, null, promise);
+ const cb = new CreateConnectionCallback(this, null, promise);
factory.create(endpoints, false, this.getEndpointSelection()).then(
- function(connection, compress)
- {
- cb.setConnection(connection, compress);
- }).exception(
- function(ex)
- {
- cb.setException(ex);
- });
+ values => cb.setConnection(values)).catch(ex => cb.setException(ex));
}
else
{
@@ -2343,37 +2365,31 @@ var RoutableReference = Class(Reference, {
// create a new connection even if there's an existing
// connection for one of the endpoints.
//
- var v = [ endpoints[0] ];
- cb = new CreateConnectionCallback(this, endpoints, promise);
- factory.create(v, true, this.getEndpointSelection()).then(
- function(connection, compress)
- {
- cb.setConnection(connection, compress);
- }).exception(
- function(ex)
- {
- cb.setException(ex);
- });
+ const cb = new CreateConnectionCallback(this, endpoints, promise);
+ factory.create([ endpoints[0] ], true, this.getEndpointSelection()).then(
+ values => cb.setConnection(values)).catch(ex => cb.setException(ex));
}
-
return promise;
}
-});
+}
Ice.RoutableReference = RoutableReference;
module.exports.Ice = Ice;
-var CreateConnectionCallback = Class({
- __init__: function(r, endpoints, promise)
+class CreateConnectionCallback
+{
+ constructor(r, endpoints, promise)
{
this.ref = r;
this.endpoints = endpoints;
this.promise = promise;
this.i = 0;
this.exception = null;
- },
- setConnection: function(connection, compress)
+ }
+
+ setConnection(values)
{
+ const [connection, compress] = values;
//
// If we have a router, set the object adapter for this router
// (if any) to the new connection, so that callbacks from the
@@ -2383,9 +2399,10 @@ var CreateConnectionCallback = Class({
{
connection.setAdapter(this.ref.getRouterInfo().getAdapter());
}
- this.promise.succeed(connection, compress);
- },
- setException: function(ex)
+ this.promise.resolve(values);
+ }
+
+ setException(ex)
{
if(this.exception === null)
{
@@ -2394,21 +2411,14 @@ var CreateConnectionCallback = Class({
if(this.endpoints === null || ++this.i === this.endpoints.length)
{
- this.promise.fail(this.exception);
+ this.promise.reject(this.exception);
return;
}
- var more = this.i != this.endpoints.length - 1;
- var arr = [ this.endpoints[this.i] ];
- var self = this;
- this.ref.getInstance().outgoingConnectionFactory().create(arr, more, this.ref.getEndpointSelection()).then(
- function(connection, compress)
- {
- self.setConnection(connection, compress);
- }).exception(
- function(ex)
- {
- self.setException(ex);
- });
+ this.ref.getInstance().outgoingConnectionFactory().create(
+ [ this.endpoints[this.i] ],
+ this.i != this.endpoints.length - 1,
+ this.ref.getEndpointSelection()).then(values => this.setConnection(values))
+ .catch(ex => this.setException(ex));
}
-});
+}
diff --git a/js/src/Ice/ReferenceMode.js b/js/src/Ice/ReferenceMode.js
index 3ad15f59f97..70a50b049ec 100644
--- a/js/src/Ice/ReferenceMode.js
+++ b/js/src/Ice/ReferenceMode.js
@@ -7,7 +7,7 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
//
// Using a separate module for these constants so that ObjectPrx does
diff --git a/js/src/Ice/RequestHandlerFactory.js b/js/src/Ice/RequestHandlerFactory.js
index e23e0c0d172..955bc5efa9c 100644
--- a/js/src/Ice/RequestHandlerFactory.js
+++ b/js/src/Ice/RequestHandlerFactory.js
@@ -7,30 +7,31 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
"../Ice/HashMap",
"../Ice/Reference",
"../Ice/ConnectRequestHandler"
]);
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var ConnectRequestHandler = Ice.ConnectRequestHandler;
+const Debug = Ice.Debug;
+const HashMap = Ice.HashMap;
+const ConnectRequestHandler = Ice.ConnectRequestHandler;
-var RequestHandlerFactory = Ice.Class({
- __init__: function(instance)
+class RequestHandlerFactory
+{
+ constructor(instance)
{
this._instance = instance;
this._handlers = new HashMap(HashMap.compareEquals);
- },
- getRequestHandler: function(ref, proxy)
+ }
+
+ getRequestHandler(ref, proxy)
{
- var connect = false;
- var handler;
+ let connect = false;
+ let handler;
if(ref.getCacheConnection())
{
handler = this._handlers.get(ref);
@@ -49,18 +50,19 @@ var RequestHandlerFactory = Ice.Class({
if(connect)
{
- ref.getConnection().then(function(connection, compress)
+ ref.getConnection().then(values =>
{
- handler.setConnection(connection, compress);
+ handler.setConnection(values);
},
- function(ex)
+ ex =>
{
handler.setException(ex);
});
}
return proxy.__setRequestHandler(handler.connect(proxy));
- },
- removeRequestHandler: function(ref, handler)
+ }
+
+ removeRequestHandler(ref, handler)
{
if(ref.getCacheConnection())
{
@@ -70,7 +72,7 @@ var RequestHandlerFactory = Ice.Class({
}
}
}
-});
+}
Ice.RequestHandlerFactory = RequestHandlerFactory;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/RetryException.js b/js/src/Ice/RetryException.js
index de3f7fdedc9..869e162fb91 100644
--- a/js/src/Ice/RetryException.js
+++ b/js/src/Ice/RetryException.js
@@ -7,12 +7,14 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/Exception", "../Ice/Debug", "../Ice/LocalException"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/Debug", "../Ice/LocalException"]);
-var RetryException = Ice.Class(Error, {
- __init__: function(ex)
+class RetryException extends Error
+{
+ constructor(ex)
{
+ super();
if(ex instanceof Ice.LocalException)
{
this._ex = ex;
@@ -23,13 +25,12 @@ var RetryException = Ice.Class(Error, {
this._ex = ex._ex;
}
}
-});
-
-var prototype = RetryException.prototype;
-
-Object.defineProperty(prototype, "inner", {
- get: function() { return this._ex; }
-});
+
+ get inner()
+ {
+ return this._ex;
+ }
+}
Ice.RetryException = RetryException;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/RetryQueue.js b/js/src/Ice/RetryQueue.js
index 5a4e5f61ca2..6e9af19492d 100644
--- a/js/src/Ice/RetryQueue.js
+++ b/js/src/Ice/RetryQueue.js
@@ -7,52 +7,93 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/LocalException"]);
+const Ice = require("../Ice/LocalException").Ice;
-var Class = Ice.Class;
+class RetryTask
+{
+ constructor(instance, queue, outAsync, interval)
+ {
+ this._instance = instance;
+ this._queue = queue;
+ this._outAsync = outAsync;
+ }
+
+ run()
+ {
+ this._outAsync.__retry();
+ this._queue.remove(this);
+ }
+
+ destroy()
+ {
+ try
+ {
+ this._outAsync.__abort(new Ice.CommunicatorDestroyedException());
+ }
+ catch(ex)
+ {
+ // Abort shouldn't throw if there's no callback, ignore.
+ }
+ }
+
+ asyncRequestCanceled(outAsync, ex)
+ {
+ if(this._queue.cancel(this))
+ {
+ if(this._instance.traceLevels().retry >= 1)
+ {
+ this._instance.initializationData().logger.trace(this._instance.traceLevels().retryCat,
+ "operation retry canceled\n" + ex.toString());
+ }
+ this._outAsync.__completedEx(ex);
+ }
+ }
+}
-var RetryQueue = Class({
- __init__: function(instance)
+class RetryQueue
+{
+ constructor(instance)
{
this._instance = instance;
this._requests = [];
- },
- add: function(outAsync, interval)
+ }
+
+ add(outAsync, interval)
{
if(this._instance === null)
{
throw new Ice.CommunicatorDestroyedException();
}
- var task = new RetryTask(this._instance, this, outAsync);
+ let task = new RetryTask(this._instance, this, outAsync);
outAsync.__cancelable(task); // This will throw if the request is canceled
- task.token = this._instance.timer().schedule(function()
- {
- task.run();
- }, interval);
+ task.token = this._instance.timer().schedule(() => task.run(), interval);
this._requests.push(task);
- },
- destroy: function()
+ }
+
+ destroy()
{
- for(var i = 0; i < this._requests.length; ++i)
- {
- this._instance.timer().cancel(this._requests[i].token);
- this._requests[i].destroy();
- }
+ this._requests.forEach(request =>
+ {
+ this._instance.timer().cancel(request.token);
+ request.destroy();
+ });
+
this._requests = [];
this._instance = null;
- },
- remove: function(task)
+ }
+
+ remove(task)
{
- var idx = this._requests.indexOf(task);
+ const idx = this._requests.indexOf(task);
if(idx >= 0)
{
this._requests.splice(idx, 1);
}
- },
- cancel: function(task)
+ }
+
+ cancel(task)
{
- var idx = this._requests.indexOf(task);
+ const idx = this._requests.indexOf(task);
if(idx >= 0)
{
this._requests.splice(idx, 1);
@@ -60,43 +101,7 @@ var RetryQueue = Class({
}
return false;
}
-});
+}
Ice.RetryQueue = RetryQueue;
-var RetryTask = Class({
- __init__: function(instance, queue, outAsync, interval)
- {
- this._instance = instance;
- this._queue = queue;
- this._outAsync = outAsync;
- },
- run: function()
- {
- this._outAsync.__retry();
- this._queue.remove(this);
- },
- destroy: function()
- {
- try
- {
- this._outAsync.__abort(new Ice.CommunicatorDestroyedException());
- }
- catch(ex)
- {
- // Abort shouldn't throw if there's no callback, ignore.
- }
- },
- asyncRequestCanceled: function(outAsync, ex)
- {
- if(this._queue.cancel(this))
- {
- if(this._instance.traceLevels().retry >= 1)
- {
- this._instance.initializationData().logger.trace(this._instance.traceLevels().retryCat,
- "operation retry canceled\n" + ex.toString());
- }
- this._outAsync.__completedEx(ex);
- }
- }
-});
module.exports.Ice = Ice;
diff --git a/js/src/Ice/RouterInfo.js b/js/src/Ice/RouterInfo.js
index 15326dd8ef3..d382663daa6 100644
--- a/js/src/Ice/RouterInfo.js
+++ b/js/src/Ice/RouterInfo.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/ArrayUtil",
"../Ice/Debug",
"../Ice/HashMap",
@@ -19,13 +18,13 @@ Ice.__M.require(module,
"../Ice/Exception"
]);
-var ArrayUtil = Ice.ArrayUtil;
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var Promise = Ice.Promise;
+const ArrayUtil = Ice.ArrayUtil;
+const Debug = Ice.Debug;
+const HashMap = Ice.HashMap;
-var RouterInfo = Ice.Class({
- __init__: function(router)
+class RouterInfo
+{
+ constructor(router)
{
this._router = router;
@@ -36,15 +35,17 @@ var RouterInfo = Ice.Class({
this._adapter = null;
this._identities = new HashMap(HashMap.compareEquals); // Set<Identity> = Map<Identity, 1>
this._evictedIdentities = [];
- },
- destroy: function()
+ }
+
+ destroy()
{
this._clientEndpoints = [];
this._serverEndpoints = [];
this._adapter = null;
this._identities.clear();
- },
- equals: function(rhs)
+ }
+
+ equals(rhs)
{
if(this === rhs)
{
@@ -57,59 +58,51 @@ var RouterInfo = Ice.Class({
}
return false;
- },
- hashCode: function()
+ }
+
+ hashCode()
{
return this._router.hashCode();
- },
- getRouter: function()
+ }
+
+ getRouter()
{
//
// No mutex lock necessary, _router is immutable.
//
return this._router;
- },
- getClientEndpoints: function()
+ }
+
+ getClientEndpoints()
{
- var promise = new Promise();
+ const promise = new Ice.Promise();
if(this._clientEndpoints !== null)
{
- promise.succeed(this._clientEndpoints);
+ promise.resolve(this._clientEndpoints);
}
else
{
- var self = this;
- this._router.getClientProxy().then(
- function(clientProxy)
- {
- self.setClientEndpoints(clientProxy, promise);
- }).exception(
- function(ex)
- {
- promise.fail(ex);
- });
+ this._router.getClientProxy().then(proxy => this.setClientEndpoints(proxy, promise)).catch(promise.reject);
}
return promise;
- },
- getServerEndpoints: function()
+ }
+
+
+ getServerEndpoints()
{
if(this._serverEndpoints !== null) // Lazy initialization.
{
- return new Promise().succeed(this._serverEndpoints);
+ return Ice.Promise.resolve(this._serverEndpoints);
}
else
{
- var self = this;
- return this._router.getServerProxy().then(
- function(proxy)
- {
- return self.setServerEndpoints(proxy);
- });
+ return this._router.getServerProxy().then(proxy => this.setServerEndpoints(proxy));
}
- },
- addProxy: function(proxy)
+ }
+
+ addProxy(proxy)
{
Debug.assert(proxy !== null);
@@ -118,31 +111,34 @@ var RouterInfo = Ice.Class({
//
// Only add the proxy to the router if it's not already in our local map.
//
- return new Promise().succeed();
+ return Ice.Promise.resolve();
}
else
{
- var self = this;
return this._router.addProxies([ proxy ]).then(
- function(evictedProxies)
+ evictedProxies =>
{
- self.addAndEvictProxies(proxy, evictedProxies);
+ this.addAndEvictProxies(proxy, evictedProxies);
});
}
- },
- setAdapter: function(adapter)
+ }
+
+ setAdapter(adapter)
{
this._adapter = adapter;
- },
- getAdapter: function()
+ }
+
+ getAdapter()
{
return this._adapter;
- },
- clearCache: function(ref)
+ }
+
+ clearCache(ref)
{
this._identities.delete(ref.getIdentity());
- },
- setClientEndpoints: function(clientProxy, promise)
+ }
+
+ setClientEndpoints(clientProxy, promise)
{
if(this._clientEndpoints === null)
{
@@ -152,7 +148,7 @@ var RouterInfo = Ice.Class({
// If getClientProxy() return nil, use router endpoints.
//
this._clientEndpoints = this._router.__reference().getEndpoints();
- promise.succeed(this._clientEndpoints);
+ promise.resolve(this._clientEndpoints);
}
else
{
@@ -163,26 +159,21 @@ var RouterInfo = Ice.Class({
// router, we must use the same timeout as the already
// existing connection.
//
- var self = this;
this._router.ice_getConnection().then(
- function(con)
+ con =>
{
- var proxy = clientProxy.ice_timeout(con.timeout());
- self._clientEndpoints = proxy.__reference().getEndpoints();
- promise.succeed(self._clientEndpoints);
- }).exception(
- function(ex)
- {
- promise.fail(ex);
- });
+ this._clientEndpoints = clientProxy.ice_timeout(con.timeout()).__reference().getEndpoints();
+ promise.resolve(this._clientEndpoints);
+ }).catch(promise.reject);
}
}
else
{
- promise.succeed(this._clientEndpoints);
+ promise.resolve(this._clientEndpoints);
}
- },
- setServerEndpoints: function(serverProxy)
+ }
+
+ setServerEndpoints(serverProxy)
{
if(serverProxy === null)
{
@@ -192,16 +183,16 @@ var RouterInfo = Ice.Class({
serverProxy = serverProxy.ice_router(null); // The server proxy cannot be routed.
this._serverEndpoints = serverProxy.__reference().getEndpoints();
return this._serverEndpoints;
- },
- addAndEvictProxies: function(proxy, evictedProxies)
+ }
+
+ addAndEvictProxies(proxy, evictedProxies)
{
//
// Check if the proxy hasn't already been evicted by a
// concurrent addProxies call. If it's the case, don't
// add it to our local map.
//
- var index = ArrayUtil.indexOf(this._evictedIdentities, proxy.ice_getIdentity(),
- function(i1, i2) { return i1.equals(i2); });
+ const index = this._evictedIdentities.findIndex(e => e.equals(proxy.ice_getIdentity()));
if(index >= 0)
{
this._evictedIdentities.splice(index, 1);
@@ -218,12 +209,12 @@ var RouterInfo = Ice.Class({
//
// We also must remove whatever proxies the router evicted.
//
- for(var i = 0; i < evictedProxies.length; ++i)
- {
- this._identities.delete(evictedProxies[i].ice_getIdentity());
- }
+ evictedProxies.forEach(proxy =>
+ {
+ this._identities.delete(proxy.ice_getIdentity());
+ });
}
-});
+}
Ice.RouterInfo = RouterInfo;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/RouterManager.js b/js/src/Ice/RouterManager.js
index b3003b5fd55..2faac35ca82 100644
--- a/js/src/Ice/RouterManager.js
+++ b/js/src/Ice/RouterManager.js
@@ -7,31 +7,34 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/HashMap", "../Ice/RouterInfo", "../Ice/Router"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/HashMap", "../Ice/RouterInfo", "../Ice/Router"]);
-var HashMap = Ice.HashMap;
-var RouterInfo = Ice.RouterInfo;
-var RouterPrx = Ice.RouterPrx;
+const HashMap = Ice.HashMap;
+const RouterInfo = Ice.RouterInfo;
+const RouterPrx = Ice.RouterPrx;
-var RouterManager = Ice.Class({
- __init__: function()
+class RouterManager
+{
+ constructor()
{
this._table = new HashMap(HashMap.compareEquals); // Map<Ice.RouterPrx, RouterInfo>
- },
- destroy: function()
+ }
+
+ destroy()
{
- for(var e = this._table.entries; e !== null; e = e.next)
+ for(let router of this._table.values())
{
- e.value.destroy();
+ router.destroy();
}
this._table.clear();
- },
+ }
+
//
// Returns router info for a given router. Automatically creates
// the router info if it doesn't exist yet.
//
- find: function(rtr)
+ find(rtr)
{
if(rtr === null)
{
@@ -41,9 +44,9 @@ var RouterManager = Ice.Class({
//
// The router cannot be routed.
//
- var router = RouterPrx.uncheckedCast(rtr.ice_router(null));
+ const router = RouterPrx.uncheckedCast(rtr.ice_router(null));
- var info = this._table.get(router);
+ let info = this._table.get(router);
if(info === undefined)
{
info = new RouterInfo(router);
@@ -51,20 +54,21 @@ var RouterManager = Ice.Class({
}
return info;
- },
- erase: function(rtr)
+ }
+
+ erase(rtr)
{
- var info = null;
+ let info = null;
if(rtr !== null)
{
// The router cannot be routed.
- var router = RouterPrx.uncheckedCast(rtr.ice_router(null));
+ let router = RouterPrx.uncheckedCast(rtr.ice_router(null));
info = this._table.get(router);
this._table.delete(router);
}
return info;
}
-});
+}
Ice.RouterManager = RouterManager;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ServantManager.js b/js/src/Ice/ServantManager.js
index ef71975cbb2..d388b366f40 100644
--- a/js/src/Ice/ServantManager.js
+++ b/js/src/Ice/ServantManager.js
@@ -7,33 +7,35 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
- "../Ice/HashMap",
"../Ice/LocalException",
- "../Ice/StringUtil"
+ "../Ice/StringUtil",
+ "../Ice/IdentityUtil",
+ "../Ice/HashMap"
]);
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var StringUtil = Ice.StringUtil;
+const Debug = Ice.Debug;
+const StringUtil = Ice.StringUtil;
+const HashMap = Ice.HashMap;
//
// Only for use by Ice.ObjectAdatperI.
//
-var ServantManager = Ice.Class({
- __init__: function(instance, adapterName)
+class ServantManager
+{
+ constructor(instance, adapterName)
{
this._instance = instance;
this._adapterName = adapterName;
- this._servantMapMap = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, Map<String, Ice.Object> >
- this._defaultServantMap = new HashMap(); // Map<String, Ice.Object>
- this._locatorMap = new HashMap(); // Map<String, Ice.ServantLocator>
- },
- addServant: function(servant, ident, facet)
+ this._servantMapMap = new HashMap(HashMap.compareEquals); // Map<Ice.Identity, Map<String, Ice.Object> >
+ this._defaultServantMap = new Map(); // Map<String, Ice.Object>
+ this._locatorMap = new Map(); // Map<String, Ice.ServantLocator>
+ }
+
+ addServant(servant, ident, facet)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
@@ -42,17 +44,17 @@ var ServantManager = Ice.Class({
facet = "";
}
- var m = this._servantMapMap.get(ident);
+ let m = this._servantMapMap.get(ident);
if(m === undefined)
{
- m = new HashMap();
+ m = new Map();
this._servantMapMap.set(ident, m);
}
else
{
if(m.has(facet))
{
- var ex = new Ice.AlreadyRegisteredException();
+ const ex = new Ice.AlreadyRegisteredException();
ex.id = Ice.identityToString(ident);
ex.kindOfObject = "servant";
if(facet.length > 0)
@@ -64,23 +66,24 @@ var ServantManager = Ice.Class({
}
m.set(facet, servant);
- },
- addDefaultServant: function(servant, category)
+ }
+
+ addDefaultServant(servant, category)
{
Debug.assert(this._instance !== null); // Must not be called after destruction
- var obj = this._defaultServantMap.get(category);
- if(obj !== undefined)
+ if(this._defaultServantMap.has(category))
{
- var ex = new Ice.AlreadyRegisteredException();
+ const ex = new Ice.AlreadyRegisteredException();
ex.kindOfObject = "default servant";
ex.id = category;
throw ex;
}
this._defaultServantMap.set(category, servant);
- },
- removeServant: function(ident, facet)
+ }
+
+ removeServant(ident, facet)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
@@ -89,10 +92,10 @@ var ServantManager = Ice.Class({
facet = "";
}
- var m = this._servantMapMap.get(ident);
+ const m = this._servantMapMap.get(ident);
if(m === undefined || !m.has(facet))
{
- var ex = new Ice.NotRegisteredException();
+ const ex = new Ice.NotRegisteredException();
ex.id = Ice.identityToString(ident);
ex.kindOfObject = "servant";
if(facet.length > 0)
@@ -102,7 +105,7 @@ var ServantManager = Ice.Class({
throw ex;
}
- var obj = m.get(facet);
+ const obj = m.get(facet);
m.delete(facet);
if(m.size === 0)
@@ -111,15 +114,16 @@ var ServantManager = Ice.Class({
}
return obj;
- },
- removeDefaultServant: function(category)
+ }
+
+ removeDefaultServant(category)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var obj = this._defaultServantMap.get(category);
+ const obj = this._defaultServantMap.get(category);
if(obj === undefined)
{
- var ex = new Ice.NotRegisteredException();
+ const ex = new Ice.NotRegisteredException();
ex.kindOfObject = "default servant";
ex.id = category;
throw ex;
@@ -127,15 +131,16 @@ var ServantManager = Ice.Class({
this._defaultServantMap.delete(category);
return obj;
- },
- removeAllFacets: function(ident)
+ }
+
+ removeAllFacets(ident)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var m = this._servantMapMap.get(ident);
+ const m = this._servantMapMap.get(ident);
if(m === undefined)
{
- var ex = new Ice.NotRegisteredException();
+ const ex = new Ice.NotRegisteredException();
ex.id = Ice.identityToString(ident);
ex.kindOfObject = "servant";
throw ex;
@@ -144,8 +149,9 @@ var ServantManager = Ice.Class({
this._servantMapMap.delete(ident);
return m;
- },
- findServant: function(ident, facet)
+ }
+
+ findServant(ident, facet)
{
//
// This assert is not valid if the adapter dispatch incoming
@@ -160,8 +166,8 @@ var ServantManager = Ice.Class({
facet = "";
}
- var m = this._servantMapMap.get(ident);
- var obj = null;
+ const m = this._servantMapMap.get(ident);
+ let obj = null;
if(m === undefined)
{
obj = this._defaultServantMap.get(ident.category);
@@ -176,27 +182,30 @@ var ServantManager = Ice.Class({
}
return obj === undefined ? null : obj;
- },
- findDefaultServant: function(category)
+ }
+
+ findDefaultServant(category)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var ds = this._defaultServantMap.get(category);
+ const ds = this._defaultServantMap.get(category);
return ds === undefined ? null : ds;
- },
- findAllFacets: function(ident)
+ }
+
+ findAllFacets(ident)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var m = this._servantMapMap.get(ident);
+ const m = this._servantMapMap.get(ident);
if(m !== undefined)
{
- return m.clone();
+ return new Map(m);
}
- return new HashMap();
- },
- hasServant: function(ident)
+ return new Map();
+ }
+
+ hasServant(ident)
{
//
// This assert is not valid if the adapter dispatch incoming
@@ -206,7 +215,7 @@ var ServantManager = Ice.Class({
//
//Debug.assert(this._instance !== null); // Must not be called after destruction.
- var m = this._servantMapMap.get(ident);
+ const m = this._servantMapMap.get(ident);
if(m === undefined)
{
return false;
@@ -216,38 +225,40 @@ var ServantManager = Ice.Class({
Debug.assert(m.size > 0);
return true;
}
- },
- addServantLocator: function(locator, category)
+ }
+
+ addServantLocator(locator, category)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var l = this._locatorMap.get(category);
- if(l !== undefined)
+ if(this._locatorMap.has(category))
{
- var ex = new Ice.AlreadyRegisteredException();
+ const ex = new Ice.AlreadyRegisteredException();
ex.id = StringUtil.escapeString(category, "");
ex.kindOfObject = "servant locator";
throw ex;
}
this._locatorMap.set(category, locator);
- },
- removeServantLocator: function(category)
+ }
+
+ removeServantLocator(category)
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var l = this._locatorMap.get(category);
+ const l = this._locatorMap.get(category);
if(l === undefined)
{
- var ex = new Ice.NotRegisteredException();
+ const ex = new Ice.NotRegisteredException();
ex.id = StringUtil.escapeString(category, "");
ex.kindOfObject = "servant locator";
throw ex;
}
this._locatorMap.delete(category);
return l;
- },
- findServantLocator: function(category)
+ }
+
+ findServantLocator(category)
{
//
// This assert is not valid if the adapter dispatch incoming
@@ -257,40 +268,40 @@ var ServantManager = Ice.Class({
//
//Debug.assert(this._instance !== null); // Must not be called after destruction.
- var l = this._locatorMap.get(category);
+ const l = this._locatorMap.get(category);
return l === undefined ? null : l;
- },
+ }
+
//
// Only for use by Ice.ObjectAdapterI.
//
- destroy: function()
+ destroy()
{
Debug.assert(this._instance !== null); // Must not be called after destruction.
- var logger = this._instance.initializationData().logger;
+ const logger = this._instance.initializationData().logger;
this._servantMapMap.clear();
this._defaultServantMap.clear();
- var locatorMap = this._locatorMap.clone();
+ const locatorMap = new Map(this._locatorMap);
this._locatorMap.clear();
this._instance = null;
- for(var e = locatorMap.entries; e !== null; e = e.next)
+ for(let [key, locator] of locatorMap)
{
- var locator = e.value;
try
{
- locator.deactivate(e.key);
+ locator.deactivate(key);
}
catch(ex)
{
- var s = "exception during locator deactivation:\n" + "object adapter: `" + this._adapterName +
- "'\n" + "locator category: `" + e.key + "'\n" + ex.toString();
- logger.error(s);
+ logger.error("exception during locator deactivation:\nobject adapter: `" +
+ this._adapterName + "'\nlocator category: `" + key + "'\n" +
+ ex.toString());
}
}
}
-});
+}
Ice.ServantManager = ServantManager;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/SocketOperation.js b/js/src/Ice/SocketOperation.js
index e9ece7f52f3..9889bcd1d08 100644
--- a/js/src/Ice/SocketOperation.js
+++ b/js/src/Ice/SocketOperation.js
@@ -7,7 +7,7 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.SocketOperation =
{
None: 0,
diff --git a/js/src/Ice/Stream.js b/js/src/Ice/Stream.js
index 39aae104b87..915a1fdaf0a 100644
--- a/js/src/Ice/Stream.js
+++ b/js/src/Ice/Stream.js
@@ -7,15 +7,13 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-var __M = Ice.__M;
+const Ice = require("../Ice/ModuleRegistry").Ice;
+const __M = Ice.__M;
__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
"../Ice/ExUtil",
"../Ice/FormatType",
- "../Ice/HashMap",
"../Ice/Object",
"../Ice/OptionalFormat",
"../Ice/Protocol",
@@ -29,22 +27,21 @@ __M.require(module,
"../Ice/UnknownSlicedValue"
]);
-var Debug = Ice.Debug;
-var ExUtil = Ice.ExUtil;
-var FormatType = Ice.FormatType;
-var HashMap = Ice.HashMap;
-var IceObject = Ice.Object;
-var OptionalFormat = Ice.OptionalFormat;
-var Protocol = Ice.Protocol;
-var TraceUtil = Ice.TraceUtil;
-var ArrayUtil = Ice.ArrayUtil;
-var SlicedData = Ice.SlicedData;
-var Class = Ice.Class;
-
-var SliceType = {};
-SliceType.NoSlice = 0;
-SliceType.ValueSlice = 1;
-SliceType.ExceptionSlice = 2;
+const Debug = Ice.Debug;
+const ExUtil = Ice.ExUtil;
+const FormatType = Ice.FormatType;
+const OptionalFormat = Ice.OptionalFormat;
+const Protocol = Ice.Protocol;
+const TraceUtil = Ice.TraceUtil;
+const ArrayUtil = Ice.ArrayUtil;
+const SlicedData = Ice.SlicedData;
+
+const SliceType =
+{
+ NoSlice: 0,
+ ValueSlice: 1,
+ ExceptionSlice: 2
+};
//
// Number.isNaN polyfill for compatibility with IE
@@ -60,44 +57,50 @@ Number.isNaN = Number.isNaN || function(value)
// InputStream
//
-var IndirectPatchEntry = function(index, cb)
+class IndirectPatchEntry
{
- this.index = index;
- this.cb = cb;
-};
+ constructor(index, cb)
+ {
+ this.index = index;
+ this.cb = cb;
+ }
+}
-var EncapsDecoder = Class({
- __init__: function(stream, encaps, sliceValues, f)
+class EncapsDecoder
+{
+ constructor(stream, encaps, sliceValues, f)
{
this._stream = stream;
this._encaps = encaps;
this._sliceValues = sliceValues;
this._valueFactoryManager = f;
- this._patchMap = null; // Lazy initialized, HashMap<int, Patcher[] >()
- this._unmarshaledMap = new HashMap(); // HashMap<int, Ice.Object>()
- this._typeIdMap = null; // Lazy initialized, HashMap<int, String>
+ this._patchMap = null; // Lazy initialized, Map<int, Patcher[] >()
+ this._unmarshaledMap = new Map(); // Map<int, Ice.Object>()
+ this._typeIdMap = null; // Lazy initialized, Map<int, String>
this._typeIdIndex = 0;
this._valueList = null; // Lazy initialized. Ice.Object[]
- },
- readOptional: function()
+ }
+
+ readOptional()
{
return false;
- },
- readPendingValues: function()
+ }
+
+ readPendingValues()
{
- },
- readTypeId: function(isIndex)
+ }
+
+ readTypeId(isIndex)
{
- var typeId, index;
if(this._typeIdMap === null) // Lazy initialization
{
- this._typeIdMap = new HashMap(); // Map<int, String>();
+ this._typeIdMap = new Map(); // Map<int, String>();
}
+ let typeId;
if(isIndex)
{
- index = this._stream.readSize();
- typeId = this._typeIdMap.get(index);
+ typeId = this._typeIdMap.get(this._stream.readSize());
if(typeId === undefined)
{
throw new Ice.UnmarshalOutOfBoundsException();
@@ -109,14 +112,15 @@ var EncapsDecoder = Class({
this._typeIdMap.set(++this._typeIdIndex, typeId);
}
return typeId;
- },
- newInstance: function(typeId)
+ }
+
+ newInstance(typeId)
{
//
// Try to find a factory registered for the specific type.
//
- var userFactory = this._valueFactoryManager.find(typeId);
- var v = null;
+ let userFactory = this._valueFactoryManager.find(typeId);
+ let v = null;
if(userFactory !== undefined)
{
@@ -145,8 +149,9 @@ var EncapsDecoder = Class({
}
return v;
- },
- addPatchEntry: function(index, cb)
+ }
+
+ addPatchEntry(index, cb)
{
Debug.assert(index > 0);
@@ -154,7 +159,7 @@ var EncapsDecoder = Class({
// Check if we have already unmarshaled the instance. If that's the case,
// just call the callback and we're done.
//
- var obj = this._unmarshaledMap.get(index);
+ const obj = this._unmarshaledMap.get(index);
if(obj !== undefined && obj !== null)
{
cb.call(null, obj);
@@ -163,7 +168,7 @@ var EncapsDecoder = Class({
if(this._patchMap === null) // Lazy initialization
{
- this._patchMap = new HashMap(); // HashMap<Integer, Patcher[] >();
+ this._patchMap = new Map(); // Map<Integer, Patcher[] >();
}
//
@@ -171,7 +176,7 @@ var EncapsDecoder = Class({
// the callback will be called when the instance is
// unmarshaled.
//
- var l = this._patchMap.get(index);
+ let l = this._patchMap.get(index);
if(l === undefined)
{
//
@@ -186,11 +191,10 @@ var EncapsDecoder = Class({
// Append a patch entry for this instance.
//
l.push(cb);
- },
- unmarshal: function(index, v)
- {
- var i, length, l;
+ }
+ unmarshal(index, v)
+ {
//
// Add the instance to the map of unmarshaled instances, this must
// be done before reading the instances (for circular references).
@@ -207,7 +211,7 @@ var EncapsDecoder = Class({
//
// Patch all instances now that the instance is unmarshaled.
//
- l = this._patchMap.get(index);
+ const l = this._patchMap.get(index);
if(l !== undefined)
{
Debug.assert(l.length > 0);
@@ -215,7 +219,7 @@ var EncapsDecoder = Class({
//
// Patch all pointers that refer to the instance.
//
- for(i = 0, length = l.length; i < length; ++i)
+ for(let i = 0; i < l.length; ++i)
{
l[i](v);
}
@@ -256,7 +260,7 @@ var EncapsDecoder = Class({
// unmarshaled in order to ensure that any instance data members
// have been properly patched.
//
- for(i = 0, length = this._valueList.length; i < length; i++)
+ for(let i = 0; i < this._valueList.length; i++)
{
try
{
@@ -272,22 +276,24 @@ var EncapsDecoder = Class({
}
}
}
-});
+}
-var EncapsDecoder10 = Class(EncapsDecoder, {
- __init__: function(stream, encaps, sliceValues, f)
+class EncapsDecoder10 extends EncapsDecoder
+{
+ constructor(stream, encaps, sliceValues, f)
{
- EncapsDecoder.call(this, stream, encaps, sliceValues, f);
+ super(stream, encaps, sliceValues, f);
this._sliceType = SliceType.NoSlice;
- },
- readValue: function(cb)
+ }
+
+ readValue(cb)
{
Debug.assert(cb !== null);
//
// Instance references are encoded as a negative integer in 1.0.
//
- var index = this._stream.readInt();
+ let index = this._stream.readInt();
if(index > 0)
{
throw new Ice.MarshalException("invalid object id");
@@ -302,8 +308,9 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
{
this.addPatchEntry(index, cb);
}
- },
- throwException: function()
+ }
+
+ throwException()
{
Debug.assert(this._sliceType === SliceType.NoSlice);
@@ -314,7 +321,7 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
// This allows reading the pending instances even if some part of
// the exception was sliced.
//
- var usesClasses = this._stream.readBool();
+ const usesClasses = this._stream.readBool();
this._sliceType = SliceType.ExceptionSlice;
this._skipFirstSlice = false;
@@ -323,10 +330,10 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
// Read the first slice header.
//
this.startSlice();
- var mostDerivedId = this._typeId;
+ const mostDerivedId = this._typeId;
while(true)
{
- var userEx = this._stream.createUserException(this._typeId);
+ const userEx = this._stream.createUserException(this._typeId);
//
// We found the exception.
@@ -368,22 +375,23 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
throw ex;
}
}
- },
- startInstance: function(sliceType)
+ }
+
+ startInstance(sliceType)
{
Debug.assert(this._sliceType === sliceType);
this._skipFirstSlice = true;
- },
- endInstance: function(/*preserve*/)
+ }
+
+ endInstance(/*preserve*/)
{
- var sz;
//
// Read the Ice::Object slice.
//
if(this._sliceType === SliceType.ValueSlice)
{
this.startSlice();
- sz = this._stream.readSize(); // For compatibility with the old AFM.
+ let sz = this._stream.readSize(); // For compatibility with the old AFM.
if(sz !== 0)
{
throw new Ice.MarshalException("invalid Object slice");
@@ -393,10 +401,10 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
this._sliceType = SliceType.NoSlice;
return null;
- },
- startSlice: function()
+ }
+
+ startSlice()
{
- var isIndex;
//
// If first slice, don't read the header, it was already read in
// readInstance or throwException to find the factory.
@@ -415,7 +423,7 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
//
if(this._sliceType === SliceType.ValueSlice) // For exceptions, the type ID is always encoded as a string
{
- isIndex = this._stream.readBool();
+ let isIndex = this._stream.readBool();
this._typeId = this.readTypeId(isIndex);
}
else
@@ -430,23 +438,26 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
}
return this._typeId;
- },
- endSlice: function()
+ }
+
+ endSlice()
{
- },
- skipSlice: function()
+ }
+
+ skipSlice()
{
this._stream.traceSkipSlice(this._typeId, this._sliceType);
Debug.assert(this._sliceSize >= 4);
this._stream.skip(this._sliceSize - 4);
- },
- readPendingValues: function()
+ }
+
+ readPendingValues()
{
- var k, num;
+ let num;
do
{
num = this._stream.readSize();
- for(k = num; k > 0; --k)
+ for(let k = num; k > 0; --k)
{
this.readInstance();
}
@@ -461,12 +472,12 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
//
throw new Ice.MarshalException("index for class received, but no instance");
}
- },
- readInstance: function()
+ }
+
+ readInstance()
{
- var index = this._stream.readInt(),
- mostDerivedId,
- v = null;
+ let index = this._stream.readInt();
+ let v = null;
if(index <= 0)
{
@@ -480,14 +491,14 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
// Read the first slice header.
//
this.startSlice();
- mostDerivedId = this._typeId;
+ const mostDerivedId = this._typeId;
while(true)
{
//
// For the 1.0 encoding, the type ID for the base Object class
// marks the last slice.
//
- if(this._typeId == IceObject.ice_staticId())
+ if(this._typeId == Ice.Object.ice_staticId())
{
throw new Ice.NoValueFactoryException("", mostDerivedId);
}
@@ -523,19 +534,21 @@ var EncapsDecoder10 = Class(EncapsDecoder, {
//
this.unmarshal(index, v);
}
-});
+}
-var EncapsDecoder11 = Class(EncapsDecoder, {
- __init__: function(stream, encaps, sliceValues, f, r)
+class EncapsDecoder11 extends EncapsDecoder
+{
+ constructor(stream, encaps, sliceValues, f, r)
{
- EncapsDecoder.call(this, stream, encaps, sliceValues, f);
+ super(stream, encaps, sliceValues, f);
this._compactIdResolver = r;
this._current = null;
this._valueIdIndex = 1;
- },
- readValue: function(cb)
+ }
+
+ readValue(cb)
{
- var index = this._stream.readSize();
+ const index = this._stream.readSize();
if(index < 0)
{
throw new Ice.MarshalException("invalid object id");
@@ -566,18 +579,16 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
{
this._current.indirectPatchList = []; // IndirectPatchEntry[]
}
- var e = new IndirectPatchEntry();
- e.index = index - 1;
- e.cb = cb;
- this._current.indirectPatchList.push(e);
+ this._current.indirectPatchList.push(new IndirectPatchEntry(index - 1, cb));
}
}
else
{
this.readInstance(index, cb);
}
- },
- throwException: function()
+ }
+
+ throwException()
{
Debug.assert(this._current === null);
@@ -587,11 +598,11 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
// Read the first slice header.
//
this.startSlice();
- var mostDerivedId = this._current.typeId;
+ const mostDerivedId = this._current.typeId;
while(true)
{
- var userEx = this._stream.createUserException(this._current.typeId);
+ const userEx = this._stream.createUserException(this._current.typeId);
//
// We found the exception.
@@ -620,16 +631,18 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
this.startSlice();
}
- },
- startInstance: function(sliceType)
+ }
+
+ startInstance(sliceType)
{
Debug.assert(sliceType !== undefined);
Debug.assert(this._current.sliceType !== null && this._current.sliceType === sliceType);
this._current.skipFirstSlice = true;
- },
- endInstance: function(preserve)
+ }
+
+ endInstance(preserve)
{
- var slicedData = null;
+ let slicedData = null;
if(preserve)
{
slicedData = this.readSlicedData();
@@ -641,8 +654,9 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
}
this._current = this._current.previous;
return slicedData;
- },
- startSlice: function()
+ }
+
+ startSlice()
{
//
// If first slice, don't read the header, it was already read in
@@ -708,14 +722,10 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
}
return this._current.typeId;
- },
- endSlice: function()
- {
- var e,
- i,
- indirectionTable = [],
- length;
+ }
+ endSlice()
+ {
if((this._current.sliceFlags & Protocol.FLAG_HAS_OPTIONAL_MEMBERS) !== 0)
{
this._stream.skipOptionals();
@@ -727,11 +737,12 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
//
if((this._current.sliceFlags & Protocol.FLAG_HAS_INDIRECTION_TABLE) !== 0)
{
+ let indirectionTable = [];
//
// The table is written as a sequence<size> to conserve space.
//
- length = this._stream.readAndCheckSeqSize(1);
- for(i = 0; i < length; ++i)
+ let length = this._stream.readAndCheckSeqSize(1);
+ for(let i = 0; i < length; ++i)
{
indirectionTable[i] = this.readInstance(this._stream.readSize(), null);
}
@@ -746,7 +757,7 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
throw new Ice.MarshalException("empty indirection table");
}
if((this._current.indirectPatchList === null || this._current.indirectPatchList.length === 0) &&
- (this._current.sliceFlags & Protocol.FLAG_HAS_OPTIONAL_MEMBERS) === 0)
+ (this._current.sliceFlags & Protocol.FLAG_HAS_OPTIONAL_MEMBERS) === 0)
{
throw new Ice.MarshalException("no references to indirection table");
}
@@ -756,25 +767,25 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
//
if(this._current.indirectPatchList !== null)
{
- for(i = 0, length = this._current.indirectPatchList.length; i < length; ++i)
- {
- e = this._current.indirectPatchList[i];
- Debug.assert(e.index >= 0);
- if(e.index >= indirectionTable.length)
+ this._current.indirectPatchList.forEach(e =>
{
- throw new Ice.MarshalException("indirection out of range");
- }
- this.addPatchEntry(indirectionTable[e.index], e.cb);
- }
+ Debug.assert(e.index >= 0);
+ if(e.index >= indirectionTable.length)
+ {
+ throw new Ice.MarshalException("indirection out of range");
+ }
+ this.addPatchEntry(indirectionTable[e.index], e.cb);
+ });
this._current.indirectPatchList.length = 0;
}
}
- },
- skipSlice: function()
+ }
+
+ skipSlice()
{
this._stream.traceSkipSlice(this._current.typeId, this._current.sliceType);
- var start = this._stream.pos;
+ const start = this._stream.pos;
if((this._current.sliceFlags & Protocol.FLAG_HAS_SLICE_SIZE) !== 0)
{
@@ -805,15 +816,15 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
//
// Preserve this slice.
//
- var info = new Ice.SliceInfo();
+ const info = new Ice.SliceInfo();
info.typeId = this._current.typeId;
info.compactId = this._current.compactId;
info.hasOptionalMembers = (this._current.sliceFlags & Protocol.FLAG_HAS_OPTIONAL_MEMBERS) !== 0;
info.isLastSlice = (this._current.sliceFlags & Protocol.FLAG_IS_LAST_SLICE) !== 0;
- var b = this._stream._buf;
- var end = b.position;
- var dataEnd = end;
+ const b = this._stream._buf;
+ const end = b.position;
+ let dataEnd = end;
if(info.hasOptionalMembers)
{
//
@@ -841,9 +852,9 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
if((this._current.sliceFlags & Protocol.FLAG_HAS_INDIRECTION_TABLE) !== 0)
{
- var length = this._stream.readAndCheckSeqSize(1);
- var indirectionTable = [];
- for(var i = 0; i < length; ++i)
+ let length = this._stream.readAndCheckSeqSize(1);
+ let indirectionTable = [];
+ for(let i = 0; i < length; ++i)
{
indirectionTable[i] = this.readInstance(this._stream.readSize(), null);
}
@@ -855,8 +866,9 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
}
this._current.slices.push(info);
- },
- readOptional: function(readTag, expectedFormat)
+ }
+
+ readOptional(readTag, expectedFormat)
{
if(this._current === null)
{
@@ -867,13 +879,13 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
return this._stream.readOptImpl(readTag, expectedFormat);
}
return false;
- },
- readInstance: function(index, cb)
+ }
+
+ readInstance(index, cb)
{
Debug.assert(index > 0);
- var mostDerivedId,
- v = null;
+ let v = null;
if(index > 1)
{
@@ -897,7 +909,7 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
// Read the first slice header.
//
this.startSlice();
- mostDerivedId = this._current.typeId;
+ const mostDerivedId = this._current.typeId;
while(true)
{
if(this._current.compactId >= 0)
@@ -989,11 +1001,10 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
}
return index;
- },
- readSlicedData: function()
- {
- var i, ii, table, info, j, jj;
+ }
+ readSlicedData()
+ {
if(this._current.slices === null) // No preserved slices.
{
return null;
@@ -1004,7 +1015,7 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
// in _slices.
//
Debug.assert(this._current.slices.length === this._current.indirectionTables.length);
- for(i = 0, ii = this._current.slices.length; i < ii; ++i)
+ for(let i = 0; i < this._current.slices.length; ++i)
{
//
// We use the "instances" list in SliceInfo to hold references
@@ -1012,18 +1023,21 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
// been read yet in the case of a circular reference to an
// enclosing instance.
//
- table = this._current.indirectionTables[i];
- info = this._current.slices[i];
+ const table = this._current.indirectionTables[i];
+ const info = this._current.slices[i];
info.instances = [];
- jj = table ? table.length : 0;
- for(j = 0; j < jj; ++j)
+ if(table)
{
- this.addPatchEntry(table[j], sequencePatcher(info.instances, j, IceObject));
+ for(let j = 0; j < table.length; ++j)
+ {
+ this.addPatchEntry(table[j], sequencePatcher(info.instances, j, Ice.Object));
+ }
}
}
return new SlicedData(ArrayUtil.clone(this._current.slices));
- },
- push: function(sliceType)
+ }
+
+ push(sliceType)
{
if(this._current === null)
{
@@ -1036,34 +1050,37 @@ var EncapsDecoder11 = Class(EncapsDecoder, {
this._current.sliceType = sliceType;
this._current.skipFirstSlice = false;
}
-});
+}
-EncapsDecoder11.InstanceData = function(previous)
+EncapsDecoder11.InstanceData = class
{
- if(previous !== null)
+ constructor(previous)
{
- previous.next = this;
- }
- this.previous = previous;
- this.next = null;
-
- // Instance attributes
- this.sliceType = null;
- this.skipFirstSlice = false;
- this.slices = null; // Preserved slices. Ice.SliceInfo[]
- this.indirectionTables = null; // int[][]
+ if(previous !== null)
+ {
+ previous.next = this;
+ }
+ this.previous = previous;
+ this.next = null;
- // Slice attributes
- this.sliceFlags = 0;
- this.sliceSize = 0;
- this.typeId = null;
- this.compactId = 0;
- this.indirectPatchList = null; // Lazy initialized, IndirectPatchEntry[]
+ // Instance attributes
+ this.sliceType = null;
+ this.skipFirstSlice = false;
+ this.slices = null; // Preserved slices. Ice.SliceInfo[]
+ this.indirectionTables = null; // int[][]
+
+ // Slice attributes
+ this.sliceFlags = 0;
+ this.sliceSize = 0;
+ this.typeId = null;
+ this.compactId = 0;
+ this.indirectPatchList = null; // Lazy initialized, IndirectPatchEntry[]
+ }
};
-var sequencePatcher = function(seq, index, T)
+const sequencePatcher = function(seq, index, T)
{
- return function(v)
+ return v =>
{
if(v !== null && !(v instanceof T))
{
@@ -1073,8 +1090,9 @@ var sequencePatcher = function(seq, index, T)
};
};
-var ReadEncaps = Class({
- __init__: function()
+class ReadEncaps
+{
+ constructor()
{
this.start = 0;
this.sz = 0;
@@ -1082,22 +1100,25 @@ var ReadEncaps = Class({
this.encoding_1_0 = false;
this.decoder = null;
this.next = null;
- },
- reset: function()
+ }
+
+ reset()
{
this.decoder = null;
- },
- setEncoding: function(encoding)
+ }
+
+ setEncoding(encoding)
{
this.encoding = encoding;
this.encoding_1_0 = encoding.equals(Ice.Encoding_1_0);
}
-});
+}
-var InputStream = Class({
- __init__: function(arg1, arg2, arg3)
+class InputStream
+{
+ constructor(arg1, arg2, arg3)
{
- var args =
+ const args =
{
instance: null,
encoding: null,
@@ -1106,8 +1127,9 @@ var InputStream = Class({
};
this._checkArgs([arg1, arg2, arg3], args);
this._initialize(args);
- },
- _checkArgs: function(arr, args)
+ }
+
+ _checkArgs(arr, args)
{
//
// The constructor can accept a variety of argument combinations:
@@ -1133,43 +1155,43 @@ var InputStream = Class({
// (encoding, buffer)
// (encoding, buffer)
//
- for(i = 0; i < arr.length; ++i)
- {
- var arg = arr[i];
- if(arg !== null && arg !== undefined)
+ arr.forEach(arg =>
{
- if(arg.constructor === Ice.Communicator)
- {
- args.instance = arg.instance;
- }
- else if(arg.constructor === Ice.Instance)
- {
- args.instance = arg;
- }
- else if(arg.constructor === Ice.EncodingVersion)
- {
- args.encoding = arg;
- }
- else if(arg.constructor === Ice.Buffer)
- {
- args.buffer = arg;
- }
- else if(arg.constructor === Array)
+ if(arg !== null && arg !== undefined)
{
- args.bytes = arg;
- }
- else
- {
- throw new Ice.InitializationException("unknown argument to InputStream constructor");
+ if(arg.constructor === Ice.Communicator)
+ {
+ args.instance = arg.instance;
+ }
+ else if(arg.constructor === Ice.Instance)
+ {
+ args.instance = arg;
+ }
+ else if(arg.constructor === Ice.EncodingVersion)
+ {
+ args.encoding = arg;
+ }
+ else if(arg.constructor === Ice.Buffer)
+ {
+ args.buffer = arg;
+ }
+ else if(arg.constructor === Array)
+ {
+ args.bytes = arg;
+ }
+ else
+ {
+ throw new Ice.InitializationException("unknown argument to InputStream constructor");
+ }
}
- }
- }
+ });
if(args.buffer !== null && args.bytes !== null)
{
throw new Ice.InitializationException("invalid argument to InputStream constructor");
}
- },
- _initialize: function(args)
+ }
+
+ _initialize(args)
{
this._instance = args.instance;
this._encoding = args.encoding;
@@ -1204,7 +1226,7 @@ var InputStream = Class({
if(args.bytes !== null)
{
- this._buf = new Ice.Buffer(data);
+ this._buf = new Ice.Buffer(args.bytes);
}
else if(args.buffer !== null)
{
@@ -1214,16 +1236,18 @@ var InputStream = Class({
{
this._buf = new Ice.Buffer();
}
- },
+ }
+
//
// This function allows this object to be reused, rather than reallocated.
//
- reset: function()
+ reset()
{
this._buf.reset();
this.clear();
- },
- clear: function()
+ }
+
+ clear()
{
if(this._encapsStack !== null)
{
@@ -1236,33 +1260,17 @@ var InputStream = Class({
this._startSeq = -1;
this._sliceValues = true;
- },
- swap: function(other)
+ }
+
+ swap(other)
{
Debug.assert(this._instance === other._instance);
-
- var tmpBuf, tmpEncoding, tmpTraceSlicing, tmpClosure, tmpSliceValues, tmpStartSeq, tmpMinSeqSize, tmpSizePos,
- tmpVfm, tmpLogger, tmpCompactIdResolver;
-
- tmpBuf = other._buf;
- other._buf = this._buf;
- this._buf = tmpBuf;
-
- tmpEncoding = other._encoding;
- other._encoding = this._encoding;
- this._encoding = tmpEncoding;
-
- tmpTraceSlicing = other._traceSlicing;
- other._traceSlicing = this._traceSlicing;
- this._traceSlicing = tmpTraceSlicing;
-
- tmpClosure = other._closure;
- other._closure = this._closure;
- this._closure = tmpClosure;
-
- tmpSliceValues = other._sliceValues;
- other._sliceValues = this._sliceValues;
- this._sliceValues = tmpSliceValues;
+
+ [other._buf, this._buf] = [this._buf, other._buf];
+ [other._encoding, this._encoding] = [this._encoding, other._encoding];
+ [other._traceSlicing, this._traceSlicing] = [this._traceSlicing, other._traceSlicing];
+ [other._closure, this._closure] = [this._closure, other.closure];
+ [other._sliceValues, this._sliceValues] = [this._sliceValues, other._sliceValues];
//
// Swap is never called for InputStreams that have encapsulations being read/write. However,
@@ -1272,62 +1280,52 @@ var InputStream = Class({
this.resetEncapsulation();
other.resetEncapsulation();
- tmpStartSeq = other._startSeq;
- other._startSeq = this._startSeq;
- this._startSeq = tmpStartSeq;
-
- tmpMinSeqSize = other._minSeqSize;
- other._minSeqSize = this._minSeqSize;
- this._minSeqSize = tmpMinSeqSize;
-
- tmpSizePos = other._sizePos;
- other._sizePos = this._sizePos;
- this._sizePos = tmpSizePos;
-
- tmpVfm = other._valueFactoryManager;
- other._valueFactoryManager = this._valueFactoryManager;
- this._valueFactoryManager = tmpVfm;
-
- tmpLogger = other._logger;
- other._logger = this._logger;
- this._logger = tmpLogger;
+ [other._startSeq, this._startSeq] = [this._startSeq, other._startSeq];
+ [other._minSeqSize, this._minSeqSize] = [this._minSeqSize, other._minSeqSize];
+ [other._sizePos, this._sizePos] = [this._sizePos, other._sizePos];
+ [other._valueFactoryManager, this._valueFactoryManager] = [this._valueFactoryManager, other._valueFactoryManager];
+ [other._logger, this._logger] = [this._logger, other._logger];
+ [other._compactIdResolver, this._compactIdResolver] = [this._compactIdResolver, other._compactIdResolver];
+ }
- tmpCompactIdResolver = other._compactIdResolver;
- other._compactIdResolver = this._compactIdResolver;
- this._compactIdResolver = tmpCompactIdResolver;
- },
- resetEncapsulation: function()
+ resetEncapsulation()
{
this._encapsStack = null;
- },
- resize: function(sz)
+ }
+
+ resize(sz)
{
this._buf.resize(sz);
this._buf.position = sz;
- },
- startValue: function()
+ }
+
+ startValue()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
this._encapsStack.decoder.startInstance(SliceType.ValueSlice);
- },
- endValue: function(preserve)
+ }
+
+ endValue(preserve)
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
return this._encapsStack.decoder.endInstance(preserve);
- },
- startException: function()
+ }
+
+ startException()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
this._encapsStack.decoder.startInstance(SliceType.ExceptionSlice);
- },
- endException: function(preserve)
+ }
+
+ endException(preserve)
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
return this._encapsStack.decoder.endInstance(preserve);
- },
- startEncapsulation: function()
+ }
+
+ startEncapsulation()
{
- var curr = this._encapsCache;
+ let curr = this._encapsCache;
if(curr !== null)
{
curr.reset();
@@ -1347,7 +1345,7 @@ var InputStream = Class({
// I must know in advance how many bytes the size information will require in the data
// stream. If I use an Int, it is always 4 bytes. For readSize(), it could be 1 or 5 bytes.
//
- var sz = this.readInt();
+ const sz = this.readInt();
if(sz < 6)
{
throw new Ice.UnmarshalOutOfBoundsException();
@@ -1358,14 +1356,15 @@ var InputStream = Class({
}
this._encapsStack.sz = sz;
- var encoding = new Ice.EncodingVersion();
+ const encoding = new Ice.EncodingVersion();
encoding.__read(this);
Protocol.checkSupportedEncoding(encoding); // Make sure the encoding is supported.
this._encapsStack.setEncoding(encoding);
return encoding;
- },
- endEncapsulation: function()
+ }
+
+ endEncapsulation()
{
Debug.assert(this._encapsStack !== null);
@@ -1401,15 +1400,16 @@ var InputStream = Class({
}
}
- var curr = this._encapsStack;
+ const curr = this._encapsStack;
this._encapsStack = curr.next;
curr.next = this._encapsCache;
this._encapsCache = curr;
this._encapsCache.reset();
- },
- skipEmptyEncapsulation: function()
+ }
+
+ skipEmptyEncapsulation()
{
- var sz = this.readInt();
+ const sz = this.readInt();
if(sz < 6)
{
throw new Ice.EncapsulationException();
@@ -1419,7 +1419,7 @@ var InputStream = Class({
throw new Ice.UnmarshalOutOfBoundsException();
}
- var encoding = new Ice.EncodingVersion();
+ const encoding = new Ice.EncodingVersion();
encoding.__read(this);
if(encoding.equals(Ice.Encoding_1_0))
{
@@ -1435,11 +1435,12 @@ var InputStream = Class({
this._buf.position = this._buf.position + sz - 6;
}
return encoding;
- },
- readEncapsulation: function(encoding)
+ }
+
+ readEncapsulation(encoding)
{
Debug.assert(encoding !== undefined);
- var sz = this.readInt();
+ const sz = this.readInt();
if(sz < 6)
{
throw new Ice.UnmarshalOutOfBoundsException();
@@ -1468,24 +1469,27 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- getEncoding: function()
+ }
+
+ getEncoding()
{
return this._encapsStack !== null ? this._encapsStack.encoding : this._encoding;
- },
- getEncapsulationSize: function()
+ }
+
+ getEncapsulationSize()
{
Debug.assert(this._encapsStack !== null);
return this._encapsStack.sz - 6;
- },
- skipEncapsulation: function()
+ }
+
+ skipEncapsulation()
{
- var sz = this.readInt();
+ const sz = this.readInt();
if(sz < 6)
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- var encoding = new Ice.EncodingVersion();
+ const encoding = new Ice.EncodingVersion();
encoding.__read(this);
try
{
@@ -1496,23 +1500,27 @@ var InputStream = Class({
throw new Ice.UnmarshalOutOfBoundsException();
}
return encoding;
- },
- startSlice: function() // Returns type ID of next slice
+ }
+
+ startSlice() // Returns type ID of next slice
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
return this._encapsStack.decoder.startSlice();
- },
- endSlice: function()
+ }
+
+ endSlice()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
this._encapsStack.decoder.endSlice();
- },
- skipSlice: function()
+ }
+
+ skipSlice()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.decoder !== null);
this._encapsStack.decoder.skipSlice();
- },
- readPendingValues: function()
+ }
+
+ readPendingValues()
{
if(this._encapsStack !== null && this._encapsStack.decoder !== null)
{
@@ -1532,15 +1540,16 @@ var InputStream = Class({
//
this.skipSize();
}
- },
- readSize: function()
+ }
+
+ readSize()
{
try
{
- var b = this._buf.get();
+ const b = this._buf.get();
if(b === 255)
{
- var v = this._buf.getInt();
+ const v = this._buf.getInt();
if(v < 0)
{
throw new Ice.UnmarshalOutOfBoundsException();
@@ -1553,10 +1562,11 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readAndCheckSeqSize: function(minSize)
+ }
+
+ readAndCheckSeqSize(minSize)
{
- var sz = this.readSize();
+ const sz = this.readSize();
if(sz === 0)
{
@@ -1601,8 +1611,9 @@ var InputStream = Class({
}
return sz;
- },
- readBlob: function(sz)
+ }
+
+ readBlob(sz)
{
if(this._buf.remaining < sz)
{
@@ -1616,8 +1627,9 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readOptional: function(tag, expectedFormat)
+ }
+
+ readOptional(tag, expectedFormat)
{
Debug.assert(this._encapsStack !== null);
if(this._encapsStack.decoder !== null)
@@ -1625,8 +1637,9 @@ var InputStream = Class({
return this._encapsStack.decoder.readOptional(tag, expectedFormat);
}
return this.readOptImpl(tag, expectedFormat);
- },
- readOptionalHelper: function(tag, format, read)
+ }
+
+ readOptionalHelper(tag, format, read)
{
if(this.readOptional(tag, format))
{
@@ -1636,8 +1649,9 @@ var InputStream = Class({
{
return undefined;
}
- },
- readByte: function()
+ }
+
+ readByte()
{
try
{
@@ -1647,12 +1661,14 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readByteSeq: function()
+ }
+
+ readByteSeq()
{
return this._buf.getArray(this.readAndCheckSeqSize(1));
- },
- readBool: function()
+ }
+
+ readBool()
{
try
{
@@ -1662,8 +1678,9 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readShort: function()
+ }
+
+ readShort()
{
try
{
@@ -1673,8 +1690,9 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readInt: function()
+ }
+
+ readInt()
{
try
{
@@ -1684,8 +1702,9 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readLong: function()
+ }
+
+ readLong()
{
try
{
@@ -1695,8 +1714,9 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readFloat: function()
+ }
+
+ readFloat()
{
try
{
@@ -1706,8 +1726,9 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readDouble: function()
+ }
+
+ readDouble()
{
try
{
@@ -1717,10 +1738,11 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readString: function()
+ }
+
+ readString()
{
- var len = this.readSize();
+ const len = this.readSize();
if(len === 0)
{
return "";
@@ -1741,12 +1763,14 @@ var InputStream = Class({
{
throw new Ice.UnmarshalOutOfBoundsException();
}
- },
- readProxy: function(type)
+ }
+
+ readProxy(type)
{
return this._instance.proxyFactory().streamToProxy(this, type);
- },
- readOptionalProxy: function(tag, type)
+ }
+
+ readOptionalProxy(tag, type)
{
if(this.readOptional(tag, OptionalFormat.FSize))
{
@@ -1757,10 +1781,11 @@ var InputStream = Class({
{
return undefined;
}
- },
- readEnum: function(T)
+ }
+
+ readEnum(T)
{
- var v;
+ let v;
if(this.getEncoding().equals(Ice.Encoding_1_0))
{
if(T.maxValue < 127)
@@ -1781,14 +1806,15 @@ var InputStream = Class({
v = this.readSize();
}
- var e = T.valueOf(v);
+ const e = T.valueOf(v);
if(e === undefined)
{
throw new Ice.MarshalException("enumerator value " + v + " is out of range");
}
return e;
- },
- readOptionalEnum: function(tag, T)
+ }
+
+ readOptionalEnum(tag, T)
{
if(this.readOptional(tag, OptionalFormat.Size))
{
@@ -1798,8 +1824,9 @@ var InputStream = Class({
{
return undefined;
}
- },
- readValue: function(cb, T)
+ }
+
+ readValue(cb, T)
{
this.initEncaps();
//
@@ -1810,7 +1837,7 @@ var InputStream = Class({
//
this._encapsStack.decoder.readValue.call(
this._encapsStack.decoder,
- function(obj)
+ obj =>
{
if(obj !== null && !(obj.ice_instanceof(T)))
{
@@ -1818,8 +1845,9 @@ var InputStream = Class({
}
cb(obj);
});
- },
- readOptionalValue: function(tag, cb, T)
+ }
+
+ readOptionalValue(tag, cb, T)
{
if(this.readOptional(tag, OptionalFormat.Class))
{
@@ -1829,16 +1857,16 @@ var InputStream = Class({
{
cb(undefined);
}
- },
- throwException: function()
+ }
+
+ throwException()
{
this.initEncaps();
this._encapsStack.decoder.throwException();
- },
- readOptImpl: function(readTag, expectedFormat)
- {
- var b, v, format, tag, offset;
+ }
+ readOptImpl(readTag, expectedFormat)
+ {
if(this.isEncoding_1_0())
{
return false; // Optional members aren't supported with the 1.0 encoding.
@@ -1851,7 +1879,7 @@ var InputStream = Class({
return false; // End of encapsulation also indicates end of optionals.
}
- v = this.readByte();
+ const v = this.readByte();
if(v === Protocol.OPTIONAL_END_MARKER)
{
@@ -1859,8 +1887,8 @@ var InputStream = Class({
return false;
}
- format = OptionalFormat.valueOf(v & 0x07); // First 3 bits.
- tag = v >> 3;
+ const format = OptionalFormat.valueOf(v & 0x07); // First 3 bits.
+ let tag = v >> 3;
if(tag === 30)
{
tag = this.readSize();
@@ -1868,7 +1896,7 @@ var InputStream = Class({
if(tag > readTag)
{
- offset = tag < 30 ? 1 : (tag < 255 ? 2 : 6); // Rewind
+ const offset = tag < 30 ? 1 : (tag < 255 ? 2 : 6); // Rewind
this._buf.position -= offset;
return false; // No optional data members with the requested tag.
}
@@ -1885,8 +1913,9 @@ var InputStream = Class({
return true;
}
}
- },
- skipOptional: function(format)
+ }
+
+ skipOptional(format)
{
switch(format)
{
@@ -1915,10 +1944,10 @@ var InputStream = Class({
this.readValue(null, Ice.Object);
break;
}
- },
- skipOptionals: function()
+ }
+
+ skipOptionals()
{
- var b, v, format;
//
// Skip remaining un-read optional members.
//
@@ -1929,54 +1958,57 @@ var InputStream = Class({
return; // End of encapsulation also indicates end of optionals.
}
- b = this.readByte();
- v = b < 0 ? b + 256 : b;
+ const b = this.readByte();
+ const v = b < 0 ? b + 256 : b;
if(v === Protocol.OPTIONAL_END_MARKER)
{
return;
}
- format = OptionalFormat.valueOf(v & 0x07); // Read first 3 bits.
+ const format = OptionalFormat.valueOf(v & 0x07); // Read first 3 bits.
if((v >> 3) === 30)
{
this.skipSize();
}
this.skipOptional(format);
}
- },
- skip: function(size)
+ }
+
+ skip(size)
{
if(size > this._buf.remaining)
{
throw new Ice.UnmarshalOutOfBoundsException();
}
this._buf.position += size;
- },
- skipSize: function()
+ }
+
+ skipSize()
{
- var b = this.readByte();
+ const b = this.readByte();
if(b === 255)
{
this.skip(4);
}
- },
- isEmpty: function()
+ }
+
+ isEmpty()
{
return this._buf.empty();
- },
- expand: function(n)
+ }
+
+ expand(n)
{
this._buf.expand(n);
- },
- createInstance: function(id)
+ }
+
+ createInstance(id)
{
- var obj = null, Class;
+ let obj = null;
try
{
- var typeId = id.length > 2 ? id.substr(2).replace(/::/g, ".") : "";
- /*jshint -W061 */
- Class = __M.type(typeId);
- /*jshint +W061 */
+ const typeId = id.length > 2 ? id.substr(2).replace(/::/g, ".") : "";
+ const Class = __M.type(typeId);
if(Class !== undefined)
{
obj = new Class();
@@ -1988,17 +2020,16 @@ var InputStream = Class({
}
return obj;
- },
- createUserException: function(id)
+ }
+
+ createUserException(id)
{
- var userEx = null, Class;
+ let userEx = null, Class;
try
{
- var typeId = id.length > 2 ? id.substr(2).replace(/::/g, ".") : "";
- /*jshint -W061 */
- Class = __M.type(typeId);
- /*jshint +W061 */
+ const typeId = id.length > 2 ? id.substr(2).replace(/::/g, ".") : "";
+ const Class = __M.type(typeId);
if(Class !== undefined)
{
userEx = new Class();
@@ -2008,19 +2039,21 @@ var InputStream = Class({
{
throw new Ice.MarshalException(ex);
}
-
return userEx;
- },
- resolveCompactId: function(compactId)
+ }
+
+ resolveCompactId(compactId)
{
- var typeId = Ice.CompactIdRegistry.get(compactId);
+ const typeId = Ice.CompactIdRegistry.get(compactId);
return typeId === undefined ? "" : typeId;
- },
- isEncoding_1_0: function()
+ }
+
+ isEncoding_1_0()
{
return this._encapsStack !== null ? this._encapsStack.encoding_1_0 : this._encoding.equals(Ice.Encoding_1_0);
- },
- initEncaps: function()
+ }
+
+ initEncaps()
{
if(this._encapsStack === null) // Lazy initialization
{
@@ -2050,8 +2083,9 @@ var InputStream = Class({
this._valueFactoryManager, this._compactIdResolver);
}
}
- },
- traceSkipSlice: function(typeId, sliceType)
+ }
+
+ traceSkipSlice(typeId, sliceType)
{
if(this._traceSlicing && this._logger !== null)
{
@@ -2059,113 +2093,153 @@ var InputStream = Class({
this._logger);
}
}
-});
+
+ //
+ // Sets the value factory manager to use when marshaling value instances. If the stream
+ // was initialized with a communicator, the communicator's value factory manager will
+ // be used by default.
+ //
+ get valueFactoryManager()
+ {
+ return this._valueFactoryManager;
+ }
-var defineProperty = Object.defineProperty;
+ set valueFactoryManager(value)
+ {
+ this._valueFactoryManager = value !== undefined ? value : null;
+ }
-//
-// Sets the value factory manager to use when marshaling value instances. If the stream
-// was initialized with a communicator, the communicator's value factory manager will
-// be used by default.
-//
-defineProperty(InputStream.prototype, "valueFactoryManager", {
- get: function() { return this._valueFactoryManager; },
- set: function(vfm) { this._valueFactoryManager = vfm !== undefined ? vfm : null; }
-});
+ //
+ // Sets the logger to use when logging trace messages. If the stream
+ // was initialized with a communicator, the communicator's logger will
+ // be used by default.
+ //
+ get logger()
+ {
+ return this._logger;
+ }
-//
-// Sets the logger to use when logging trace messages. If the stream
-// was initialized with a communicator, the communicator's logger will
-// be used by default.
-//
-defineProperty(InputStream.prototype, "logger", {
- get: function() { return this._logger; },
- set: function(l) { this._logger = l !== undefined ? l : null; }
-});
+ set logger(value)
+ {
+ this._logger = value !== undefined ? value : null;
+ }
+
+ //
+ // Sets the compact ID resolver to use when unmarshaling value and exception
+ // instances. If the stream was initialized with a communicator, the communicator's
+ // resolver will be used by default.
+ //
+ get compactIdResolver()
+ {
+ return this._compactIdResolver;
+ }
-//
-// Sets the compact ID resolver to use when unmarshaling value and exception
-// instances. If the stream was initialized with a communicator, the communicator's
-// resolver will be used by default.
-//
-defineProperty(InputStream.prototype, "compactIdResolver", {
- get: function() { return this._compactIdResolver; },
- set: function(r) { this._compactIdResolver = r !== undefined ? r : null; }
-});
+ set compactIdResolver(value)
+ {
+ this._compactIdResolver = value !== undefined ? value : null;
+ }
-//
-// Determines the behavior of the stream when extracting instances of Slice classes.
-// A instance is "sliced" when a factory cannot be found for a Slice type ID.
-// The stream's default behavior is to slice instances.
-//
-// If slicing is disabled and the stream encounters a Slice type ID
-// during decoding for which no value factory is installed, it raises
-// NoValueFactoryException.
-//
-defineProperty(InputStream.prototype, "sliceValues", {
- get: function() { return this._sliceValues; },
- set: function(b) { this._sliceValues = b; }
-});
+ //
+ // Determines the behavior of the stream when extracting instances of Slice classes.
+ // A instance is "sliced" when a factory cannot be found for a Slice type ID.
+ // The stream's default behavior is to slice instances.
+ //
+ // If slicing is disabled and the stream encounters a Slice type ID
+ // during decoding for which no value factory is installed, it raises
+ // NoValueFactoryException.
+ //
+ get sliceValues()
+ {
+ return this._sliceValues;
+ }
-//
-// Determines whether the stream logs messages about slicing instances of Slice values.
-//
-defineProperty(InputStream.prototype, "traceSlicing", {
- get: function() { return this._traceSlicing; },
- set: function(b) { this._traceSlicing = b; }
-});
+ set sliceValues(value)
+ {
+ this._sliceValues = value;
+ }
+
+ //
+ // Determines whether the stream logs messages about slicing instances of Slice values.
+ //
+ get traceSlicing()
+ {
+ return this._traceSlicing;
+ }
-defineProperty(InputStream.prototype, "pos", {
- get: function() { return this._buf.position; },
- set: function(n) { this._buf.position = n; }
-});
+ set traceSlicing(value)
+ {
+ this._traceSlicing = value;
+ }
+
+ get pos()
+ {
+ return this._buf.position;
+ }
-defineProperty(InputStream.prototype, "size", {
- get: function() { return this._buf.limit; }
-});
+ set pos(value)
+ {
+ this._buf.position = value;
+ }
+
+ get size()
+ {
+ return this._buf.limit;
+ }
-defineProperty(InputStream.prototype, "instance", {
- get: function() { return this._instance; }
-});
+ get instance()
+ {
+ return this._instance;
+ }
-defineProperty(InputStream.prototype, "closure", {
- get: function() { return this._type; },
- set: function(type) { this._type = type; }
-});
+ get closure()
+ {
+ return this._type;
+ }
+
+ set closure(value)
+ {
+ this._type = value;
+ }
-defineProperty(InputStream.prototype, "buffer", {
- get: function() { return this._buf; }
-});
+ get buffer()
+ {
+ return this._buf;
+ }
+}
//
// OutputStream
//
-var EncapsEncoder = Class({
- __init__: function(stream, encaps)
+class EncapsEncoder
+{
+ constructor(stream, encaps)
{
this._stream = stream;
this._encaps = encaps;
- this._marshaledMap = new HashMap(); // HashMap<Ice.Object, int>;
- this._typeIdMap = null; // Lazy initialized. HashMap<String, int>
+ this._marshaledMap = new Map(); // Map<Ice.Object, int>;
+ this._typeIdMap = null; // Lazy initialized. Map<String, int>
this._typeIdIndex = 0;
- },
- writeOptional: function()
+ }
+
+ writeOptional()
{
return false;
- },
- writePendingValues: function()
+ }
+
+ writePendingValues()
{
return undefined;
- },
- registerTypeId: function(typeId)
+ }
+
+ registerTypeId(typeId)
{
if(this._typeIdMap === null) // Lazy initialization
{
- this._typeIdMap = new HashMap(); // HashMap<String, int>
+ this._typeIdMap = new Map(); // Map<String, int>
}
- var p = this._typeIdMap.get(typeId);
+ const p = this._typeIdMap.get(typeId);
if(p !== undefined)
{
return p;
@@ -2176,18 +2250,20 @@ var EncapsEncoder = Class({
return -1;
}
}
-});
+}
-var EncapsEncoder10 = Class(EncapsEncoder, {
- __init__: function(stream, encaps)
+class EncapsEncoder10 extends EncapsEncoder
+{
+ constructor(stream, encaps)
{
- EncapsEncoder.call(this, stream, encaps);
+ super(stream, encaps);
this._sliceType = SliceType.NoSlice;
this._writeSlice = 0; // Position of the slice data members
this._valueIdIndex = 0;
- this._toBeMarshaledMap = new HashMap(); // HashMap<Ice.Object, Integer>();
- },
- writeValue: function(v)
+ this._toBeMarshaledMap = new Map(); // Map<Ice.Object, Integer>();
+ }
+
+ writeValue(v)
{
Debug.assert(v !== undefined);
//
@@ -2201,8 +2277,9 @@ var EncapsEncoder10 = Class(EncapsEncoder, {
{
this._stream.writeInt(0);
}
- },
- writeUserException: function(v)
+ }
+
+ writeUserException(v)
{
Debug.assert(v !== null && v !== undefined);
//
@@ -2213,32 +2290,35 @@ var EncapsEncoder10 = Class(EncapsEncoder, {
// This allows reading the pending instances even if some part of
// the exception was sliced.
//
- var usesClasses = v.__usesClasses();
+ const usesClasses = v.__usesClasses();
this._stream.writeBool(usesClasses);
v.__write(this._stream);
if(usesClasses)
{
this.writePendingValues();
}
- },
- startInstance: function(sliceType)
+ }
+
+ startInstance(sliceType)
{
this._sliceType = sliceType;
- },
- endInstance: function()
+ }
+
+ endInstance()
{
if(this._sliceType === SliceType.ValueSlice)
{
//
// Write the Object slice.
//
- this.startSlice(IceObject.ice_staticId(), -1, true);
+ this.startSlice(Ice.Object.ice_staticId(), -1, true);
this._stream.writeSize(0); // For compatibility with the old AFM.
this.endSlice();
}
this._sliceType = SliceType.NoSlice;
- },
- startSlice: function(typeId)
+ }
+
+ startSlice(typeId)
{
//
// For instance slices, encode a boolean to indicate how the type ID
@@ -2247,7 +2327,7 @@ var EncapsEncoder10 = Class(EncapsEncoder, {
//
if(this._sliceType === SliceType.ValueSlice)
{
- var index = this.registerTypeId(typeId);
+ const index = this.registerTypeId(typeId);
if(index < 0)
{
this._stream.writeBool(false);
@@ -2267,40 +2347,38 @@ var EncapsEncoder10 = Class(EncapsEncoder, {
this._stream.writeInt(0); // Placeholder for the slice length.
this._writeSlice = this._stream.pos;
- },
- endSlice: function()
+ }
+
+ endSlice()
{
//
// Write the slice length.
//
- var sz = this._stream.pos - this._writeSlice + 4;
+ const sz = this._stream.pos - this._writeSlice + 4;
this._stream.rewriteInt(sz, this._writeSlice - 4);
- },
- writePendingValues: function()
+ }
+
+ writePendingValues()
{
- var self = this,
- writeCB = function(key, value)
- {
- //
- // Ask the instance to marshal itself. Any new class
- // instances that are triggered by the classes marshaled
- // are added to toBeMarshaledMap.
- //
- self._stream.writeInt(value);
-
- try
- {
- key.ice_preMarshal();
- }
- catch(ex)
- {
- self._stream.instance.initializationData().logger.warning(
- "exception raised by ice_preMarshal:\n" + ex.toString());
- }
-
- key.__write(self._stream);
- },
- savedMap;
+ const writeCB = (value, key) =>
+ {
+ //
+ // Ask the instance to marshal itself. Any new class
+ // instances that are triggered by the classes marshaled
+ // are added to toBeMarshaledMap.
+ //
+ this._stream.writeInt(value);
+ try
+ {
+ key.ice_preMarshal();
+ }
+ catch(ex)
+ {
+ this._stream.instance.initializationData().logger.warning(
+ "exception raised by ice_preMarshal:\n" + ex.toString());
+ }
+ key.__write(this._stream);
+ };
while(this._toBeMarshaledMap.size > 0)
{
@@ -2310,23 +2388,24 @@ var EncapsEncoder10 = Class(EncapsEncoder, {
// marshalled instances" into _toBeMarshaledMap while writing
// instances.
//
- this._marshaledMap.merge(this._toBeMarshaledMap);
+ this._toBeMarshaledMap.forEach((value, key) => this._marshaledMap.set(key, value));
- savedMap = this._toBeMarshaledMap;
- this._toBeMarshaledMap = new HashMap(); // HashMap<Ice.Object, int>();
+ const savedMap = this._toBeMarshaledMap;
+ this._toBeMarshaledMap = new Map(); // Map<Ice.Object, int>();
this._stream.writeSize(savedMap.size);
savedMap.forEach(writeCB);
}
this._stream.writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
- },
- registerValue: function(v)
+ }
+
+ registerValue(v)
{
Debug.assert(v !== null);
//
// Look for this instance in the to-be-marshaled map.
//
- var p = this._toBeMarshaledMap.get(v);
+ let p = this._toBeMarshaledMap.get(v);
if(p !== undefined)
{
return p;
@@ -2348,19 +2427,20 @@ var EncapsEncoder10 = Class(EncapsEncoder, {
this._toBeMarshaledMap.set(v, ++this._valueIdIndex);
return this._valueIdIndex;
}
-});
+}
-var EncapsEncoder11 = Class(EncapsEncoder, {
- __init__: function(stream, encaps)
+class EncapsEncoder11 extends EncapsEncoder
+{
+ constructor(stream, encaps)
{
- EncapsEncoder.call(this, stream, encaps);
+ super(stream, encaps);
this._current = null;
this._valueIdIndex = 1;
- },
- writeValue: function(v)
+ }
+
+ writeValue(v)
{
Debug.assert(v !== undefined);
- var index, idx;
if(v === null)
{
this._stream.writeSize(0);
@@ -2370,7 +2450,7 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
if(this._current.indirectionTable === null) // Lazy initialization
{
this._current.indirectionTable = []; // Ice.Object[]
- this._current.indirectionMap = new HashMap(); // HashMap<Ice.Object, int>
+ this._current.indirectionMap = new Map(); // Map<Ice.Object, int>
}
//
@@ -2380,11 +2460,11 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
// each slice and is always read (even if the Slice is
// unknown).
//
- index = this._current.indirectionMap.get(v);
+ const index = this._current.indirectionMap.get(v);
if(index === undefined)
{
this._current.indirectionTable.push(v);
- idx = this._current.indirectionTable.length; // Position + 1 (0 is reserved for nil)
+ const idx = this._current.indirectionTable.length; // Position + 1 (0 is reserved for nil)
this._current.indirectionMap.set(v, idx);
this._stream.writeSize(idx);
}
@@ -2397,17 +2477,20 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
{
this.writeInstance(v); // Write the instance or a reference if already marshaled.
}
- },
- writePendingValues: function()
+ }
+
+ writePendingValues()
{
return undefined;
- },
- writeUserException: function(v)
+ }
+
+ writeUserException(v)
{
Debug.assert(v !== null && v !== undefined);
v.__write(this._stream);
- },
- startInstance: function(sliceType, data)
+ }
+
+ startInstance(sliceType, data)
{
if(this._current === null)
{
@@ -2425,15 +2508,17 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
{
this.writeSlicedData(data);
}
- },
- endInstance: function()
+ }
+
+ endInstance()
{
this._current = this._current.previous;
- },
- startSlice: function(typeId, compactId, last)
+ }
+
+ startSlice(typeId, compactId, last)
{
Debug.assert((this._current.indirectionTable === null || this._current.indirectionTable.length === 0) &&
- (this._current.indirectionMap === null || this._current.indirectionMap.size === 0));
+ (this._current.indirectionMap === null || this._current.indirectionMap.size === 0));
this._current.sliceFlagsPos = this._stream.pos;
@@ -2470,7 +2555,7 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
}
else
{
- var index = this.registerTypeId(typeId);
+ const index = this.registerTypeId(typeId);
if(index < 0)
{
this._current.sliceFlags |= Protocol.FLAG_HAS_TYPE_ID_STRING;
@@ -2496,11 +2581,10 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
this._current.writeSlice = this._stream.pos;
this._current.firstSlice = false;
- },
- endSlice: function()
- {
- var sz, i, length;
+ }
+ endSlice()
+ {
//
// Write the optional member end marker if some optional members
// were encoded. Note that the optional members are encoded before
@@ -2516,7 +2600,7 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
//
if((this._current.sliceFlags & Protocol.FLAG_HAS_SLICE_SIZE) !== 0)
{
- sz = this._stream.pos - this._current.writeSlice + 4;
+ const sz = this._stream.pos - this._current.writeSlice + 4;
this._stream.rewriteInt(sz, this._current.writeSlice - 4);
}
@@ -2532,10 +2616,7 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
// Write the indirection instance table.
//
this._stream.writeSize(this._current.indirectionTable.length);
- for(i = 0, length = this._current.indirectionTable.length; i < length; ++i)
- {
- this.writeInstance(this._current.indirectionTable[i]);
- }
+ this._current.indirectionTable.forEach(o => this.writeInstance(o));
this._current.indirectionTable.length = 0; // Faster way to clean array in JavaScript
this._current.indirectionMap.clear();
}
@@ -2544,8 +2625,9 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
// Finally, update the slice flags.
//
this._stream.rewriteByte(this._current.sliceFlags, this._current.sliceFlagsPos);
- },
- writeOptional: function(tag, format)
+ }
+
+ writeOptional(tag, format)
{
if(this._current === null)
{
@@ -2559,8 +2641,9 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
}
return false;
- },
- writeSlicedData: function(slicedData)
+ }
+
+ writeSlicedData(slicedData)
{
Debug.assert(slicedData !== null && slicedData !== undefined);
@@ -2575,52 +2658,47 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
return;
}
- var i, ii, info,
- j, jj;
-
- for(i = 0, ii = slicedData.slices.length; i < ii; ++i)
- {
- info = slicedData.slices[i];
- this.startSlice(info.typeId, info.compactId, info.isLastSlice);
-
- //
- // Write the bytes associated with this slice.
- //
- this._stream.writeBlob(info.bytes);
-
- if(info.hasOptionalMembers)
+ slicedData.slices.forEach(info =>
{
- this._current.sliceFlags |= Protocol.FLAG_HAS_OPTIONAL_MEMBERS;
- }
+ this.startSlice(info.typeId, info.compactId, info.isLastSlice);
- //
- // Make sure to also re-write the instance indirection table.
- //
- if(info.instances !== null && info.instances.length > 0)
- {
- if(this._current.indirectionTable === null) // Lazy initialization
+ //
+ // Write the bytes associated with this slice.
+ //
+ this._stream.writeBlob(info.bytes);
+
+ if(info.hasOptionalMembers)
{
- this._current.indirectionTable = []; // Ice.Object[]
- this._current.indirectionMap = new HashMap(); // HashMap<Ice.Object, int>
+ this._current.sliceFlags |= Protocol.FLAG_HAS_OPTIONAL_MEMBERS;
}
- for(j = 0, jj = info.instances.length; j < jj; ++j)
+ //
+ // Make sure to also re-write the instance indirection table.
+ //
+ if(info.instances !== null && info.instances.length > 0)
{
- this._current.indirectionTable.push(info.instances[j]);
+ if(this._current.indirectionTable === null) // Lazy initialization
+ {
+ this._current.indirectionTable = []; // Ice.Object[]
+ this._current.indirectionMap = new Map(); // Map<Ice.Object, int>
+ }
+
+
+ info.instances.forEach(instance => this._current.indirectionTable.push(instance));
}
- }
- this.endSlice();
- }
- },
- writeInstance: function(v)
+ this.endSlice();
+ });
+ }
+
+ writeInstance(v)
{
Debug.assert(v !== null && v !== undefined);
//
// If the instance was already marshaled, just write it's ID.
//
- var p = this._marshaledMap.get(v);
+ const p = this._marshaledMap.get(v);
if(p !== undefined)
{
this._stream.writeSize(p);
@@ -2646,32 +2724,36 @@ var EncapsEncoder11 = Class(EncapsEncoder, {
this._stream.writeSize(1); // Object instance marker.
v.__write(this._stream);
}
-});
+}
-EncapsEncoder11.InstanceData = function(previous)
+EncapsEncoder11.InstanceData = class
{
- Debug.assert(previous !== undefined);
- if(previous !== null)
+ constructor(previous)
{
- previous.next = this;
- }
- this.previous = previous;
- this.next = null;
+ Debug.assert(previous !== undefined);
+ if(previous !== null)
+ {
+ previous.next = this;
+ }
+ this.previous = previous;
+ this.next = null;
- // Instance attributes
- this.sliceType = null;
- this.firstSlice = false;
+ // Instance attributes
+ this.sliceType = null;
+ this.firstSlice = false;
- // Slice attributes
- this.sliceFlags = 0;
- this.writeSlice = 0; // Position of the slice data members
- this.sliceFlagsPos = 0; // Position of the slice flags
- this.indirectionTable = null; // Ice.Object[]
- this.indirectionMap = null; // HashMap<Ice.Object, int>
+ // Slice attributes
+ this.sliceFlags = 0;
+ this.writeSlice = 0; // Position of the slice data members
+ this.sliceFlagsPos = 0; // Position of the slice flags
+ this.indirectionTable = null; // Ice.Object[]
+ this.indirectionMap = null; // Map<Ice.Object, int>
+ }
};
-var WriteEncaps = Class({
- __init__: function()
+class WriteEncaps
+{
+ constructor()
{
this.start = 0;
this.format = FormatType.DefaultFormat;
@@ -2679,20 +2761,23 @@ var WriteEncaps = Class({
this.encoding_1_0 = false;
this.encoder = null;
this.next = null;
- },
- reset: function()
+ }
+
+ reset()
{
this.encoder = null;
- },
- setEncoding: function(encoding)
+ }
+
+ setEncoding(encoding)
{
this.encoding = encoding;
this.encoding_1_0 = encoding.equals(Ice.Encoding_1_0);
}
-});
+}
-var OutputStream = Class({
- __init__: function(arg1, arg2)
+class OutputStream
+{
+ constructor(arg1, arg2)
{
this._instance = null;
this._encoding = null;
@@ -2752,16 +2837,18 @@ var OutputStream = Class({
}
this._format = FormatType.CompactFormat;
}
- },
+ }
+
//
// This function allows this object to be reused, rather than reallocated.
//
- reset: function()
+ reset()
{
this._buf.reset();
this.clear();
- },
- clear: function()
+ }
+
+ clear()
{
if(this._encapsStack !== null)
{
@@ -2771,29 +2858,20 @@ var OutputStream = Class({
this._encapsCache.reset();
this._encapsStack = null;
}
- },
- finished: function()
+ }
+
+ finished()
{
- var buf = this.prepareWrite();
- return buf.getArray(this.size);
- },
- swap: function(other)
+ return this.prepareWrite().getArray(this.size);
+ }
+
+ swap(other)
{
Debug.assert(this._instance === other._instance);
- var tmpBuf, tmpEncoding, tmpClosure;
-
- tmpBuf = other._buf;
- other._buf = this._buf;
- this._buf = tmpBuf;
-
- tmpEncoding = other._encoding;
- other._encoding = this._encoding;
- this._encoding = tmpEncoding;
-
- tmpClosure = other._closure;
- other._closure = this._closure;
- this._closure = tmpClosure;
+ [other._buf, this._buf] = [this._buf, other._buf];
+ [other._encoding, this._encoding] = [this._encoding, other._encoding];
+ [other._closure, this._closure] = [this._closure, other._closure];
//
// Swap is never called for streams that have encapsulations being written. However,
@@ -2802,42 +2880,50 @@ var OutputStream = Class({
//
this.resetEncapsulation();
other.resetEncapsulation();
- },
- resetEncapsulation: function()
+ }
+
+ resetEncapsulation()
{
this._encapsStack = null;
- },
- resize: function(sz)
+ }
+
+ resize(sz)
{
this._buf.resize(sz);
this._buf.position = sz;
- },
- prepareWrite: function()
+ }
+
+ prepareWrite()
{
this._buf.position = 0;
return this._buf;
- },
- startValue: function(data)
+ }
+
+ startValue(data)
{
Debug.assert(this._encapsStack !== null && this._encapsStack.encoder !== null);
this._encapsStack.encoder.startInstance(SliceType.ValueSlice, data);
- },
- endValue: function()
+ }
+
+ endValue()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.encoder !== null);
this._encapsStack.encoder.endInstance();
- },
- startException: function(data)
+ }
+
+ startException(data)
{
Debug.assert(this._encapsStack !== null && this._encapsStack.encoder !== null);
this._encapsStack.encoder.startInstance(SliceType.ExceptionSlice, data);
- },
- endException: function()
+ }
+
+ endException()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.encoder !== null);
this._encapsStack.encoder.endInstance();
- },
- startEncapsulation: function(encoding, format)
+ }
+
+ startEncapsulation(encoding, format)
{
//
// If no encoding version is specified, use the current write
@@ -2861,7 +2947,7 @@ var OutputStream = Class({
Protocol.checkSupportedEncoding(encoding);
- var curr = this._encapsCache;
+ let curr = this._encapsCache;
if(curr !== null)
{
curr.reset();
@@ -2880,29 +2966,32 @@ var OutputStream = Class({
this.writeInt(0); // Placeholder for the encapsulation length.
this._encapsStack.encoding.__write(this);
- },
- endEncapsulation: function()
+ }
+
+ endEncapsulation()
{
Debug.assert(this._encapsStack);
// Size includes size and version.
- var start = this._encapsStack.start;
- var sz = this._buf.limit - start;
+ const start = this._encapsStack.start;
+ const sz = this._buf.limit - start;
this._buf.putIntAt(start, sz);
- var curr = this._encapsStack;
+ const curr = this._encapsStack;
this._encapsStack = curr.next;
curr.next = this._encapsCache;
this._encapsCache = curr;
this._encapsCache.reset();
- },
- writeEmptyEncapsulation: function(encoding)
+ }
+
+ writeEmptyEncapsulation(encoding)
{
Protocol.checkSupportedEncoding(encoding);
this.writeInt(6); // Size
encoding.__write(this);
- },
- writeEncapsulation: function(v)
+ }
+
+ writeEncapsulation(v)
{
if(v.length < 6)
{
@@ -2910,22 +2999,26 @@ var OutputStream = Class({
}
this.expand(v.length);
this._buf.putArray(v);
- },
- getEncoding: function()
+ }
+
+ getEncoding()
{
return this._encapsStack !== null ? this._encapsStack.encoding : this._encoding;
- },
- startSlice: function(typeId, compactId, last)
+ }
+
+ startSlice(typeId, compactId, last)
{
Debug.assert(this._encapsStack !== null && this._encapsStack.encoder !== null);
this._encapsStack.encoder.startSlice(typeId, compactId, last);
- },
- endSlice: function()
+ }
+
+ endSlice()
{
Debug.assert(this._encapsStack !== null && this._encapsStack.encoder !== null);
this._encapsStack.encoder.endSlice();
- },
- writePendingValues: function()
+ }
+
+ writePendingValues()
{
if(this._encapsStack !== null && this._encapsStack.encoder !== null)
{
@@ -2945,8 +3038,9 @@ var OutputStream = Class({
//
this.writeSize(0);
}
- },
- writeSize: function(v)
+ }
+
+ writeSize(v)
{
if(v > 254)
{
@@ -2959,19 +3053,22 @@ var OutputStream = Class({
this.expand(1);
this._buf.put(v);
}
- },
- startSize: function()
+ }
+
+ startSize()
{
- var pos = this._buf.position;
+ const pos = this._buf.position;
this.writeInt(0); // Placeholder for 32-bit size
return pos;
- },
- endSize: function(pos)
+ }
+
+ endSize(pos)
{
Debug.assert(pos >= 0);
this.rewriteInt(this._buf.position - pos - 4, pos);
- },
- writeBlob: function(v)
+ }
+
+ writeBlob(v)
{
if(v === null)
{
@@ -2979,9 +3076,10 @@ var OutputStream = Class({
}
this.expand(v.length);
this._buf.putArray(v);
- },
+ }
+
// Read/write format and tag for optionals
- writeOptional: function(tag, format)
+ writeOptional(tag, format)
{
Debug.assert(this._encapsStack !== null);
if(this._encapsStack.encoder !== null)
@@ -2989,8 +3087,9 @@ var OutputStream = Class({
return this._encapsStack.encoder.writeOptional(tag, format);
}
return this.writeOptImpl(tag, format);
- },
- writeOptionalHelper: function(tag, format, write, v)
+ }
+
+ writeOptionalHelper(tag, format, write, v)
{
if(v !== undefined)
{
@@ -2999,17 +3098,20 @@ var OutputStream = Class({
write.call(this, v);
}
}
- },
- writeByte: function(v)
+ }
+
+ writeByte(v)
{
this.expand(1);
this._buf.put(v);
- },
- rewriteByte: function(v, dest)
+ }
+
+ rewriteByte(v, dest)
{
this._buf.putAt(dest, v);
- },
- writeByteSeq: function(v)
+ }
+
+ writeByteSeq(v)
{
if(v === null || v.length === 0)
{
@@ -3021,46 +3123,55 @@ var OutputStream = Class({
this.expand(v.length);
this._buf.putArray(v);
}
- },
- writeBool: function(v)
+ }
+
+ writeBool(v)
{
this.expand(1);
this._buf.put(v ? 1 : 0);
- },
- rewriteBool: function(v, dest)
+ }
+
+ rewriteBool(v, dest)
{
this._buf.putAt(dest, v ? 1 : 0);
- },
- writeShort: function(v)
+ }
+
+ writeShort(v)
{
this.expand(2);
this._buf.putShort(v);
- },
- writeInt: function(v)
+ }
+
+ writeInt(v)
{
this.expand(4);
this._buf.putInt(v);
- },
- rewriteInt: function(v, dest)
+ }
+
+ rewriteInt(v, dest)
{
this._buf.putIntAt(dest, v);
- },
- writeLong: function(v)
+ }
+
+ writeLong(v)
{
this.expand(8);
this._buf.putLong(v);
- },
- writeFloat: function(v)
+ }
+
+ writeFloat(v)
{
this.expand(4);
this._buf.putFloat(v);
- },
- writeDouble: function(v)
+ }
+
+ writeDouble(v)
{
this.expand(8);
this._buf.putDouble(v);
- },
- writeString: function(v)
+ }
+
+ writeString(v)
{
if(v === null || v.length === 0)
{
@@ -3070,8 +3181,9 @@ var OutputStream = Class({
{
this._buf.writeString(this, v);
}
- },
- writeProxy: function(v)
+ }
+
+ writeProxy(v)
{
if(v !== null)
{
@@ -3079,23 +3191,25 @@ var OutputStream = Class({
}
else
{
- var ident = new Ice.Identity();
+ const ident = new Ice.Identity();
ident.__write(this);
}
- },
- writeOptionalProxy: function(tag, v)
+ }
+
+ writeOptionalProxy(tag, v)
{
if(v !== undefined)
{
if(this.writeOptional(tag, OptionalFormat.FSize))
{
- var pos = this.startSize();
+ const pos = this.startSize();
this.writeProxy(v);
this.endSize(pos);
}
}
- },
- writeEnum: function(v)
+ }
+
+ writeEnum(v)
{
if(this.isEncoding_1_0())
{
@@ -3116,13 +3230,15 @@ var OutputStream = Class({
{
this.writeSize(v.value);
}
- },
- writeValue: function(v)
+ }
+
+ writeValue(v)
{
this.initEncaps();
this._encapsStack.encoder.writeValue(v);
- },
- writeOptionalValue: function(tag, v)
+ }
+
+ writeOptionalValue(tag, v)
{
if(v !== undefined)
{
@@ -3131,20 +3247,22 @@ var OutputStream = Class({
this.writeValue(v);
}
}
- },
- writeUserException: function(e)
+ }
+
+ writeUserException(e)
{
this.initEncaps();
this._encapsStack.encoder.writeUserException(e);
- },
- writeOptImpl: function(tag, format)
+ }
+
+ writeOptImpl(tag, format)
{
if(this.isEncoding_1_0())
{
return false; // Optional members aren't supported with the 1.0 encoding.
}
- var v = format.value;
+ let v = format.value;
if(tag < 30)
{
v |= tag << 3;
@@ -3157,20 +3275,24 @@ var OutputStream = Class({
this.writeSize(tag);
}
return true;
- },
- isEmpty: function()
+ }
+
+ isEmpty()
{
return this._buf.empty();
- },
- expand: function(n)
+ }
+
+ expand(n)
{
this._buf.expand(n);
- },
- isEncoding_1_0: function()
+ }
+
+ isEncoding_1_0()
{
return this._encapsStack ? this._encapsStack.encoding_1_0 : this._encoding.equals(Ice.Encoding_1_0);
- },
- initEncaps: function()
+ }
+
+ initEncaps()
{
if(!this._encapsStack) // Lazy initialization
{
@@ -3203,79 +3325,117 @@ var OutputStream = Class({
}
}
}
-});
+
+ //
+ // Sets the encoding format for class and exception instances.
+ //
+ get format()
+ {
+ return this._format;
+ }
-//
-// Sets the encoding format for class and exception instances.
-//
-defineProperty(OutputStream.prototype, "format", {
- get: function() { return this._format; },
- set: function(f) { this._format = f; }
-});
-
-defineProperty(OutputStream.prototype, "pos", {
- get: function() { return this._buf.position; },
- set: function(n) { this._buf.position = n; }
-});
-
-defineProperty(OutputStream.prototype, "size", {
- get: function() { return this._buf.limit; }
-});
-
-defineProperty(OutputStream.prototype, "instance", {
- get: function() { return this._instance; }
-});
-
-defineProperty(OutputStream.prototype, "closure", {
- get: function() { return this._closure; },
- set: function(closure) { this._closure = closure; }
-});
-
-defineProperty(OutputStream.prototype, "buffer", {
- get: function() { return this._buf; }
-});
-
-var defineBuiltinHelper = function(write, read, sz, format, min, max)
+ set format(value)
+ {
+ this._format = value;
+ }
+
+ get pos()
+ {
+ return this._buf.position;
+ }
+
+ set pos(value)
+ {
+ this._buf.position = value;
+ }
+
+ get size()
+ {
+ return this._buf.limit;
+ }
+
+ get instance()
+ {
+ return this._instance;
+ }
+
+ get closure()
+ {
+ return this._closure;
+ }
+
+ set closure(value)
+ {
+ this._closure = value;
+ }
+
+ get buffer()
+ {
+ return this._buf;
+ }
+}
+
+const defineBuiltinHelper = function(write, read, sz, format, min, max)
{
- var helper = {
- write: function(os, v) { return write.call(os, v); },
- read: function(is) { return read.call(is); },
- writeOptional: function(os, tag, v) { os.writeOptionalHelper(tag, format, write, v); },
- readOptional: function(is, tag) { return is.readOptionalHelper(tag, format, read); },
+ const helper = class
+ {
+ static write(os, v)
+ {
+ return write.call(os, v);
+ }
+
+ static read(is)
+ {
+ return read.call(is);
+ }
+
+ static writeOptional(os, tag, v)
+ {
+ os.writeOptionalHelper(tag, format, write, v);
+ }
+
+ static readOptional(is, tag)
+ {
+ return is.readOptionalHelper(tag, format, read);
+ }
+
+ static get minWireSize()
+ {
+ return sz;
+ }
};
if(min !== undefined && max !== undefined)
{
- helper.validate = function(v) {
+ helper.validate = function(v)
+ {
return v >= min && v <= max;
};
}
- defineProperty(helper, "minWireSize", {
- get: function() { return sz; }
- });
+
return helper;
};
-var istr = InputStream.prototype;
-var ostr = OutputStream.prototype;
+const istr = InputStream.prototype;
+const ostr = OutputStream.prototype;
//
// Constants to use in number type range checks.
//
-var MIN_UINT8_VALUE = 0x0;
-var MAX_UINT8_VALUE = 0xFF;
+const MIN_UINT8_VALUE = 0x0;
+const MAX_UINT8_VALUE = 0xFF;
-var MIN_INT16_VALUE = -0x8000;
-var MAX_INT16_VALUE = 0x7FFF;
+const MIN_INT16_VALUE = -0x8000;
+const MAX_INT16_VALUE = 0x7FFF;
-var MIN_UINT32_VALUE = 0x0;
-var MAX_UINT32_VALUE = 0xFFFFFFFF;
+const MIN_UINT32_VALUE = 0x0;
+const MAX_UINT32_VALUE = 0xFFFFFFFF;
-var MIN_INT32_VALUE = -0x80000000;
-var MAX_INT32_VALUE = 0x7FFFFFFF;
+const MIN_INT32_VALUE = -0x80000000;
+const MAX_INT32_VALUE = 0x7FFFFFFF;
-var MIN_FLOAT32_VALUE = -3.4028234664e+38;
-var MAX_FLOAT32_VALUE = 3.4028234664e+38;
+const MIN_FLOAT32_VALUE = -3.4028234664e+38;
+const MAX_FLOAT32_VALUE = 3.4028234664e+38;
Ice.ByteHelper = defineBuiltinHelper(ostr.writeByte, istr.readByte, 1, Ice.OptionalFormat.F1,
MIN_UINT8_VALUE, MAX_UINT8_VALUE);
@@ -3315,32 +3475,37 @@ Ice.LongHelper.validate = function(v)
Ice.StringHelper = defineBuiltinHelper(ostr.writeString, istr.readString, 1, Ice.OptionalFormat.VSize);
-Ice.ObjectHelper = {
- write: function(os, v)
+Ice.ObjectHelper = class
+{
+ static write(os, v)
{
os.writeValue(v);
- },
- read: function(is)
+ }
+
+ static read(is)
{
- var o;
- is.readValue(function(v) { o = v; }, Ice.Object);
+ let o;
+ is.readValue(v => o = v, Ice.Object);
return o;
- },
- writeOptional: function(os, tag, v)
+ }
+
+ static writeOptional(os, tag, v)
{
os.writeOptionalValue(tag, Ice.OptionalFormat.Class, ostr.writeValue, v);
- },
- readOptional: function(is, tag)
+ }
+
+ static readOptional(is, tag)
{
- var o;
- is.readOptionalValue(tag, function(v) { o = v; }, Ice.Object);
+ let o;
+ is.readOptionalValue(tag, v => o = v, Ice.Object);
return o;
- },
-};
+ }
-defineProperty(Ice.ObjectHelper, "minWireSize", {
- get: function() { return 1; }
-});
+ static get minWireSize()
+ {
+ return 1;
+ }
+};
Ice.InputStream = InputStream;
Ice.OutputStream = OutputStream;
diff --git a/js/src/Ice/StreamHelpers.js b/js/src/Ice/StreamHelpers.js
index bb50543fcfc..7f96cee8e2c 100644
--- a/js/src/Ice/StreamHelpers.js
+++ b/js/src/Ice/StreamHelpers.js
@@ -7,15 +7,12 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/HashMap", "../Ice/OptionalFormat"]);
+const Ice = require("../Ice/OptionalFormat").Ice;
-var Class = Ice.Class;
-var defineProperty = Object.defineProperty;
-var HashMap = Ice.HashMap;
-var OptionalFormat = Ice.OptionalFormat;
+const defineProperty = Object.defineProperty;
+const OptionalFormat = Ice.OptionalFormat;
-var StreamHelpers = {};
+const StreamHelpers = {};
StreamHelpers.FSizeOptHelper = function()
{
@@ -23,7 +20,7 @@ StreamHelpers.FSizeOptHelper = function()
{
if(v !== undefined && os.writeOptional(tag, OptionalFormat.FSize))
{
- var pos = os.startSize();
+ const pos = os.startSize();
this.write(os, v);
os.endSize(pos);
}
@@ -31,7 +28,7 @@ StreamHelpers.FSizeOptHelper = function()
this.readOptional = function(is, tag)
{
- var v;
+ let v;
if(is.readOptional(tag, OptionalFormat.FSize))
{
is.skip(4);
@@ -54,7 +51,7 @@ StreamHelpers.VSizeOptHelper = function()
this.readOptional = function(is, tag)
{
- var v;
+ let v;
if(is.readOptional(tag, OptionalFormat.VSize))
{
is.skipSize();
@@ -70,7 +67,7 @@ StreamHelpers.VSizeContainerOptHelper = function(elementSize)
{
if(v !== undefined && os.writeOptional(tag, OptionalFormat.VSize))
{
- var sz = this.size(v);
+ const sz = this.size(v);
os.writeSize(sz > 254 ? sz * elementSize + 5 : sz * elementSize + 1);
this.write(os, v);
}
@@ -78,7 +75,7 @@ StreamHelpers.VSizeContainerOptHelper = function(elementSize)
this.readOptional = function(is, tag)
{
- var v;
+ let v;
if(is.readOptional(tag, OptionalFormat.VSize))
{
is.skipSize();
@@ -100,7 +97,7 @@ StreamHelpers.VSizeContainer1OptHelper = function()
this.readOptional = function(is, tag)
{
- var v;
+ let v;
if(is.readOptional(tag, OptionalFormat.VSize))
{
v = this.read(is);
@@ -112,8 +109,9 @@ StreamHelpers.VSizeContainer1OptHelper = function()
//
// Sequence helper to write sequences
//
-var SequenceHelper = Class({
- write: function(os, v)
+class SequenceHelper
+{
+ write(os, v)
{
if(v === null || v.length === 0)
{
@@ -121,38 +119,43 @@ var SequenceHelper = Class({
}
else
{
- var helper = this.elementHelper;
+ const helper = this.elementHelper;
os.writeSize(v.length);
- for(var i = 0; i < v.length; ++i)
+ for(let i = 0; i < v.length; ++i)
{
helper.write(os, v[i]);
}
}
- },
- read: function(is)
+ }
+
+ read(is)
{
- var helper = this.elementHelper; // Cache the element helper.
- var sz = is.readAndCheckSeqSize(helper.minWireSize);
- var v = [];
+ const helper = this.elementHelper; // Cache the element helper.
+ const sz = is.readAndCheckSeqSize(helper.minWireSize);
+ const v = [];
v.length = sz;
- for(var i = 0; i < sz; ++i)
+ for(let i = 0; i < sz; ++i)
{
v[i] = helper.read(is);
}
return v;
- },
- size: function(v)
+ }
+
+ size(v)
{
return (v === null || v === undefined) ? 0 : v.length;
}
-});
+
+ get minWireSize()
+ {
+ return 1;
+ }
+}
+
-defineProperty(SequenceHelper.prototype, "minWireSize", {
- get: function(){ return 1; }
-});
// Speacialization optimized for ByteSeq
-var byteSeqHelper = new SequenceHelper();
+const byteSeqHelper = new SequenceHelper();
byteSeqHelper.write = function(os, v) { return os.writeByteSeq(v); };
byteSeqHelper.read = function(is) { return is.readByteSeq(); };
defineProperty(byteSeqHelper, "elementHelper", {
@@ -161,18 +164,18 @@ defineProperty(byteSeqHelper, "elementHelper", {
StreamHelpers.VSizeContainer1OptHelper.call(byteSeqHelper);
// Read method for value sequences
-var valueSequenceHelperRead = function(is)
+const valueSequenceHelperRead = function(is)
{
- var sz = is.readAndCheckSeqSize(1);
- var v = [];
+ const sz = is.readAndCheckSeqSize(1);
+ const v = [];
v.length = sz;
- var elementType = this.elementType;
- var readValueAtIndex = function(idx)
+ const elementType = this.elementType;
+ const readValueAtIndex = function(idx)
{
- is.readValue(function(obj) { v[idx] = obj; }, elementType);
+ is.readValue(obj => v[idx] = obj, elementType);
};
- for(var i = 0; i < sz; ++i)
+ for(let i = 0; i < sz; ++i)
{
readValueAtIndex(i);
}
@@ -186,7 +189,7 @@ StreamHelpers.generateSeqHelper = function(elementHelper, fixed, elementType)
return byteSeqHelper;
}
- var helper = new SequenceHelper();
+ const helper = new SequenceHelper();
if(fixed)
{
if(elementHelper.minWireSize === 1)
@@ -221,8 +224,9 @@ StreamHelpers.generateSeqHelper = function(elementHelper, fixed, elementType)
//
// Dictionary helper to write dictionaries
//
-var DictionaryHelper = Class({
- write: function(os, v)
+class DictionaryHelper
+{
+ write(os, v)
{
if(v === null || v.size === 0)
{
@@ -230,54 +234,57 @@ var DictionaryHelper = Class({
}
else
{
- var keyHelper = this.keyHelper;
- var valueHelper = this.valueHelper;
+ const keyHelper = this.keyHelper;
+ const valueHelper = this.valueHelper;
os.writeSize(v.size);
- for(var e = v.entries; e !== null; e = e.next)
+ for(let [key, value] of v)
{
- keyHelper.write(os, e.key);
- valueHelper.write(os, e.value);
+ keyHelper.write(os, key);
+ valueHelper.write(os, value);
}
}
- },
- read: function(is)
+ }
+
+ read(is)
{
- var mapType = this.mapType;
- var v = new mapType();
- var sz = is.readSize();
- var keyHelper = this.keyHelper;
- var valueHelper = this.valueHelper;
- for(var i = 0; i < sz; ++i)
+ const mapType = this.mapType;
+ const v = new mapType();
+ const sz = is.readSize();
+ const keyHelper = this.keyHelper;
+ const valueHelper = this.valueHelper;
+ for(let i = 0; i < sz; ++i)
{
v.set(keyHelper.read(is), valueHelper.read(is));
}
return v;
- },
- size: function(v)
+ }
+
+ size(v)
{
return (v === null || v === undefined) ? 0 : v.size;
}
-});
-
-Object.defineProperty(DictionaryHelper.prototype, "minWireSize", {
- get: function(){ return 1; }
-});
+
+ get minWireSize()
+ {
+ return 1;
+ }
+}
// Read method for dictionaries of values
-var valueDictionaryHelperRead = function(is)
+const valueDictionaryHelperRead = function(is)
{
- var sz = is.readSize();
- var mapType = this.mapType;
- var v = new mapType();
- var valueType = this.valueType;
+ const sz = is.readSize();
+ const mapType = this.mapType;
+ const v = new mapType();
+ const valueType = this.valueType;
- var readValueForKey = function(key)
+ const readValueForKey = function(key)
{
is.readValue(function(obj) { v.set(key, obj); }, valueType);
};
- var keyHelper = this.keyHelper;
- for(var i = 0; i < sz; ++i)
+ const keyHelper = this.keyHelper;
+ for(let i = 0; i < sz; ++i)
{
readValueForKey(keyHelper.read(is));
}
@@ -286,7 +293,7 @@ var valueDictionaryHelperRead = function(is)
StreamHelpers.generateDictHelper = function(keyHelper, valueHelper, fixed, valueType, mapType)
{
- var helper = new DictionaryHelper();
+ const helper = new DictionaryHelper();
if(fixed)
{
StreamHelpers.VSizeContainerOptHelper.call(helper, keyHelper.minWireSize + valueHelper.minWireSize);
@@ -295,12 +302,15 @@ StreamHelpers.generateDictHelper = function(keyHelper, valueHelper, fixed, value
{
StreamHelpers.FSizeOptHelper.call(helper);
}
+
defineProperty(helper, "mapType", {
get: function(){ return mapType; }
});
+
defineProperty(helper, "keyHelper", {
get: function(){ return keyHelper; }
});
+
defineProperty(helper, "valueHelper", {
get: function(){ return valueHelper; }
});
@@ -310,6 +320,7 @@ StreamHelpers.generateDictHelper = function(keyHelper, valueHelper, fixed, value
defineProperty(helper, "valueType", {
get: function(){ return valueType; }
});
+
helper.read = valueDictionaryHelperRead;
}
diff --git a/js/src/Ice/StringUtil.js b/js/src/Ice/StringUtil.js
index ff5e81da60b..1673f4d745a 100644
--- a/js/src/Ice/StringUtil.js
+++ b/js/src/Ice/StringUtil.js
@@ -7,66 +7,58 @@
//
// **********************************************************************
-var Ice = require("../Ice/Debug").Ice;
-var Debug = Ice.Debug;
+const Ice = require("../Ice/Debug").Ice;
+const Debug = Ice.Debug;
-Ice.StringUtil =
+Ice.StringUtil = class
{
//
// Return the index of the first character in str to
// appear in match, starting from start. Returns -1 if none is
// found.
//
- findFirstOf: function(str, match, start)
+ static findFirstOf(str, match, start)
{
start = start === undefined ? 0 : start;
-
- var len = str.length;
- for(var i = start; i < len; i++)
+ for(let i = start; i < str.length; i++)
{
- var ch = str.charAt(i);
+ const ch = str.charAt(i);
if(match.indexOf(ch) != -1)
{
return i;
}
}
-
return -1;
- },
+ }
//
// Return the index of the first character in str which does
// not appear in match, starting from start. Returns -1 if none is
// found.
//
- findFirstNotOf: function(str, match, start)
+ static findFirstNotOf(str, match, start)
{
start = start === undefined ? 0 : start;
-
- var len = str.length;
- for(var i = start; i < len; i++)
+ for(let i = start; i < str.length; i++)
{
- var ch = str.charAt(i);
+ const ch = str.charAt(i);
if(match.indexOf(ch) == -1)
{
return i;
}
}
-
return -1;
- },
+ }
//
// Add escape sequences (such as "\n", or "\007") to make a string
// readable in ASCII. Any characters that appear in special are
// prefixed with a backlash in the returned string.
//
- escapeString: function(s, special)
+ static escapeString(s, special)
{
special = special === undefined ? null : special;
-
- var i, length;
if(special !== null)
{
- for(i = 0, length = special.length; i < length; ++i)
+ for(let i = 0; i < special.length; ++i)
{
if(special.charCodeAt(i) < 32 || special.charCodeAt(i) > 126)
{
@@ -75,10 +67,10 @@ Ice.StringUtil =
}
}
- var result = [], c;
- for(i = 0, length = s.length; i < length; ++i)
+ let result = [];
+ for(let i = 0; i < s.length; ++i)
{
- c = s.charCodeAt(i);
+ const c = s.charCodeAt(i);
if(c < 128)
{
encodeChar(c, result, special);
@@ -97,33 +89,32 @@ Ice.StringUtil =
}
return result.join("");
- },
+ }
//
// Remove escape sequences added by escapeString. Throws Error
// for an invalid input string.
//
- unescapeString: function(s, start, end)
+ static unescapeString(s, start, end)
{
start = start === undefined ? 0 : start;
end = end === undefined ? s.length : end;
Debug.assert(start >= 0 && start <= end && end <= s.length);
- var arr = [];
+ const arr = [];
decodeString(s, start, end, arr);
return arr.join("");
- },
+ }
//
// Split string helper; returns null for unmatched quotes
//
- splitString: function(str, delim)
+ static splitString(str, delim)
{
- var v = [];
- var s = "";
- var pos = 0;
-
- var quoteChar = null;
+ const v = [];
+ let s = "";
+ let pos = 0;
+ let quoteChar = null;
while(pos < str.length)
{
if(quoteChar === null && (str.charAt(pos) === '"' || str.charAt(pos) === '\''))
@@ -177,24 +168,23 @@ Ice.StringUtil =
}
return v;
- },
+ }
//
// If a single or double quotation mark is found at the start position,
// then the position of the matching closing quote is returned. If no
// quotation mark is found at the start position, then 0 is returned.
// If no matching closing quote is found, then -1 is returned.
//
- checkQuote: function(s, start)
+ static checkQuote(s, start)
{
start = start === undefined ? 0 : start;
- var quoteChar = s.charAt(start);
+ let quoteChar = s.charAt(start);
if(quoteChar == '"' || quoteChar == '\'')
{
start++;
- var len = s.length;
- var pos;
- while(start < len && (pos = s.indexOf(quoteChar, start)) != -1)
+ let pos;
+ while(start < s.length && (pos = s.indexOf(quoteChar, start)) != -1)
{
if(s.charAt(pos - 1) != '\\')
{
@@ -205,22 +195,19 @@ Ice.StringUtil =
return -1; // Unmatched quote
}
return 0; // Not quoted
- },
- hashCode: function(s)
+ }
+ static hashCode(s)
{
- var hash = 0;
- var n = s.length;
-
- for(var i = 0; i < n; i++)
+ let hash = 0;
+ for(let i = 0; i < s.length; i++)
{
hash = 31 * hash + s.charCodeAt(i);
}
-
return hash;
- },
- toInt: function(s)
+ }
+ static toInt(s)
{
- var n = parseInt(s, 10);
+ const n = parseInt(s, 10);
if(isNaN(n))
{
throw new Error("conversion of `" + s + "' to int failed");
@@ -285,7 +272,7 @@ function encodeChar(b, sb, special)
if(!(b >= 32 && b <= 126))
{
sb.push('\\');
- var octal = b.toString(8);
+ const octal = b.toString(8);
//
// Add leading zeroes so that we avoid problems during
// decoding. For example, consider the encoded string
@@ -294,7 +281,7 @@ function encodeChar(b, sb, special)
// the result would be incorrectly interpreted by the
// decoder as a single character with value 11.
//
- for(var j = octal.length; j < 3; j++)
+ for(let j = octal.length; j < 3; j++)
{
sb.push('0');
}
@@ -302,7 +289,7 @@ function encodeChar(b, sb, special)
}
else
{
- var c = String.fromCharCode(b);
+ const c = String.fromCharCode(b);
if(special !== null && special.indexOf(c) !== -1)
{
sb.push('\\');
@@ -318,10 +305,10 @@ function encodeChar(b, sb, special)
}
function checkChar(s, pos)
{
- var n = s.charCodeAt(pos);
+ const n = s.charCodeAt(pos);
if(!(n >= 32 && n <= 126))
{
- var msg;
+ let msg;
if(pos > 0)
{
msg = "character after `" + s.substring(0, pos) + "'";
@@ -351,7 +338,7 @@ function decodeChar(s, start, end, nextStart)
throw new Error("EOF while decoding string");
}
- var c;
+ let c;
if(s.charAt(start) != '\\')
{
@@ -411,11 +398,11 @@ function decodeChar(s, start, end, nextStart)
case '6':
case '7':
{
- var octalChars = "01234567";
- var val = 0;
- for(var j = 0; j < 3 && start < end; ++j)
+ const octalChars = "01234567";
+ let val = 0;
+ for(let j = 0; j < 3 && start < end; ++j)
{
- var ch = s.charAt(start++);
+ const ch = s.charAt(start++);
if(octalChars.indexOf(ch) == -1)
{
--start;
@@ -425,8 +412,7 @@ function decodeChar(s, start, end, nextStart)
}
if(val > 255)
{
- var msg = "octal value \\" + val.toString(8) + " (" + val + ") is out of range";
- throw new Error(msg);
+ throw new Error("octal value \\" + val.toString(8) + " (" + val + ") is out of range");
}
c = val;
break;
@@ -448,10 +434,10 @@ function decodeChar(s, start, end, nextStart)
//
function decodeString(s, start, end, arr)
{
- var nextStart = { 'value': 0 }, c, c2, c3;
+ let nextStart = { 'value': 0 };
while(start < end)
{
- c = decodeChar(s, start, end, nextStart);
+ const c = decodeChar(s, start, end, nextStart);
start = nextStart.value;
if(c < 128)
@@ -460,15 +446,15 @@ function decodeString(s, start, end, arr)
}
else if(c > 191 && c < 224)
{
- c2 = decodeChar(s, start, end, nextStart);
+ const c2 = decodeChar(s, start, end, nextStart);
start = nextStart.value;
arr.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
}
else
{
- c2 = decodeChar(s, start, end, nextStart);
+ const c2 = decodeChar(s, start, end, nextStart);
start = nextStart.value;
- c3 = decodeChar(s, start, end, nextStart);
+ const c3 = decodeChar(s, start, end, nextStart);
start = nextStart.value;
arr.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
}
diff --git a/js/src/Ice/Struct.js b/js/src/Ice/Struct.js
index 7f283603bf9..566a3534981 100644
--- a/js/src/Ice/Struct.js
+++ b/js/src/Ice/Struct.js
@@ -7,7 +7,7 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
"../Ice/HashUtil",
@@ -15,14 +15,14 @@ Ice.__M.require(module,
"../Ice/StreamHelpers"
]);
-var ArrayUtil = Ice.ArrayUtil;
+const ArrayUtil = Ice.ArrayUtil;
//
// Use generic equality test from ArrayUtil.
//
-var eq = ArrayUtil.eq;
+const eq = ArrayUtil.eq;
-var equals = function(other)
+function equals(other)
{
if(this === other)
{
@@ -39,11 +39,10 @@ var equals = function(other)
return false;
}
- var e1, e2;
- for(var key in this)
+ for(let key in this)
{
- e1 = this[key];
- e2 = other[key];
+ let e1 = this[key];
+ let e2 = other[key];
if(typeof e1 == "function")
{
continue; // Don't need to compare functions
@@ -54,15 +53,14 @@ var equals = function(other)
}
}
return true;
-};
+}
-var clone = function()
+function clone()
{
- var other = new this.constructor();
- var e;
- for(var key in this)
+ const other = new this.constructor();
+ for(let key in this)
{
- e = this[key];
+ let e = this[key];
if(e === undefined || e === null)
{
other[key] = e;
@@ -85,9 +83,9 @@ var clone = function()
}
}
return other;
-};
+}
-var memberHashCode = function(h, e)
+function memberHashCode(h, e)
{
if(typeof e.hashCode == "function")
{
@@ -99,7 +97,7 @@ var memberHashCode = function(h, e)
}
else
{
- var t = typeof(e);
+ const t = typeof(e);
if(e instanceof String || t == "string")
{
return Ice.HashUtil.addString(h, e);
@@ -113,15 +111,14 @@ var memberHashCode = function(h, e)
return Ice.HashUtil.addBoolean(h, e);
}
}
-};
+}
-var hashCode = function()
+function hashCode()
{
- var __h = 5381;
- var e;
- for(var key in this)
+ let __h = 5381;
+ for(let key in this)
{
- e = this[key];
+ let e = this[key];
if(e === undefined || e === null || typeof e == "function")
{
continue;
@@ -129,12 +126,10 @@ var hashCode = function()
__h = memberHashCode(__h, e);
}
return __h;
-};
+}
-Ice.Slice.defineStruct = function(constructor, legalKeyType, writeImpl, readImpl, minWireSize, fixed)
+Ice.Slice.defineStruct = function(obj, legalKeyType, variableLength)
{
- var obj = constructor;
-
obj.prototype.clone = clone;
obj.prototype.equals = equals;
@@ -147,10 +142,8 @@ Ice.Slice.defineStruct = function(constructor, legalKeyType, writeImpl, readImpl
obj.prototype.hashCode = hashCode;
}
- if(readImpl && writeImpl)
+ if(obj.prototype.__write && obj.prototype.__read)
{
- obj.prototype.__write = writeImpl;
- obj.prototype.__read = readImpl;
obj.write = function(os, v)
{
if(!v)
@@ -163,6 +156,7 @@ Ice.Slice.defineStruct = function(constructor, legalKeyType, writeImpl, readImpl
}
v.__write(os);
};
+
obj.read = function(is, v)
{
if(!v || !(v instanceof this))
@@ -172,16 +166,14 @@ Ice.Slice.defineStruct = function(constructor, legalKeyType, writeImpl, readImpl
v.__read(is);
return v;
};
- Object.defineProperty(obj, "minWireSize", {
- get: function() { return minWireSize; }
- });
- if(fixed)
+
+ if(variableLength)
{
- Ice.StreamHelpers.VSizeOptHelper.call(obj);
+ Ice.StreamHelpers.FSizeOptHelper.call(obj);
}
else
{
- Ice.StreamHelpers.FSizeOptHelper.call(obj);
+ Ice.StreamHelpers.VSizeOptHelper.call(obj);
}
}
return obj;
diff --git a/js/src/Ice/TcpEndpointFactory.js b/js/src/Ice/TcpEndpointFactory.js
index ad7bc526ccd..64236d1f522 100644
--- a/js/src/Ice/TcpEndpointFactory.js
+++ b/js/src/Ice/TcpEndpointFactory.js
@@ -7,45 +7,50 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/TcpEndpointI"]);
+const Ice = require("../Ice/TcpEndpointI").Ice;
+const TcpEndpointI = Ice.TcpEndpointI;
-var TcpEndpointI = Ice.TcpEndpointI;
-
-var TcpEndpointFactory = Ice.Class({
- __init__: function(instance)
+class TcpEndpointFactory
+{
+ constructor(instance)
{
this._instance = instance;
- },
- type: function()
+ }
+
+ type()
{
return this._instance.type();
- },
- protocol: function()
+ }
+
+ protocol()
{
return this._instance.protocol();
- },
- create: function(args, oaEndpoint)
+ }
+
+ create(args, oaEndpoint)
{
- var e = new TcpEndpointI(this._instance);
+ const e = new TcpEndpointI(this._instance);
e.initWithOptions(args, oaEndpoint);
return e;
- },
- read: function(s)
+ }
+
+ read(s)
{
- var e = new TcpEndpointI(this._instance);
+ const e = new TcpEndpointI(this._instance);
e.initWithStream(s);
return e;
- },
- destroy: function()
+ }
+
+ destroy()
{
this._instance = null;
- },
- clone:function(instance)
+ }
+
+ clone(instance)
{
return new TcpEndpointFactory(instance);
}
-});
+}
Ice.TcpEndpointFactory = TcpEndpointFactory;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/TcpEndpointI.js b/js/src/Ice/TcpEndpointI.js
index 745ea52d10e..82a57feba39 100644
--- a/js/src/Ice/TcpEndpointI.js
+++ b/js/src/Ice/TcpEndpointI.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
"../Ice/HashUtil",
"../Ice/StringUtil",
@@ -20,44 +19,47 @@ Ice.__M.require(module,
"../Ice/EndpointInfo"
]);
-var IceSSL = Ice.__M.require(module, ["../Ice/EndpointInfo"]).IceSSL;
+const IceSSL = Ice.__M.require(module, ["../Ice/EndpointInfo"]).IceSSL;
-var Debug = Ice.Debug;
-var HashUtil = Ice.HashUtil;
-var StringUtil = Ice.StringUtil;
-var TcpTransceiver = typeof(Ice.TcpTransceiver) !== "undefined" ? Ice.TcpTransceiver : null;
-var Class = Ice.Class;
+const Debug = Ice.Debug;
+const HashUtil = Ice.HashUtil;
+const StringUtil = Ice.StringUtil;
+const TcpTransceiver = typeof(Ice.TcpTransceiver) !== "undefined" ? Ice.TcpTransceiver : null;
-var TcpEndpointI = Class(Ice.IPEndpointI, {
- __init__: function(instance, ho, po, sif, ti, conId, co)
+class TcpEndpointI extends Ice.IPEndpointI
+{
+ constructor(instance, ho, po, sif, ti, conId, co)
{
- Ice.IPEndpointI.call(this, instance, ho, po, sif, conId);
+ super(instance, ho, po, sif, conId);
this._timeout = ti === undefined ? (instance ? instance.defaultTimeout() : undefined) : ti;
this._compress = co === undefined ? false : co;
- },
+ }
+
//
// Return the endpoint information.
//
- getInfo: function()
+ getInfo()
{
- var info = new Ice.TCPEndpointInfo();
+ const info = new Ice.TCPEndpointInfo();
this.fillEndpointInfo(info);
return this.secure() ? new IceSSL.EndpointInfo(info, info.timeout, info.compress) : info;
- },
+ }
+
//
// Return the timeout for the endpoint in milliseconds. 0 means
// non-blocking, -1 means no timeout.
//
- timeout: function()
+ timeout()
{
return this._timeout;
- },
+ }
+
//
// Return a new endpoint with a different timeout value, provided
// that timeouts are supported by the endpoint. Otherwise the same
// endpoint is returned.
//
- changeTimeout: function(timeout)
+ changeTimeout(timeout)
{
if(timeout === this._timeout)
{
@@ -68,11 +70,12 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
return new TcpEndpointI(this._instance, this._host, this._port, this._sourceAddr, timeout,
this._connectionId, this._compress);
}
- },
+ }
+
//
// Return a new endpoint with a different connection id.
//
- changeConnectionId: function(connectionId)
+ changeConnectionId(connectionId)
{
if(connectionId === this._connectionId)
{
@@ -83,21 +86,23 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
return new TcpEndpointI(this._instance, this._host, this._port, this._sourceAddr, this._timeout,
connectionId, this._compress);
}
- },
+ }
+
//
// Return true if the endpoints support bzip2 compress, or false
// otherwise.
//
- compress: function()
+ compress()
{
return this._compress;
- },
+ }
+
//
// Return a new endpoint with a different compression value,
// provided that compression is supported by the
// endpoint. Otherwise the same endpoint is returned.
//
- changeCompress: function(compress)
+ changeCompress(compress)
{
if(compress === this._compress)
{
@@ -108,31 +113,35 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
return new TcpEndpointI(this._instance, this._host, this._port, this._sourceAddr, this._timeout,
this._connectionId, compress);
}
- },
+ }
+
//
// Return true if the endpoint is datagram-based.
//
- datagram: function()
+ datagram()
{
return false;
- },
- connectable: function()
+ }
+
+ connectable()
{
//
// TCP endpoints are not connectable when running in a browser, SSL
// isn't currently supported.
//
return TcpTransceiver !== null && !this.secure();
- },
- connect: function()
+ }
+
+ connect()
{
Debug.assert(!this.secure());
return TcpTransceiver.createOutgoing(this._instance, this.getAddress(), this._sourceAddr);
- },
+ }
+
//
// Convert the endpoint to its string form
//
- options: function()
+ options()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
@@ -141,7 +150,7 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
// these features. Please review for all features that depend on the
// format of proxyToString() before changing this and related code.
//
- var s = Ice.IPEndpointI.prototype.options.call(this);
+ let s = super.options();
if(this._timeout == -1)
{
s += " -t infinite";
@@ -156,8 +165,9 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
s += " -z";
}
return s;
- },
- compareTo: function(p)
+ }
+
+ compareTo(p)
{
if(this === p)
{
@@ -192,36 +202,41 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
return 1;
}
- return Ice.IPEndpointI.prototype.compareTo.call(this, p);
- },
- streamWriteImpl: function(s)
+ return super.compareTo(p);
+ }
+
+ streamWriteImpl(s)
{
- Ice.IPEndpointI.prototype.streamWriteImpl.call(this, s);
+ super.streamWriteImpl(s);
s.writeInt(this._timeout);
s.writeBool(this._compress);
- },
- hashInit: function(h)
+ }
+
+ hashInit(h)
{
- h = Ice.IPEndpointI.prototype.hashInit.call(this, h);
+ h = super.hashInit(h);
h = HashUtil.addNumber(h, this._timeout);
h = HashUtil.addBoolean(h, this._compress);
return h;
- },
- fillEndpointInfo: function(info)
+ }
+
+ fillEndpointInfo(info)
{
- Ice.IPEndpointI.prototype.fillEndpointInfo.call(this, info);
+ super.fillEndpointInfo(info);
info.timeout = this._timeout;
info.compress = this._compress;
- },
- initWithStream: function(s)
+ }
+
+ initWithStream(s)
{
- Ice.IPEndpointI.prototype.initWithStream.call(this, s);
+ super.initWithStream(s);
this._timeout = s.readInt();
this._compress = s.readBool();
- },
- checkOption: function(option, argument, endpoint)
+ }
+
+ checkOption(option, argument, endpoint)
{
- if(Ice.IPEndpointI.prototype.checkOption.call(this, option, argument, endpoint))
+ if(super.checkOption(option, argument, endpoint))
{
return true;
}
@@ -239,7 +254,7 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
}
else
{
- var invalid = false;
+ let invalid = false;
try
{
this._timeout = StringUtil.toInt(argument);
@@ -270,12 +285,13 @@ var TcpEndpointI = Class(Ice.IPEndpointI, {
return false;
}
return true;
- },
- createEndpoint: function(host, port, conId)
+ }
+
+ createEndpoint(host, port, conId)
{
return new TcpEndpointI(this._instance, host, port, this._sourceAddr, this._timeout, conId, this._compress);
}
-});
+}
Ice.TcpEndpointI = TcpEndpointI;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js
index 396c8b79ce1..99950fd8aa3 100644
--- a/js/src/Ice/TcpTransceiver.js
+++ b/js/src/Ice/TcpTransceiver.js
@@ -7,12 +7,11 @@
//
// **********************************************************************
-var net = require("net");
+const net = require("net");
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
"../Ice/ExUtil",
"../Ice/SocketOperation",
@@ -22,39 +21,41 @@ Ice.__M.require(module,
"../Ice/Timer"
]);
-var Debug = Ice.Debug;
-var ExUtil = Ice.ExUtil;
-var Network = Ice.Network;
-var SocketOperation = Ice.SocketOperation;
-var LocalException = Ice.LocalException;
-var SocketException = Ice.SocketException;
-var Timer = Ice.Timer;
-
-var StateNeedConnect = 0;
-var StateConnectPending = 1;
-var StateProxyConnectRequest = 2;
-var StateProxyConnectRequestPending = 3;
-var StateConnected = 4;
-var StateClosed = 5;
-
-var TcpTransceiver = Ice.Class({
- __init__: function(instance)
+const Debug = Ice.Debug;
+const ExUtil = Ice.ExUtil;
+const Network = Ice.Network;
+const SocketOperation = Ice.SocketOperation;
+const LocalException = Ice.LocalException;
+const SocketException = Ice.SocketException;
+const Timer = Ice.Timer;
+
+const StateNeedConnect = 0;
+const StateConnectPending = 1;
+const StateProxyConnectRequest = 2;
+const StateProxyConnectRequestPending = 3;
+const StateConnected = 4;
+const StateClosed = 5;
+
+class TcpTransceiver
+{
+ constructor(instance)
{
this._logger = instance.logger();
this._readBuffers = [];
this._readPosition = 0;
this._maxSendPacketSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", 512 * 1024);
- },
- setCallbacks: function(connectedCallback, bytesAvailableCallback, bytesWrittenCallback)
+ }
+
+ setCallbacks(connectedCallback, bytesAvailableCallback, bytesWrittenCallback)
{
this._connectedCallback = connectedCallback;
this._bytesAvailableCallback = bytesAvailableCallback;
this._bytesWrittenCallback = bytesWrittenCallback;
- },
+ }
//
// Returns SocketOperation.None when initialization is complete.
//
- initialize: function(readBuffer, writeBuffer)
+ initialize(readBuffer, writeBuffer)
{
try
{
@@ -70,9 +71,8 @@ var TcpTransceiver = Ice.Class({
host: this._addr.host,
localAddress: this._sourceAddr});
- var self = this;
- this._fd.on("connect", function() { self.socketConnected(); });
- this._fd.on("data", function(buf) { self.socketBytesAvailable(buf); });
+ this._fd.on("connect", () => this.socketConnected());
+ this._fd.on("data", buf => this.socketBytesAvailable(buf));
//
// The error callback can be triggered from the socket
@@ -81,8 +81,8 @@ var TcpTransceiver = Ice.Class({
// setImmediate. We do the same for close as a
// precaution. See also issue #6226.
//
- this._fd.on("close", function(err) { Timer.setImmediate(function() { self.socketClosed(err); }); });
- this._fd.on("error", function(err) { Timer.setImmediate(function() { self.socketError(err); }); });
+ this._fd.on("close", err => Timer.setImmediate(() => this.socketClosed(err)));
+ this._fd.on("error", err => Timer.setImmediate(() => this.socketError(err)));
return SocketOperation.Connect; // Waiting for connect to complete.
}
@@ -123,8 +123,9 @@ var TcpTransceiver = Ice.Class({
Debug.assert(this._state === StateConnected);
return SocketOperation.None;
- },
- register: function()
+ }
+
+ register()
{
this._registered = true;
this._fd.resume();
@@ -132,8 +133,9 @@ var TcpTransceiver = Ice.Class({
{
this._bytesAvailableCallback();
}
- },
- unregister: function()
+ }
+
+ unregister()
{
if(this._fd === null)
{
@@ -142,8 +144,9 @@ var TcpTransceiver = Ice.Class({
}
this._registered = false;
this._fd.pause();
- },
- close: function()
+ }
+
+ close()
{
if(this._fd === null)
{
@@ -163,19 +166,18 @@ var TcpTransceiver = Ice.Class({
{
this._fd = null;
}
- },
+ }
//
// Returns true if all of the data was flushed to the kernel buffer.
//
- write: function(byteBuffer)
+ write(byteBuffer)
{
if(this._exception)
{
throw this._exception;
}
- var bytesTotal = byteBuffer.remaining;
- var packetSize = bytesTotal;
+ let packetSize = byteBuffer.remaining;
Debug.assert(packetSize > 0);
if(this._maxSendPacketSize > 0 && packetSize > this._maxSendPacketSize)
@@ -185,17 +187,17 @@ var TcpTransceiver = Ice.Class({
while(packetSize > 0)
{
- var slice = byteBuffer.b.slice(byteBuffer.position, byteBuffer.position + packetSize);
+ const slice = byteBuffer.b.slice(byteBuffer.position, byteBuffer.position + packetSize);
- var self = this;
- var sync = true;
+ let sync = true;
/*jshint -W083 */
- sync = this._fd.write(slice, null, function() {
- if(!sync)
+ sync = this._fd.write(new Buffer(slice), null, () =>
{
- self._bytesWrittenCallback();
- }
- });
+ if(!sync)
+ {
+ this._bytesWrittenCallback();
+ }
+ });
/*jshint +W083 */
byteBuffer.position = byteBuffer.position + packetSize;
@@ -214,8 +216,9 @@ var TcpTransceiver = Ice.Class({
}
}
return true;
- },
- read: function(byteBuffer, moreData)
+ }
+
+ read(byteBuffer, moreData)
{
if(this._exception)
{
@@ -229,9 +232,8 @@ var TcpTransceiver = Ice.Class({
return false; // No data available.
}
- var avail = this._readBuffers[0].length - this._readPosition;
+ let avail = this._readBuffers[0].length - this._readPosition;
Debug.assert(avail > 0);
- var remaining = byteBuffer.remaining;
while(byteBuffer.remaining > 0)
{
@@ -240,8 +242,8 @@ var TcpTransceiver = Ice.Class({
avail = byteBuffer.remaining;
}
- this._readBuffers[0].copy(byteBuffer.b, byteBuffer.position, this._readPosition,
- this._readPosition + avail);
+ this._readBuffers[0].copy(new Buffer(byteBuffer.b), byteBuffer.position, this._readPosition,
+ this._readPosition + avail);
byteBuffer.position += avail;
this._readPosition += avail;
@@ -265,15 +267,17 @@ var TcpTransceiver = Ice.Class({
moreData.value = this._readBuffers.length > 0;
return byteBuffer.remaining === 0;
- },
- type: function()
+ }
+
+ type()
{
return "tcp";
- },
- getInfo: function()
+ }
+
+ getInfo()
{
Debug.assert(this._fd !== null);
- var info = new Ice.TCPConnectionInfo();
+ const info = new Ice.TCPConnectionInfo();
info.localAddress = this._fd.localAddress;
info.localPort = this._fd.localPort;
info.remoteAddress = this._fd.remoteAddress;
@@ -281,24 +285,29 @@ var TcpTransceiver = Ice.Class({
info.rcvSize = -1;
info.sndSize = this._maxSendPacketSize;
return info;
- },
- checkSendSize: function(stream)
+ }
+
+ checkSendSize(stream)
{
- },
- setBufferSize: function(rcvSize, sndSize)
+ }
+
+ setBufferSize(rcvSize, sndSize)
{
this._maxSendPacketSize = sndSize;
- },
- toString: function()
+ }
+
+ toString()
{
return this._desc;
- },
- socketConnected: function()
+ }
+
+ socketConnected()
{
Debug.assert(this._connectedCallback !== null);
this._connectedCallback();
- },
- socketBytesAvailable: function(buf)
+ }
+
+ socketBytesAvailable(buf)
{
Debug.assert(this._bytesAvailableCallback !== null);
@@ -311,8 +320,9 @@ var TcpTransceiver = Ice.Class({
this._readBuffers.push(buf);
this._bytesAvailableCallback();
}
- },
- socketClosed: function(err)
+ }
+
+ socketClosed(err)
{
//
// Don't call the closed callback if an error occurred; the error callback
@@ -322,8 +332,9 @@ var TcpTransceiver = Ice.Class({
{
this.socketError(null);
}
- },
- socketError: function(err)
+ }
+
+ socketError(err)
{
this._exception = translateError(this._state, err);
if(this._state < StateConnected)
@@ -335,7 +346,37 @@ var TcpTransceiver = Ice.Class({
this._bytesAvailableCallback();
}
}
-});
+
+ static createOutgoing(instance, addr, sourceAddr)
+ {
+ const transceiver = new TcpTransceiver(instance);
+
+ transceiver._fd = null;
+ transceiver._addr = addr;
+ transceiver._sourceAddr = sourceAddr;
+ transceiver._desc = "local address = <not connected>\nremote address = " + addr.host + ":" + addr.port;
+ transceiver._state = StateNeedConnect;
+ transceiver._registered = false;
+ transceiver._exception = null;
+
+ return transceiver;
+ }
+
+ static createIncoming(instance, fd)
+ {
+ const transceiver = new TcpTransceiver(instance);
+
+ transceiver._fd = fd;
+ transceiver._addr = null;
+ transceiver._sourceAddr = null;
+ transceiver._desc = fdToString(fd);
+ transceiver._state = StateConnected;
+ transceiver._registered = false;
+ transceiver._exception = null;
+
+ return transceiver;
+ }
+}
function fdToString(fd, targetAddr)
{
@@ -376,7 +417,7 @@ function addressesToString(localHost, localPort, remoteHost, remotePort, targetA
remoteHost = remoteHost === undefined ? null : remoteHost;
targetAddr = targetAddr === undefined ? null : targetAddr;
- var s = [];
+ const s = [];
s.push("local address = ");
s.push(localHost + ":" + localPort);
@@ -399,46 +440,16 @@ function addressesToString(localHost, localPort, remoteHost, remotePort, targetA
return s.join("");
}
-TcpTransceiver.createOutgoing = function(instance, addr, sourceAddr)
-{
- var transceiver = new TcpTransceiver(instance);
-
- transceiver._fd = null;
- transceiver._addr = addr;
- transceiver._sourceAddr = sourceAddr;
- transceiver._desc = "local address = <not connected>\nremote address = " + addr.host + ":" + addr.port;
- transceiver._state = StateNeedConnect;
- transceiver._registered = false;
- transceiver._exception = null;
- return transceiver;
-};
-
-TcpTransceiver.createIncoming = function(instance, fd)
-{
- var transceiver = new TcpTransceiver(instance);
-
- transceiver._fd = fd;
- transceiver._addr = null;
- transceiver._sourceAddr = null;
- transceiver._desc = fdToString(fd);
- transceiver._state = StateConnected;
- transceiver._registered = false;
- transceiver._exception = null;
-
- return transceiver;
-};
-
-
-var ECONNABORTED = "ECONNABORTED";
-var ECONNREFUSED = "ECONNREFUSED";
-var ECONNRESET = "ECONNRESET";
-var EHOSTUNREACH = "EHOSTUNREACH";
-var ENETUNREACH = "ENETUNREACH";
-var ENOTCONN = "ENOTCONN";
-var EPIPE = "EPIPE";
-var ESHUTDOWN = "ESHUTDOWN";
-var ETIMEDOUT = "ETIMEDOUT";
+const ECONNABORTED = "ECONNABORTED";
+const ECONNREFUSED = "ECONNREFUSED";
+const ECONNRESET = "ECONNRESET";
+const EHOSTUNREACH = "EHOSTUNREACH";
+const ENETUNREACH = "ENETUNREACH";
+const ENOTCONN = "ENOTCONN";
+const EPIPE = "EPIPE";
+const ESHUTDOWN = "ESHUTDOWN";
+const ETIMEDOUT = "ETIMEDOUT";
function connectionRefused(err)
{
diff --git a/js/src/Ice/Timer.js b/js/src/Ice/Timer.js
index d87f6671d10..67d849c5140 100644
--- a/js/src/Ice/Timer.js
+++ b/js/src/Ice/Timer.js
@@ -7,66 +7,60 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/HashMap", "../Ice/LocalException", "../Ice/Class", "../Ice/TimerUtil"]);
+const Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, ["../Ice/LocalException", "../Ice/TimerUtil"]);
-var HashMap = Ice.HashMap;
-var CommunicatorDestroyedException = Ice.CommunicatorDestroyedException;
+const CommunicatorDestroyedException = Ice.CommunicatorDestroyedException;
-var Timer = Ice.Class({
- __init__: function(logger)
+class Timer
+{
+ constructor(logger)
{
this._logger = logger;
this._destroyed = false;
this._tokenId = 0;
- this._tokens = new HashMap();
- },
- destroy: function()
+ this._tokens = new Map();
+ }
+
+ destroy()
{
- var self = this;
- this._tokens.forEach(function(key, value){
- self.cancel(key);
- });
+ this._tokens.forEach((value, key) => this.cancel(key));
this._destroyed = true;
this._tokens.clear();
- },
- schedule: function(callback, delay)
+ }
+
+ schedule(callback, delay)
{
if(this._destroyed)
{
throw new CommunicatorDestroyedException();
}
-
- var token = this._tokenId++;
- var self = this;
- var id = Timer.setTimeout(function() { self.handleTimeout(token); }, delay);
+ const token = this._tokenId++;
+ const id = Timer.setTimeout(() => this.handleTimeout(token), delay);
this._tokens.set(token, { callback: callback, id: id, isInterval: false });
-
return token;
- },
- scheduleRepeated: function(callback, period)
+ }
+
+ scheduleRepeated(callback, period)
{
if(this._destroyed)
{
throw new CommunicatorDestroyedException();
}
-
- var token = this._tokenId++;
- var self = this;
-
- var id = Timer.setInterval(function() { self.handleInterval(token); }, period);
+ const token = this._tokenId++;
+ const id = Timer.setInterval(() => this.handleInterval(token), period);
this._tokens.set(token, { callback: callback, id: id, isInterval: true });
-
return token;
- },
- cancel: function(id)
+ }
+
+ cancel(id)
{
if(this._destroyed)
{
return false;
}
- var token = this._tokens.get(id);
+ const token = this._tokens.get(id);
if(token === undefined)
{
return false;
@@ -83,15 +77,16 @@ var Timer = Ice.Class({
}
return true;
- },
- handleTimeout: function(id)
+ }
+
+ handleTimeout(id)
{
if(this._destroyed)
{
return;
}
- var token = this._tokens.get(id);
+ const token = this._tokens.get(id);
if(token !== undefined)
{
this._tokens.delete(id);
@@ -104,15 +99,16 @@ var Timer = Ice.Class({
this._logger.warning("uncaught exception while executing timer:\n" + ex);
}
}
- },
- handleInterval: function(id)
+ }
+
+ handleInterval(id)
{
if(this._destroyed)
{
return;
}
- var token = this._tokens.get(id);
+ const token = this._tokens.get(id);
if(token !== undefined)
{
try
@@ -125,7 +121,7 @@ var Timer = Ice.Class({
}
}
}
-});
+}
Timer.setTimeout = Ice.Timer.setTimeout;
Timer.clearTimeout = Ice.Timer.clearTimeout;
diff --git a/js/src/Ice/TimerUtil.js b/js/src/Ice/TimerUtil.js
index bcf8bdbdc14..d525fa22070 100644
--- a/js/src/Ice/TimerUtil.js
+++ b/js/src/Ice/TimerUtil.js
@@ -7,9 +7,11 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
-var Timer = {};
+class Timer
+{
+}
Timer.setTimeout = setTimeout;
Timer.clearTimeout = clearTimeout;
diff --git a/js/src/Ice/TraceLevels.js b/js/src/Ice/TraceLevels.js
index 83131032699..1cdc117c28c 100644
--- a/js/src/Ice/TraceLevels.js
+++ b/js/src/Ice/TraceLevels.js
@@ -7,56 +7,77 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.TraceLevels = function(properties)
{
- var networkCat = "Network";
- var protocolCat = "Protocol";
- var retryCat = "Retry";
- var locationCat = "Locator";
- var slicingCat = "Slicing";
-
- var keyBase = "Ice.Trace.";
-
- var network = properties.getPropertyAsInt(keyBase + networkCat);
- var protocol = properties.getPropertyAsInt(keyBase + protocolCat);
- var retry = properties.getPropertyAsInt(keyBase + retryCat);
- var location = properties.getPropertyAsInt(keyBase + locationCat);
- var slicing = properties.getPropertyAsInt(keyBase + slicingCat);
+ const networkCat = "Network";
+ const protocolCat = "Protocol";
+ const retryCat = "Retry";
+ const locationCat = "Locator";
+ const slicingCat = "Slicing";
+
+ const keyBase = "Ice.Trace.";
+
+ const network = properties.getPropertyAsInt(keyBase + networkCat);
+ const protocol = properties.getPropertyAsInt(keyBase + protocolCat);
+ const retry = properties.getPropertyAsInt(keyBase + retryCat);
+ const location = properties.getPropertyAsInt(keyBase + locationCat);
+ const slicing = properties.getPropertyAsInt(keyBase + slicingCat);
+
properties.getPropertyAsInt(keyBase + "ThreadPool"); // Avoid an "unused property" warning.
- return Object.create(null, {
- 'network': {
- get: function() { return network; }
- },
- 'networkCat': {
- get: function() { return networkCat; }
- },
- 'protocol': {
- get: function() { return protocol; }
- },
- 'protocolCat': {
- get: function() { return protocolCat; }
- },
- 'retry': {
- get: function() { return retry; }
- },
- 'retryCat': {
- get: function() { return retryCat; }
- },
- 'location': {
- get: function() { return location; }
- },
- 'locationCat': {
- get: function() { return locationCat; }
- },
- 'slicing': {
- get: function() { return slicing; }
- },
- 'slicingCat': {
- get: function() { return slicingCat; }
- }
- });
+ return class
+ {
+ static get network()
+ {
+ return network;
+ }
+
+ static get networkCat()
+ {
+ return networkCat;
+ }
+
+ static get protocol()
+ {
+ return protocol;
+ }
+
+ static get protocolCat()
+ {
+ return protocolCat;
+ }
+
+ static get retry()
+ {
+ return retry;
+ }
+
+ static get retryCat()
+ {
+ return retryCat;
+ }
+
+ static get location()
+ {
+ return location;
+ }
+
+ static get locationCat()
+ {
+ return locationCat;
+ }
+
+ static get slicing()
+ {
+ return slicing;
+ }
+
+ static get slicingCat()
+ {
+ return slicingCat;
+ }
+ };
};
module.exports.Ice = Ice;
diff --git a/js/src/Ice/TraceUtil.js b/js/src/Ice/TraceUtil.js
index f341bb20232..3d8c2c93304 100644
--- a/js/src/Ice/TraceUtil.js
+++ b/js/src/Ice/TraceUtil.js
@@ -7,11 +7,10 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
"../Ice/Debug",
- "../Ice/HashMap",
"../Ice/Protocol",
"../Ice/StringUtil",
"../Ice/Current",
@@ -21,185 +20,43 @@ Ice.__M.require(module,
//
// Local aliases.
//
-var Debug = Ice.Debug;
-var HashMap = Ice.HashMap;
-var Protocol = Ice.Protocol;
-var StringUtil = Ice.StringUtil;
-var OperationMode = Ice.OperationMode;
-var Identity = Ice.Identity;
+const Debug = Ice.Debug;
+const Protocol = Ice.Protocol;
+const StringUtil = Ice.StringUtil;
+const OperationMode = Ice.OperationMode;
+const Identity = Ice.Identity;
-var TraceUtil = {};
-
-TraceUtil.traceSend = function(stream, logger, traceLevels)
-{
- if(traceLevels.protocol >= 1)
- {
- var p = stream.pos;
- var is = new Ice.InputStream(stream.instance, stream.getEncoding(), stream.buffer);
- is.pos = 0;
-
- var s = [];
- var type = printMessage(s, is);
-
- logger.trace(traceLevels.protocolCat, "sending " + getMessageTypeAsString(type) + " " + s.join(""));
-
- stream.pos = p;
- }
-};
-
-TraceUtil.traceRecv = function(stream, logger, traceLevels)
-{
- if(traceLevels.protocol >= 1)
- {
- var p = stream.pos;
- stream.pos = 0;
-
- var s = [];
- var type = printMessage(s, stream);
-
- logger.trace(traceLevels.protocolCat, "received " + getMessageTypeAsString(type) + " " + s.join(""));
-
- stream.pos = p;
- }
-};
-
-TraceUtil.traceOut = function(heading, stream, logger, traceLevels)
-{
- if(traceLevels.protocol >= 1)
- {
- var p = stream.pos;
- var is = new Ice.InputStream(stream.instance, stream.getEncoding(), stream.buffer);
- is.pos = 0;
-
- var s = [];
- s.push(heading);
- printMessage(s, is);
-
- logger.trace(traceLevels.protocolCat, s.join(""));
- stream.pos = p;
- }
-};
-
-TraceUtil.traceIn = function(heading, stream, logger, traceLevels)
-{
- if(traceLevels.protocol >= 1)
- {
- var p = stream.pos;
- stream.pos = 0;
-
- var s = [];
- s.push(heading);
- printMessage(s, stream);
-
- logger.trace(traceLevels.protocolCat, s.join(""));
- stream.pos = p;
- }
-};
-
-var slicingIds = new HashMap();
+const slicingIds = new Map();
function traceSlicing(kind, typeId, slicingCat, logger)
{
if(!slicingIds.has(typeId))
{
- var s = "unknown " + kind + " type `" + typeId + "'";
- logger.trace(slicingCat, s);
+ logger.trace(slicingCat, `unknown ${kind} type \`${typeId}'`);
slicingIds.set(typeId, 1);
}
}
-TraceUtil.dumpStream = function(stream)
-{
- var pos = stream.pos;
- stream.pos = 0;
-
- var data = stream.readBlob(stream.size());
- TraceUtil.dumpOctets(data);
-
- stream.pos = pos;
-};
-
-TraceUtil.dumpOctets = function(data)
-{
- var inc = 8;
- var buf = [];
-
- for(var i = 0; i < data.length; i += inc)
- {
- var j;
- for(j = i; j - i < inc; j++)
- {
- if(j < data.length)
- {
- var n = data[j];
- if(n < 0)
- {
- n += 256;
- }
- var s;
- if(n < 10)
- {
- s = " " + n;
- }
- else if(n < 100)
- {
- s = " " + n;
- }
- else
- {
- s = "" + n;
- }
- buf.push(s + " ");
- }
- else
- {
- buf.push(" ");
- }
- }
-
- buf.push('"');
-
- for(j = i; j < data.length && j - i < inc; j++)
- {
- if(data[j] >= 32 && data[j] < 127)
- {
- buf.push(String.fromCharCode(data[j]));
- }
- else
- {
- buf.push('.');
- }
- }
-
- buf.push("\"\n");
- }
-
- console.log(buf.join(""));
-};
-
-Ice.TraceUtil = TraceUtil;
-module.exports.Ice = Ice;
-
function printIdentityFacetOperation(s, stream)
{
- var identity = new Identity();
+ const identity = new Identity();
identity.__read(stream);
s.push("\nidentity = " + Ice.identityToString(identity));
- var facet = Ice.StringSeqHelper.read(stream);
+ const facet = Ice.StringSeqHelper.read(stream);
s.push("\nfacet = ");
if(facet.length > 0)
{
s.push(StringUtil.escapeString(facet[0], ""));
}
- var operation = stream.readString();
+ const operation = stream.readString();
s.push("\noperation = " + operation);
}
function printRequest(s, stream)
{
- var requestId = stream.readInt();
+ const requestId = stream.readInt();
s.push("\nrequest id = " + requestId);
if(requestId === 0)
{
@@ -211,10 +68,10 @@ function printRequest(s, stream)
function printBatchRequest(s, stream)
{
- var batchRequestNum = stream.readInt();
+ const batchRequestNum = stream.readInt();
s.push("\nnumber of requests = " + batchRequestNum);
- for(var i = 0; i < batchRequestNum; ++i)
+ for(let i = 0; i < batchRequestNum; ++i)
{
s.push("\nrequest #" + i + ':');
printRequestHeader(s, stream);
@@ -223,10 +80,10 @@ function printBatchRequest(s, stream)
function printReply(s, stream)
{
- var requestId = stream.readInt();
+ const requestId = stream.readInt();
s.push("\nrequest id = " + requestId);
- var replyStatus = stream.readByte();
+ const replyStatus = stream.readByte();
s.push("\nreply status = " + replyStatus + ' ');
switch(replyStatus)
@@ -309,7 +166,7 @@ function printReply(s, stream)
}
}
- var unknown = stream.readString();
+ const unknown = stream.readString();
s.push("\nunknown = " + unknown);
break;
}
@@ -323,7 +180,7 @@ function printReply(s, stream)
if(replyStatus === Protocol.replyOK || replyStatus === Protocol.replyUserException)
{
- var ver = stream.skipEncapsulation();
+ const ver = stream.skipEncapsulation();
if(!ver.equals(Ice.Encoding_1_0))
{
s.push("\nencoding = ");
@@ -336,7 +193,7 @@ function printRequestHeader(s, stream)
{
printIdentityFacetOperation(s, stream);
- var mode = stream.readByte();
+ const mode = stream.readByte();
s.push("\nmode = " + mode + ' ');
switch(OperationMode.valueOf(mode))
{
@@ -365,12 +222,12 @@ function printRequestHeader(s, stream)
}
}
- var sz = stream.readSize();
+ let sz = stream.readSize();
s.push("\ncontext = ");
while(sz-- > 0)
{
- var key = stream.readString();
- var value = stream.readString();
+ const key = stream.readString();
+ const value = stream.readString();
s.push(key + '/'+ value);
if(sz > 0)
{
@@ -378,7 +235,7 @@ function printRequestHeader(s, stream)
}
}
- var ver = stream.skipEncapsulation();
+ const ver = stream.skipEncapsulation();
if(!ver.equals(Ice.Encoding_1_0))
{
s.push("\nencoding = ");
@@ -393,22 +250,22 @@ function printHeader(s, stream)
stream.readByte();
stream.readByte();
-// var pMajor = stream.readByte();
-// var pMinor = stream.readByte();
+// const pMajor = stream.readByte();
+// const pMinor = stream.readByte();
// s.push("\nprotocol version = " + pMajor + "." + pMinor);
stream.readByte(); // major
stream.readByte(); // minor
-// var eMajor = stream.readByte();
-// var eMinor = stream.readByte();
+// const eMajor = stream.readByte();
+// const eMinor = stream.readByte();
// s.push("\nencoding version = " + eMajor + "." + eMinor);
stream.readByte(); // major
stream.readByte(); // minor
- var type = stream.readByte();
+ const type = stream.readByte();
s.push("\nmessage type = " + type + " (" + getMessageTypeAsString(type) + ')');
- var compress = stream.readByte();
+ const compress = stream.readByte();
s.push("\ncompression status = " + compress + ' ');
switch(compress)
{
@@ -437,14 +294,14 @@ function printHeader(s, stream)
}
}
- var size = stream.readInt();
+ const size = stream.readInt();
s.push("\nmessage size = " + size);
return type;
}
function printMessage(s, stream)
{
- var type = printHeader(s, stream);
+ const type = printHeader(s, stream);
switch(type)
{
@@ -500,3 +357,143 @@ function getMessageTypeAsString(type)
return "unknown";
}
}
+
+class TraceUtil
+{
+ static traceSend(stream, logger, traceLevels)
+ {
+ if(traceLevels.protocol >= 1)
+ {
+ const p = stream.pos;
+ const is = new Ice.InputStream(stream.instance, stream.getEncoding(), stream.buffer);
+ is.pos = 0;
+
+ const s = [];
+ const type = printMessage(s, is);
+
+ logger.trace(traceLevels.protocolCat, "sending " + getMessageTypeAsString(type) + " " + s.join(""));
+
+ stream.pos = p;
+ }
+ }
+
+ static traceRecv(stream, logger, traceLevels)
+ {
+ if(traceLevels.protocol >= 1)
+ {
+ const p = stream.pos;
+ stream.pos = 0;
+
+ const s = [];
+ const type = printMessage(s, stream);
+
+ logger.trace(traceLevels.protocolCat, "received " + getMessageTypeAsString(type) + " " + s.join(""));
+
+ stream.pos = p;
+ }
+ }
+
+ static traceOut(heading, stream, logger, traceLevels)
+ {
+ if(traceLevels.protocol >= 1)
+ {
+ const p = stream.pos;
+ const is = new Ice.InputStream(stream.instance, stream.getEncoding(), stream.buffer);
+ is.pos = 0;
+
+ const s = [];
+ s.push(heading);
+ printMessage(s, is);
+
+ logger.trace(traceLevels.protocolCat, s.join(""));
+ stream.pos = p;
+ }
+ }
+
+ static traceIn(heading, stream, logger, traceLevels)
+ {
+ if(traceLevels.protocol >= 1)
+ {
+ const p = stream.pos;
+ stream.pos = 0;
+
+ const s = [];
+ s.push(heading);
+ printMessage(s, stream);
+
+ logger.trace(traceLevels.protocolCat, s.join(""));
+ stream.pos = p;
+ }
+ }
+
+ static dumpStream(stream)
+ {
+ const pos = stream.pos;
+ stream.pos = 0;
+
+ const data = stream.readBlob(stream.size());
+ TraceUtil.dumpOctets(data);
+
+ stream.pos = pos;
+ }
+
+ static dumpOctets(data)
+ {
+ const inc = 8;
+ const buf = [];
+
+ for(let i = 0; i < data.length; i += inc)
+ {
+ for(let j = i; j - i < inc; j++)
+ {
+ if(j < data.length)
+ {
+ let n = data[j];
+ if(n < 0)
+ {
+ n += 256;
+ }
+ let s;
+ if(n < 10)
+ {
+ s = " " + n;
+ }
+ else if(n < 100)
+ {
+ s = " " + n;
+ }
+ else
+ {
+ s = "" + n;
+ }
+ buf.push(s + " ");
+ }
+ else
+ {
+ buf.push(" ");
+ }
+ }
+
+ buf.push('"');
+
+ for(let j = i; j < data.length && j - i < inc; j++)
+ {
+ if(data[j] >= 32 && data[j] < 127)
+ {
+ buf.push(String.fromCharCode(data[j]));
+ }
+ else
+ {
+ buf.push('.');
+ }
+ }
+
+ buf.push("\"\n");
+ }
+
+ console.log(buf.join(""));
+ }
+}
+
+Ice.TraceUtil = TraceUtil;
+module.exports.Ice = Ice;
diff --git a/js/src/Ice/UUID.js b/js/src/Ice/UUID.js
index 29645ef98ff..42bbaae03d4 100644
--- a/js/src/Ice/UUID.js
+++ b/js/src/Ice/UUID.js
@@ -9,15 +9,15 @@
function generateUUID()
{
- var d = new Date().getTime();
- var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = (d + Math.random() * 16) % 16 | 0;
+ let d = new Date().getTime();
+ let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
+ let r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c == 'x' ? r : (r & 0x7 | 0x8)).toString(16);
});
return uuid;
}
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.generateUUID = generateUUID;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/UnknownSlicedValue.js b/js/src/Ice/UnknownSlicedValue.js
index 754cb776f21..f653e715345 100644
--- a/js/src/Ice/UnknownSlicedValue.js
+++ b/js/src/Ice/UnknownSlicedValue.js
@@ -7,70 +7,79 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Object", "../Ice/Class"]);
+const Ice = require("../Ice/Object").Ice;
-var SliceInfo = function()
+class SliceInfo
{
- /**
- * The Slice type ID for this slice.
- **/
- this.typeId = "";
+ constructor()
+ {
+ /**
+ * The Slice type ID for this slice.
+ **/
+ this.typeId = "";
- /**
- * The Slice compact type ID for this slice.
- **/
- this.compactId = -1;
+ /**
+ * The Slice compact type ID for this slice.
+ **/
+ this.compactId = -1;
- /**
- * The encoded bytes for this slice, including the leading size integer.
- **/
- this.bytes = [];
+ /**
+ * The encoded bytes for this slice, including the leading size integer.
+ **/
+ this.bytes = [];
- /**
- * The class instances referenced by this slice.
- **/
- this.instances = [];
+ /**
+ * The class instances referenced by this slice.
+ **/
+ this.instances = [];
- /**
- * Whether or not the slice contains optional members.
- **/
- this.hasOptionalMembers = false;
+ /**
+ * Whether or not the slice contains optional members.
+ **/
+ this.hasOptionalMembers = false;
- /**
- * Whether or not this is the last slice.
- **/
- this.isLastSlice = false;
-};
+ /**
+ * Whether or not this is the last slice.
+ **/
+ this.isLastSlice = false;
+ }
+}
Ice.SliceInfo = SliceInfo;
-var SlicedData = function(slices)
+class SlicedData
{
- this.slices = slices;
-};
+ constructor(slices)
+ {
+ this.slices = slices;
+ }
+}
Ice.SlicedData = SlicedData;
-var UnknownSlicedValue = Ice.Class(Ice.Object,
+class UnknownSlicedValue extends Ice.Object
+{
+ constructor(unknownTypeId)
+ {
+ super();
+ this._unknownTypeId = unknownTypeId;
+ }
+
+ getUnknownTypeId()
+ {
+ return this._unknownTypeId;
+ }
+
+ __write(os)
+ {
+ os.startValue(this._slicedData);
+ os.endValue();
+ }
+
+ __read(is)
{
- __init__: function(unknownTypeId)
- {
- this._unknownTypeId = unknownTypeId;
- },
- getUnknownTypeId: function()
- {
- return this._unknownTypeId;
- },
- __write: function(os)
- {
- os.startValue(this._slicedData);
- os.endValue();
- },
- __read: function(is)
- {
- is.startValue();
- this._slicedData = is.endValue(true);
- }
- });
+ is.startValue();
+ this._slicedData = is.endValue(true);
+ }
+}
Ice.UnknownSlicedValue = UnknownSlicedValue;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/ValueFactoryManagerI.js b/js/src/Ice/ValueFactoryManagerI.js
index 1026912cae2..03f9436a439 100644
--- a/js/src/Ice/ValueFactoryManagerI.js
+++ b/js/src/Ice/ValueFactoryManagerI.js
@@ -7,43 +7,40 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/HashMap", "../Ice/LocalException"]);
+const Ice = require("../Ice/LocalException").Ice;
-var HashMap = Ice.HashMap;
-var AlreadyRegisteredException = Ice.AlreadyRegisteredException;
-var NotRegisteredException = Ice.NotRegisteredException;
+const AlreadyRegisteredException = Ice.AlreadyRegisteredException;
+const NotRegisteredException = Ice.NotRegisteredException;
//
// Only for use by Instance
//
-var ValueFactoryManagerI = Ice.Class({
- __init__: function()
+class ValueFactoryManagerI
+{
+ constructor()
{
- this._factoryMap = new HashMap(); // Map<String, ValueFactory>
- },
- add: function(factory, id)
+ this._factoryMap = new Map(); // Map<String, ValueFactory>
+ }
+
+ add(factory, id)
{
- var o, ex;
- o = this._factoryMap.get(id);
- if(o !== undefined)
+ if(this._factoryMap.has(id))
{
- ex = new AlreadyRegisteredException();
- ex.id = id;
- ex.kindOfObject = "value factory";
- throw ex;
+ throw new AlreadyRegisteredException("value factory", id);
}
this._factoryMap.set(id, factory);
- },
- find: function(id)
+ }
+
+ find(id)
{
return this._factoryMap.get(id);
- },
- destroy: function()
+ }
+
+ destroy()
{
- this._factoryMap = new HashMap(); // Map<String, ValueFactory>
+ this._factoryMap = new Map(); // Map<String, ValueFactory>
}
-});
+}
Ice.ValueFactoryManagerI = ValueFactoryManagerI;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/WSEndpoint.js b/js/src/Ice/WSEndpoint.js
index b36a2ca64b1..8a7501f97b3 100644
--- a/js/src/Ice/WSEndpoint.js
+++ b/js/src/Ice/WSEndpoint.js
@@ -7,11 +7,10 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/HashUtil",
"../Ice/StringUtil",
"../Ice/EndpointI",
@@ -19,49 +18,56 @@ Ice.__M.require(module,
"../Ice/WSTransceiver",
"../Ice/EndpointInfo"
]);
-var IceSSL = Ice.__M.module("IceSSL");
-var HashUtil = Ice.HashUtil;
-var StringUtil = Ice.StringUtil;
-var EndpointI = Ice.EndpointI;
-var Class = Ice.Class;
+const IceSSL = Ice.__M.module("IceSSL");
+const HashUtil = Ice.HashUtil;
+const StringUtil = Ice.StringUtil;
+const EndpointI = Ice.EndpointI;
-var WSEndpoint = Class(EndpointI, {
- __init__: function(instance, del, re)
+class WSEndpoint extends EndpointI
+{
+ constructor(instance, del, re)
{
+ super();
this._instance = instance;
this._delegate = del;
this._resource = re || "/";
- },
- getInfo: function()
+ }
+
+ getInfo()
{
- var info = new Ice.WSEndpointInfo();
+ let info = new Ice.WSEndpointInfo();
info.resource = this._resource;
info.underlying = this._delegate.getInfo();
info.timeout = info.underlying.timeout;
info.compress = info.underlying.compress;
return info;
- },
- type: function()
+ }
+
+ type()
{
return this._delegate.type();
- },
- protocol: function()
+ }
+
+ protocol()
{
return this._delegate.protocol();
- },
- streamWrite: function(s)
+ }
+
+ streamWrite(s)
{
s.startEncapsulation();
this._delegate.streamWriteImpl(s);
s.writeString(this._resource);
s.endEncapsulation();
- },
- timeout: function()
+ }
+
+ timeout()
{
return this._delegate.timeout();
- },
- changeTimeout: function(timeout)
+ }
+
+ changeTimeout(timeout)
{
if(timeout === this._delegate.timeout())
{
@@ -71,8 +77,9 @@ var WSEndpoint = Class(EndpointI, {
{
return new WSEndpoint(this._instance, this._delegate.changeTimeout(timeout), this._resource);
}
- },
- changeConnectionId: function(connectionId)
+ }
+
+ changeConnectionId(connectionId)
{
if(connectionId === this._delegate.connectionId())
{
@@ -82,12 +89,14 @@ var WSEndpoint = Class(EndpointI, {
{
return new WSEndpoint(this._instance, this._delegate.changeConnectionId(connectionId), this._resource);
}
- },
- compress: function()
+ }
+
+ compress()
{
return this._delegate.compress();
- },
- changeCompress: function(compress)
+ }
+
+ changeCompress(compress)
{
if(compress === this._delegate.compress())
{
@@ -97,23 +106,27 @@ var WSEndpoint = Class(EndpointI, {
{
return new WSEndpoint(this._instance, this._delegate.changeCompress(compress), this._resource);
}
- },
- datagram: function()
+ }
+
+ datagram()
{
return this._delegate.datagram();
- },
- secure: function()
+ }
+
+ secure()
{
return this._delegate.secure();
- },
- connect: function()
+ }
+
+ connect()
{
return Ice.WSTransceiver.createOutgoing(this._instance,
this._delegate.secure(),
this._delegate.getAddress(),
this._resource);
- },
- hashCode: function()
+ }
+
+ hashCode()
{
if(this._hashCode === undefined)
{
@@ -121,8 +134,9 @@ var WSEndpoint = Class(EndpointI, {
this._hashCode = HashUtil.addString(this._hashCode, this._resource);
}
return this._hashCode;
- },
- compareTo: function(p)
+ }
+
+ compareTo(p)
{
if(this === p)
{
@@ -139,7 +153,7 @@ var WSEndpoint = Class(EndpointI, {
return this.type() < p.type() ? -1 : 1;
}
- var r = this._delegate.compareTo(p._delegate);
+ let r = this._delegate.compareTo(p._delegate);
if(r !== 0)
{
return r;
@@ -151,8 +165,9 @@ var WSEndpoint = Class(EndpointI, {
}
return 0;
- },
- options: function()
+ }
+
+ options()
{
//
// WARNING: Certain features, such as proxy validation in Glacier2,
@@ -161,7 +176,7 @@ var WSEndpoint = Class(EndpointI, {
// these features. Please review for all features that depend on the
// format of proxyToString() before changing this and related code.
//
- var s = this._delegate.options();
+ let s = this._delegate.options();
if(this._resource !== null && this._resource.length > 0)
{
@@ -170,16 +185,19 @@ var WSEndpoint = Class(EndpointI, {
}
return s;
- },
- toConnectorString: function()
+ }
+
+ toConnectorString()
{
return this._delegate.toConnectorString();
- },
- initWithStream: function(s)
+ }
+
+ initWithStream(s)
{
this._resource = s.readString();
- },
- checkOption: function(option, argument, endpoint)
+ }
+
+ checkOption(option, argument, endpoint)
{
if(option === "-r")
{
@@ -194,8 +212,8 @@ var WSEndpoint = Class(EndpointI, {
return false;
}
return true;
- },
-});
+ }
+}
if(typeof(Ice.WSTransceiver) !== "undefined")
{
diff --git a/js/src/Ice/WSEndpointFactory.js b/js/src/Ice/WSEndpointFactory.js
index 156b3a5d30c..31dca2a0657 100644
--- a/js/src/Ice/WSEndpointFactory.js
+++ b/js/src/Ice/WSEndpointFactory.js
@@ -7,42 +7,48 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
-Ice.__M.require(module, ["../Ice/Class", "../Ice/WSEndpoint"]);
+const Ice = require("../Ice/WSEndpoint").Ice;
+const WSEndpoint = Ice.WSEndpoint;
-var WSEndpoint = Ice.WSEndpoint;
-
-var WSEndpointFactory = Ice.Class({
- __init__:function(instance, delegate)
+class WSEndpointFactory extends WSEndpoint
+{
+ constructor(instance, delegate)
{
+ super();
this._instance = instance;
this._delegate = delegate;
- },
- type: function()
+ }
+
+ type()
{
return this._instance.type();
- },
- protocol: function()
+ }
+
+ protocol()
{
return this._instance.protocol();
- },
- create: function(args, oaEndpoint)
+ }
+
+ create(args, oaEndpoint)
{
- var e = new WSEndpoint(this._instance, this._delegate.create(args, oaEndpoint));
+ let e = new WSEndpoint(this._instance, this._delegate.create(args, oaEndpoint));
e.initWithOptions(args);
return e;
- },
- read: function(s)
+ }
+
+ read(s)
{
- var e = new WSEndpoint(this._instance, this._delegate.read(s));
+ let e = new WSEndpoint(this._instance, this._delegate.read(s));
e.initWithStream(s);
return e;
- },
- destroy: function()
+ }
+
+ destroy()
{
this._delegate.destroy();
this._instance = null;
}
-});
+}
+
Ice.WSEndpointFactory = WSEndpointFactory;
exports.Ice = Ice; \ No newline at end of file
diff --git a/js/src/Ice/browser/Buffer.js b/js/src/Ice/browser/Buffer.js
deleted file mode 100644
index eebf271da66..00000000000
--- a/js/src/Ice/browser/Buffer.js
+++ /dev/null
@@ -1,419 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-var Ice = require("../Ice/ModuleRegistry").Ice;
-
-Ice.__M.require(module, ["../Ice/Class", "../Ice/Long"]);
-
-var Long = Ice.Long;
-
-//
-// IE 10 doesn't implement ArrayBuffer.slice
-//
-
-if(!ArrayBuffer.prototype.slice)
-{
- ArrayBuffer.prototype.slice = function (start, end)
- {
- var b = new Uint8Array(this);
- end = end === undefined ? b.length : end;
- var result = new Uint8Array(new ArrayBuffer(end - start));
- for(var i = 0, length = result.length; i < length; i++)
- {
- result[i] = b[i + start];
- }
- return result.buffer;
- };
-}
-
-var __BufferOverflowException__ = "BufferOverflowException";
-var __BufferUnderflowException__ = "BufferUnderflowException";
-var __IndexOutOfBoundsException__ = "IndexOutOfBoundsException";
-
-//
-// Buffer implementation to be used by web browsers, it uses ArrayBuffer as
-// the store.
-//
-var Buffer = Ice.Class({
- __init__: function(buffer)
- {
- if(buffer !== undefined)
- {
- this.b = buffer;
- this.v = new DataView(this.b);
- }
- else
- {
- this.b = null; // ArrayBuffer
- this.v = null; // DataView
- }
- this._position = 0;
- this._limit = 0;
- this._shrinkCounter = 0;
- },
- empty: function()
- {
- return this._limit === 0;
- },
- resize: function(n)
- {
- if(n === 0)
- {
- this.clear();
- }
- else if(n > this.capacity)
- {
- this.reserve(n);
- }
- this._limit = n;
- },
- clear: function()
- {
- this.b = null;
- this.v = null;
- this._position = 0;
- this._limit = 0;
- },
- //
- // Call expand(n) to add room for n additional bytes. Note that expand()
- // examines the current position of the buffer first; we don't want to
- // expand the buffer if the caller is writing to a location that is
- // already in the buffer.
- //
- expand: function(n)
- {
- var sz = this.capacity === 0 ? n : this._position + n;
- if(sz > this._limit)
- {
- this.resize(sz);
- }
- },
- reset: function()
- {
- if(this._limit > 0 && this._limit * 2 < this.capacity)
- {
- //
- // If the current buffer size is smaller than the
- // buffer capacity, we shrink the buffer memory to the
- // current size. This is to avoid holding on to too much
- // memory if it's not needed anymore.
- //
- if(++this._shrinkCounter > 2)
- {
- this.reserve(this._limit);
- this._shrinkCounter = 0;
- }
- }
- else
- {
- this._shrinkCounter = 0;
- }
- this._limit = 0;
- this._position = 0;
- },
- reserve: function(n)
- {
- if(n > this.capacity)
- {
- var capacity = Math.max(n, 2 * this.capacity);
- capacity = Math.max(1024, capacity);
- if(!this.b)
- {
- this.b = new ArrayBuffer(capacity);
- }
- else
- {
- var b = new Uint8Array(capacity);
- b.set(new Uint8Array(this.b));
- this.b = b.buffer;
- }
- this.v = new DataView(this.b);
- }
- else if(n < this.capacity)
- {
- this.b = this.b.slice(0, this.capacity);
- this.v = new DataView(this.b);
- }
- else
- {
- return;
- }
- },
- put: function(v)
- {
- if(this._position === this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- this.v.setUint8(this._position, v);
- this._position++;
- },
- putAt: function(i, v)
- {
- if(i >= this._limit)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- this.v.setUint8(i, v);
- },
- putArray: function(v)
- {
- //Expects an Uint8Array
- if(!(v instanceof Uint8Array))
- {
- throw new TypeError('argument is not a Uint8Array');
- }
- if(v.byteLength > 0)
- {
- if(this._position + v.length > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- new Uint8Array(this.b, 0, this.b.byteLength).set(v, this._position);
- this._position += v.byteLength;
- }
- },
- putShort: function(v)
- {
- if(this._position + 2 > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- this.v.setInt16(this._position, v, true);
- this._position += 2;
- },
- putInt: function(v)
- {
- if(this._position + 4 > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- this.v.setInt32(this._position, v, true);
- this._position += 4;
- },
- putIntAt: function(i, v)
- {
- if(i + 4 > this._limit || i < 0)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- this.v.setInt32(i, v, true);
- },
- putFloat: function(v)
- {
- if(this._position + 4 > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- this.v.setFloat32(this._position, v, true);
- this._position += 4;
- },
- putDouble: function(v)
- {
- if(this._position + 8 > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- this.v.setFloat64(this._position, v, true);
- this._position += 8;
- },
- putLong: function(v)
- {
- if(this._position + 8 > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- this.v.setInt32(this._position, v.low, true);
- this._position += 4;
- this.v.setInt32(this._position, v.high, true);
- this._position += 4;
- },
- writeString: function(stream, v)
- {
- //
- // Encode the string as utf8
- //
- var encoded = unescape(encodeURIComponent(v));
-
- stream.writeSize(encoded.length);
- stream.expand(encoded.length);
- this.putString(encoded, encoded.length);
- },
- putString: function(v, sz)
- {
- if(this._position + sz > this._limit)
- {
- throw new Error(__BufferOverflowException__);
- }
- for(var i = 0; i < sz; ++i)
- {
- this.v.setUint8(this._position, v.charCodeAt(i));
- this._position++;
- }
- },
- get: function()
- {
- if(this._position >= this._limit)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var v = this.v.getUint8(this._position);
- this._position++;
- return v;
- },
- getAt: function(i)
- {
- if(i < 0 || i >= this._limit)
- {
- throw new Error(__IndexOutOfBoundsException__);
- }
- return this.v.getUint8(i);
- },
- getArray: function(length)
- {
- if(this._position + length > this._limit)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var buffer = this.b.slice(this._position, this._position + length);
- this._position += length;
- return new Uint8Array(buffer);
- },
- getArrayAt: function(position, length)
- {
- if(position + length > this._limit)
- {
- throw new Error(__BufferUnderflowException__);
- }
- length = length === undefined ? (this.b.byteLength - position) : length;
- return new Uint8Array(this.b.slice(position, position + length));
- },
- getShort: function()
- {
- if(this._limit - this._position < 2)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var v = this.v.getInt16(this._position, true);
- this._position += 2;
- return v;
- },
- getInt: function()
- {
- if(this._limit - this._position < 4)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var v = this.v.getInt32(this._position, true);
- this._position += 4;
- return v;
- },
- getFloat: function()
- {
- if(this._limit - this._position < 4)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var v = this.v.getFloat32(this._position, true);
- this._position += 4;
- return v;
- },
- getDouble: function()
- {
- if(this._limit - this._position < 8)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var v = this.v.getFloat64(this._position, true);
- this._position += 8;
- return v;
- },
- getLong: function()
- {
- if(this._limit - this._position < 8)
- {
- throw new Error(__BufferUnderflowException__);
- }
- var v = new Long();
- v.low = this.v.getUint32(this._position, true);
- this._position += 4;
- v.high = this.v.getUint32(this._position, true);
- this._position += 4;
- return v;
- },
- getString: function(length)
- {
- if(this._position + length > this._limit)
- {
- throw new Error(__BufferUnderflowException__);
- }
-
- var data = new DataView(this.b, this._position, length);
- var s = "";
-
- for(var i = 0; i < length; ++i)
- {
- s += String.fromCharCode(data.getUint8(i));
- }
- this._position += length;
- s = decodeURIComponent(escape(s));
- return s;
- }
-});
-
-var prototype = Buffer.prototype;
-
-Object.defineProperty(prototype, "position", {
- get: function() { return this._position; },
- set: function(position){
- if(position >= 0 && position <= this._limit)
- {
- this._position = position;
- }
- }
-});
-
-Object.defineProperty(prototype, "limit", {
- get: function() { return this._limit; },
- set: function(limit){
- if(limit <= this.capacity)
- {
- this._limit = limit;
- if(this._position > limit)
- {
- this._position = limit;
- }
- }
- }
-});
-
-Object.defineProperty(prototype, "capacity", {
- get: function() { return this.b === null ? 0 : this.b.byteLength; }
-});
-
-Object.defineProperty(prototype, "remaining", {
- get: function() { return this._limit - this._position; }
-});
-
-//
-// Create a native buffer from an array of bytes.
-//
-Buffer.createNative = function(data)
-{
- if(data === undefined)
- {
- return new Uint8Array(0);
- }
- else
- {
- return new Uint8Array(data);
- }
-};
-
-Ice.Buffer = Buffer;
diff --git a/js/src/Ice/browser/Debug.js b/js/src/Ice/browser/Debug.js
index 8b561e0c548..abb8a59287c 100644
--- a/js/src/Ice/browser/Debug.js
+++ b/js/src/Ice/browser/Debug.js
@@ -7,22 +7,23 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module, ["../Ice/Class", "../Ice/Exception"]);
-Ice.AssertionFailedException = Ice.Class(Error,
+class AssertionFailedException extends Error
+{
+ constructor(message)
{
- __init__: function(message)
- {
- Error.call(this);
- Ice.Exception.captureStackTrace(this);
- this.message = message;
- }
- });
+ super();
+ Ice.Exception.captureStackTrace(this);
+ this.message = message;
+ }
+}
+Ice.AssertionFailedException = AssertionFailedException;
-Ice.Debug =
+class Debug
{
- assert: function(b, msg)
+ static assert(b, msg)
{
if(!b)
{
@@ -31,5 +32,7 @@ Ice.Debug =
throw new Ice.AssertionFailedException(msg === undefined ? "assertion failed" : msg);
}
}
-};
+}
+
+Ice.Debug = Debug;
module.exports.Ice = Ice;
diff --git a/js/src/Ice/browser/ModuleRegistry.js b/js/src/Ice/browser/ModuleRegistry.js
index a0f521b13f3..53ba91aacec 100644
--- a/js/src/Ice/browser/ModuleRegistry.js
+++ b/js/src/Ice/browser/ModuleRegistry.js
@@ -8,12 +8,12 @@
// **********************************************************************
/* globals self */
-var __root = typeof(window) !== "undefined" ? window : self;
+const __root = typeof(window) !== "undefined" ? window : typeof(global) !== "undefined" ? global : typeof(self) !== "undefined" ? self : {};
/* globals -self */
-var __M =
+class __M
{
- module: function(name)
+ static module(name)
{
var m = __root[name];
if(m === undefined)
@@ -22,12 +22,14 @@ var __M =
__root[name] = m;
}
return m;
- },
- require: function(name)
+ }
+
+ static require(name)
{
return __root;
- },
- type: function(scoped)
+ }
+
+ static type(scoped)
{
if(scoped === undefined)
{
@@ -46,9 +48,9 @@ var __M =
}
return T;
}
-};
+}
-var Ice = __M.module("Ice");
+const Ice = __M.module("Ice");
Ice.__require = function()
{
diff --git a/js/src/Ice/browser/TimerUtil.js b/js/src/Ice/browser/TimerUtil.js
index 99c7b3f2608..970f2a877b5 100644
--- a/js/src/Ice/browser/TimerUtil.js
+++ b/js/src/Ice/browser/TimerUtil.js
@@ -14,7 +14,7 @@
/* global WorkerGlobalScope */
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
//
// Create a timer object that uses the default browser methods. Note that we also
@@ -24,36 +24,57 @@ var Ice = require("../Ice/ModuleRegistry").Ice;
//
function createTimerObject()
{
- var Timer = {};
- Timer.setTimeout = function () { setTimeout.apply(null, arguments); };
- Timer.clearTimeout = function () { clearTimeout.apply(null, arguments); };
- Timer.setInterval = function () { setInterval.apply(null, arguments); };
- Timer.clearInterval = function () { clearInterval.apply(null, arguments); };
- Timer.setImmediate = typeof(setImmediate) == "function" ?
- function () { setImmediate.apply(null, arguments); } :
- function () { setTimeout.apply(null, arguments); };
- return Timer;
-}
+ let Timer = class
+ {
+ static setTimeout()
+ {
+ setTimeout.apply(null, arguments);
+ }
+
+ static clearTimeout()
+ {
+ clearTimeout.apply(null, arguments);
+ }
+ static setInterval()
+ {
+ setInterval.apply(null, arguments);
+ }
-Ice.__M.require(module,
- [
- "../Ice/HashMap",
- ]);
+ static clearInterval()
+ {
+ clearInterval.apply(null, arguments);
+ }
+ };
+
+ if(typeof(setImmediate) == "function")
+ {
+ Timer.setImmediate = function()
+ {
+ setImmediate.apply(null, arguments);
+ };
+ }
+ else
+ {
+ Timer.setImmediate = function()
+ {
+ setTimeout.apply(null, arguments);
+ };
+ }
-var HashMap = Ice.HashMap;
+ return Timer;
+}
-var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
+const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || 9007199254740991;
-var _timers = new HashMap();
+const _timers = new Map();
-var _SetTimeoutType = 0,
- _SetIntervalType = 1,
- _SetImmediateType = 2,
- _ClearTimeoutType = 3,
- _ClearIntervalType = 4;
+const _SetTimeoutType = 0,
+ _SetIntervalType = 1,
+ _SetImmediateType = 2,
+ _ClearTimeoutType = 3,
+ _ClearIntervalType = 4;
-var Timer = {};
var worker;
var _nextId = 0;
@@ -67,59 +88,62 @@ var nextId = function()
return _nextId++;
};
-Timer.setTimeout = function(cb, ms)
-{
- var id = nextId();
- _timers.set(id, cb);
- worker.postMessage({type: _SetTimeoutType, id: id, ms: ms});
- return id;
-};
-
-Timer.clearTimeout = function(id)
+class Timer
{
- _timers.delete(id);
- worker.postMessage({type: _ClearTimeoutType, id: id});
-};
-
-Timer.setInterval = function(cb, ms)
-{
- var id = nextId();
- _timers.set(id, cb);
- worker.postMessage({type: _SetIntervalType, id: id, ms: ms});
- return id;
-};
+ static setTimeout(cb, ms)
+ {
+ var id = nextId();
+ _timers.set(id, cb);
+ worker.postMessage({type: _SetTimeoutType, id: id, ms: ms});
+ return id;
+ }
-Timer.clearInterval = function(id)
-{
- _timers.delete(id);
- worker.postMessage({type: _ClearIntervalType, id: id});
-};
+ static clearTimeout(id)
+ {
+ _timers.delete(id);
+ worker.postMessage({type: _ClearTimeoutType, id: id});
+ }
-Timer.setImmediate = function(cb)
-{
- var id = nextId();
- _timers.set(id, cb);
- worker.postMessage({type: _SetImmediateType, id: id});
- return id;
-};
+ static setInterval(cb, ms)
+ {
+ var id = nextId();
+ _timers.set(id, cb);
+ worker.postMessage({type: _SetIntervalType, id: id, ms: ms});
+ return id;
+ }
-Timer.onmessage = function(e)
-{
- var cb;
- if(e.data.type === _SetIntervalType)
+ static clearInterval(id)
{
- cb = _timers.get(e.data.id);
+ _timers.delete(id);
+ worker.postMessage({type: _ClearIntervalType, id: id});
}
- else
+
+ static setImmediate(cb)
{
- cb = _timers.delete(e.data.id);
+ var id = nextId();
+ _timers.set(id, cb);
+ worker.postMessage({type: _SetImmediateType, id: id});
+ return id;
}
- if(cb !== undefined)
+ static onmessage(e)
{
- cb.call();
+ var cb;
+ if(e.data.type === _SetIntervalType)
+ {
+ cb = _timers.get(e.data.id);
+ }
+ else
+ {
+ cb = _timers.delete(e.data.id);
+ }
+
+ if(cb !== undefined)
+ {
+ cb.call();
+ }
}
-};
+}
var workerCode = function()
{
@@ -137,23 +161,15 @@ var workerCode = function()
var timers = {};
- self.onmessage = function(e)
+ self.onmessage = e =>
{
if(e.data.type == _wSetTimeoutType)
{
- timers[e.data.id] = setTimeout(function()
- {
- self.postMessage(e.data);
- },
- e.data.ms);
+ timers[e.data.id] = setTimeout(() => self.postMessage(e.data), e.data.ms);
}
else if(e.data.type == _wSetIntervalType)
{
- timers[e.data.id] = setInterval(function()
- {
- self.postMessage(e.data);
- },
- e.data.ms);
+ timers[e.data.id] = setInterval(() => self.postMessage(e.data), e.data.ms);
}
else if(e.data.type == _wSetImmediateType)
{
@@ -177,7 +193,14 @@ var workerCode = function()
}.toString() + "());";
};
-if(worker === undefined)
+if(self == this)
+{
+ //
+ // If we are running in a worker don't spawn a separate worker for the timer
+ //
+ Ice.Timer = createTimerObject();
+}
+else if(worker === undefined)
{
var url;
try
diff --git a/js/src/Ice/browser/WSTransceiver.js b/js/src/Ice/browser/WSTransceiver.js
index 675bcbfd518..dae8f618430 100644
--- a/js/src/Ice/browser/WSTransceiver.js
+++ b/js/src/Ice/browser/WSTransceiver.js
@@ -7,10 +7,9 @@
//
// **********************************************************************
-var Ice = require("../Ice/ModuleRegistry").Ice;
+const Ice = require("../Ice/ModuleRegistry").Ice;
Ice.__M.require(module,
[
- "../Ice/Class",
"../Ice/Debug",
"../Ice/ExUtil",
"../Ice/Network",
@@ -21,7 +20,7 @@ Ice.__M.require(module,
"../Ice/Timer",
"../Ice/ConnectionInfo"
]);
-var IceSSL = Ice.__M.module("IceSSL");
+const IceSSL = Ice.__M.module("IceSSL");
//
// With Chrome we don't want to close the socket while connection is in progress,
@@ -29,49 +28,51 @@ var IceSSL = Ice.__M.module("IceSSL");
//
// We need to check for Edge browser as it might include Chrome in its user agent.
//
-var IsChrome = navigator.userAgent.indexOf("Edge/") === -1 &&
- navigator.userAgent.indexOf("Chrome/") !== -1;
-
-var Debug = Ice.Debug;
-var ExUtil = Ice.ExUtil;
-var Network = Ice.Network;
-var SocketOperation = Ice.SocketOperation;
-var Conn = Ice.Connection;
-var LocalException = Ice.LocalException;
-var SocketException = Ice.SocketException;
-var Timer = Ice.Timer;
-
-var StateNeedConnect = 0;
-var StateConnectPending = 1;
-var StateConnected = 2;
-var StateClosePending = 3;
-var StateClosed = 4;
-
-var WSTransceiver = Ice.Class({
- __init__: function(instance)
+const IsChrome = navigator.userAgent.indexOf("Edge/") === -1 &&
+ navigator.userAgent.indexOf("Chrome/") !== -1;
+
+const Debug = Ice.Debug;
+const ExUtil = Ice.ExUtil;
+const Network = Ice.Network;
+const SocketOperation = Ice.SocketOperation;
+const Conn = Ice.Connection;
+const LocalException = Ice.LocalException;
+const SocketException = Ice.SocketException;
+const Timer = Ice.Timer;
+
+const StateNeedConnect = 0;
+const StateConnectPending = 1;
+const StateConnected = 2;
+const StateClosePending = 3;
+const StateClosed = 4;
+
+class WSTransceiver
+{
+ constructor(instance)
{
- this._logger = instance.logger();
this._readBuffers = [];
this._readPosition = 0;
this._maxSendPacketSize = instance.properties().getPropertyAsIntWithDefault("Ice.TCP.SndSize", 512 * 1024);
this._writeReadyTimeout = 0;
- },
- writeReadyTimeout: function()
+ }
+
+ writeReadyTimeout()
{
var t = Math.round(this._writeReadyTimeout);
this._writeReadyTimeout += (this._writeReadyTimeout >= 5 ? 5 : 0.2);
return Math.min(t, 25);
- },
- setCallbacks: function(connectedCallback, bytesAvailableCallback, bytesWrittenCallback)
+ }
+
+ setCallbacks(connectedCallback, bytesAvailableCallback, bytesWrittenCallback)
{
this._connectedCallback = connectedCallback;
this._bytesAvailableCallback = bytesAvailableCallback;
this._bytesWrittenCallback = bytesWrittenCallback;
- },
+ }
//
// Returns SocketOperation.None when initialization is complete.
//
- initialize: function(readBuffer, writeBuffer)
+ initialize(readBuffer, writeBuffer)
{
try
{
@@ -85,10 +86,9 @@ var WSTransceiver = Ice.Class({
this._state = StateConnectPending;
this._fd = new WebSocket(this._url, "ice.zeroc.com");
this._fd.binaryType = "arraybuffer";
- var self = this;
- this._fd.onopen = function(e) { self.socketConnected(e); };
- this._fd.onmessage = function(e) { self.socketBytesAvailable(e.data); };
- this._fd.onclose = function(e) { self.socketClosed(e); };
+ this._fd.onopen = e => this.socketConnected(e);
+ this._fd.onmessage = e => this.socketBytesAvailable(e.data);
+ this._fd.onclose = e => this.socketClosed(e);
return SocketOperation.Connect; // Waiting for connect to complete.
}
else if(this._state === StateConnectPending)
@@ -111,8 +111,9 @@ var WSTransceiver = Ice.Class({
Debug.assert(this._state === StateConnected);
return SocketOperation.None;
- },
- register: function()
+ }
+
+ register()
{
//
// Register the socket data listener.
@@ -123,15 +124,17 @@ var WSTransceiver = Ice.Class({
this._bytesAvailableCallback();
this._hasBytesAvailable = false;
}
- },
- unregister: function()
+ }
+
+ unregister()
{
//
// Unregister the socket data listener.
//
this._registered = false;
- },
- close: function()
+ }
+
+ close()
{
if(this._fd === null)
{
@@ -167,11 +170,12 @@ var WSTransceiver = Ice.Class({
{
this._fd = null;
}
- },
+ }
+
//
// Returns true if all of the data was flushed to the kernel buffer.
//
- write: function(byteBuffer)
+ write(byteBuffer)
{
if(this._exception)
{
@@ -195,12 +199,11 @@ var WSTransceiver = Ice.Class({
Debug.assert(packetSize > 0);
if(this._fd.bufferedAmount + packetSize > this._maxSendPacketSize)
{
- var transceiver = this;
- Timer.setTimeout(function()
+ Timer.setTimeout(() =>
{
- if(transceiver._fd && transceiver._fd.bufferedAmount + packetSize <= transceiver._maxSendPacketSize)
+ if(this._fd && this._fd.bufferedAmount + packetSize <= this._maxSendPacketSize)
{
- transceiver._bytesWrittenCallback();
+ this._bytesWrittenCallback();
}
},
this.writeReadyTimeout());
@@ -212,8 +215,9 @@ var WSTransceiver = Ice.Class({
byteBuffer.position = byteBuffer.position + packetSize;
}
return true;
- },
- read: function(byteBuffer, moreData)
+ }
+
+ read(byteBuffer, moreData)
{
if(this._exception)
{
@@ -264,12 +268,14 @@ var WSTransceiver = Ice.Class({
moreData.value = this._readBuffers.byteLength > 0;
return byteBuffer.remaining === 0;
- },
- type: function()
+ }
+
+ type()
{
return this._secure ? "wss" : "ws";
- },
- getInfo: function()
+ }
+
+ getInfo()
{
Debug.assert(this._fd !== null);
var info = new Ice.WSConnectionInfo();
@@ -283,19 +289,23 @@ var WSTransceiver = Ice.Class({
info.sndSize = this._maxSendPacketSize;
info.headers = {};
return info;
- },
- checkSendSize: function(stream)
+ }
+
+ checkSendSize(stream)
{
- },
- setBufferSize: function(rcvSize, sndSize)
+ }
+
+ setBufferSize(rcvSize, sndSize)
{
this._maxSendPacketSize = sndSize;
- },
- toString: function()
+ }
+
+ toString()
{
return this._desc;
- },
- socketConnected: function(e)
+ }
+
+ socketConnected(e)
{
if(this._state == StateClosePending)
{
@@ -305,8 +315,9 @@ var WSTransceiver = Ice.Class({
Debug.assert(this._connectedCallback !== null);
this._connectedCallback();
- },
- socketBytesAvailable: function(buf)
+ }
+
+ socketBytesAvailable(buf)
{
Debug.assert(this._bytesAvailableCallback !== null);
if(buf.byteLength > 0)
@@ -321,8 +332,9 @@ var WSTransceiver = Ice.Class({
this._hasBytesAvailable = true;
}
}
- },
- socketClosed: function(err)
+ }
+
+ socketClosed(err)
{
if(this._state == StateClosePending)
{
@@ -339,8 +351,30 @@ var WSTransceiver = Ice.Class({
{
this._bytesAvailableCallback();
}
- },
-});
+ }
+
+ static createOutgoing(instance, secure, addr, resource)
+ {
+ var transceiver = new WSTransceiver(instance);
+
+ var url = secure ? "wss" : "ws";
+ url += "://" + addr.host;
+ if(addr.port !== 80)
+ {
+ url += ":" + addr.port;
+ }
+ url += resource ? resource : "/";
+ transceiver._url = url;
+ transceiver._fd = null;
+ transceiver._addr = addr;
+ transceiver._desc = "local address = <not available>\nremote address = " + addr.host + ":" + addr.port;
+ transceiver._state = StateNeedConnect;
+ transceiver._secure = secure;
+ transceiver._exception = null;
+
+ return transceiver;
+ }
+}
function fdToString(address)
{
@@ -363,26 +397,4 @@ function translateError(state, err)
}
}
-WSTransceiver.createOutgoing = function(instance, secure, addr, resource)
-{
- var transceiver = new WSTransceiver(instance);
-
- var url = secure ? "wss" : "ws";
- url += "://" + addr.host;
- if(addr.port !== 80)
- {
- url += ":" + addr.port;
- }
- url += resource ? resource : "/";
- transceiver._url = url;
- transceiver._fd = null;
- transceiver._addr = addr;
- transceiver._desc = "local address = <not available>\nremote address = " + addr.host + ":" + addr.port;
- transceiver._state = StateNeedConnect;
- transceiver._secure = secure;
- transceiver._exception = null;
-
- return transceiver;
-};
-
Ice.WSTransceiver = WSTransceiver;
diff --git a/js/src/Ice/sources.json b/js/src/Ice/sources.json
index 76e9e62ae25..658cee32b68 100644
--- a/js/src/Ice/sources.json
+++ b/js/src/Ice/sources.json
@@ -33,7 +33,7 @@
"AsyncStatus.js",
"Base64.js",
"BatchRequestQueue.js",
- "Class.js",
+ "Buffer.js",
"Communicator.js",
"CompactIdRegistry.js",
"ConnectionI.js",
@@ -60,6 +60,7 @@
"LocatorTable.js",
"Logger.js",
"Long.js",
+ "MapUtil.js",
"Object.js",
"ObjectAdapterFactory.js",
"ObjectAdapterI.js",
@@ -103,7 +104,6 @@
"WSEndpointFactory.js"],
"node":[
- "Buffer.js",
"Debug.js",
"Ice.js",
"ModuleRegistry.js",
@@ -111,7 +111,6 @@
"TimerUtil.js"],
"browser":[
- "browser/Buffer.js",
"browser/Debug.js",
"browser/ModuleRegistry.js",
"browser/TimerUtil.js",
diff --git a/js/test/Common/Common.js b/js/test/Common/Common.js
index 3738c86b6b4..635e2b6e834 100644
--- a/js/test/Common/Common.js
+++ b/js/test/Common/Common.js
@@ -25,9 +25,10 @@ var run = function(m)
var id = new Ice.InitializationData();
id.properties = Ice.createProperties(process.argv);
var test = m.require("./Client").__test__;
- test({write: write, writeLine: writeLine}, id).exception(
- function(ex, r)
+ test({write: write, writeLine: writeLine}, id).catch(
+ function(values)
{
+ let [ex, r] = values;
console.log(ex.toString());
if(r instanceof Ice.AsyncResult)
{
diff --git a/js/test/Common/TestCases.json b/js/test/Common/TestCases.json
index 535080da002..729e7b85132 100644
--- a/js/test/Common/TestCases.json
+++ b/js/test/Common/TestCases.json
@@ -114,7 +114,7 @@
},
"Ice/optional":
{
- "files": ["Test.js", "Client.js"],
+ "files": ["Test.js", "Client.js", "ClientPrivate.js"],
"configurations":
[
{
@@ -130,11 +130,7 @@
},
"Ice/optionalBidir":
{
- "files": ["Test.js", "TestAMD.js", "InitialI.js", "AMDInitialI.js", "../optional/Client.js", "Client.js"]
- },
- "Ice/promise":
- {
- "files": ["Client.js"]
+ "files": ["Test.js", "TestAMD.js", "InitialI.js", "AMDInitialI.js", "../optional/Client.js", "../optional/ClientPrivate.js", "Client.js"]
},
"Ice/properties":
{
diff --git a/js/test/Common/TestRunner.js b/js/test/Common/TestRunner.js
index 05740476993..2ad39859a7a 100644
--- a/js/test/Common/TestRunner.js
+++ b/js/test/Common/TestRunner.js
@@ -26,11 +26,77 @@ function isWorker()
function runTest(name, language, defaultHost, protocol, configurations, out)
{
+ //
+ // This logger is setup to work with Web Workers and normal scripts using
+ // the received out object. With some browser like Safari using console.log
+ // method doesn't work when running inside a web worker.
+ //
+ var Logger =
+ {
+ print(message)
+ {
+ out.writeLine(message, false);
+ },
+ trace:function(category, message)
+ {
+ var s = [];
+ var d = new Date();
+ s.push("-- ");
+ s.push(this.timestamp());
+ s.push(' ');
+ s.push(this._prefix);
+ s.push(category);
+ s.push(": ");
+ s.push(message);
+ out.writeLine(s.join(""), true);
+ },
+ warning:function(message)
+ {
+ var s = [];
+ var d = new Date();
+ s.push("-! ");
+ s.push(this.timestamp());
+ s.push(' ');
+ s.push(this._prefix);
+ s.push("warning: ");
+ s.push(message);
+ out.writeLine(s.join(""), true);
+ },
+ error:function(message)
+ {
+ var s = [];
+ var d = new Date();
+ s.push("!! ");
+ s.push(this.timestamp());
+ s.push(' ');
+ s.push(this._prefix);
+ s.push("error: ");
+ s.push(message);
+ out.writeLine(s.join(""), true);
+ },
+ getPrefix: function()
+ {
+ return "";
+ },
+ cloneWithPrefix: function(prefix)
+ {
+ return Logger;
+ },
+ timestamp:function()
+ {
+ var d = new Date();
+ return d.toLocaleString("en-US", this._dateformat) + "." + d.getMilliseconds();
+ }
+ };
+
var server, communicator;
var id = new Ice.InitializationData();
+ id.logger = Logger;
id.properties = Ice.createProperties();
id.properties.setProperty("Ice.Default.Host", defaultHost);
id.properties.setProperty("Ice.Default.Protocol", protocol);
+ //id.properties.setProperty("Ice.Trace.Protocol", "1");
+ //id.properties.setProperty("Ice.Trace.Network", "3");
return Ice.Promise.try(
function()
@@ -55,7 +121,7 @@ function runTest(name, language, defaultHost, protocol, configurations, out)
configurations = [ { configName: "", desc: "default configuration" } ];
}
- var prev = new Ice.Promise().succeed();
+ var prev = Ice.Promise.resolve();
configurations.forEach(
function(config)
{
@@ -101,7 +167,7 @@ function runTest(name, language, defaultHost, protocol, configurations, out)
return server.waitTestSuccess();
}
}
- ).exception(
+ ).catch(
function(ex)
{
if(server)
@@ -143,13 +209,9 @@ function runTest(name, language, defaultHost, protocol, configurations, out)
{
return true;
},
- function(ex, r)
+ function(ex)
{
out.writeLine("");
- if(r instanceof Ice.AsyncResult)
- {
- out.writeLine("exception occurred in call to " + r.operation);
- }
if(ex instanceof Test.Common.ServerFailedException)
{
out.writeLine("Server failed to start:\n");
diff --git a/js/test/Common/TestSuite.js b/js/test/Common/TestSuite.js
index 1c42f4edad4..8a4acb95177 100644
--- a/js/test/Common/TestSuite.js
+++ b/js/test/Common/TestSuite.js
@@ -46,9 +46,16 @@ $(document).ready(
function nextTest()
{
+ var path = $("#test").val();
+ if(document.location.pathname.indexOf("/es5/") !== -1 &&
+ path.indexOf("/es5/") === -1)
+ {
+ path = path.replace("/test/Ice/", "/test/Ice/es5/");
+ }
+
document.location.assign(new URI()
.host(document.location.host)
- .pathname($("#test").val())
+ .pathname(path)
.search(
{
language: $("#language").val(),
@@ -96,9 +103,16 @@ $(document).ready(
function updateLocation()
{
+ var path = $("#test").val();
+ if(document.location.pathname.indexOf("/es5/") !== -1 &&
+ path.indexOf("/es5/") === -1)
+ {
+ path = path.replace("/test/Ice/", "/test/Ice/es5/");
+ }
+
document.location.assign(new URI()
.host(document.location.host)
- .pathname($("#test").val())
+ .pathname(path)
.search(
{
language: $("#language").val(),
@@ -130,6 +144,7 @@ $(document).ready(
next(e.data.success);
}
};
+
worker.postMessage(
{
type: "RunTest",
@@ -140,7 +155,8 @@ $(document).ready(
defaultHost: document.location.hostname || "127.0.0.1",
protocol: $("#protocol").val(),
configurations: TestCases[current].configurations,
- files: TestCases[current].files
+ files: TestCases[current].files,
+ es5: document.location.pathname.indexOf("/es5/") !== -1
}
});
}
diff --git a/js/test/Common/Worker.js b/js/test/Common/Worker.js
index e7789c45ded..450a1dba73b 100644
--- a/js/test/Common/Worker.js
+++ b/js/test/Common/Worker.js
@@ -29,12 +29,27 @@ self.onmessage = function(e)
if(e.data.type == "RunTest")
{
var test = e.data.test;
- self.importScripts("/lib/Ice.js");
- self.importScripts("/test/Common/Controller.js");
+ if(test.es5)
+ {
+ self.importScripts("/node_modules/babel-polyfill/dist/polyfill.js");
+ self.importScripts("/node_modules/regenerator-runtime/runtime.js");
+ self.importScripts("/lib/es5/Ice.js");
+ self.importScripts("/test/Common/es5/Controller.js");
+ }
+ else
+ {
+ self.importScripts("/lib/Ice.js");
+ self.importScripts("/test/Common/Controller.js");
+ }
self.importScripts("/test/Common/TestRunner.js");
for(var i = 0; i < test.files.length; ++i)
{
- self.importScripts("/test/" + test.name + "/" + test.files[i]);
+ var f = "/test/" + test.name + "/" + test.files[i];
+ if(test.es5)
+ {
+ f = f.replace("/test/Ice/", "/test/Ice/es5/");
+ }
+ self.importScripts(f);
}
runTest(test.name, test.language, test.defaultHost, test.protocol, test.configurations, Output).then(
function(r)
diff --git a/js/test/Glacier2/router/Client.js b/js/test/Glacier2/router/Client.js
index 384d108ff95..c207321d37f 100644
--- a/js/test/Glacier2/router/Client.js
+++ b/js/test/Glacier2/router/Client.js
@@ -25,40 +25,43 @@
var CallbackPrx = Test.CallbackPrx;
var CallbackReceiverPrx = Test.CallbackReceiverPrx;
- var CallbackReceiverI = function()
+ class CallbackReceiverI extends Test.CallbackReceiver
{
- this._callback = false;
- this._p = new Promise();
- };
- CallbackReceiverI.prototype = new Test.CallbackReceiver();
- CallbackReceiverI.prototype.constructor = CallbackReceiverI;
+ constructor()
+ {
+ super();
+ this._callback = false;
+ this._p = new Promise();
+ }
- CallbackReceiverI.prototype.callback = function(current)
- {
- test(!this._callback);
- this._p.succeed();
- };
- CallbackReceiverI.prototype.callbackEx = function(current)
- {
- this.callback(current);
- var ex = new Test.CallbackException();
- ex.someValue = 3.14;
- ex.someString = "3.14";
- throw ex;
- };
+ callback(current)
+ {
+ test(!this._callback);
+ this._p.resolve();
+ }
- CallbackReceiverI.prototype.callbackOK = function()
- {
- var p = new Promise();
- var self = this;
- this._p.then(function(){
- p.succeed();
- this._callback = false;
- self._p = new Promise();
- });
- return p;
- };
+ callbackEx(current)
+ {
+ this.callback(current);
+ var ex = new Test.CallbackException();
+ ex.someValue = 3.14;
+ ex.someString = "3.14";
+ throw ex;
+ }
+
+ callbackOK()
+ {
+ var p = new Promise();
+ this._p.then(() =>
+ {
+ p.resolve();
+ this._callback = false;
+ this._p = new Promise();
+ });
+ return p;
+ }
+ }
var allTests = function(out, communicator)
{
@@ -376,7 +379,7 @@
test(ex instanceof Ice.LocalException);
out.writeLine("ok");
}
- );
+ ).catch(e => console.log(e));
};
var run = function(out, id)
diff --git a/js/test/Ice/acm/Client.js b/js/test/Ice/acm/Client.js
index 9d4d6764bab..6c3b74e89cb 100644
--- a/js/test/Ice/acm/Client.js
+++ b/js/test/Ice/acm/Client.js
@@ -21,44 +21,49 @@
}
};
- var LoggerI = Ice.Class({
- __init__: function(out)
+ class LoggerI
+ {
+ constructor(out)
{
this._messages = [];
this._out = out;
- },
- print: function(msg)
+ }
+
+ print(msg)
{
this._messages.push(msg);
- },
- trace: function(category, message)
+ }
+
+ trace(category, message)
{
this._messages.push("[" + category + "] " + message);
- },
- warning: function(message)
+ }
+
+ warning(message)
{
this._messages.push("warning: " + message);
- },
- error: function(message)
+ }
+
+ error(message)
{
this._messages.push("error: " + message);
- },
- cloneWithPrefix: function(prefix)
+ }
+
+ cloneWithPrefix(prefix)
{
return this;
- },
- dump: function()
+ }
+
+ dump()
{
- for(var i = 0; i < this._messages.length; ++i)
- {
- this._out.writeLine(this._messages[i]);
- }
+ this._messages.forEach(message => this._out.writeLine(message));
this._messages = [];
}
- });
+ }
- var TestCase = Ice.Class({
- __init__: function(name, com, out)
+ class TestCase
+ {
+ constructor(name, com, out)
{
this._name = name;
this._com = com;
@@ -75,8 +80,9 @@
this._heartbeat = 0;
this._closed = false;
- },
- init: function()
+ }
+
+ init()
{
var initData = new Ice.InitializationData();
initData.properties = this._com.ice_getCommunicator().getProperties().clone();
@@ -98,23 +104,20 @@
//initData.properties.setProperty("Ice.Trace.Network", "2");
this._communicator = Ice.initialize(initData);
- var self = this;
return this._com.createObjectAdapter(this._serverACMTimeout,
this._serverACMClose,
- this._serverACMHeartbeat).then(function(adapter)
+ this._serverACMHeartbeat).then(adapter =>
{
- self._adapter = adapter;
+ this._adapter = adapter;
});
- },
- destroy: function()
+ }
+
+ destroy()
{
- var self = this;
- return this._adapter.deactivate().then(function()
- {
- return self._communicator.destroy();
- });
- },
- join: function(out)
+ return this._adapter.deactivate().then(() => this._communicator.destroy());
+ }
+
+ join(out)
{
this._logger.dump();
out.write("testing " + this._name + "... ");
@@ -127,257 +130,234 @@
out.writeLine("failed! " + this._msg);
test(false);
}
- },
- start: function()
+ }
+
+ start()
{
- var proxy = null;
- var self = this;
- return this._adapter.getTestIntf().then(
- function(prx)
- {
- proxy = Test.TestIntfPrx.uncheckedCast(self._communicator.stringToProxy(prx.toString()));
- return proxy.ice_getConnection();
- }
- ).then(
- function(con)
+ return this._adapter.getTestIntf().then(prx =>
{
- con.setCloseCallback(function(connection)
- {
- self._closed = true;
- });
- con.setHeartbeatCallback(function(connection)
- {
- ++self._heartbeat;
- });
- return self.runTestCase(self._adapter, proxy);
- }
- ).exception(
- function(ex)
- {
- self._msg = "unexpected exception:\n" + ex.toString() + "\n" + ex.stack;
- }
- );
- },
- runTestCase: function(adapter, proxy)
+ prx = Test.TestIntfPrx.uncheckedCast(this._communicator.stringToProxy(prx.toString()));
+ return prx.ice_getConnection().then(con =>
+ {
+ con.setCloseCallback(connection => this._closed = true);
+
+ con.setHeartbeatCallback(connection => ++this._heartbeat);
+
+ return this.runTestCase(this._adapter, prx);
+ }).catch(ex =>
+ {
+ this._msg = "unexpected exception:\n" + ex.toString() + "\n" + ex.stack;
+ });
+ });
+ }
+
+ runTestCase(adapter, proxy)
{
test(false); // Abstract
- },
- setClientACM: function(timeout, close, heartbeat)
+ }
+
+ setClientACM(timeout, close, heartbeat)
{
this._clientACMTimeout = timeout;
this._clientACMClose = close;
this._clientACMHeartbeat = heartbeat;
- },
- setServerACM: function(timeout, close, heartbeat)
+ }
+
+ setServerACM(timeout, close, heartbeat)
{
this._serverACMTimeout = timeout;
this._serverACMClose = close;
this._serverACMHeartbeat = heartbeat;
}
- });
+ }
- var InvocationHeartbeatTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class InvocationHeartbeatTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "invocation heartbeat", com, out);
- },
- runTestCase: function(adapter, proxy)
+ super("invocation heartbeat", com, out);
+ }
+
+ runTestCase(adapter, proxy)
{
- var self = this;
- return proxy.sleep(2).then(
- function()
+ return proxy.sleep(2).then(() =>
{
- test(self._heartbeat >= 2);
- }
- );
+ test(this._heartbeat >= 2);
+ });
}
- });
+ }
- var InvocationHeartbeatOnHoldTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class InvocationHeartbeatOnHoldTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "invocation with heartbeat on hold", com, out);
+ super("invocation with heartbeat on hold", com, out);
// Use default ACM configuration.
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
// When the OA is put on hold, connections shouldn't
// send heartbeats, the invocation should therefore
// fail.
- var self = this;
return proxy.sleepAndHold(10).then(
- function()
- {
- test(false);
- },
- function(ex)
- {
- test(self._closed);
- return adapter.activate().then(function()
- {
- return proxy.interruptSleep();
- });
- }
- );
+ () => test(false),
+ ex => test(this._closed))
+ .then(() => adapter.activate())
+ .then(() => proxy.interruptSleep());
}
- });
+ }
- var InvocationNoHeartbeatTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class InvocationNoHeartbeatTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "invocation with no heartbeat", com, out);
+ super("invocation with no heartbeat", com, out);
this.setServerACM(1, 2, 0); // Disable heartbeat on invocations
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
// Heartbeats are disabled on the server, the
// invocation should fail since heartbeats are
// expected.
- var self = this;
return proxy.sleep(10).then(
- function()
- {
- test(false);
- },
- function(ex)
+ () => test(false),
+ ex =>
{
- test(self._heartbeat === 0);
- test(self._closed);
+ test(this._heartbeat === 0);
+ test(this._closed);
return proxy.interruptSleep();
- }
- );
+ });
}
- });
+ }
- var InvocationHeartbeatCloseOnIdleTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class InvocationHeartbeatCloseOnIdleTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "invocation with no heartbeat and close on idle", com, out);
+ super("invocation with no heartbeat and close on idle", com, out);
this.setClientACM(1, 1, 0); // Only close on idle.
this.setServerACM(1, 2, 0); // Disable heartbeat on invocations
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
// No close on invocation, the call should succeed this
// time.
- var self = this;
- return proxy.sleep(2).then(function()
+ return proxy.sleep(2).then(() =>
{
- test(self._heartbeat === 0);
- test(!self._closed);
+ test(this._heartbeat === 0);
+ test(!this._closed);
});
}
- });
+ }
- var CloseOnIdleTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class CloseOnIdleTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "close on idle", com, out);
+ super("close on idle", com, out);
this.setClientACM(1, 1, 0); // Only close on idle
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
- var self = this;
- return Ice.Promise.delay(1500).then(function()
+ return Ice.Promise.delay(2000).then(() =>
{
- test(self._heartbeat === 0);
- test(self._closed);
+ test(this._heartbeat === 0);
+ test(this._closed);
});
}
- });
+ }
- var CloseOnInvocationTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class CloseOnInvocationTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "close on invocation", com, out);
+ super("close on invocation", com, out);
this.setClientACM(1, 2, 0); // Only close on invocation
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
- var self = this;
- return Ice.Promise.delay(1500).then(function()
+ return Ice.Promise.delay(1500).then(() =>
{
- test(self._heartbeat === 0);
- test(!self._closed);
+ test(this._heartbeat === 0);
+ test(!this._closed);
});
}
- });
+ }
- var CloseOnIdleAndInvocationTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class CloseOnIdleAndInvocationTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "close on idle and invocation", com, out);
+ super("close on idle and invocation", com, out);
this.setClientACM(1, 3, 0); // Only close on idle and invocation
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
//
// Put the adapter on hold. The server will not respond to
// the graceful close. This allows to test whether or not
// the close is graceful or forceful.
//
- var self = this;
return adapter.hold().delay(1500).then(
- function()
+ () =>
{
- test(self._heartbeat === 0);
- test(!self._closed); // Not closed yet because of graceful close.
+ test(this._heartbeat === 0);
+ test(!this._closed); // Not closed yet because of graceful close.
return adapter.activate();
- }
- ).delay(500).then(
- function()
- {
- test(self._closed); // Connection should be closed this time.
- }
- );
+ }).delay(500).then(() => test(this._closed)); // Connection should be closed this time.
}
- });
+ }
- var ForcefullCloseOnIdleAndInvocationTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class ForcefullCloseOnIdleAndInvocationTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "forcefull close on idle and invocation", com, out);
+ super("forcefull close on idle and invocation", com, out);
this.setClientACM(1, 4, 0); // Only close on idle and invocation
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
- var self = this;
return adapter.hold().delay(1500).then(
- function()
+ () =>
{
- test(self._heartbeat === 0);
- test(self._closed); // Connection closed forcefully by ACM
+ test(this._heartbeat === 0);
+ test(this._closed); // Connection closed forcefully by ACM
});
}
- });
+ }
- var HeartbeatOnIdleTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class HeartbeatOnIdleTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "heartbeat on idle", com, out);
+ super("heartbeat on idle", com, out);
this.setServerACM(1, -1, 2); // Enable server heartbeats.
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
- var self = this;
- return Ice.Promise.delay(2000).then(
- function()
- {
- test(self._heartbeat >= 3);
- });
+ return Ice.Promise.delay(2000).then(() => test(this._heartbeat >= 3));
}
- });
+ }
- var HeartbeatAlwaysTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class HeartbeatAlwaysTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "heartbeat always", com, out);
+ super("heartbeat always", com, out);
this.setServerACM(1, -1, 3); // Enable server heartbeats.
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
- var self = this;
- var p = new Ice.Promise().succeed();
+ var p = Promise.resolve();
// Use this function so we don't have a function defined
// inside of a loop
@@ -390,20 +370,19 @@
{
p = p.then(icePing(proxy)).delay(200);
}
- return p.then(function()
- {
- test(self._heartbeat >= 3);
- });
+ return p.then(() => test(this._heartbeat >= 3));
}
- });
+ }
- var SetACMTest = Ice.Class(TestCase, {
- __init__: function(com, out)
+ class SetACMTest extends TestCase
+ {
+ constructor(com, out)
{
- TestCase.call(this, "setACM/getACM", com, out);
+ super("setACM/getACM", com, out);
this.setClientACM(15, 4, 0);
- },
- runTestCase: function(adapter, proxy)
+ }
+
+ runTestCase(adapter, proxy)
{
var acm = new Ice.ACM();
acm = proxy.ice_getCachedConnection().getACM();
@@ -427,7 +406,7 @@
return proxy.waitForHeartbeat(2);
}
- });
+ }
var allTests = function(out, communicator)
{
@@ -466,69 +445,23 @@
tests.push(new SetACMTest(com, out));
}
- var promises = [];
- for(var test in tests)
- {
- promises.push(tests[test].init());
- }
-
- return Ice.Promise.all(promises).then(
- function()
- {
- promises = [];
- for(var test in tests)
+ return Ice.Promise.all(tests.map(test => test.init())
+ ).then(() => Ice.Promise.all(tests.map(test => test.start()))
+ ).then(() => tests.forEach(test => test.join(out))
+ ).then(() => Ice.Promise.all(tests.map(test => test.destroy()))
+ ).then(() =>
{
- promises.push(tests[test].start());
+ out.write("shutting down... ");
+ return com.shutdown();
}
- return Ice.Promise.all(promises);
- }
- ).then(
- function()
- {
- for(var test in tests)
- {
- tests[test].join(out);
- }
- }
- ).then(
- function()
- {
- promises = [];
- for(var test in tests)
- {
- promises.push(tests[test].destroy());
- }
- return Ice.Promise.all(promises);
- }
- ).then(
- function()
- {
- out.write("shutting down... ");
- return com.shutdown();
- }
- ).then(
- function()
- {
- out.writeLine("ok");
- }
- );
+ ).then(() => out.writeLine("ok"));
};
var run = function(out, id)
{
id.properties.setProperty("Ice.Warn.Connections", "0");
var c = Ice.initialize(id);
- return Promise.try(
- function()
- {
- return allTests(out, c);
- }
- ).finally(
- function()
- {
- return c.destroy();
- }
- );
+ return Promise.try(() => allTests(out, c)).finally(() => c.destroy());
};
exports.__test__ = run;
exports.__runServer__ = true;
diff --git a/js/test/Ice/ami/Client.js b/js/test/Ice/ami/Client.js
index 8052b8e77d3..ec34dcba326 100644
--- a/js/test/Ice/ami/Client.js
+++ b/js/test/Ice/ami/Client.js
@@ -26,7 +26,7 @@
}
catch(err)
{
- promise.fail(err);
+ promise.reject(err);
throw err;
}
}
@@ -39,19 +39,16 @@
connectionId = "";
}
var p = proxy;
- return p.ice_connectionId(connectionId).ice_getConnection().then(
- function(c)
+ return p.ice_connectionId(connectionId).ice_getConnection().then(c =>
{
p = p.constructor.uncheckedCast(c.createProxy(proxy.ice_getIdentity())).ice_batchOneway();
return p.ice_getConnection();
}
- ).then(
- function(c)
+ ).then(c =>
{
test(p.ice_getCachedConnection() === c);
return p;
- }
- );
+ });
};
var result = null;
@@ -62,108 +59,52 @@
var b1 = null;
var b2 = null;
- Promise.try(
- function()
+ Promise.try(() =>
{
out.write("testing batch requests with proxy... ");
- return p.opBatchCount().then(
- function(count)
+ return p.opBatchCount().then(count =>
{
test(count === 0);
b1 = p.ice_batchOneway();
- test(b1.opBatch().completed());
- test(b1.opBatch().completed());
- return b1.ice_flushBatchRequests();
- }
- ).then(
- function(r1)
- {
- test(r1.completed());
- return p.waitForBatch(2);
- }
- ).then(
- function()
- {
+ test(b1.opBatch());
+ test(b1.opBatch());
return b1.ice_flushBatchRequests();
}
- ).then(
- function(r2)
- {
- test(r2.completed());
- }
- ).then(
- function()
- {
- out.writeLine("ok");
- }
- );
+ ).then(() => p.waitForBatch(2)
+ ).then(() => b1.ice_flushBatchRequests()
+ ).then(() => out.writeLine("ok"));
}
- ).then(
- function()
+ ).then(() =>
{
out.write("testing batch requests with connection... ");
- return p.opBatchCount().then(
- function(count)
+ return p.opBatchCount().then(count =>
{
test(count === 0);
- return getConnectionBatchProxy(p).then(
- function(prx)
+ return getConnectionBatchProxy(p).then(prx =>
{
b1 = prx;
var connection = b1.ice_getCachedConnection();
- test(b1.opBatch().completed());
- test(b1.opBatch().completed());
+ test(b1.opBatch());
+ test(b1.opBatch());
return connection.flushBatchRequests();
});
}
- ).then(
- function(r1)
- {
- test(r1.completed());
- return p.waitForBatch(2);
- }
- ).then(
- function()
- {
- return b1.ice_getConnection().then(function(connection)
- {
- return connection.flushBatchRequests();
- });
- }
- ).then(
- function(r2)
- {
- test(r2.completed());
- }
- ).then(
- function()
- {
- out.writeLine("ok");
- }
- );
+ ).then(() => p.waitForBatch(2)
+ ).then(() => b1.ice_getConnection().then(connection => connection.flushBatchRequests())
+ ).then(() => out.writeLine("ok"));
}
- ).then(
- function()
+ ).then(() =>
{
out.write("testing batch requests with communicator... ");
- return p.opBatchCount().then(
- function(count)
+ return p.opBatchCount().then(count =>
{
test(count === 0);
- test(b1.opBatch().completed());
- test(b1.opBatch().completed());
- return communicator.flushBatchRequests().then(function(r1)
- {
- test(r1.completed());
- return p.waitForBatch(2).then(
- function()
- {
- return p.opBatchCount();
- });
- });
+ test(b1.opBatch());
+ test(b1.opBatch());
+ return communicator.flushBatchRequests().then(() => p.waitForBatch(2))
+ .then(() => p.opBatchCount());
}
- ).then(
- function(batchCount)
+ ).then(batchCount =>
{
//
// AsyncResult exception - 1 connection.
@@ -171,27 +112,20 @@
test(batchCount === 0);
b1.opBatch();
b1.ice_getCachedConnection().close(false);
- return communicator.flushBatchRequests().then(function(r)
- {
- test(r.completed());
- return p.opBatchCount();
- });
+ return communicator.flushBatchRequests().then(() => p.opBatchCount());
}
- ).then(
- function(batchCount)
+ ).then(batchCount =>
{
//
// AsyncResult exception - 2 connections
//
test(batchCount === 0);
- return getConnectionBatchProxy(p).then(
- function(prx)
+ return getConnectionBatchProxy(p).then(prx =>
{
b1 = prx;
return getConnectionBatchProxy(p, "2");
}
- ).then( // Ensure connection is established.
- function(prx)
+ ).then(prx => // Ensure connection is established.
{
b2 = prx;
b1.opBatch();
@@ -200,18 +134,10 @@
b2.opBatch();
return communicator.flushBatchRequests();
}
- ).then(function(r)
- {
- test(r.completed());
- return p.waitForBatch(4).then(
- function()
- {
- return p.opBatchCount();
- });
- });
+ ).then(() => p.waitForBatch(4))
+ .then(() => p.opBatchCount());
}
- ).then(
- function(batchCount)
+ ).then(batchCount =>
{
//
// AsyncResult exception - 2 connections - 1 failure.
@@ -220,14 +146,12 @@
// Exceptions should not be reported.
//
test(batchCount === 0);
- return getConnectionBatchProxy(p).then(
- function(prx)
+ return getConnectionBatchProxy(p).then(prx =>
{
b1 = prx;
return getConnectionBatchProxy(p, "2");
}
- ).then( // Ensure connection is established.
- function(prx)
+ ).then(prx => // Ensure connection is established.
{
b2 = prx;
b1.opBatch();
@@ -235,18 +159,10 @@
b1.ice_getCachedConnection().close(false);
return communicator.flushBatchRequests();
}
- ).then(function(r)
- {
- test(r.completed());
- return p.waitForBatch(1).then(
- function()
- {
- return p.opBatchCount();
- });
- });
+ ).then(() => p.waitForBatch(1)
+ ).then(() => p.opBatchCount());
}
- ).then(
- function(batchCount)
+ ).then(batchCount =>
{
//
// AsyncResult exception - 2 connections - 2 failures.
@@ -255,14 +171,12 @@
// Exceptions should not be reported.
//
test(batchCount === 0);
- return getConnectionBatchProxy(p).then(
- function(prx)
+ return getConnectionBatchProxy(p).then(prx =>
{
b1 = prx;
return getConnectionBatchProxy(p, "2");
}
- ).then( // Ensure connection is established.
- function(prx)
+ ).then(prx => // Ensure connection is established.
{
b2 = prx;
b1.opBatch();
@@ -271,52 +185,29 @@
b2.ice_getCachedConnection().close(false);
return communicator.flushBatchRequests();
}
- ).then(function(r)
- {
- test(r.completed());
- return p.opBatchCount();
- });
+ ).then(() => p.opBatchCount());
}
- ).then(
- function(batchCount)
+ ).then(batchCount =>
{
test(batchCount === 0);
out.writeLine("ok");
- }
- );
+ });
}
- ).then(
- function()
+ ).then(() =>
{
out.write("testing AsyncResult operations... ");
var indirect = Test.TestIntfPrx.uncheckedCast(p.ice_adapterId("dummy"));
- return indirect.op().exception(
- function(ex, r)
- {
- try
- {
- r.throwLocalException();
- }
- catch(ex)
- {
- test(ex instanceof Ice.NoEndpointException);
- }
- }
- ).then(
- function()
- {
- return testController.holdAdapter();
- }
- ).then(
- function()
+
+ return indirect.op().catch(ex => test(ex instanceof Ice.NoEndpointException)
+ ).then(() => testController.holdAdapter()
+ ).then(() =>
{
var r1 = p.op();
var r2 = null;
var seq = Ice.Buffer.createNative(new Array(100000));
while((r2 = p.opWithPayload(seq)).sentSynchronously());
-
test(r1.sentSynchronously() && r1.isSent() && !r1.isCompleted() ||
!r1.sentSynchronously() && !r1.isCompleted());
@@ -327,23 +218,19 @@
test(r1.operation === "op");
test(r2.operation === "opWithPayload");
- return r1.then(
- function()
+ return r1.then(() =>
{
test(r1.isSent());
test(r1.isCompleted());
return r2;
}
- ).then(
- function()
+ ).then(() =>
{
test(r2.isSent());
test(r2.isCompleted());
- }
- );
+ });
}
- ).then(
- function()
+ ).then(() =>
{
r = p.ice_ping();
test(r.operation === "ice_ping");
@@ -389,21 +276,16 @@
test(r.communicator == communicator);
test(r.proxy === null);
}
- ).then(
- function()
- {
- return testController.holdAdapter();
- }
- ).then(
- function()
+ ).then(() => testController.holdAdapter()
+ ).then(() =>
{
- var seq = Ice.Buffer.createNative(new Array(100024));
+ var seq = Ice.Buffer.createNative(new Array(100000));
while((r = p.opWithPayload(seq)).sentSynchronously());
-
test(!r.isSent());
var r1 = p.ice_ping();
var r2 = p.ice_id();
+
r1.cancel();
r2.cancel();
@@ -416,6 +298,7 @@
{
test(ex instanceof Ice.InvocationCanceledException);
}
+
try
{
r2.throwLocalException();
@@ -426,29 +309,20 @@
test(ex instanceof Ice.InvocationCanceledException);
}
- return testController.resumeAdapter().then(
- function()
- {
- return p.ice_ping().then(
- function()
- {
- test(!r1.isSent() && r1.isCompleted());
- test(!r2.isSent() && r2.isCompleted());
- });
- });
- }
- ).then(
- function()
- {
- return testController.holdAdapter();
+ return testController.resumeAdapter()
+ .then(() => p.ice_ping())
+ .then(() =>
+ {
+ test(!r1.isSent() && r1.isCompleted());
+ test(!r2.isSent() && r2.isCompleted());
+ });
}
- ).then(
- function()
+ ).then(() => testController.holdAdapter()
+ ).then(() =>
{
var r1 = p.op();
var r2 = p.ice_id();
- return p.ice_oneway().ice_ping().then(
- function()
+ return p.ice_oneway().ice_ping().then(() =>
{
r1.cancel();
r2.cancel();
@@ -474,36 +348,23 @@
testController.resumeAdapter();
});
}
- ).then(
- function()
- {
- out.writeLine("ok");
- });
+ ).then(() => out.writeLine("ok"));
}
).then(
- function()
- {
- return p.shutdown();
- },
- function(ex)
+ () => p.shutdown(),
+ ex =>
{
console.log("unexpected exception:\n" + ex);
test(false);
}
- ).then(
- function()
- {
- promise.succeed();
- }
- );
+ ).then(promise.resolve, promise.reject);
return promise;
}
exports.__test__ = function(out, id)
{
var communicator = Ice.initialize(id);
- return Promise.try(
- function()
+ return Promise.try(() =>
{
if(typeof(navigator) !== 'undefined' && isSafari() && isWorker())
{
@@ -515,13 +376,7 @@
{
return allTests(communicator, out);
}
- }
- ).finally(
- function()
- {
- communicator.destroy();
- }
- );
+ }).finally(() => communicator.destroy());
};
exports.__runServer__ = true;
}
diff --git a/js/test/Ice/binding/Client.js b/js/test/Ice/binding/Client.js
index 30b0604fd59..075c5f491b8 100644
--- a/js/test/Ice/binding/Client.js
+++ b/js/test/Ice/binding/Client.js
@@ -19,13 +19,10 @@
{
if(array.length === 0)
{
- return new Promise.succeed();
+ return Promise.resolve();
}
var p = null;
- array.forEach(function(e)
- {
- p = p ? p.then(fn(e)) : fn(e);
- });
+ array.forEach(e => p = p ? p.then(fn(e)) : fn(e));
return p;
};
@@ -60,21 +57,17 @@
var createTestIntfPrx = function(adapters)
{
var endpoints = [];
- var closePromises = [];
var p = null;
return Promise.all(adapters.map(function(adapter){ return adapter.getTestIntf(); })).then(
- function()
+ function(results)
{
- var results = Array.prototype.slice.call(arguments);
results.forEach(
function(r)
{
- p = r[0];
- test(p);
+ p = r;
endpoints = endpoints.concat(p.ice_getEndpoints());
- }
- );
+ });
return Test.TestIntfPrx.uncheckedCast(p.ice_endpoints(endpoints));
});
};
@@ -89,7 +82,7 @@
{
if(adapters.length > 0)
{
- f1(adapters);
+ return (adapters);
}
}
);
@@ -108,7 +101,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -141,48 +134,44 @@
function(obj)
{
adapter = obj;
- return Promise.all(adapter.getTestIntf(), adapter.getTestIntf());
+ return Promise.all([adapter.getTestIntf(), adapter.getTestIntf()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- test1 = r1[0];
- test2 = r2[0];
-
- return Promise.all(test1.ice_getConnection(), test2.ice_getConnection());
+ [test1, test2] = r;
+ return Promise.all([test1.ice_getConnection(), test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- conn1 = r1[0];
- conn2 = r2[0];
+ [conn1, conn2] = r;
test(conn1 === conn2);
- return Promise.all(test1.ice_ping(), test2.ice_ping());
+ return Promise.all([test1.ice_ping(), test2.ice_ping()]);
}
).then(
- function(r1, r2)
+ function(r)
{
+ let [r1, r2] = r;
return com.deactivateObjectAdapter(adapter);
}
).then(
function()
{
test3 = Test.TestIntfPrx.uncheckedCast(test1);
- return Promise.all(test3.ice_getConnection(), test1.ice_getConnection());
+ return Promise.all([test3.ice_getConnection(), test1.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- conn3 = r1[0];
- conn1 = r2[0];
+ [conn3, conn1] = r;
test(conn3 === conn1);
- return Promise.all(test3.ice_getConnection(), test2.ice_getConnection());
+ return Promise.all([test3.ice_getConnection(), test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- conn3 = r1[0];
- conn2 = r2[0];
+ [conn3, conn2] = r;
test(conn3 === conn2);
return test3.ice_ping();
}
@@ -206,21 +195,19 @@
{
out.write("testing binding with multiple endpoints... ");
- return Promise.all(
+ return Promise.all([
com.createObjectAdapter("Adapter11", "default"),
com.createObjectAdapter("Adapter12", "default"),
- com.createObjectAdapter("Adapter13", "default"));
+ com.createObjectAdapter("Adapter13", "default")]);
}
).then(
//
// Ensure that when a connection is opened it's reused for new
// proxies and that all endpoints are eventually tried.
//
- function(r1, r2, r3)
+ function(r)
{
- adapters.push(r1[0]);
- adapters.push(r2[0]);
- adapters.push(r3[0]);
+ adapters.push(...r);
var f1 = function(names)
{
@@ -243,17 +230,19 @@
function(obj)
{
test3 = obj;
- return Promise.all(test1.ice_getConnection(), test2.ice_getConnection());
+ return Promise.all([test1.ice_getConnection(), test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
+ let [r1, r2] = r;
test(r1[0] === r2[0]);
- return Promise.all(test2.ice_getConnection(), test3.ice_getConnection());
+ return Promise.all([test2.ice_getConnection(), test3.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
+ let [r1, r2] = r;
test(r1[0] === r2[0]);
return test1.getAdapterName();
}
@@ -440,8 +429,7 @@
{
return f1(names);
}
- }
- );
+ });
};
return f1(ArrayUtil.clone(names));
}
@@ -498,9 +486,9 @@
return com.createObjectAdapter(name, "default");
})
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
var count = 20;
var adapterCount = adapters.length;
var proxies = new Array(10);
@@ -508,7 +496,7 @@
var f1 = function(count, adapterCount, proxies)
{
- var p1 = count === 10 ? com.deactivateObjectAdapter(adapters[2]) : new Promise().succeed();
+ var p1 = count === 10 ? com.deactivateObjectAdapter(adapters[2]) : Promise.resolve();
return p1.then(
function()
{
@@ -560,7 +548,7 @@
return forEach(proxies,
function(proxy)
{
- return proxy.ice_ping().exception(
+ return proxy.ice_ping().catch(
function(ex)
{
test(ex instanceof Ice.LocalException);
@@ -621,12 +609,7 @@
function()
{
out.writeLine("ok");
- },
- function(ex)
- {
- out.writeLine("failed! " + ex.stack);
- }
- );
+ });
}
).then(
function()
@@ -641,14 +624,14 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); }));
}
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
return createTestIntfPrx(adapters);
},
function(ex)
{
- console.log(ex.toString());
+ console.log(ex.stack);
test(false);
}
).then(
@@ -658,8 +641,7 @@
var f1 = function()
{
- return prx.getAdapterName().then(
- function(name)
+ return prx.getAdapterName().then(name =>
{
if(names.indexOf(name) !== -1)
{
@@ -667,24 +649,8 @@
}
return prx.ice_getConnection();
}
- ).then(
- function(conn)
- {
- return conn.close(false);
- }
- ).then(
- function()
- {
- if(names.length > 0)
- {
- return f1();
- }
- else
- {
- return prx;
- }
- }
- );
+ ).then(conn => conn.close(false)
+ ).then(() => names.length > 0 ? f1() : prx);
};
return f1();
@@ -751,9 +717,9 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); }));
}
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
return createTestIntfPrx(adapters);
}
).then(
@@ -883,14 +849,15 @@
test2 = Test.TestIntfPrx.uncheckedCast(obj.ice_connectionCached(false));
test(!test1.ice_isConnectionCached());
test(!test2.ice_isConnectionCached());
- return Promise.all(test1.ice_getConnection(),
- test2.ice_getConnection());
+ return Promise.all([test1.ice_getConnection(),
+ test2.ice_getConnection()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- test(r1[0] && r2[0]);
- test(r1[0] == r2[0]);
+ let [r1, r2] = r;
+ test(r1 && r2);
+ test(r1 == r2);
return test1.ice_ping();
}
).then(
@@ -902,8 +869,8 @@
function()
{
var test3 = Test.TestIntfPrx.uncheckedCast(test1);
- return Promise.all(test3.ice_getConnection(),
- test1.ice_getConnection());
+ return Promise.all([test3.ice_getConnection(),
+ test1.ice_getConnection()]);
}
).then(
function()
@@ -932,9 +899,9 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); }));
}
).then(
- function()
+ function(r)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = r;
var f2 = function(prx)
{
@@ -1024,7 +991,7 @@
return Promise.all(names.map(function(name) { return com.createObjectAdapter(name, "default"); })).then(
function(a)
{
- adapters = Array.prototype.slice.call(arguments).map(function(r) { return r[0]; });
+ adapters = a;
return createTestIntfPrx(adapters);
}
).then(
@@ -1129,21 +1096,14 @@
{
return com.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.rejectr);
return p;
};
var run = function(out, id)
{
+ //id.properties.setProperty("Ice.Trace.Protocol", "1");
+ //id.properties.setProperty("Ice.Trace.Network", "2");
var p = new Ice.Promise();
setTimeout(
function()
@@ -1153,14 +1113,14 @@
allTests(out, id).then(function(){
return communicator.destroy();
}).then(function(){
- p.succeed();
- }).exception(function(ex){
- p.fail(ex);
+ p.resolve();
+ }).catch(function(ex){
+ p.reject(ex);
});
}
catch(ex)
{
- p.fail(ex);
+ p.reject(ex);
}
});
return p;
diff --git a/js/test/Ice/defaultValue/Client.js b/js/test/Ice/defaultValue/Client.js
index 4a33c43c396..0e626fa90e5 100644
--- a/js/test/Ice/defaultValue/Client.js
+++ b/js/test/Ice/defaultValue/Client.js
@@ -196,16 +196,7 @@
out.writeLine("ok");
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
exports.__test__ = run;
diff --git a/js/test/Ice/enums/Client.js b/js/test/Ice/enums/Client.js
index 1b0457b9c55..707f0f87b45 100644
--- a/js/test/Ice/enums/Client.js
+++ b/js/test/Ice/enums/Client.js
@@ -27,7 +27,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -144,73 +144,73 @@
return proxy.opByte(Test.ByteEnum.benum1);
}
).then(
- function(r, b1)
+ function(r)
{
- test(r === b1);
- test(r === Test.ByteEnum.benum1);
+ var [ret, b1] = r;
+ test(ret === b1);
+ test(ret === Test.ByteEnum.benum1);
return proxy.opByte(Test.ByteEnum.benum11);
}
).then(
- function(r, b11)
+ function(r)
{
- test(r === b11);
- test(r === Test.ByteEnum.benum11);
+ var [ret, b11] = r;
+ test(ret === b11);
+ test(ret === Test.ByteEnum.benum11);
return proxy.opShort(Test.ShortEnum.senum1);
}
).then(
- function(r, s1)
+ function(r)
{
- test(r === s1);
- test(r === Test.ShortEnum.senum1);
+ var [ret, s1] = r;
+ test(ret === s1);
+ test(ret === Test.ShortEnum.senum1);
return proxy.opShort(Test.ShortEnum.senum11);
}
).then(
- function(r, s11)
+ function(r)
{
- test(r === s11);
- test(r === Test.ShortEnum.senum11);
+ var [ret, s11] = r;
+ test(ret === s11);
+ test(ret === Test.ShortEnum.senum11);
return proxy.opInt(Test.IntEnum.ienum1);
}
).then(
- function(r, i1)
+ function(r)
{
- test(r === i1);
- test(r === Test.IntEnum.ienum1);
+ var [ret, i1] = r;
+ test(ret === i1);
+ test(ret === Test.IntEnum.ienum1);
return proxy.opInt(Test.IntEnum.ienum11);
}
).then(
- function(r, i11)
+ function(r)
{
- test(r === i11);
- test(r === Test.IntEnum.ienum11);
+ var [ret, i11] = r;
+ test(ret === i11);
+ test(ret === Test.IntEnum.ienum11);
return proxy.opInt(Test.IntEnum.ienum12);
}
).then(
- function(r, i12)
+ function(r)
{
- test(r === i12);
- test(r === Test.IntEnum.ienum12);
+ var [ret, i12] = r;
+ test(ret === i12);
+ test(ret === Test.IntEnum.ienum12);
return proxy.opSimple(Test.SimpleEnum.green);
}
).then(
- function(r, g)
+ function(r)
{
- test(r === g);
- test(r === Test.SimpleEnum.green);
+ var [ret, g] = r;
+ test(ret === g);
+ test(ret === Test.SimpleEnum.green);
out.writeLine("ok");
return proxy.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
+
return p;
};
@@ -226,8 +226,10 @@
function()
{
return c.destroy();
- }
- );
+ }).catch(e =>
+ {
+ console.log(e);
+ });
};
exports.__test__ = run;
exports.__runServer__ = true;
diff --git a/js/test/Ice/exceptions/Client.js b/js/test/Ice/exceptions/Client.js
index 7c54701e5b0..2b2c789b9fc 100644
--- a/js/test/Ice/exceptions/Client.js
+++ b/js/test/Ice/exceptions/Client.js
@@ -16,29 +16,25 @@
var allTests = function(out, communicator, Test, bidir)
{
- var EmptyI = function()
+ class EmptyI extends Test.Empty
{
- };
-
- EmptyI.prototype = new Test.Empty();
- EmptyI.prototype.constructor = EmptyI;
-
- var ServantLocatorI = function()
- {
- };
+ }
- ServantLocatorI.prototype.locate = function(curr, cookie)
+ class ServantLocatorI
{
- return null;
- };
+ locate(curr, cookie)
+ {
+ return null;
+ }
- ServantLocatorI.prototype.finished = function(curr, servant, cookie)
- {
- };
+ finished(curr, servant, cookie)
+ {
+ }
- ServantLocatorI.prototype.deactivate = function(category)
- {
- };
+ deactivate(category)
+ {
+ }
+ }
function ValueFactoryI()
{
@@ -56,7 +52,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -249,7 +245,7 @@
out.write("testing checked cast... ");
return Test.ThrowerPrx.checkedCast(base);
}
- ).then(
+ ).then(
function(obj)
{
thrower = obj;
@@ -460,16 +456,7 @@
out.writeLine("ok");
return thrower.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
@@ -483,12 +470,7 @@
{
return allTests(out, c, Test);
}
- ).finally(
- function()
- {
- return c.destroy();
- }
- );
+ ).finally(() => c.destroy);
};
exports.__test__ = run;
exports.__clientAllTests__ = allTests;
diff --git a/js/test/Ice/exceptionsBidir/AMDThrowerI.js b/js/test/Ice/exceptionsBidir/AMDThrowerI.js
index 9193de590f9..3fc9bfd3a19 100644
--- a/js/test/Ice/exceptionsBidir/AMDThrowerI.js
+++ b/js/test/Ice/exceptionsBidir/AMDThrowerI.js
@@ -21,31 +21,32 @@
}
};
- var AMDThrowerI = Class(TestAMD.Thrower, {
- shutdown_async: function(cb, current)
+ class AMDThrowerI extends TestAMD.Thrower
+ {
+ shutdown_async(cb, current)
{
current.adapter.getCommunicator().shutdown();
cb.ice_response();
- },
+ }
- supportsUndeclaredExceptions_async: function(cb, current)
+ supportsUndeclaredExceptions_async(cb, current)
{
cb.ice_response(true);
- },
+ }
- supportsAssertException_async: function(cb, current)
+ supportsAssertException_async(cb, current)
{
cb.ice_response(false);
- },
+ }
- throwAasA_async: function(cb, a, current)
+ throwAasA_async(cb, a, current)
{
var ex = new TestAMD.A();
ex.aMem = a;
cb.ice_exception(ex);
- },
+ }
- throwAorDasAorD_async: function(cb, a, current)
+ throwAorDasAorD_async(cb, a, current)
{
var ex;
if(a > 0)
@@ -60,107 +61,104 @@
ex.dMem = a;
cb.ice_exception(ex);
}
- },
+ }
- throwBasA_async: function(cb, a, b, current)
+ throwBasA_async(cb, a, b, current)
{
this.throwBasB_async(cb, a, b, current);
- },
+ }
- throwBasB_async: function(cb, a, b, current)
+ throwBasB_async(cb, a, b, current)
{
var ex = new TestAMD.B();
ex.aMem = a;
ex.bMem = b;
cb.ice_exception(ex);
- },
+ }
- throwCasA_async: function(cb, a, b, c, current)
+ throwCasA_async(cb, a, b, c, current)
{
this.throwCasC_async(cb, a, b, c, current);
- },
+ }
- throwCasB_async: function(cb, a, b, c, current)
+ throwCasB_async(cb, a, b, c, current)
{
this.throwCasC_async(cb, a, b, c, current);
- },
+ }
- throwCasC_async: function(cb, a, b, c, current)
+ throwCasC_async(cb, a, b, c, current)
{
var ex = new TestAMD.C();
ex.aMem = a;
ex.bMem = b;
ex.cMem = c;
cb.ice_exception(ex);
- },
+ }
- throwUndeclaredA_async: function(cb, a, current)
+ throwUndeclaredA_async(cb, a, current)
{
var ex = new TestAMD.A();
ex.aMem = a;
cb.ice_exception(ex);
- },
+ }
- throwUndeclaredB_async: function(cb, a, b, current)
+ throwUndeclaredB_async(cb, a, b, current)
{
var ex = new TestAMD.B();
ex.aMem = a;
ex.bMem = b;
cb.ice_exception(ex);
- },
+ }
- throwUndeclaredC_async: function(cb, a, b, c, current)
+ throwUndeclaredC_async(cb, a, b, c, current)
{
var ex = new TestAMD.C();
ex.aMem = a;
ex.bMem = b;
ex.cMem = c;
cb.ice_exception(ex);
- },
+ }
- throwLocalException_async: function(cb, current)
+ throwLocalException_async(cb, current)
{
cb.ice_exception(new Ice.TimeoutException());
- },
+ }
- throwLocalExceptionIdempotent_async: function(cb, current)
+ throwLocalExceptionIdempotent_async(cb, current)
{
cb.ice_exception(new Ice.TimeoutException());
- },
+ }
- throwNonIceException_async: function(cb, current)
+ throwNonIceException_async(cb, current)
{
cb.ice_exception(new Error());
- },
+ }
- throwAssertException_async: function(cb, current)
+ throwAssertException_async(cb, current)
{
test(false);
- },
+ }
- throwMemoryLimitException_async: function(cb, seq, current)
+ throwMemoryLimitException_async(cb, seq, current)
{
cb.ice_response(Ice.Buffer.createNative(1024 * 20)); // 20KB is over the configured 10KB message size max.
- },
+ }
- throwAfterResponse_async: function(cb, current)
+ throwAfterResponse_async(cb, current)
{
cb.ice_response();
-
throw new Error();
- },
+ }
- throwAfterException_async: function(cb, current)
+ throwAfterException_async(cb, current)
{
cb.ice_exception(new TestAMD.A());
throw new Error();
}
- });
-
+ }
exports.AMDThrowerI = AMDThrowerI;
}
(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : this.Ice.__require,
typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : this));
-
diff --git a/js/test/Ice/exceptionsBidir/ThrowerI.js b/js/test/Ice/exceptionsBidir/ThrowerI.js
index 6d5c8b01e79..9d1a3492df7 100644
--- a/js/test/Ice/exceptionsBidir/ThrowerI.js
+++ b/js/test/Ice/exceptionsBidir/ThrowerI.js
@@ -22,30 +22,31 @@
}
};
- var ThrowerI = Class(Test.Thrower, {
- shutdown: function(current)
+ class ThrowerI extends Test.Thrower
+ {
+ shutdown(current)
{
current.adapter.getCommunicator().shutdown();
- },
+ }
- supportsUndeclaredExceptions: function(current)
+ supportsUndeclaredExceptions(current)
{
return true;
- },
+ }
- supportsAssertException: function(current)
+ supportsAssertException(current)
{
return false;
- },
+ }
- throwAasA: function(a, current)
+ throwAasA(a, current)
{
var ex = new Test.A();
ex.aMem = a;
throw ex;
- },
+ }
- throwAorDasAorD: function(a, current)
+ throwAorDasAorD(a, current)
{
var ex;
if(a > 0)
@@ -60,104 +61,104 @@
ex.dMem = a;
throw ex;
}
- },
+ }
- throwBasA: function(a, b, current)
+ throwBasA(a, b, current)
{
this.throwBasB(a, b, current);
- },
+ }
- throwBasB: function(a, b, current)
+ throwBasB(a, b, current)
{
var ex = new Test.B();
ex.aMem = a;
ex.bMem = b;
throw ex;
- },
+ }
- throwCasA: function(a, b, c, current)
+ throwCasA(a, b, c, current)
{
this.throwCasC(a, b, c, current);
- },
+ }
- throwCasB: function(a, b, c, current)
+ throwCasB(a, b, c, current)
{
this.throwCasC(a, b, c, current);
- },
+ }
- throwCasC: function(a, b, c, current)
+ throwCasC(a, b, c, current)
{
var ex = new Test.C();
ex.aMem = a;
ex.bMem = b;
ex.cMem = c;
throw ex;
- },
+ }
- throwUndeclaredA: function(a, current)
+ throwUndeclaredA(a, current)
{
var ex = new Test.A();
ex.aMem = a;
throw ex;
- },
+ }
- throwUndeclaredB: function(a, b, current)
+ throwUndeclaredB(a, b, current)
{
var ex = new Test.B();
ex.aMem = a;
ex.bMem = b;
throw ex;
- },
+ }
- throwUndeclaredC: function(a, b, c, current)
+ throwUndeclaredC(a, b, c, current)
{
var ex = new Test.C();
ex.aMem = a;
ex.bMem = b;
ex.cMem = c;
throw ex;
- },
+ }
- throwLocalException: function(current)
+ throwLocalException(current)
{
throw new Ice.TimeoutException();
- },
+ }
- throwLocalExceptionIdempotent: function(current)
+ throwLocalExceptionIdempotent(current)
{
throw new Ice.TimeoutException();
- },
+ }
- throwNonIceException: function(current)
+ throwNonIceException(current)
{
throw new Error();
- },
+ }
- throwAssertException: function(current)
+ throwAssertException(current)
{
test(false);
- },
+ }
- throwMemoryLimitException: function(seq, current)
+ throwMemoryLimitException(seq, current)
{
return Ice.Buffer.createNative(1024 * 20); // 20KB is over the configured 10KB message size max.
- },
+ }
- throwAfterResponse: function(current)
+ throwAfterResponse(current)
{
//
// Only relevant for AMD.
//
- },
+ }
- throwAfterException: function(current)
+ throwAfterException(current)
{
//
// Only relevant for AMD.
//
throw new Test.A();
- },
- });
+ }
+ }
exports.ThrowerI = ThrowerI;
}
diff --git a/js/test/Ice/facets/Client.js b/js/test/Ice/facets/Client.js
index d1f8c84b12b..5441bf6b858 100644
--- a/js/test/Ice/facets/Client.js
+++ b/js/test/Ice/facets/Client.js
@@ -26,7 +26,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -131,19 +131,16 @@
test(d !== null);
test(d.equals(db));
- return Promise.all(
- d.callA(),
- d.callB(),
- d.callC(),
- d.callD());
+ return Promise.all([d.callA(), d.callB(), d.callC(), d.callD()]);
}
).then(
- function(r1, r2, r3, r4)
+ function(r)
{
- test(r1[0] == "A");
- test(r2[0] == "B");
- test(r3[0] == "C");
- test(r4[0] == "D");
+ var [r1, r2, r3, r4] = r;
+ test(r1 == "A");
+ test(r2 == "B");
+ test(r3 == "C");
+ test(r4 == "D");
out.writeLine("ok");
out.write("testing facets A, B, C, and D... ");
return Test.DPrx.checkedCast(d, "facetABCD");
@@ -154,19 +151,16 @@
df = obj;
test(df !== null);
- return Promise.all(
- df.callA(),
- df.callB(),
- df.callC(),
- df.callD());
+ return Promise.all([df.callA(), df.callB(), df.callC(), df.callD()]);
}
).then(
- function(r1, r2, r3, r4)
+ function(r)
{
- test(r1[0] == "A");
- test(r2[0] == "B");
- test(r3[0] == "C");
- test(r4[0] == "D");
+ var [r1, r2, r3, r4] = r;
+ test(r1 == "A");
+ test(r2 == "B");
+ test(r3 == "C");
+ test(r4 == "D");
out.writeLine("ok");
out.write("testing facets E and F... ");
return Test.FPrx.checkedCast(d, "facetEF");
@@ -177,15 +171,14 @@
ff = obj;
test(ff !== null);
- return Promise.all(
- ff.callE(),
- ff.callF());
+ return Promise.all([ff.callE(), ff.callF()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- test(r1[0] == "E");
- test(r2[0] == "F");
+ var [r1, r2] = r;
+ test(r1 == "E");
+ test(r2 == "F");
out.writeLine("ok");
out.write("testing facet G... ");
return Test.GPrx.checkedCast(ff, "facetGH");
@@ -211,28 +204,19 @@
hf = obj;
test(hf !== null);
- return Promise.all(
- hf.callG(),
- hf.callH());
+ return Promise.all([hf.callG(), hf.callH()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- test(r1[0] == "G");
- test(r2[0] == "H");
+ var [r1, r2] = r;
+ test(r1 == "G");
+ test(r2 == "H");
out.writeLine("ok");
return gf.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
+
return p;
};
diff --git a/js/test/Ice/facetsBidir/Client.js b/js/test/Ice/facetsBidir/Client.js
index cadc1356968..296e3eb4590 100644
--- a/js/test/Ice/facetsBidir/Client.js
+++ b/js/test/Ice/facetsBidir/Client.js
@@ -35,7 +35,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -128,15 +128,7 @@
return Client.__clientAllTests__(out, communicator);
});
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- });
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/facetsBidir/TestI.js b/js/test/Ice/facetsBidir/TestI.js
index cc9c2df56d6..90cf8a4fc8c 100644
--- a/js/test/Ice/facetsBidir/TestI.js
+++ b/js/test/Ice/facetsBidir/TestI.js
@@ -12,64 +12,64 @@
var Ice = require("ice").Ice;
var Test = require("Test").Test;
- var Class = Ice.Class;
-
- var DI = Class(Test.D, {
- callA: function(current)
+ exports.DI = class extends Test.D
+ {
+ callA(current)
{
return "A";
- },
- callB: function(current)
+ }
+
+ callB(current)
{
return "B";
- },
- callC: function(current)
+ }
+
+ callC(current)
{
return "C";
- },
- callD: function(current)
+ }
+
+ callD(current)
{
return "D";
}
- });
-
- exports.DI = DI;
-
- var EmptyI = Class(Test.Empty, {});
+ };
- exports.EmptyI = EmptyI;
+ exports.EmptyI = class extends Test.Empty
+ {
+ };
- var FI = Class(Test.F, {
- callE: function(current)
+ exports.FI = class extends Test.F
+ {
+ callE(current)
{
return "E";
- },
- callF: function(current)
+ }
+
+ callF(current)
{
return "F";
}
- });
-
- exports.FI = FI;
+ };
- var HI = Class(Test.H, {
- callG: function(current)
+ exports.HI = class extends Test.H
+ {
+ callG(current)
{
return "G";
- },
- callH: function(current)
+ }
+
+ callH(current)
{
return "H";
- },
- shutdown: function(current)
+ }
+
+ shutdown(current)
{
current.adapter.getCommunicator().shutdown();
}
- });
-
- exports.HI = HI;
+ };
}
(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : this.Ice.__require,
typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : this));
-
diff --git a/js/test/Ice/hashmap/Client.js b/js/test/Ice/hashmap/Client.js
deleted file mode 100644
index d982253bb4a..00000000000
--- a/js/test/Ice/hashmap/Client.js
+++ /dev/null
@@ -1,253 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-(function(module, require, exports)
-{
- var Ice = require("ice").Ice;
-
- var Promise = Ice.Promise;
-
- var fill = function(arr, val)
- {
- for(var i = 0; i < arr.length; ++i)
- {
- arr[i] = val;
- }
- };
-
- var testKeys = function(keys, keyComparator, valueComparator)
- {
- var test = function(b)
- {
- if(!b)
- {
- throw new Error("test failed");
- }
- };
-
- var h = new Ice.HashMap(keyComparator, valueComparator);
- var i;
- for(i = 0; i < keys.length; ++i)
- {
- h.set(keys[i], i);
- }
-
- //
- // Test the keys.
- //
- for(i = 0; i < keys.length; ++i)
- {
- test(h.has(keys[i]));
- test(h.get(keys[i]) === i);
- test(h.delete(keys[i]) === i);
- test(!h.has(keys[i]));
- h.set(keys[i], i);
- test(h.has(keys[i]));
- }
-
- //
- // Use an array to keep track of whether we've encountered all entries.
- //
- var a = [];
- a.length = keys.length;
-
- //
- // Test the keys() method.
- //
- fill(a, false);
- var k = h.keys();
- test(k.length === keys.length);
- for(i = 0; i < k.length; ++i)
- {
- var p = keys.indexOf(k[i]);
- test(p != -1);
- a[p] = true;
- }
- test(a.indexOf(false) === -1);
-
- //
- // Test the values() method.
- //
- fill(a, false);
- var v = h.values();
- test(v.length === keys.length);
- for(i = 0; i < v.length; ++i)
- {
- a[v[i]] = true;
- }
- test(a.indexOf(false) === -1);
-
- //
- // Test the forEach() method.
- //
- fill(a, false);
- h.forEach(function(key, val)
- {
- test(keys[val] === key);
- a[val] = true;
- });
- test(a.indexOf(false) === -1);
-
- //
- // Test the clone() & equals() methods.
- //
- var h2 = h.clone();
- test(h2.equals(h));
-
- //
- // Test the clear() method.
- //
- h.clear();
- test(h.size === 0);
- };
-
- var allTests = function(out)
- {
- var p = new Ice.Promise();
- var test = function(b)
- {
- if(!b)
- {
- try
- {
- throw new Error("test failed");
- }
- catch(err)
- {
- p.fail(err);
- throw err;
- }
- }
- };
-
- Promise.try(
- function()
- {
- out.write("testing Ice.HashMap... ");
-
- var h = new Ice.HashMap();
-
- //
- // Test null key.
- //
- h.set(null, 1);
- test(h.has(null));
- test(h.get(null) === 1);
- h.set(null, 2);
- test(h.get(null) === 2);
- test(h.delete(null) === 2);
- test(!h.has(null));
-
- //
- // Test NaN key.
- //
- h.set(NaN, 1);
- test(h.has(NaN));
- test(h.has(-NaN));
- test(h.get(NaN) === 1);
- test(h.get(-NaN) === 1);
- h.set(NaN, 2);
- test(h.get(NaN) === 2);
- test(h.delete(NaN) === 2);
- test(!h.has(NaN));
-
- //
- // Test zero key.
- //
- h.set(0, 1);
- test(h.has(0));
- test(h.has(-0));
- test(h.get(0) === 1);
- test(h.get(-0) === 1);
- h.set(0, 2);
- test(h.get(0) === 2);
- test(h.delete(0) === 2);
- test(!h.has(0));
-
- //
- // Test integer keys.
- //
- var k = [];
- k.length = 1000;
- var i;
- for(i = 0; i < k.length; ++i)
- {
- k[i] = i;
- }
- testKeys(k);
-
- //
- // Test string keys.
- //
- k.length = 100;
- for(i = 0; i < k.length; ++i)
- {
- k[i] = Ice.generateUUID();
- }
- testKeys(k);
-
- //
- // Test boolean keys.
- //
- testKeys([true, false]);
-
- //
- // Test object keys (with hashCode methods).
- //
- testKeys([Ice.OperationMode.Normal, Ice.OperationMode.Nonmutating, Ice.OperationMode.Idempotent]);
-
- //
- // Test object keys (with hashCode methods and custom key comparator).
- //
- function createObject(i)
- {
- var obj =
- {
- key:i,
- hashCode:function()
- {
- return i;
- }
- };
- return obj;
- }
- k.length = 10;
- for(i = 0; i < k.length; ++i)
- {
- k[i] = createObject(i);
- }
- var eq = function(a, b) { return a.key === b.key; };
- testKeys(k, eq, eq);
-
- out.writeLine("ok");
- }
- ).exception(
- function(ex)
- {
- p.fail(ex);
- }
- );
- return p;
- };
-
- var run = function(out, id)
- {
- return Promise.try(
- function()
- {
- return allTests(out);
- }
- );
- };
- exports.__test__ = run;
- exports.__runServer__ = true;
-}
-(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
- typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : this.Ice.__require,
- typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : this));
diff --git a/js/test/Ice/hashmap/run.js b/js/test/Ice/hashmap/run.js
deleted file mode 100644
index fc8c9a16e7c..00000000000
--- a/js/test/Ice/hashmap/run.js
+++ /dev/null
@@ -1,10 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-require("../../Common/Common").run(module);
diff --git a/js/test/Ice/hashmap/run.py b/js/test/Ice/hashmap/run.py
deleted file mode 100755
index 3f5ff03f708..00000000000
--- a/js/test/Ice/hashmap/run.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-# **********************************************************************
-#
-# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import os, sys
-
-path = [ ".", "..", "../..", "../../..", "../../../..", "../../../../.." ]
-head = os.path.dirname(sys.argv[0])
-if len(head) > 0:
- path = [os.path.join(head, p) for p in path]
-path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
-if len(path) == 0:
- raise RuntimeError("can't find toplevel directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-TestUtil.simpleTest()
diff --git a/js/test/Ice/hold/Client.js b/js/test/Ice/hold/Client.js
index fd648040976..02055490d93 100644
--- a/js/test/Ice/hold/Client.js
+++ b/js/test/Ice/hold/Client.js
@@ -49,7 +49,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -82,7 +82,7 @@
out.write("changing state between active and hold rapidly... ");
var i;
- var r = new Ice.Promise().succeed();
+ var r = Ice.Promise.resolve();
/*jshint -W083 */
// Ignore this since we do not use i and
// have only a small number of iterations
@@ -307,12 +307,13 @@
function()
{
out.writeLine("ok");
- p.succeed();
+ p.resolve();
},
function(ex)
{
+ console.log(ex);
out.writeLine("failed!");
- p.fail(ex);
+ p.reject(ex);
});
return p;
};
diff --git a/js/test/Ice/info/Client.js b/js/test/Ice/info/Client.js
index 84ce30495f1..b1f743aa130 100644
--- a/js/test/Ice/info/Client.js
+++ b/js/test/Ice/info/Client.js
@@ -134,7 +134,7 @@
connection.setBufferSize(1024, 2048);
info = connection.getInfo();
- ipinfo = getTCPConnectionInfo(info);
+ let ipinfo = getTCPConnectionInfo(info);
test(!info.incoming);
test(info.adapterName.length === 0);
if(connection.type() != "ws" && connection.type() != "wss")
@@ -207,7 +207,12 @@
).finally(
function()
{
- communicator.destroy();
+ out.write("communicator destroy... ");
+ communicator.destroy().then(
+ function()
+ {
+ out.writeLine("ok");
+ });
}
);
};
diff --git a/js/test/Ice/inheritance/Client.js b/js/test/Ice/inheritance/Client.js
index 4ca0046de7a..50f1aac191b 100644
--- a/js/test/Ice/inheritance/Client.js
+++ b/js/test/Ice/inheritance/Client.js
@@ -28,7 +28,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -54,18 +54,19 @@
out.writeLine("ok");
out.write("getting proxies for class hierarchy... ");
- return Promise.all(initial.caop(),
- initial.cbop(),
- initial.ccop(),
- initial.cdop());
+ return Promise.all([initial.caop(), initial.cbop(),initial.ccop(), initial.cdop()]);
}
).then(
- function(r1, r2, r3, r4)
+ function(r)
{
- ca = r1[0];
- cb = r2[0];
- cc = r3[0];
- cd = r4[0];
+ var r1 = r[0],
+ r2 = r[1],
+ r3 = r[2],
+ r4 = r[3];
+ ca = r1;
+ cb = r2;
+ cc = r3;
+ cd = r4;
test(ca !== cb);
test(ca !== cc);
@@ -76,19 +77,17 @@
out.writeLine("ok");
out.write("getting proxies for interface hierarchy... ");
- return Promise.all(initial.iaop(),
- initial.ib1op(),
- initial.ib2op(),
- initial.icop());
+ return Promise.all([initial.iaop(), initial.ib1op(), initial.ib2op(), initial.icop()]);
}
).then(
- function(r1, r2, r3, r4)
+ function(r)
{
- ia = r1[0];
- ib1 = r2[0];
+ var [r1, r2, r3, r4] = r;
+ ia = r1;
+ ib1 = r2;
test(ib1.ice_instanceof(Test.MB.IB1Prx));
- ib2 = r3[0];
- ic = r4[0];
+ ib2 = r3;
+ ic = r4;
test(ia !== ib1);
test(ia !== ib2);
@@ -97,7 +96,7 @@
test(ib2 !== ic);
out.writeLine("ok");
out.write("invoking proxy operations on class hierarchy... ");
- return Promise.all(
+ return Promise.all([
ca.caop(ca), // r1
ca.caop(cb), // r2
ca.caop(cc), // r3
@@ -117,42 +116,41 @@
cc.cbop(cc), // r17
cc.ccop(cc), // r18
cc.ccop(cc), // r19
- cc.ccop(cc)); // r20
+ cc.ccop(cc)]); // r20
}
).then(
- function(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
- r11, r12, r13, r14, r15, r16, r17, r18, r19, r20)
+ function(r)
{
- test(r1[0].equals(ca));
- test(r2[0].equals(cb));
- test(r3[0].equals(cc));
- test(r4[0].equals(ca));
- test(r5[0].equals(cb));
- test(r6[0].equals(cc));
- test(r7[0].equals(ca));
- test(r8[0].equals(cb));
- test(r9[0].equals(cc));
- test(r10[0].equals(cb));
- test(r11[0].equals(cb));
- test(r12[0].equals(cc));
- test(r13[0].equals(cc));
- test(r14[0].equals(cb));
- test(r15[0].equals(cb));
- test(r16[0].equals(cc));
- test(r17[0].equals(cc));
- test(r18[0].equals(cc));
- test(r19[0].equals(cc));
- test(r20[0].equals(cc));
+ test(r[0].equals(ca));
+ test(r[1].equals(cb));
+ test(r[2].equals(cc));
+ test(r[3].equals(ca));
+ test(r[4].equals(cb));
+ test(r[5].equals(cc));
+ test(r[6].equals(ca));
+ test(r[7].equals(cb));
+ test(r[8].equals(cc));
+ test(r[9].equals(cb));
+ test(r[10].equals(cb));
+ test(r[11].equals(cc));
+ test(r[12].equals(cc));
+ test(r[13].equals(cb));
+ test(r[14].equals(cb));
+ test(r[15].equals(cc));
+ test(r[16].equals(cc));
+ test(r[17].equals(cc));
+ test(r[18].equals(cc));
+ test(r[19].equals(cc));
out.writeLine("ok");
out.write("ditto, but for interface hierarchy... ");
- return Promise.all(
+ return Promise.all([
ia.iaop(ia), // r1
ia.iaop(ib1), // r2
ia.iaop(ib2), // r3
ia.iaop(ic), // r4
- ib1.ib1op(ia), // r5
+ ib1.ib1op(ia), // r5
ib1.iaop(ib1), // r6
ib1.iaop(ib2), // r7
ib1.iaop(ic), // r8
@@ -183,55 +181,52 @@
ic.icop(ic), // r33
ic.icop(ic), // r34
ic.icop(ic), // r35
- ic.icop(ic)); // r36
+ ic.icop(ic)]); // r36
}
).then(
- function(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
- r11, r12, r13, r14, r15, r16, r17, r18, r19, r20,
- r21, r22, r23, r24, r25, r26, r27, r28, r29, r30,
- r31, r32, r33, r34, r35, r36)
+ function(r)
{
- test(r1[0].equals(ia));
- test(r2[0].equals(ib1));
- test(r3[0].equals(ib2));
- test(r4[0].equals(ic));
- test(r5[0].equals(ia));
- test(r6[0].equals(ib1));
- test(r7[0].equals(ib2));
- test(r8[0].equals(ic));
- test(r9[0].equals(ia));
- test(r10[0].equals(ib1));
- test(r11[0].equals(ib2));
- test(r12[0].equals(ic));
- test(r13[0].equals(ia));
- test(r14[0].equals(ib1));
- test(r15[0].equals(ib2));
- test(r16[0].equals(ic));
- test(r17[0].equals(ib1));
- test(r18[0].equals(ib1));
- test(r19[0].equals(ic));
- test(r20[0].equals(ic));
- test(r21[0].equals(ib1));
- test(r22[0].equals(ib1));
- test(r23[0].equals(ic));
- test(r24[0].equals(ic));
- test(r25[0].equals(ib2));
- test(r26[0].equals(ib2));
- test(r27[0].equals(ic));
- test(r28[0].equals(ic));
- test(r29[0].equals(ib2));
- test(r30[0].equals(ib2));
- test(r31[0].equals(ic));
- test(r32[0].equals(ic));
- test(r33[0].equals(ic));
- test(r34[0].equals(ic));
- test(r35[0].equals(ic));
- test(r36[0].equals(ic));
+ test(r[0].equals(ia));
+ test(r[1].equals(ib1));
+ test(r[2].equals(ib2));
+ test(r[3].equals(ic));
+ test(r[4].equals(ia));
+ test(r[5].equals(ib1));
+ test(r[6].equals(ib2));
+ test(r[7].equals(ic));
+ test(r[8].equals(ia));
+ test(r[9].equals(ib1));
+ test(r[10].equals(ib2));
+ test(r[11].equals(ic));
+ test(r[12].equals(ia));
+ test(r[13].equals(ib1));
+ test(r[14].equals(ib2));
+ test(r[15].equals(ic));
+ test(r[16].equals(ib1));
+ test(r[17].equals(ib1));
+ test(r[18].equals(ic));
+ test(r[19].equals(ic));
+ test(r[20].equals(ib1));
+ test(r[21].equals(ib1));
+ test(r[22].equals(ic));
+ test(r[23].equals(ic));
+ test(r[24].equals(ib2));
+ test(r[25].equals(ib2));
+ test(r[26].equals(ic));
+ test(r[27].equals(ic));
+ test(r[28].equals(ib2));
+ test(r[29].equals(ib2));
+ test(r[30].equals(ic));
+ test(r[31].equals(ic));
+ test(r[32].equals(ic));
+ test(r[33].equals(ic));
+ test(r[34].equals(ic));
+ test(r[35].equals(ic));
out.writeLine("ok");
out.write("ditto, but for class implementing interfaces... ");
- return Promise.all(
+ return Promise.all([
cd.caop(cd), // r1
cd.cbop(cd), // r2
cd.ccop(cd), // r3
@@ -243,37 +238,27 @@
cd.cdop(cd), // r9
cd.cdop(cd), // r10
cd.cdop(cd), // r11
- cd.cdop(cd)); // r12
+ cd.cdop(cd)]); // r12
}
).then(
- function(r1, r2, r3, r4, r5, r6, r7, r8, r9, r10,
- r11, r12)
+ function(r)
{
- test(r1[0].equals(cd));
- test(r2[0].equals(cd));
- test(r3[0].equals(cd));
- test(r4[0].equals(cd));
- test(r5[0].equals(cd));
- test(r6[0].equals(cd));
- test(r7[0].equals(cd));
- test(r8[0].equals(cd));
- test(r9[0].equals(cd));
- test(r10[0].equals(cd));
- test(r11[0].equals(cd));
- test(r12[0].equals(cd));
+ test(r[0].equals(cd));
+ test(r[1].equals(cd));
+ test(r[2].equals(cd));
+ test(r[3].equals(cd));
+ test(r[4].equals(cd));
+ test(r[5].equals(cd));
+ test(r[6].equals(cd));
+ test(r[7].equals(cd));
+ test(r[8].equals(cd));
+ test(r[9].equals(cd));
+ test(r[10].equals(cd));
+ test(r[11].equals(cd));
out.writeLine("ok");
return initial.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/inheritanceBidir/InitialI.js b/js/test/Ice/inheritanceBidir/InitialI.js
index 84dbd0cdc58..d373cec8008 100644
--- a/js/test/Ice/inheritanceBidir/InitialI.js
+++ b/js/test/Ice/inheritanceBidir/InitialI.js
@@ -12,123 +12,145 @@
var Ice = require("ice").Ice;
var Test = require("Test").Test;
- var Class = Ice.Class;
-
- var CAI = Class(Test.MA.CA, {
- caop: function(p, current)
+ class CAI extends Test.MA.CA
+ {
+ caop(p, current)
{
return p;
}
- });
+ }
- var CBI = Class(Test.MB.CB, {
- caop: function(p, current)
+ class CBI extends Test.MB.CB
+ {
+ caop(p, current)
{
return p;
- },
- cbop: function(p, current)
+ }
+
+ cbop(p, current)
{
return p;
}
- });
+ }
- var CCI = Class(Test.MA.CC, {
- caop: function(p, current)
+ class CCI extends Test.MA.CC
+ {
+ caop(p, current)
{
return p;
- },
- ccop: function(p, current)
+ }
+
+ ccop(p, current)
{
return p;
- },
- cbop: function(p, current)
+ }
+
+ cbop(p, current)
{
return p;
}
- });
+ }
- var CDI = Class(Test.MA.CD, {
- caop: function(p, current)
+ class CDI extends Test.MA.CD
+ {
+ caop(p, current)
{
return p;
- },
- ccop: function(p, current)
+ }
+
+ ccop(p, current)
{
return p;
- },
- cdop: function(p, current)
+ }
+
+ cdop(p, current)
{
return p;
- },
- iaop: function(p, current)
+ }
+
+ iaop(p, current)
{
return p;
- },
- cbop: function(p, current)
+ }
+
+ cbop(p, current)
{
return p;
- },
- ib1op: function(p, current)
+ }
+
+ ib1op(p, current)
{
return p;
- },
- ib2op: function(p, current)
+ }
+
+ ib2op(p, current)
{
return p;
}
- });
+ }
- var IAI = Class(Test.MA.IA, {
- iaop: function(p, current)
+ class IAI extends Test.MA.IA
+ {
+ iaop(p, current)
{
return p;
}
- });
+ }
- var IB1I = Class(Test.MB.IB1, {
- iaop: function(p, current)
+ class IB1I extends Test.MB.IB1
+ {
+ iaop(p, current)
{
return p;
- },
- ib1op: function(p, current)
+ }
+
+ ib1op(p, current)
{
return p;
}
- });
+ }
- var IB2I = Class(Test.MB.IB2, {
- iaop: function(p, current)
+ class IB2I extends Test.MB.IB2
+ {
+ iaop(p, current)
{
return p;
- },
- ib2op: function(p, current)
+ }
+
+ ib2op(p, current)
{
return p;
}
- });
+ }
- var ICI = Class(Test.MA.IC, {
- iaop: function(p, current)
+ class ICI extends Test.MA.IC
+ {
+ iaop(p, current)
{
return p;
- },
- icop: function(p, current)
+ }
+
+ icop(p, current)
{
return p;
- },
- ib1op: function(p, current)
+ }
+
+ ib1op(p, current)
{
return p;
- },
- ib2op: function(p, current)
+ }
+
+ ib2op(p, current)
{
return p;
}
- });
+ }
- var InitialI = Class(Test.Initial, {
- __init__: function(adapter, obj)
+ class InitialI extends Test.Initial
+ {
+ constructor(adapter, obj)
{
+ super();
var endpts = obj.ice_getEndpoints();
this._ca = Test.MA.CAPrx.uncheckedCast(adapter.addWithUUID(new CAI()).ice_endpoints(endpts));
this._cb = Test.MB.CBPrx.uncheckedCast(adapter.addWithUUID(new CBI()).ice_endpoints(endpts));
@@ -138,44 +160,53 @@
this._ib1 = Test.MB.IB1Prx.uncheckedCast(adapter.addWithUUID(new IB1I()).ice_endpoints(endpts));
this._ib2 = Test.MB.IB2Prx.uncheckedCast(adapter.addWithUUID(new IB2I()).ice_endpoints(endpts));
this._ic = Test.MA.ICPrx.uncheckedCast(adapter.addWithUUID(new ICI()).ice_endpoints(endpts));
- },
- caop: function(current)
+ }
+
+ caop(current)
{
return this._ca;
- },
- cbop: function(current)
+ }
+
+ cbop(current)
{
return this._cb;
- },
- ccop: function(current)
+ }
+
+ ccop(current)
{
return this._cc;
- },
- cdop: function(current)
+ }
+
+ cdop(current)
{
return this._cd;
- },
- iaop: function(current)
+ }
+
+ iaop(current)
{
return this._ia;
- },
- ib1op: function(current)
+ }
+
+ ib1op(current)
{
return this._ib1;
- },
- ib2op: function(current)
+ }
+
+ ib2op(current)
{
return this._ib2;
- },
- icop: function(current)
+ }
+
+ icop(current)
{
return this._ic;
- },
- shutdown: function(current)
+ }
+
+ shutdown(current)
{
current.adapter.getCommunicator().shutdown();
}
- });
+ }
exports.InitialI = InitialI;
}
diff --git a/js/test/Ice/location/Client.js b/js/test/Ice/location/Client.js
index 013c409c8ed..f237aa6ca82 100644
--- a/js/test/Ice/location/Client.js
+++ b/js/test/Ice/location/Client.js
@@ -29,7 +29,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -377,14 +377,10 @@
test(count == newCount);
Ice.Timer.setTimeout(
function(){
- p.succeed(count);
+ p.resolve(count);
}, 1200);
},
- function(ex)
- {
- p.fail(ex);
- }
- );
+ p.reject);
return p;
}
).then(
@@ -443,14 +439,14 @@
function(newCount)
{
test(count == newCount);
- p.succeed(count);
+ p.resolve(count);
}
- ).exception(
+ ).catch(
function(ex)
{
Ice.Timer.setTimeout(
function(){
- p.fail(ex);
+ p.reject(ex);
}, 1200);
});
return p;
@@ -512,13 +508,9 @@
function(newCount)
{
test(count == newCount);
- p.succeed(count);
+ p.resolve(count);
}
- ).exception(
- function(ex)
- {
- p.fail(ex);
- });
+ ).catch(p.reject);
return p;
}
).then(
@@ -535,13 +527,9 @@
function(newCount)
{
test(count == newCount);
- p.succeed(count);
+ p.resolve(count);
}
- ).exception(
- function(ex)
- {
- p.fail(ex);
- });
+ ).catch(p.reject);
return p;
}
).then(
@@ -558,13 +546,9 @@
function(newCount)
{
test(count == newCount);
- p.succeed(count);
+ p.resolve(count);
}
- ).exception(
- function(ex)
- {
- p.fail(ex);
- });
+ ).catch(p.reject);
return p;
}
).then(
@@ -579,14 +563,14 @@
function(o)
{
obj = o;
- return Promise.all(obj.getHello(), obj.getReplicatedHello());
+ return Promise.all([obj.getHello(), obj.getReplicatedHello()]);
}
).then(
- function(r1, r2)
+ function(r)
{
- hello = r1[0];
+ hello = r[0];
test(hello.ice_getAdapterId() == "TestAdapter");
- hello = r2[0];
+ hello = r[1];
test(hello.ice_getAdapterId() == "ReplicatedAdapter");
return hello.sayHello();
}
@@ -633,12 +617,9 @@
function(newCount)
{
test(++count == newCount);
- p.succeed(count);
+ p.resolve(count);
}
- ).exception(
- function(ex){
- p.fail(ex);
- });
+ ).catch(p.reject);
return p;
}
).then(
@@ -652,7 +633,7 @@
var p = new Promise();
- Promise.all.apply(Promise, all).then(
+ Promise.all(all).then(
function()
{
return locator.getRequestCount();
@@ -668,13 +649,9 @@
}
hello = hello.ice_adapterId("unknown");
count = newCount;
- p.succeed(count);
+ p.resolve(count);
}
- ).exception(
- function(ex)
- {
- p.fail(ex);
- });
+ ).catch(p.reject);
return p;
}
).then(
@@ -696,13 +673,13 @@
}
else
{
- p.succeed();
+ p.resolve();
}
};
var okCB = function()
{
- p.fail("test failed");
+ p.reject("test failed");
};
for(var i = 0; i < 1000; ++i)
@@ -951,12 +928,9 @@
{
count += 3;
test(count === newCount);
- p1.succeed(count);
+ p1.resolve(count);
}
- ).exception(
- function(ex){
- p1.fail(ex);
- });
+ ).catch(p1.reject);
return p1;
}
@@ -992,14 +966,10 @@
test(count = newCount);
Ice.Timer.setTimeout(
function(){
- p1.succeed(count);
+ p1.resolve(count);
}, 1200);
}
- ).exception(
- function(ex)
- {
- p1.fail(ex);
- });
+ ).catch(p1.reject);
return p1;
}
).then(
@@ -1016,18 +986,7 @@
// 1s timeout.
return ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping();
}
- ).then(
- function()
- {
- p1.succeed();
- }
- ).exception(
- function(ex)
- {
- p1.fail(ex);
- }
- );
-
+ ).then(p1.resolve, p1.reject);
return p1;
}
).then(
@@ -1045,19 +1004,14 @@
{
if(ex instanceof Ice.LocalException)
{
- p1.succeed();
+ p1.resolve();
}
else
{
- p1.fail(ex);
+ p1.reject(ex);
}
}
- ).exception(
- function(ex)
- {
- p1.fail(ex);
- }
- );
+ ).catch(p1.reject);
};
f1();
@@ -1074,24 +1028,20 @@
ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping().then(
function()
{
- Ice.Timer.setTimeout(function(){ f1(); }, 10000);
+ Ice.Timer.setTimeout(f1, 10000);
},
function(ex)
{
if(ex instanceof Ice.LocalException)
{
- p1.succeed();
+ p1.resolve();
}
else
{
- p1.fail(ex);
+ p1.reject(ex);
}
}
- ).exception(
- function(ex)
- {
- p1.fail(ex);
- });
+ ).catch(p1.reject);
};
f1();
@@ -1102,17 +1052,7 @@
{
return ic.destroy();
}
- ).then(
- function()
- {
- p.succeed();
- }
- ).exception(
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
}
).then(
@@ -1237,14 +1177,9 @@
function(newCount)
{
test(++count == newCount);
- p.succeed();
+ p.resolve();
}
- ).exception(
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).catch(p.reject);
return p;
}
@@ -1299,16 +1234,7 @@
{
out.writeLine("ok");
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/number/Client.js b/js/test/Ice/number/Client.js
index 1abcbfd8670..e571037b266 100644
--- a/js/test/Ice/number/Client.js
+++ b/js/test/Ice/number/Client.js
@@ -22,8 +22,7 @@
var run = function(out)
{
- return Promise.try(
- function()
+ return Promise.try(() =>
{
out.write("Testing Ice.Long... ");
//
diff --git a/js/test/Ice/objects/Client.js b/js/test/Ice/objects/Client.js
index 6b0f339d8f3..1c002abfe50 100644
--- a/js/test/Ice/objects/Client.js
+++ b/js/test/Ice/objects/Client.js
@@ -14,107 +14,82 @@
var Promise = Ice.Promise;
- var BI = function()
+ class BI extends Test.B
{
- Test.B.call(this);
- };
-
- BI.prototype = new Test.B();
-
- BI.prototype.ice_preMarshal = function()
- {
- this.preMarshalInvoked = true;
- };
-
- BI.prototype.ice_postUnmarshal = function()
- {
- this.postUnmarshalInvoked = true;
- };
-
- var CI = function()
- {
- Test.C.call(this);
- };
-
- CI.prototype = new Test.C();
-
- CI.prototype.ice_preMarshal = function()
- {
- this.preMarshalInvoked = true;
- };
+ ice_preMarshal()
+ {
+ this.preMarshalInvoked = true;
+ }
- CI.prototype.ice_postUnmarshal = function()
- {
- this.postUnmarshalInvoked = true;
- };
+ ice_postUnmarshal()
+ {
+ this.postUnmarshalInvoked = true;
+ }
+ }
- var DI = function()
+ class CI extends Test.C
{
- Test.D.call(this);
- };
+ ice_preMarshal()
+ {
+ this.preMarshalInvoked = true;
+ }
- DI.prototype = new Test.D();
+ ice_postUnmarshal()
+ {
+ this.postUnmarshalInvoked = true;
+ }
+ }
- DI.prototype.ice_preMarshal = function()
+ class DI extends Test.D
{
- this.preMarshalInvoked = true;
- };
+ ice_preMarshal()
+ {
+ this.preMarshalInvoked = true;
+ }
- DI.prototype.ice_postUnmarshal = function()
- {
- this.postUnmarshalInvoked = true;
- };
+ ice_postUnmarshal()
+ {
+ this.postUnmarshalInvoked = true;
+ }
+ }
- var EI = function()
+ class EI extends Test.E
{
- Test.E.call(this, 1, "hello");
- };
-
- EI.prototype = new Test.E();
-
- EI.prototype.constructor = EI;
+ constructor()
+ {
+ super(1, "hello");
+ }
- EI.prototype.checkValues = function(current)
- {
- return this.i == 1 && this.s == "hello";
- };
+ checkValues(current)
+ {
+ return this.i == 1 && this.s == "hello";
+ }
+ }
- var FI = function(e)
+ class FI extends Test.F
{
- if(e !== undefined)
+ constructor(e)
{
- Test.F.call(this, e, e);
+ super(e, e);
}
- };
-
- FI.prototype = new Test.F();
- FI.prototype.checkValues = function(current)
- {
- return this.e1 !== null && this.e1 === this.e2;
- };
+ checkValues(current)
+ {
+ return this.e1 !== null && this.e1 === this.e2;
+ }
+ }
- var HI = function()
+ class HI extends Test.H
{
- Test.H.call(this);
- };
-
- HI.prototype = new Test.H();
- HI.prototype.constructor = HI;
+ }
- var II = function()
+ class II extends Test.I
{
- Test.I.call(this);
- };
- II.prototype = new Test.I();
- II.prototype.constructor = II;
+ }
- var JI = function()
+ class JI extends Test.J
{
- Test.J.call(this);
- };
- JI.prototype = new Test.J();
- JI.prototype.constructor = JI;
+ }
function MyValueFactory(type)
{
@@ -146,23 +121,18 @@
return null;
}
- var MyObjectFactory = function()
+ class MyObjectFactory extends Ice.ObjectFactory
{
- Ice.ObjectFactory.call(this);
- };
- MyObjectFactory.prototype = new Ice.ObjectFactory();
-
- MyObjectFactory.prototype.constructor = MyObjectFactory;
-
- MyObjectFactory.prototype.create = function(type)
- {
- return null;
- };
+ create(type)
+ {
+ return null;
+ }
- MyObjectFactory.prototype.destroy = function()
- {
- };
+ destroy()
+ {
+ }
+ }
var allTests = function(out, communicator)
{
@@ -179,7 +149,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -210,22 +180,19 @@
out.write("testing checked cast... ");
return Test.InitialPrx.checkedCast(base);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
initial = obj;
test(initial !== null);
test(initial.equals(base));
out.writeLine("ok");
}
- ).then(
- function()
+ ).then(() =>
{
out.write("getting B1... ");
return initial.getB1();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
b1 = obj;
test(b1 !== null);
@@ -233,8 +200,7 @@
out.write("getting B2... ");
return initial.getB2();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
b2 = obj;
test(b2 !== null);
@@ -242,8 +208,7 @@
out.write("getting C... ");
return initial.getC();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
c = obj;
test(c !== null);
@@ -251,15 +216,13 @@
out.write("getting D... ");
return initial.getD();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
d = obj;
test(d !== null);
out.writeLine("ok");
}
- ).then(
- function()
+ ).then(() =>
{
out.write("checking consistency... ");
test(b1 !== b2);
@@ -293,9 +256,9 @@
return initial.getAll();
}
- ).then(
- function(b1, b2, c, d)
+ ).then(r =>
{
+ var [b1, b2, c, d] = r;
test(b1);
test(b2);
test(c);
@@ -332,14 +295,12 @@
out.write("testing protected members... ");
return initial.getE();
}
- ).then(
- function(e)
+ ).then(e =>
{
test(e.checkValues());
return initial.getF();
}
- ).then(
- function(f)
+ ).then(f =>
{
test(f.checkValues());
test(f.e2.checkValues());
@@ -347,22 +308,19 @@
out.write("getting I, J and H... ");
return initial.getI();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
i = obj;
test(i);
return initial.getJ();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
j = obj;
test(j);
return initial.getH();
}
- ).then(
- function(obj)
+ ).then(obj =>
{
h = obj;
test(h);
@@ -373,8 +331,7 @@
new Test.A1("a3"),
new Test.A1("a4")));
}
- ).then(
- function(d1)
+ ).then(d1 =>
{
test(d1.a1.name == "a1");
test(d1.a2.name == "a2");
@@ -384,12 +341,8 @@
out.write("throw EDerived... ");
return initial.throwEDerived();
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
test(ex instanceof Test.EDerived);
test(ex.a1.name == "a1");
@@ -400,39 +353,29 @@
out.write("setting I... ");
return initial.setI(i);
}
- ).then(
- function()
- {
- return initial.setI(j);
- }
- ).then(
- function()
- {
- return initial.setI(h);
- }
- ).then(
- function()
+ ).then(() => initial.setI(j)
+ ).then(() => initial.setI(h)
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing sequences... ");
return initial.opBaseSeq([]);
}
- ).then(
- function(retS, outS)
+ ).then(r =>
{
+ var [retS, outS] = r;
return initial.opBaseSeq([new Test.Base(new Test.S(), "")]);
}
- ).then(
- function(retS, outS)
+ ).then(r =>
{
+ var [retS, outS] = r;
test(retS.length === 1 && outS.length === 1);
out.writeLine("ok");
out.write("testing compact ID... ");
return initial.getCompact();
}
- ).then(
- function(compact)
+ ).then(compact =>
{
test(compact !== null);
out.writeLine("ok");
@@ -444,54 +387,42 @@
test(uoet !== null);
return uoet.op();
}
- ).then(
- function()
+ ).then(() =>
{
test(false);
},
- function(ex)
+ ex =>
{
test(ex instanceof Ice.UnexpectedObjectException);
test(ex.type == "::Test::AlsoEmpty");
test(ex.expectedType == "::Test::Empty");
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing inner modules... ");
return initial.getInnerA();
}
- ).then(
- function(innerA)
+ ).then(innerA =>
{
test(innerA instanceof Test.Inner.A);
test(innerA.theA instanceof Test.B);
return initial.getInnerSubA();
}
- ).then(
- function(innerA)
+ ).then(innerA =>
{
test(innerA instanceof Test.Inner.Sub.A);
test(innerA.theA instanceof Test.Inner.A);
return initial.throwInnerEx();
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
test(ex.reason == "Inner::Ex");
return initial.throwInnerSubEx();
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
test(ex.reason == "Inner::Sub::Ex");
out.writeLine("ok");
@@ -505,33 +436,14 @@
return initial.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
var run = function(out, id)
{
var c = Ice.initialize(id);
- return Promise.try(
- function()
- {
- return allTests(out, c);
- }
- ).finally(
- function()
- {
- return c.destroy();
- }
- );
+ return Promise.try(() => allTests(out, c)).finally(() => c.destroy());
};
exports.__test__ = run;
exports.__runServer__ = true;
diff --git a/js/test/Ice/operations/BatchOneways.js b/js/test/Ice/operations/BatchOneways.js
index 5c4b62164b4..35b61922f18 100644
--- a/js/test/Ice/operations/BatchOneways.js
+++ b/js/test/Ice/operations/BatchOneways.js
@@ -33,8 +33,7 @@
}
};
- Promise.try(
- function()
+ Promise.try(() =>
{
var i;
bs1 = Ice.Buffer.createNative(new Array(10 * 1024));
@@ -44,14 +43,12 @@
}
return prx.opByteSOnewayCallCount();
}
- ).then(
- function(count)
+ ).then(count =>
{
batch = prx.ice_batchOneway();
return batch.ice_getConnection();
}
- ).then(
- function()
+ ).then(() =>
{
test(batch.ice_flushBatchRequests().isCompleted()); // Empty flush
test(batch.ice_flushBatchRequests().isSent()); // Empty flush
@@ -63,101 +60,42 @@
all[i] = batch.opByteSOneway(bs1);
}
- return Promise.all(all).then(
- function()
+ return Promise.all(all).then(() =>
{
var wait = function(count)
{
if(count < 27) // 3 * 9 requests auto-flushed.
{
- return Promise.delay(10).then(
- function()
- {
- return prx.opByteSOnewayCallCount();
- }
- ).then(
- function(n)
- {
- return wait(n + count);
- }
- );
+ return Promise.delay(10)
+ .then(() => prx.opByteSOnewayCallCount())
+ .then(n => wait(n + count));
}
};
return wait(0);
- }
- );
+ });
}
- ).then(
- function()
+ ).then(() =>
{
batch2 = prx.ice_batchOneway();
- return Promise.all(batch.ice_ping(), batch2.ice_ping());
+ return Promise.all([batch.ice_ping(), batch2.ice_ping()]);
}
- ).then(
- function(count)
- {
- return batch.ice_flushBatchRequests();
- }
- ).then(
- function()
- {
- return prx.opByteSOnewayCallCount();
- }
- ).then(
- function()
- {
- return batch.ice_getConnection();
- }
- ).then(
- function(con)
- {
- if(!bidir)
- {
- return con.close(false);
- }
- }
- ).then(
- function()
- {
- return Promise.all(batch.ice_ping(), batch2.ice_ping());
- }
- ).then(
- function()
+ ).then(count => batch.ice_flushBatchRequests()
+ ).then(() => prx.opByteSOnewayCallCount()
+ ).then(() => batch.ice_getConnection()
+ ).then(con => bidir ? undefined : con.close(false)
+ ).then(() => Promise.all([batch.ice_ping(), batch2.ice_ping()])
+ ).then(() =>
{
var identity = Ice.stringToIdentity("invalid");
batch3 = batch.ice_identity(identity);
return batch3.ice_ping();
}
- ).then(
- function()
- {
- return batch3.ice_flushBatchRequests();
- }
- ).then(
- function()
- {
- // Make sure that a bogus batch request doesn't cause troubles to other ones.
- return Promise.all(batch3.ice_ping(), batch.ice_ping());
- }
- ).then(
- function()
- {
- return batch.ice_flushBatchRequests();
- }
- ).then(
- function()
- {
- return prx.opByteSOnewayCallCount();
- }
- ).then(
- function(count)
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- });
+ ).then(() => batch3.ice_flushBatchRequests()
+ // Make sure that a bogus batch request doesn't cause troubles to other ones.
+ ).then(() => Promise.all([batch3.ice_ping(), batch.ice_ping()])
+ ).then(() => batch.ice_flushBatchRequests()
+ ).then(() => prx.opByteSOnewayCallCount()
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/operations/Client.js b/js/test/Ice/operations/Client.js
index a4055f7494f..b99ac8dfa9e 100644
--- a/js/test/Ice/operations/Client.js
+++ b/js/test/Ice/operations/Client.js
@@ -22,51 +22,37 @@
{
var ref, base, cl, derived;
- return Promise.try(
- function()
+ return Promise.try(() =>
{
out.write("testing twoway operations... ");
ref = "test:default -p 12010";
base = communicator.stringToProxy(ref);
return Test.MyClassPrx.checkedCast(base);
}
- ).then(
- function(prx)
+ ).then(prx =>
{
cl = prx;
return Test.MyDerivedClassPrx.checkedCast(cl);
- },
- function(ex)
- {
- console.log(ex);
}
- ).then(
- function(prx)
+ ).then(prx =>
{
derived = prx;
return Twoways.run(communicator, cl, Test, bidir);
}
- ).then(
- function()
- {
- return Twoways.run(communicator, derived, Test, bidir);
- }
- ).then(
- function()
+ ).then(() => Twoways.run(communicator, derived, Test, bidir)
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing oneway operations... ");
return Oneways.run(communicator, cl, Test, bidir);
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing batch oneway operations... ");
return BatchOneways.run(communicator, cl, Test, bidir);
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
return cl;
@@ -77,22 +63,9 @@
{
id.properties.setProperty("Ice.BatchAutoFlushSize", "100");
var c = Ice.initialize(id);
- return Promise.try(
- function()
- {
- return allTests(out, c, Test, false);
- }
- ).then(
- function(cl)
- {
- return cl.shutdown();
- }
- ).finally(
- function()
- {
- return c.destroy();
- }
- );
+ return Promise.try(() => allTests(out, c, Test, false)
+ ).then(cl => cl.shutdown()
+ ).finally(() => c.destroy());
};
exports.__test__ = run;
exports.__clientAllTests__ = allTests;
diff --git a/js/test/Ice/operations/Oneways.js b/js/test/Ice/operations/Oneways.js
index 45b35fc2798..7664a52a85d 100644
--- a/js/test/Ice/operations/Oneways.js
+++ b/js/test/Ice/operations/Oneways.js
@@ -25,20 +25,18 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
};
- Ice.Promise.try(
- function()
+ Ice.Promise.try(() =>
{
prx = prx.ice_oneway();
return prx.ice_ping();
}
- ).then(
- function()
+ ).then(() =>
{
try
{
@@ -49,6 +47,7 @@
{
// Expected: twoway proxy required
}
+
try
{
prx.ice_id();
@@ -58,6 +57,7 @@
{
// Expected: twoway proxy required
}
+
try
{
prx.ice_ids();
@@ -70,18 +70,9 @@
return prx.opVoid();
}
- ).then(
- function()
- {
- return prx.opIdempotent();
- }
- ).then(
- function()
- {
- return prx.opNonmutating();
- }
- ).then(
- function()
+ ).then(() => prx.opIdempotent()
+ ).then(() => prx.opNonmutating()
+ ).then(() =>
{
try
{
@@ -93,15 +84,7 @@
// Expected: twoway proxy required
}
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- });
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/operations/Twoways.js b/js/test/Ice/operations/Twoways.js
index 8a098a5eb69..334621ad040 100644
--- a/js/test/Ice/operations/Twoways.js
+++ b/js/test/Ice/operations/Twoways.js
@@ -25,7 +25,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -34,8 +34,7 @@
var failCB = function(){ test(false); };
var si1, si2, ctx, combined;
- Ice.Promise.try(
- function()
+ Ice.Promise.try(() =>
{
ctx = new Ice.Context();
ctx.set("one", "ONE");
@@ -44,8 +43,7 @@
return prx.opStringLiterals();
}
- ).then(
- function(literals)
+ ).then(literals =>
{
test(Test.s0 == "\\" &&
Test.s0 == Test.sw0 &&
@@ -126,52 +124,41 @@
return prx.ice_ping();
}
- ).then(
- function()
- {
- return prx.ice_isA(Test.MyClass.ice_staticId());
- }
- ).then(
- function(b)
+ ).then(() => prx.ice_isA(Test.MyClass.ice_staticId())
+ ).then(b =>
{
test(b);
return prx.ice_id();
}
- ).then(
- function(id)
+ ).then(id =>
{
test(id === Test.MyDerivedClass.ice_staticId());
return prx.ice_ids();
}
- ).then(
- function(ids)
+ ).then(ids =>
{
test(ids.length === 3);
return prx.opVoid();
}
- ).then(
- function()
- {
- return prx.opByte(0xff, 0x0f);
- }
- ).then(
- function(retval, p3)
+ ).then(() => prx.opByte(0xff, 0x0f)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3 === 0xf0);
test(retval === 0xff);
return prx.opBool(true, false);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3);
test(!retval);
var lo = new Ice.Long(0, 12);
return prx.opShortIntLong(10, 11, lo);
}
- ).then(
- function(retval, s, i, l)
+ ).then(r =>
{
+ var [retval, s, i, l] = r;
var lo = new Ice.Long(0, 12);
test(s === 10);
test(i === 11);
@@ -179,9 +166,9 @@
test(retval.equals(lo));
return prx.opFloatDouble(3.14, 1.1E10);
}
- ).then(
- function(retval, f, d)
+ ).then(r =>
{
+ var [retval, f, d] = r;
test((f - 3.14) <= 0.01);
test(d == 1.1E10);
test(retval == 1.1E10);
@@ -189,126 +176,126 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opShortIntLong(-32768 - 1, 0, 0);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opShortIntLong(32767 + 1, 0, 0);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opShortIntLong(0, -2147483648 - 1, 0);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opShortIntLong(0, 2147483647 + 1, 0);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opShortIntLong(0, 0, new Ice.Long(0, 0xFFFFFFFF + 1));
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof RangeError);
return prx.opShortIntLong(0, 0, new Ice.Long(0xFFFFFFFF + 1, 0));
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof RangeError);
return prx.opShortIntLong(0, 0, new Ice.Long(0, -1));
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof RangeError);
return prx.opShortIntLong(Number.NaN, 0, new Ice.Long(0, 0));
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opFloatDouble(Number.MAX_VALUE, 0);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opFloatDouble(-Number.MAX_VALUE, 0);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.MarshalException);
return prx.opFloatDouble(Number.NaN, Number.NaN);
}
- ).then(
- function(retval, f, d)
+ ).then(r =>
{
+ var [retval, f, d] = r;
return prx.opFloatDouble(-Number.NaN, -Number.NaN);
}
- ).then(
- function(retval, f, d)
+ ).then(r =>
{
+ var [retval, f, d] = r;
return prx.opFloatDouble(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
}
- ).then(
- function(retval, f, d)
+ ).then(r =>
{
+ var [retval, f, d] = r;
return prx.opFloatDouble(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY);
}
- ).then(
- function(retval, f, d)
+ ).then(r =>
{
+ var [retval, f, d] = r;
return prx.opString("hello", "world");
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3 === "world hello");
test(retval === "hello world");
return prx.opMyEnum(Test.MyEnum.enum2);
}
- ).then(
- function(retval, p2)
+ ).then(r =>
{
+ var [retval, p2] = r;
test(p2 === Test.MyEnum.enum2);
test(retval === Test.MyEnum.enum3);
// Test null enum
return prx.opMyEnum(null);
}
- ).then(
- function(retval, p2)
+ ).then(r =>
{
+ var [retval, p2] = r;
test(p2 === Test.MyEnum.enum1);
test(retval === Test.MyEnum.enum3);
return prx.opMyClass(prx);
}
- ).then(
- function(retval, p2, p3)
+ ).then(r =>
{
+ var [retval, p2, p3] = r;
test(p2.ice_getIdentity().equals(Ice.stringToIdentity("test")));
test(p3.ice_getIdentity().equals(Ice.stringToIdentity("noSuchIdentity")));
test(retval.ice_getIdentity().equals(Ice.stringToIdentity("test")));
@@ -325,9 +312,9 @@
si2.s.s = "def";
return prx.opStruct(si1, si2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.p === null);
test(retval.e === Test.MyEnum.enum2);
test(retval.s.s === "def");
@@ -340,9 +327,9 @@
// Test null struct
return prx.opStruct(si1, si2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.p === null);
test(retval.e === Test.MyEnum.enum1);
test(retval.s.s === "");
@@ -354,9 +341,9 @@
var bsi2 = Ice.Buffer.createNative([ 0xf1, 0xf2, 0xf3, 0xf4 ]);
return prx.opByteS(bsi1, bsi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.length === 4);
test(p3[0] === 0x22);
test(p3[1] === 0x12);
@@ -376,9 +363,9 @@
var bsi2 = [ false ];
return prx.opBoolS(bsi1, bsi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.length == 4);
test(p3[0]);
test(p3[1]);
@@ -397,9 +384,9 @@
var lsi = [ l1, l2, l3 ];
return prx.opShortIntLongS(ssi, isi, lsi);
}
- ).then(
- function(retval, sso, iso, lso)
+ ).then(r =>
{
+ var [retval, sso, iso, lso] = r;
var l1 = new Ice.Long(0, 10);
var l2 = new Ice.Long(0, 30);
var l3 = new Ice.Long(0, 20);
@@ -428,9 +415,9 @@
var dsi = [ 1.1E10, 1.2E10, 1.3E10 ];
return prx.opFloatDoubleS(fsi, dsi);
}
- ).then(
- function(retval, fso, dso)
+ ).then(r =>
{
+ var [retval, fso, dso] = r;
test(fso.length === 2);
test((fso[0] - 3.14) <= 0.01);
test((fso[1] - 1.11) <= 0.01);
@@ -448,9 +435,9 @@
var ssi2 = [ "xyz" ];
return prx.opStringS(ssi1, ssi2);
}
- ).then(
- function(retval, sso)
+ ).then(r =>
{
+ var [retval, sso] = r;
test(sso.length === 4);
test(sso[0] === "abc");
test(sso[1] === "de");
@@ -473,9 +460,9 @@
];
return prx.opByteSS(bsi1, bsi2);
}
- ).then(
- function(retval, bso)
+ ).then(r =>
{
+ var [retval, bso] = r;
test(bso.length === 2);
test(bso[0].length === 1);
test(bso[0][0] === 0xff);
@@ -508,9 +495,9 @@
];
return prx.opBoolSS(bsi1, bsi2);
}
- ).then(
- function(retval, bso)
+ ).then(r =>
{
+ var [retval, bso] = r;
test(bso.length === 4);
test(bso[0].length === 1);
test(bso[0][0]);
@@ -552,9 +539,9 @@
return prx.opShortIntLongSS(ssi, isi, lsi);
}
- ).then(
- function(retval, sso, iso, lso)
+ ).then(r =>
{
+ var [retval, sso, iso, lso] = r;
var l1 = new Ice.Long(0, 496);
var l2 = new Ice.Long(0, 1729);
@@ -596,9 +583,9 @@
];
return prx.opFloatDoubleSS(fsi, dsi);
}
- ).then(
- function(retval, fso, dso)
+ ).then(r =>
{
+ var [retval, fso, dso] = r;
test(fso.length === 3);
test(fso[0].length === 1);
test((fso[0][0] - 3.14) <= 0.01);
@@ -633,9 +620,9 @@
];
return prx.opStringSS(ssi1, ssi2);
}
- ).then(
- function(retval, sso)
+ ).then(r =>
{
+ var [retval, sso] = r;
test(sso.length === 5);
test(sso[0].length === 1);
test(sso[0][0] === "abc");
@@ -676,9 +663,9 @@
];
return prx.opStringSSS(sssi1, sssi2);
}
- ).then(
- function(retval, ssso)
+ ).then(r =>
{
+ var [retval, ssso] = r;
test(ssso.length === 5);
test(ssso[0].length === 2);
test(ssso[0][0].length === 2);
@@ -722,13 +709,13 @@
return prx.opByteBoolD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.ByteBoolD();
tmp.set(10, true);
tmp.set(100, false);
- test(p3.equals(tmp));
+ test(Ice.MapUtil.equals(p3, tmp));
test(retval.size === 4);
test(retval.get(10) === true);
test(retval.get(11) === false);
@@ -745,13 +732,13 @@
return prx.opShortIntD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.ShortIntD();
tmp.set(110, -1);
tmp.set(1100, 123123);
- test(p3.equals(tmp));
+ test(Ice.MapUtil.equals(p3, tmp));
test(retval.size === 4);
test(retval.get(110) === -1);
test(retval.get(111) === -100);
@@ -768,16 +755,14 @@
return prx.opLongFloatD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.LongFloatD();
tmp.set(new Ice.Long(0, 999999110), -1.1);
tmp.set(new Ice.Long(0, 999999111), 123123.2);
- test(p3.equals(tmp,
- function(v1, v2) {
- return (Math.abs(v1) - Math.abs(v2)) <= 0.01; }));
+ test(p3.equals(tmp, (v1, v2) => (Math.abs(v1) - Math.abs(v2)) <= 0.01));
test(retval.size === 4);
test(Math.abs(retval.get(new Ice.Long(0, 999999110))) - Math.abs(-1.1) <= 0.01);
test(Math.abs(retval.get(new Ice.Long(0, 999999120))) - Math.abs(-100.4) <= 0.01);
@@ -794,13 +779,13 @@
return prx.opStringStringD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.StringStringD();
tmp.set("foo", "abc -1.1");
tmp.set("bar", "abc 123123.2");
- test(p3.equals(tmp));
+ test(Ice.MapUtil.equals(p3, tmp));
test(retval.size == 4);
test(retval.get("foo") === "abc -1.1");
test(retval.get("FOO") === "abc -100.4");
@@ -817,13 +802,13 @@
return prx.opStringMyEnumD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.StringMyEnumD();
tmp.set("abc", Test.MyEnum.enum1);
tmp.set("", Test.MyEnum.enum2);
- test(p3.equals(tmp));
+ test(Ice.MapUtil.equals(p3, tmp));
test(retval.size === 4);
test(retval.get("abc") === Test.MyEnum.enum1);
test(retval.get("qwerty") === Test.MyEnum.enum3);
@@ -838,12 +823,12 @@
return prx.opMyEnumStringD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.MyEnumStringD();
tmp.set(Test.MyEnum.enum1, "abc");
- test(p3.equals(tmp));
+ test(Ice.MapUtil.equals(p3, tmp));
test(retval.size === 3);
test(retval.get(Test.MyEnum.enum1) === "abc");
test(retval.get(Test.MyEnum.enum2) === "Hello!!");
@@ -863,9 +848,9 @@
return prx.opMyStructMyEnumD(di1, di2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var tmp = new Test.MyStructMyEnumD();
var ts11 = new Test.MyStruct(1, 1);
var ts12 = new Test.MyStruct(1, 2);
@@ -893,9 +878,9 @@
return prx.opByteBoolDS([ds1, ds2], [ds3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.length == 2);
test(retval[0].size == 3);
test(retval[0].get(10) === true);
@@ -928,9 +913,9 @@
return prx.opShortIntDS([di1, di2], [di3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.length == 2);
test(retval[0].size == 3);
test(retval[0].get(110) === -1);
@@ -963,9 +948,9 @@
return prx.opLongFloatDS([di1, di2], [di3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.length == 2);
test(retval[0].size == 3);
test(retval[0].get(new Ice.Long(0, 999999110)) - Math.abs(-1.1) <= 0.1);
@@ -998,9 +983,9 @@
return prx.opStringStringDS([di1, di2], [di3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.length === 2);
test(retval[0].size === 3);
test(retval[0].get("foo") === "abc -1.1");
@@ -1033,9 +1018,9 @@
return prx.opStringMyEnumDS([di1, di2], [di3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.length == 2);
test(retval[0].size == 3);
test(retval[0].get("abc") == Test.MyEnum.enum1);
@@ -1066,9 +1051,9 @@
return prx.opMyEnumStringDS([di1, di2], [di3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(retval.length == 2);
test(retval[0].size == 2);
test(retval[0].get(Test.MyEnum.enum2) === "Hello!!");
@@ -1103,9 +1088,9 @@
return prx.opMyStructMyEnumDS([di1, di2], [di3]);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
var s11 = new Test.MyStruct(1, 1);
var s12 = new Test.MyStruct(1, 2);
var s22 = new Test.MyStruct(2, 2);
@@ -1139,9 +1124,9 @@
return prx.opByteByteSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size == 1);
test(p3.get(0xf1).length === 2);
test(p3.get(0xf1)[0] === 0xf2);
@@ -1167,9 +1152,9 @@
return prx.opBoolBoolSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size === 1);
test(p3.get(false).length === 2);
test(p3.get(false)[0] === true);
@@ -1196,9 +1181,9 @@
return prx.opShortShortSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size === 1);
test(p3.get(4).length === 2);
test(p3.get(4)[0] === 6);
@@ -1228,9 +1213,9 @@
return prx.opIntIntSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size === 1);
test(p3.get(400).length === 2);
test(p3.get(400)[0] === 600);
@@ -1260,9 +1245,9 @@
return prx.opLongLongSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size == 1);
test(p3.get(new Ice.Long(0, 999999992)).length === 2);
test(p3.get(new Ice.Long(0, 999999992))[0].equals(new Ice.Long(0, 999999110)));
@@ -1292,9 +1277,9 @@
return prx.opStringFloatSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size === 1);
test(p3.get("aBc").length === 2);
test(p3.get("aBc")[0] - Math.abs(3.14) <= 0.1);
@@ -1324,9 +1309,9 @@
return prx.opStringDoubleSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size === 1);
test(p3.get("").length === 2);
test(p3.get("")[0] === 1.6E10);
@@ -1356,9 +1341,9 @@
return prx.opStringStringSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size === 1);
test(p3.get("ghi").length ===2);
test(p3.get("ghi")[0] === "and");
@@ -1388,9 +1373,9 @@
return prx.opMyEnumMyEnumSD(sdi1, sdi2);
}
- ).then(
- function(retval, p3)
+ ).then(r =>
{
+ var [retval, p3] = r;
test(p3.size == 1);
test(p3.get(Test.MyEnum.enum1).length == 2);
test(p3.get(Test.MyEnum.enum1)[0] == Test.MyEnum.enum3);
@@ -1434,107 +1419,97 @@
return next(0);
}
- ).then(
- function()
+ ).then(() =>
{
test(prx.ice_getContext().size === 0);
-
return prx.opContext();
}
- ).then(
- function(c)
+ ).then(c =>
{
- test(!c.equals(ctx));
+ test(!Ice.MapUtil.equals(c, ctx));
return prx.opContext(ctx);
}
- ).then(
- function(c)
+ ).then(c =>
{
- test(c.equals(ctx));
+ test(Ice.MapUtil.equals(c, ctx));
return Test.MyClassPrx.checkedCast(prx.ice_context(ctx));
}
- ).then(
- function(p2)
- {
- test(p2.ice_getContext().equals(ctx));
- return p2.opContext();
- }
- ).then(
- function(c, r)
- {
- test(c.equals(ctx));
- return r.proxy.opContext(ctx);
- }
- ).then(
- function(c, r)
+ ).then(p2 =>
{
- test(c.equals(ctx));
- if(!bidir)
- {
- return Ice.Promise.try(
- function()
- {
- test(c.equals(ctx));
-
- //
- // Test implicit context propagation
- //
-
- var initData = new Ice.InitializationData();
- initData.properties = communicator.getProperties().clone();
- initData.properties.setProperty("Ice.ImplicitContext", "Shared");
- var ic = Ice.initialize(initData);
- var p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010"));
- ic.getImplicitContext().setContext(ctx);
- test(ic.getImplicitContext().getContext().equals(ctx));
- return p3.opContext();
- }
- ).then(
- function(c, r)
- {
- r.communicator.getImplicitContext().put("zero", "ZERO");
- return r.proxy.opContext();
- }
- ).then(
- function(c, r)
+ test(Ice.MapUtil.equals(p2.ice_getContext(), ctx));
+ return p2.opContext().then(c =>
+ {
+ test(Ice.MapUtil.equals(c, ctx));
+ return p2.opContext(ctx);
+ }
+ ).then(c =>
+ {
+ test(Ice.MapUtil.equals(c, ctx));
+ if(!bidir)
{
- test(c.equals(r.communicator.getImplicitContext().getContext()));
+ var p3, ic;
+ return Ice.Promise.try(() =>
+ {
+ test(Ice.MapUtil.equals(c, ctx));
+
+ //
+ // Test implicit context propagation
+ //
+
+ var initData = new Ice.InitializationData();
+ initData.properties = communicator.getProperties().clone();
+ initData.properties.setProperty("Ice.ImplicitContext", "Shared");
+ ic = Ice.initialize(initData);
+ p3 = Test.MyClassPrx.uncheckedCast(ic.stringToProxy("test:default -p 12010"));
+ ic.getImplicitContext().setContext(ctx);
+ test(Ice.MapUtil.equals(ic.getImplicitContext().getContext(), ctx));
+ return p3.opContext();
+ }
+ ).then(c =>
+ {
+ ic.getImplicitContext().put("zero", "ZERO");
+ return p3.opContext();
+ }
+ ).then(c =>
+ {
+ test(Ice.MapUtil.equals(c, ic.getImplicitContext().getContext()));
- ctx = r.communicator.getImplicitContext().getContext();
+ ctx = ic.getImplicitContext().getContext();
- var prxContext = new Ice.Context();
- prxContext.set("one", "UN");
- prxContext.set("four", "QUATRE");
+ var prxContext = new Ice.Context();
+ prxContext.set("one", "UN");
+ prxContext.set("four", "QUATRE");
- combined = new Ice.Context(ctx);
- combined.merge(prxContext);
- test(combined.get("one") === "UN");
+ combined = new Ice.Context(ctx);
+ for(let [key, value] of prxContext)
+ {
+ combined.set(key, value);
+ }
+ test(combined.get("one") === "UN");
- var p3 = Test.MyClassPrx.uncheckedCast(r.proxy.ice_context(prxContext));
+ p3 = Test.MyClassPrx.uncheckedCast(p3.ice_context(prxContext));
- r.communicator.getImplicitContext().setContext(null);
+ ic.getImplicitContext().setContext(null);
- return p3.opContext();
- }
- ).then(
- function(c, r)
- {
- test(c.equals(r.proxy.ice_getContext()));
- r.communicator.getImplicitContext().setContext(ctx);
+ return p3.opContext();
+ }
+ ).then(c =>
+ {
+ test(Ice.MapUtil.equals(c, p3.ice_getContext()));
+ ic.getImplicitContext().setContext(ctx);
- return r.proxy.opContext();
- }
- ).then(
- function(c, r)
- {
- test(c.equals(combined));
+ return p3.opContext();
+ }
+ ).then(c =>
+ {
+ test(Ice.MapUtil.equals(c, combined));
- return r.communicator.destroy();
- });
- }
+ return ic.destroy();
+ });
+ }
+ });
}
- ).then(
- function()
+ ).then(() =>
{
var d = 1278312346.0 / 13.0;
var ds = [];
@@ -1545,28 +1520,11 @@
return prx.opDoubleMarshaling(d, ds);
}
- ).then(
- function()
- {
- return prx.opIdempotent();
- }
- ).then(
- function()
- {
- return prx.opNonmutating();
- }
- ).then(
- function()
- {
- return Test.MyDerivedClassPrx.checkedCast(prx);
- }
- ).then(
- function(d)
- {
- return d.opDerived();
- }
- ).then(
- function()
+ ).then(() => prx.opIdempotent()
+ ).then(() => prx.opNonmutating()
+ ).then(() => Test.MyDerivedClassPrx.checkedCast(prx)
+ ).then(d => d.opDerived()
+ ).then(() =>
{
var d = Test.MyDerivedClassPrx.uncheckedCast(prx);
var s = new Test.MyStruct1();
@@ -1595,43 +1553,33 @@
d.opMyStruct1(s),
d.opMyClass1(c)
]
- ).then(
- function()
+ ).then(r =>
{
- test(arguments[0][0] == 0xFF);
- test(arguments[1][0] == 0x7FFF);
- test(arguments[2][0] == 0x7FFFFFFF);
- var l = arguments[3][0];
+ test(r[0] == 0xFF);
+ test(r[1] == 0x7FFF);
+ test(r[2] == 0x7FFFFFFF);
+ var l = r[3];
test(l.high == 0x7FFFFFFF && l.low == 0xFFFFFFFF);
- test(arguments[4][0] == 1.0);
- test(arguments[5][0] == 1.0);
- test(arguments[6][0] == "opString1");
- test(arguments[7][0].length === 0);
- test(arguments[8][0].size === 0);
- test(arguments[9][0].length === 0);
- test(arguments[10][0].size === 0);
-
- s = arguments[11][0];
+ test(r[4] == 1.0);
+ test(r[5] == 1.0);
+ test(r[6] == "opString1");
+ test(r[7].length === 0);
+ test(r[8].size === 0);
+ test(r[9].length === 0);
+ test(r[10].size === 0);
+
+ s = r[11];
test(s.tesT == "Test.MyStruct1.s");
test(s.myClass === null);
test(s.myStruct1 == "Test.MyStruct1.myStruct1");
- c = arguments[12][0];
+ c = r[12];
test(c.tesT == "Test.MyClass1.testT");
test(c.myClass === null);
test(c.myClass1 == "Test.MyClass1.myClass1");
});
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js b/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js
index 89b164f9388..4ff956b7421 100644
--- a/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js
+++ b/js/test/Ice/operationsBidir/AMDMyDerivedClassI.js
@@ -12,8 +12,6 @@
var Ice = require("ice").Ice;
var TestAMD = require("TestAMD").TestAMD;
- var Class = Ice.Class;
-
var test = function(b)
{
if(!b)
@@ -22,301 +20,346 @@
}
};
- var AMDMyDerivedClassI = Class(TestAMD.MyDerivedClass, {
+ class AMDMyDerivedClassI extends TestAMD.MyDerivedClass
+ {
//
// Override the Object "pseudo" operations to verify the operation mode.
//
- __init__: function()
+ constructor()
{
+ super();
this._opByteSOnewayCount = 0;
- },
- ice_isA: function(id, current)
+ }
+
+ ice_isA(id, current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
return Ice.Object.prototype.ice_isA.call(this, id, current);
- },
- ice_ping: function(current)
+ }
+
+ ice_ping(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
Ice.Object.prototype.ice_ping.call(this, current);
- },
- ice_ids: function(current)
+ }
+
+ ice_ids(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
return Ice.Object.prototype.ice_ids.call(this, current);
- },
- ice_id: function(current)
+ }
+
+ ice_id(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
return Ice.Object.prototype.ice_id.call(this, current);
- },
- shutdown_async: function(cb, current)
+ }
+
+ shutdown_async(cb, current)
{
current.adapter.getCommunicator().shutdown();
cb.ice_response();
- },
- delay_async: function(cb, ms, current)
+ }
+
+ delay_async(cb, ms, current)
{
- Ice.Timer.setTimeout(
- function()
- {
- cb.ice_response();
- }, ms);
- },
- opVoid_async: function(cb, current)
+ Ice.Timer.setTimeout(() => cb.ice_response(), ms);
+ }
+
+ opVoid_async(cb, current)
{
test(current.mode === Ice.OperationMode.Normal);
cb.ice_response();
- },
- opBool_async: function(cb, p1, p2, current)
+ }
+
+ opBool_async(cb, p1, p2, current)
{
cb.ice_response(p2, p1);
- },
- opBoolS_async: function(cb, p1, p2, current)
+ }
+
+ opBoolS_async(cb, p1, p2, current)
{
var p3 = p1.concat(p2);
cb.ice_response(p1.reverse(), p3);
- },
- opBoolSS_async: function(cb, p1, p2, current)
+ }
+
+ opBoolSS_async(cb, p1, p2, current)
{
var p3 = p1.concat(p2);
cb.ice_response(p1.reverse(), p3);
- },
- opByte_async: function(cb, p1, p2, current)
+ }
+
+ opByte_async(cb, p1, p2, current)
{
cb.ice_response(p1, (p1 ^ p2) & 0xff);
- },
- opByteBoolD_async: function(cb, p1, p2, current)
+ }
+
+ opByteBoolD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opByteS_async: function(cb, p1, p2, current)
+ }
+
+ opByteS_async(cb, p1, p2, current)
{
- var i;
var p3 = Ice.Buffer.createNative(p1.length);
- for(i = 0; i < p1.length; i++)
+ for(let i = 0; i < p1.length; i++)
{
p3[i] = p1[p1.length - (i + 1)];
}
var r = Ice.Buffer.createNative(p1.length + p2.length);
- for(i = 0; i < p1.length; ++i)
+ for(let i = 0; i < p1.length; ++i)
{
r[i] = p1[i];
}
- for(i = 0; i < p2.length; ++i)
+ for(let i = 0; i < p2.length; ++i)
{
r[i + p1.length] = p2[i];
}
cb.ice_response(r, p3);
- },
- opByteSS_async: function(cb, p1, p2, current)
+ }
+
+ opByteSS_async(cb, p1, p2, current)
{
var r = p1.concat(p2);
cb.ice_response(r, p1.reverse());
- },
- opFloatDouble_async: function(cb, p1, p2, current)
+ }
+
+ opFloatDouble_async(cb, p1, p2, current)
{
cb.ice_response(p2, p1, p2);
- },
- opFloatDoubleS_async: function(cb, p1, p2, current)
+ }
+
+ opFloatDoubleS_async(cb, p1, p2, current)
{
var r = p2.concat(p1);
var p4 = p2.reverse();
cb.ice_response(r, p1, p4);
- },
- opFloatDoubleSS_async: function(cb, p1, p2, current)
+ }
+
+ opFloatDoubleSS_async(cb, p1, p2, current)
{
var r = p2.concat(p2);
var p4 = p2.reverse();
cb.ice_response(r, p1, p4);
- },
- opLongFloatD_async: function(cb, p1, p2, current)
+ }
+
+ opLongFloatD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Ice.HashMap(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opMyClass_async: function(cb, p1, current)
+ }
+
+ opMyClass_async(cb, p1, current)
{
var p2 = p1;
var p3 = TestAMD.MyClassPrx.uncheckedCast(
current.adapter.createProxy(Ice.stringToIdentity("noSuchIdentity")));
var r = TestAMD.MyClassPrx.uncheckedCast(current.adapter.createProxy(current.id));
cb.ice_response(r, p2, p3);
- },
- opMyEnum_async: function(cb, p1, current)
+ }
+
+ opMyEnum_async(cb, p1, current)
{
cb.ice_response(TestAMD.MyEnum.enum3, p1);
- },
- opShortIntD_async: function(cb, p1, p2, current)
+ }
+
+ opShortIntD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opShortIntLong_async: function(cb, p1, p2, p3, current)
+ }
+
+ opShortIntLong_async(cb, p1, p2, p3, current)
{
cb.ice_response(p3, p1, p2, p3);
- },
- opShortIntLongS_async: function(cb, p1, p2, p3, current)
+ }
+
+ opShortIntLongS_async(cb, p1, p2, p3, current)
{
cb.ice_response(p3, p1, p2.reverse(), p3.concat(p3));
- },
- opShortIntLongSS_async: function(cb, p1, p2, p3, current)
+ }
+
+ opShortIntLongSS_async(cb, p1, p2, p3, current)
{
cb.ice_response(p3, p1, p2.reverse(), p3.concat(p3));
- },
- opString_async: function(cb, p1, p2, current)
+ }
+
+ opString_async(cb, p1, p2, current)
{
cb.ice_response(p1 + " " + p2, p2 + " " + p1);
- },
- opStringMyEnumD_async: function(cb, p1, p2, current)
+ }
+
+ opStringMyEnumD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opMyEnumStringD_async: function(cb, p1, p2, current)
+ }
+
+ opMyEnumStringD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opMyStructMyEnumD_async: function(cb, p1, p2, current)
+ }
+
+ opMyStructMyEnumD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Ice.HashMap(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opByteBoolDS_async: function(cb, p1, p2, current)
+ }
+
+ opByteBoolDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opShortIntDS_async: function(cb, p1, p2, current)
+ }
+
+ opShortIntDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
+ }
- opLongFloatDS_async: function(cb, p1, p2, current)
+ opLongFloatDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opStringStringDS_async: function(cb, p1, p2, current)
+ }
+
+ opStringStringDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opStringMyEnumDS_async: function(cb, p1, p2, current)
+ }
+
+ opStringMyEnumDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opMyEnumStringDS_async: function(cb, p1, p2, current)
+ }
+
+ opMyEnumStringDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opMyStructMyEnumDS_async: function(cb, p1, p2, current)
+ }
+
+ opMyStructMyEnumDS_async(cb, p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opByteByteSD_async: function(cb, p1, p2, current)
+ }
+
+ opByteByteSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opBoolBoolSD_async: function(cb, p1, p2, current)
+ }
+
+ opBoolBoolSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opShortShortSD_async: function(cb, p1, p2, current)
+ }
+
+ opShortShortSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opIntIntSD_async: function(cb, p1, p2, current)
+ }
+
+ opIntIntSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opLongLongSD_async: function(cb, p1, p2, current)
+ }
+
+ opLongLongSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Ice.HashMap(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Ice.HashMap(p2);
cb.ice_response(r, p3);
- },
- opStringFloatSD_async: function(cb, p1, p2, current)
+ }
+
+ opStringFloatSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opStringDoubleSD_async: function(cb, p1, p2, current)
+ }
+
+ opStringDoubleSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opStringStringSD_async: function(cb, p1, p2, current)
+ }
+
+ opStringStringSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opMyEnumMyEnumSD_async: function(cb, p1, p2, current)
+ }
+
+ opMyEnumMyEnumSD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
cb.ice_response(r, p3);
- },
- opIntS_async: function(cb, s, current)
+ }
+
+ opIntS_async(cb, s, current)
{
cb.ice_response(s.map(function(v, i, arr) { return -v; }));
- },
- opByteSOneway_async: function(cb, s, current)
+ }
+
+ opByteSOneway_async(cb, s, current)
{
this._opByteSOnewayCount += 1;
cb.ice_response();
- },
- opByteSOnewayCallCount_async: function(cb, current)
+ }
+
+ opByteSOnewayCallCount_async(cb, current)
{
var count = this._opByteSOnewayCount;
this._opByteSOnewayCount = 0;
cb.ice_response(count);
- },
- opContext_async: function(cb, current)
+ }
+
+ opContext_async(cb, current)
{
cb.ice_response(current.ctx);
- },
- opDoubleMarshaling_async: function(cb, p1, p2, current)
+ }
+
+ opDoubleMarshaling_async(cb, p1, p2, current)
{
var d = 1278312346.0 / 13.0;
test(p1 === d);
@@ -325,103 +368,125 @@
test(p2[i] === d);
}
cb.ice_response();
- },
- opStringS_async: function(cb, p1, p2, current)
+ }
+
+ opStringS_async(cb, p1, p2, current)
{
var p3 = p1.concat(p2);
var r = p1.reverse();
cb.ice_response(r, p3);
- },
- opStringSS_async: function(cb, p1, p2, current)
+ }
+
+ opStringSS_async(cb, p1, p2, current)
{
var p3 = p1.concat(p2);
var r = p2.reverse();
cb.ice_response(r, p3);
- },
- opStringSSS_async: function(cb, p1, p2, current)
+ }
+
+ opStringSSS_async(cb, p1, p2, current)
{
var p3 = p1.concat(p2);
var r = p2.reverse();
cb.ice_response(r, p3);
- },
- opStringStringD_async: function(cb, p1, p2, current)
+ }
+
+ opStringStringD_async(cb, p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
cb.ice_response(r, p1);
- },
- opStruct_async: function(cb, p1, p2, current)
+ }
+
+ opStruct_async(cb, p1, p2, current)
{
p1.s.s = "a new string";
cb.ice_response(p2, p1);
- },
- opIdempotent_async: function(cb, current)
+ }
+
+ opIdempotent_async(cb, current)
{
test(current.mode === Ice.OperationMode.Idempotent);
cb.ice_response();
- },
- opNonmutating_async: function(cb, current)
+ }
+
+ opNonmutating_async(cb, current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
cb.ice_response();
- },
- opDerived_async: function(cb, current)
+ }
+
+ opDerived_async(cb, current)
{
cb.ice_response();
- },
- opByte1_async: function(cb, value, current)
+ }
+
+ opByte1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opShort1_async: function(cb, value, current)
+ }
+
+ opShort1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opInt1_async: function(cb, value, current)
+ }
+
+ opInt1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opLong1_async: function(cb, value, current)
+ }
+
+ opLong1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opFloat1_async: function(cb, value, current)
+ }
+
+ opFloat1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opDouble1_async: function(cb, value, current)
+ }
+
+ opDouble1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opString1_async: function(cb, value, current)
+ }
+
+ opString1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opStringS1_async: function(cb, value, current)
+ }
+
+ opStringS1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opByteBoolD1_async: function(cb, value, current)
+ }
+
+ opByteBoolD1_async(cb, value, current)
{
cb.ice_response(value);
- },
- opStringS2_async: function(cb, value, current)
+ }
+
+ opStringS2_async(cb, value, current)
{
cb.ice_response(value);
- },
- opByteBoolD2_async: function(cb, value, current)
+ }
+
+ opByteBoolD2_async(cb, value, current)
{
cb.ice_response(value);
- },
- opMyClass1_async: function(cb, value, current)
+ }
+
+ opMyClass1_async(cb, value, current)
{
return cb.ice_response(value);
- },
- opMyStruct1_async: function(cb, value, current)
+ }
+
+ opMyStruct1_async(cb, value, current)
{
return cb.ice_response(value);
- },
- opStringLiterals_async: function(cb, current)
+ }
+
+ opStringLiterals_async(cb, current)
{
return cb.ice_response([
TestAMD.s0, TestAMD.s1, TestAMD.s2, TestAMD.s3, TestAMD.s4, TestAMD.s5, TestAMD.s6, TestAMD.s7, TestAMD.s8, TestAMD.s9, TestAMD.s10,
@@ -429,7 +494,7 @@
TestAMD.ss0, TestAMD.ss1, TestAMD.ss2, TestAMD.ss3, TestAMD.ss4, TestAMD.ss5,
TestAMD.su0, TestAMD.su1, TestAMD.su2]);
}
- });
+ }
exports.AMDMyDerivedClassI = AMDMyDerivedClassI;
}
diff --git a/js/test/Ice/operationsBidir/Client.js b/js/test/Ice/operationsBidir/Client.js
index 1db516e498e..2a1fd97e823 100644
--- a/js/test/Ice/operationsBidir/Client.js
+++ b/js/test/Ice/operationsBidir/Client.js
@@ -20,8 +20,7 @@
var allTests = function(out, communicator, amd)
{
- return communicator.createObjectAdapter("").then(
- function(adapter)
+ return communicator.createObjectAdapter("").then(adapter =>
{
if(amd)
{
@@ -32,8 +31,7 @@
adapter.add(new MyDerivedClassI(), Ice.stringToIdentity("test"));
}
var base = communicator.stringToProxy("test:default -p 12010");
- return base.ice_getConnection().then(
- function(conn)
+ return base.ice_getConnection().then(conn =>
{
conn.setAdapter(adapter);
return Client.__clientAllTests__(out, communicator, amd ? TestAMD : Test, true);
@@ -45,46 +43,26 @@
{
id.properties.setProperty("Ice.BatchAutoFlushSize", "100");
var communicator = Ice.initialize(id);
- return Promise.try(
- function()
+ return Promise.try(() =>
{
out.writeLine("testing bidir callbacks with synchronous dispatch...");
return allTests(out, communicator, false);
}
- ).then(
- function()
- {
- return communicator.destroy();
- }
- ).then(
- function()
+ ).then(() => communicator.destroy()
+ ).then(() =>
{
communicator = Ice.initialize(id);
out.writeLine("testing bidir callbacks with asynchronous dispatch...");
return allTests(out, communicator, true);
}
- ).then(
- function()
- {
- return communicator.destroy();
- }
- ).then(
- function()
+ ).then(() => communicator.destroy()
+ ).then(() =>
{
communicator = Ice.initialize(id);
return Test.EchoPrx.checkedCast(communicator.stringToProxy("__echo:default -p 12010"));
}
- ).then(
- function(prx)
- {
- return prx.shutdown();
- }
- ).finally(
- function()
- {
- return communicator.destroy();
- }
- );
+ ).then(prx => prx.shutdown()
+ ).finally(() => communicator.destroy());
};
exports.__test__ = run;
exports.__runEchoServer__ = true;
diff --git a/js/test/Ice/operationsBidir/MyDerivedClassI.js b/js/test/Ice/operationsBidir/MyDerivedClassI.js
index 930345c9b85..e613f699f03 100644
--- a/js/test/Ice/operationsBidir/MyDerivedClassI.js
+++ b/js/test/Ice/operationsBidir/MyDerivedClassI.js
@@ -12,8 +12,6 @@
var Ice = require("ice").Ice;
var Test = require("Test").Test;
- var Class = Ice.Class;
-
var test = function(b)
{
if(!b)
@@ -22,297 +20,343 @@
}
};
- var MyDerivedClassI = Class(Test.MyDerivedClass, {
+ class MyDerivedClassI extends Test.MyDerivedClass
+ {
//
// Override the Object "pseudo" operations to verify the operation mode.
//
- __init__: function()
+ constructor()
{
+ super();
this._opByteSOnewayCount = 0;
- },
- ice_isA: function(id, current)
+ }
+
+ ice_isA(id, current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
return Ice.Object.prototype.ice_isA.call(this, id, current);
- },
- ice_ping: function(current)
+ }
+
+ ice_ping(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
Ice.Object.prototype.ice_ping.call(this, current);
- },
- ice_ids: function(current)
+ }
+
+ ice_ids(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
return Ice.Object.prototype.ice_ids.call(this, current);
- },
- ice_id: function(current)
+ }
+
+ ice_id(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
return Ice.Object.prototype.ice_id.call(this, current);
- },
- shutdown: function(current)
+ }
+
+ shutdown(current)
{
current.adapter.getCommunicator().shutdown();
- },
- delay: function(cb, ms, current)
+ }
+
+ delay(cb, ms, current)
{
- Ice.Timer.setTimeout(
- function()
- {
- cb.ice_response();
- }, ms);
- },
- opVoid: function(current)
+ Ice.Timer.setTimeout(() => cb.ice_response(), ms);
+ }
+
+ opVoid(current)
{
test(current.mode === Ice.OperationMode.Normal);
- },
- opBool: function(p1, p2, current)
+ }
+
+ opBool(p1, p2, current)
{
return [p2, p1];
- },
- opBoolS: function(p1, p2, current)
+ }
+
+ opBoolS(p1, p2, current)
{
var p3 = p1.concat(p2);
return [p1.reverse(), p3];
- },
- opBoolSS: function(p1, p2, current)
+ }
+
+ opBoolSS(p1, p2, current)
{
var p3 = p1.concat(p2);
return [p1.reverse(), p3];
- },
- opByte: function(p1, p2, current)
+ }
+
+ opByte(p1, p2, current)
{
return [p1, (p1 ^ p2) & 0xff];
- },
- opByteBoolD: function(p1, p2, current)
+ }
+
+ opByteBoolD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opByteS: function(p1, p2, current)
+ }
+
+ opByteS(p1, p2, current)
{
- var i;
var p3 = Ice.Buffer.createNative(p1.length);
- for(i = 0; i < p1.length; i++)
+ for(let i = 0; i < p1.length; i++)
{
p3[i] = p1[p1.length - (i + 1)];
}
var r = Ice.Buffer.createNative(p1.length + p2.length);
- for(i = 0; i < p1.length; ++i)
+ for(let i = 0; i < p1.length; ++i)
{
r[i] = p1[i];
}
- for(i = 0; i < p2.length; ++i)
+ for(let i = 0; i < p2.length; ++i)
{
r[i + p1.length] = p2[i];
}
return [r, p3];
- },
- opByteSS: function(p1, p2, current)
+ }
+
+ opByteSS(p1, p2, current)
{
var r = p1.concat(p2);
return [r, p1.reverse()];
- },
- opFloatDouble: function(p1, p2, current)
+ }
+
+ opFloatDouble(p1, p2, current)
{
return [p2, p1, p2];
- },
- opFloatDoubleS: function(p1, p2, current)
+ }
+
+ opFloatDoubleS(p1, p2, current)
{
var r = p2.concat(p1);
var p4 = p2.reverse();
return [r, p1, p4];
- },
- opFloatDoubleSS: function(p1, p2, current)
+ }
+
+ opFloatDoubleSS(p1, p2, current)
{
var r = p2.concat(p2);
var p4 = p2.reverse();
return [r, p1, p4];
- },
- opLongFloatD: function(p1, p2, current)
+ }
+
+ opLongFloatD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Ice.HashMap(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opMyClass: function(p1, current)
+ }
+
+ opMyClass(p1, current)
{
var p2 = p1;
var p3 = Test.MyClassPrx.uncheckedCast(
current.adapter.createProxy(Ice.stringToIdentity("noSuchIdentity")));
var r = Test.MyClassPrx.uncheckedCast(current.adapter.createProxy(current.id));
return [r, p2, p3];
- },
- opMyEnum: function(p1, current)
+ }
+
+ opMyEnum(p1, current)
{
return [Test.MyEnum.enum3, p1];
- },
- opShortIntD: function(p1, p2, current)
+ }
+
+ opShortIntD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opShortIntLong: function(p1, p2, p3, current)
+ }
+
+ opShortIntLong(p1, p2, p3, current)
{
return [p3, p1, p2, p3];
- },
- opShortIntLongS: function(p1, p2, p3, current)
+ }
+
+ opShortIntLongS(p1, p2, p3, current)
{
return [p3, p1, p2.reverse(), p3.concat(p3)];
- },
- opShortIntLongSS: function(p1, p2, p3, current)
+ }
+
+ opShortIntLongSS(p1, p2, p3, current)
{
return [p3, p1, p2.reverse(), p3.concat(p3)];
- },
- opString: function(p1, p2, current)
+ }
+
+ opString(p1, p2, current)
{
return [p1 + " " + p2, p2 + " " + p1];
- },
- opStringMyEnumD: function(p1, p2, current)
+ }
+
+ opStringMyEnumD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opMyEnumStringD: function(p1, p2, current)
+ }
+
+ opMyEnumStringD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opMyStructMyEnumD: function(p1, p2, current)
+ }
+
+ opMyStructMyEnumD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Ice.HashMap(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opByteBoolDS: function(p1, p2, current)
+ }
+
+ opByteBoolDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opShortIntDS: function(p1, p2, current)
+ }
+
+ opShortIntDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opLongFloatDS: function(p1, p2, current)
+ }
+
+ opLongFloatDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opStringStringDS: function(p1, p2, current)
+ }
+
+ opStringStringDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opStringMyEnumDS: function(p1, p2, current)
+ }
+
+ opStringMyEnumDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opMyEnumStringDS: function(p1, p2, current)
+ }
+
+ opMyEnumStringDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opMyStructMyEnumDS: function(p1, p2, current)
+ }
+
+ opMyStructMyEnumDS(p1, p2, current)
{
var p3 = p2.concat(p1);
var r = p1.reverse();
return [r, p3];
- },
- opByteByteSD: function(p1, p2, current)
+ }
+
+ opByteByteSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opBoolBoolSD: function(p1, p2, current)
+ }
+
+ opBoolBoolSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opShortShortSD: function(p1, p2, current)
+ }
+
+ opShortShortSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opIntIntSD: function(p1, p2, current)
+ }
+
+ opIntIntSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opLongLongSD: function(p1, p2, current)
+ }
+
+ opLongLongSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Ice.HashMap(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Ice.HashMap(p2);
return [r, p3];
- },
- opStringFloatSD: function(p1, p2, current)
+ }
+
+ opStringFloatSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opStringDoubleSD: function(p1, p2, current)
+ }
+
+ opStringDoubleSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opStringStringSD: function(p1, p2, current)
+ }
+
+ opStringStringSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opMyEnumMyEnumSD: function(p1, p2, current)
+ }
+
+ opMyEnumMyEnumSD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
- var p3 = p2.clone();
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
+ var p3 = new Map(p2);
return [r, p3];
- },
- opIntS: function(s, current)
+ }
+
+ opIntS(s, current)
{
return s.map(function(v, i, arr) { return -v; });
- },
- opByteSOneway: function(s, current)
+ }
+
+ opByteSOneway(s, current)
{
this._opByteSOnewayCount += 1;
- },
- opByteSOnewayCallCount: function(current)
+ }
+
+ opByteSOnewayCallCount(current)
{
var count = this._opByteSOnewayCount;
this._opByteSOnewayCount = 0;
return count;
- },
- opContext: function(current)
+ }
+
+ opContext(current)
{
return current.ctx;
- },
- opDoubleMarshaling: function(p1, p2, current)
+ }
+
+ opDoubleMarshaling(p1, p2, current)
{
var d = 1278312346.0 / 13.0;
test(p1 === d);
@@ -320,100 +364,122 @@
{
test(p2[i] === d);
}
- },
- opStringS: function(p1, p2, current)
+ }
+
+ opStringS(p1, p2, current)
{
var p3 = p1.concat(p2);
var r = p1.reverse();
return [r, p3];
- },
- opStringSS: function(p1, p2, current)
+ }
+
+ opStringSS(p1, p2, current)
{
var p3 = p1.concat(p2);
var r = p2.reverse();
return [r, p3];
- },
- opStringSSS: function(p1, p2, current)
+ }
+
+ opStringSSS(p1, p2, current)
{
var p3 = p1.concat(p2);
var r = p2.reverse();
return [r, p3];
- },
- opStringStringD: function(p1, p2, current)
+ }
+
+ opStringStringD(p1, p2, current)
{
- var r = p1.clone();
- r.merge(p2);
+ var r = new Map(p1);
+ p2.forEach((value, key) => r.set(key, value));
return [r, p1];
- },
- opStruct: function(p1, p2, current)
+ }
+
+ opStruct(p1, p2, current)
{
p1.s.s = "a new string";
return [p2, p1];
- },
- opIdempotent: function(current)
+ }
+
+ opIdempotent(current)
{
test(current.mode === Ice.OperationMode.Idempotent);
- },
- opNonmutating: function(current)
+ }
+
+ opNonmutating(current)
{
test(current.mode === Ice.OperationMode.Nonmutating);
- },
- opDerived: function(current)
+ }
+
+ opDerived(current)
{
- },
- opByte1: function(value, current)
+ }
+
+ opByte1(value, current)
{
return value;
- },
- opShort1: function(value, current)
+ }
+
+ opShort1(value, current)
{
return value;
- },
- opInt1: function(value, current)
+ }
+
+ opInt1(value, current)
{
return value;
- },
- opLong1: function(value, current)
+ }
+
+ opLong1(value, current)
{
return value;
- },
- opFloat1: function(value, current)
+ }
+
+ opFloat1(value, current)
{
return value;
- },
- opDouble1: function(value, current)
+ }
+
+ opDouble1(value, current)
{
return value;
- },
- opString1: function(value, current)
+ }
+
+ opString1(value, current)
{
return value;
- },
- opStringS1: function(value, current)
+ }
+
+ opStringS1(value, current)
{
return value;
- },
- opByteBoolD1: function(value, current)
+ }
+
+ opByteBoolD1(value, current)
{
return value;
- },
- opStringS2: function(value, current)
+ }
+
+ opStringS2(value, current)
{
return value;
- },
- opByteBoolD2: function(value, current)
+ }
+
+ opByteBoolD2(value, current)
{
return value;
- },
- opMyClass1: function(value, current)
+ }
+
+ opMyClass1(value, current)
{
return value;
- },
- opMyStruct1: function(value, current)
+ }
+
+ opMyStruct1(value, current)
{
return value;
- },
- opStringLiterals: function(current)
+ }
+
+ opStringLiterals(current)
{
return [
Test.s0, Test.s1, Test.s2, Test.s3, Test.s4, Test.s5, Test.s6, Test.s7, Test.s8, Test.s9, Test.s10,
@@ -421,7 +487,7 @@
Test.ss0, Test.ss1, Test.ss2, Test.ss3, Test.ss4, Test.ss5,
Test.su0, Test.su1, Test.su2];
}
- });
+ }
exports.MyDerivedClassI = MyDerivedClassI;
}
diff --git a/js/test/Ice/optional/Client.js b/js/test/Ice/optional/Client.js
index a6d1573db13..2b15b693fd8 100644
--- a/js/test/Ice/optional/Client.js
+++ b/js/test/Ice/optional/Client.js
@@ -33,14 +33,13 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
};
- Promise.try(
- function()
+ Promise.try(() =>
{
out.write("testing stringToProxy... ");
ref = "initial:default -p 12010";
@@ -56,8 +55,7 @@
out.write("testing checked cast... ");
return Test.InitialPrx.checkedCast(base);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
initial = obj;
test(initial !== null);
@@ -67,20 +65,17 @@
return initial.pingPong(new Test.OneOptional());
}
- ).then(
- function(oo4)
+ ).then(oo4 =>
{
test(oo4.a === undefined);
return initial.pingPong(oo1);
}
- ).then(
- function(oo5)
+ ).then(oo5 =>
{
test(oo5.a === oo1.a);
return initial.pingPong(new Test.MultiOptional());
}
- ).then(
- function(mo4)
+ ).then(mo4 =>
{
test(mo4.a === undefined);
test(mo4.b === undefined);
@@ -132,9 +127,9 @@
mo1.k = mo1;
mo1.bs = Ice.Buffer.createNative([5]);
mo1.ss = ["test", "test2"];
- mo1.iid = new Ice.HashMap();
+ mo1.iid = new Map();
mo1.iid.set(4, 3);
- mo1.sid = new Ice.HashMap();
+ mo1.sid = new Map();
mo1.sid.set("test", 10);
mo1.fs = new Test.FixedStruct();
mo1.fs.m = 78;
@@ -148,23 +143,22 @@
mo1.oos = [oo1];
mo1.oops = [Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"))];
- mo1.ied = new Ice.HashMap();
+ mo1.ied = new Map();
mo1.ied.set(4, Test.MyEnum.MyEnumMember);
- mo1.ifsd = new Ice.HashMap();
+ mo1.ifsd = new Map();
mo1.ifsd.set(4, mo1.fs);
- mo1.ivsd = new Ice.HashMap();
+ mo1.ivsd = new Map();
mo1.ivsd.set(5, mo1.vs);
- mo1.iood = new Ice.HashMap();
+ mo1.iood = new Map();
mo1.iood.set(5, new Test.OneOptional(15));
- mo1.ioopd = new Ice.HashMap();
+ mo1.ioopd = new Map();
mo1.ioopd.set(5, Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")));
mo1.bos = [false, true, false];
return initial.pingPong(mo1);
}
- ).then(
- function(mo5)
+ ).then(mo5 =>
{
test(mo1.a == mo5.a);
test(mo1.b == mo5.b);
@@ -217,8 +211,7 @@
return initial.pingPong(mo6);
}
- ).then(
- function(mo7)
+ ).then(mo7 =>
{
test(mo7.a === undefined);
test(mo7.b == mo1.b);
@@ -274,8 +267,7 @@
return initial.pingPong(mo8);
}
- ).then(
- function(mo9)
+ ).then(mo9 =>
{
test(mo9.a == mo1.a);
test(mo9.b === undefined);
@@ -316,31 +308,17 @@
initial2 = initial.ice_encodingVersion(Ice.Encoding_1_0);
var oo = new Test.OneOptional(53);
- return initial.sendOptionalClass(true, oo).then(
- function()
- {
- return initial2.sendOptionalClass(true, oo);
- }
- ).then(
- function()
- {
- return initial.returnOptionalClass(true);
- }
- ).then(
- function(oo1)
+ return initial.sendOptionalClass(true, oo)
+ .then(() => initial2.sendOptionalClass(true, oo)
+ ).then(() => initial.returnOptionalClass(true)
+ ).then(oo1 =>
{
test(oo1 !== undefined && oo1.a == 53);
return initial2.returnOptionalClass(true);
}
- ).then(
- function(oo1)
- {
- test(oo1 === undefined);
- }
- );
+ ).then(oo1 => test(oo1 === undefined));
}
- ).then(
- function()
+ ).then(() =>
{
var g = new Test.G();
g.gg1Opt = new Test.G1("gg1Opt");
@@ -349,22 +327,19 @@
g.gg1 = new Test.G1("gg1");
return initial.opG(g);
}
- ).then(
- function(g)
+ ).then(g =>
{
test(g.gg1Opt.a == "gg1Opt");
test(g.gg2.a.equals(new Ice.Long(0, 10)));
test(g.gg2Opt.a.equals(new Ice.Long(0, 20)));
test(g.gg1.a == "gg1");
}
- ).then(
- function()
+ ).then(() =>
{
var init2 = ClientPrivate.Initial2Prx.uncheckedCast(initial);
return init2.opVoid(5, "test");
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing marshaling of large containers with fixed size elements... ");
@@ -380,15 +355,14 @@
mc.fss[i] = new Test.FixedStruct();
}
- mc.ifsd = new Ice.HashMap();
+ mc.ifsd = new Map();
for(i = 0; i < 300; ++i)
{
mc.ifsd.set(i, new Test.FixedStruct());
}
return initial.pingPong(mc);
}
- ).then(
- function(mc)
+ ).then(mc =>
{
test(mc.bs.length == 1000);
test(mc.shs.length == 300);
@@ -399,8 +373,7 @@
out.write("testing tag marshaling... ");
return initial.pingPong(new Test.B());
}
- ).then(
- function(b)
+ ).then(b =>
{
test(b.ma === undefined);
test(b.mb === undefined);
@@ -413,8 +386,7 @@
return initial.pingPong(b);
}
- ).then(
- function(b)
+ ).then(b =>
{
test(b.ma == 10);
test(b.mb == 11);
@@ -429,8 +401,7 @@
f.ae = f.af;
return initial.pingPong(f);
}
- ).then(
- function(f)
+ ).then(f =>
{
test(f.ae === f.af);
@@ -439,8 +410,7 @@
return initial.pingPong(new Test.WD());
}
- ).then(
- function(wd)
+ ).then(wd =>
{
test(wd.a == 5);
test(wd.s == "test");
@@ -448,8 +418,7 @@
wd.s = undefined;
return initial.pingPong(wd);
}
- ).then(
- function(wd)
+ ).then(wd =>
{
test(wd.a === undefined);
test(wd.s === undefined);
@@ -459,231 +428,231 @@
return initial.opByte(); // same as initial.opByte(undefined);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opByte(56);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === 56);
test(p2 === 56);
return initial.opBool();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opBool(true);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === true);
test(p2 === true);
return initial.opShort();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opShort(56);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === 56);
test(p2 === 56);
return initial.opInt();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opInt(56);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === 56);
test(p2 === 56);
return initial.opLong();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opLong(new Ice.Long(0, 56));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.equals(new Ice.Long(0, 56)));
test(p2.equals(new Ice.Long(0, 56)));
return initial.opFloat();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opFloat(1.0);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === 1.0);
test(p2 === 1.0);
return initial.opDouble();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opDouble(1.0);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === 1.0);
test(p2 === 1.0);
return initial.opString();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opString("test");
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === "test");
test(p2 === "test");
return initial.opMyEnum();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opMyEnum(Test.MyEnum.MyEnumMember);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === Test.MyEnum.MyEnumMember);
test(p2 === Test.MyEnum.MyEnumMember);
return initial.opMyEnum(null); // Test null enum
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === Test.MyEnum.MyEnumMember);
test(p2 === Test.MyEnum.MyEnumMember);
return initial.opSmallStruct();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opSmallStruct(new Test.SmallStruct(56));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.equals(new Test.SmallStruct(56)));
test(p2.equals(new Test.SmallStruct(56)));
return initial.opSmallStruct(null); // Test null struct
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.equals(new Test.SmallStruct(0)));
test(p2.equals(new Test.SmallStruct(0)));
return initial.opFixedStruct();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opFixedStruct(new Test.FixedStruct(56));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.equals(new Test.FixedStruct(56)));
test(p2.equals(new Test.FixedStruct(56)));
return initial.opVarStruct();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opVarStruct(new Test.VarStruct("test"));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.equals(new Test.VarStruct("test")));
test(p2.equals(new Test.VarStruct("test")));
return initial.opOneOptional();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opOneOptional(new Test.OneOptional(58));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === p2);
test(p2.a === 58);
return initial.opOneOptionalProxy();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
return initial.opOneOptionalProxy(
Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test")));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
var p3 = Test.OneOptionalPrx.uncheckedCast(communicator.stringToProxy("test"));
test(p1.equals(p3));
test(p2.equals(p3));
return initial.opByteSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = 56; }
return initial.opByteSeq(Ice.Buffer.createNative(data));
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -693,18 +662,18 @@
}
return initial.opBoolSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = true; }
return initial.opBoolSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -714,18 +683,18 @@
}
return initial.opShortSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = 56; }
return initial.opShortSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -735,18 +704,18 @@
}
return initial.opIntSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = 56; }
return initial.opIntSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -756,18 +725,18 @@
}
return initial.opLongSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = new Ice.Long(0, 56); }
return initial.opLongSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -777,18 +746,18 @@
}
return initial.opFloatSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = 1.0; }
return initial.opFloatSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -798,18 +767,18 @@
}
return initial.opDoubleSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = 1.0; }
return initial.opDoubleSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -819,18 +788,18 @@
}
return initial.opStringSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = "test1"; }
return initial.opStringSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.length === 100);
test(p2.length === 100);
for(var i = 0; i < 100; ++i)
@@ -840,18 +809,18 @@
}
return initial.opSmallStructSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = new Test.SmallStruct(); }
return initial.opSmallStructSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
var s = new Test.SmallStruct();
test(p1.length === 100);
test(p2.length === 100);
@@ -862,18 +831,18 @@
}
return initial.opFixedStructSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = new Test.FixedStruct(); }
return initial.opFixedStructSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
var s = new Test.FixedStruct();
test(p1.length === 100);
test(p2.length === 100);
@@ -884,18 +853,18 @@
}
return initial.opVarStructSeq();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
var data = [];
for(var i = 0; i < 100; ++i){ data[i] = new Test.VarStruct(""); }
return initial.opVarStructSeq(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
var s = new Test.VarStruct("");
test(p1.length === 100);
test(p2.length === 100);
@@ -906,51 +875,51 @@
}
return initial.opIntIntDict();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
- var data = new Ice.HashMap();
+ var data = new Map();
data.set(1, 2);
data.set(2, 3);
return initial.opIntIntDict(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
- test(p1.equals(p2));
+ var [p1, p2] = r;
+ test(Ice.MapUtil.equals(p1, p2));
return initial.opStringIntDict();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
- var data = new Ice.HashMap();
+ var data = new Map();
data.set("1", 1);
data.set("2", 2);
return initial.opStringIntDict(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
- test(p1.equals(p2));
+ var [p1, p2] = r;
+ test(Ice.MapUtil.equals(p1, p2));
return initial.opIntOneOptionalDict();
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1 === undefined);
test(p2 === undefined);
- var data = new Ice.HashMap();
+ var data = new Map();
data.set(1, new Test.OneOptional(58));
data.set(2, new Test.OneOptional(59));
return initial.opIntOneOptionalDict(data);
}
- ).then(
- function(p1, p2)
+ ).then(r =>
{
+ var [p1, p2] = r;
test(p1.get(1).a === 58 && p2.get(2).a === 59);
out.writeLine("ok");
@@ -960,7 +929,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.OptionalException);
test(ex.a === undefined);
@@ -971,7 +940,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.OptionalException);
test(ex.a === 30);
@@ -981,7 +950,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.DerivedException);
test(ex.a === undefined);
@@ -993,7 +962,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.DerivedException);
test(ex.a === 30);
@@ -1004,17 +973,7 @@
out.writeLine("ok");
return initial.shutdown();
- }
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ }).then(p.resolve, p.reject);
return p;
};
@@ -1022,17 +981,7 @@
var run = function(out, id)
{
var c = Ice.initialize(id);
- return Promise.try(
- function()
- {
- return allTests(out, c, Test);
- }
- ).finally(
- function()
- {
- return c.destroy();
- }
- );
+ return Promise.try(() => allTests(out, c, Test)).finally(() => c.destroy());
};
exports.__clientAllTests__ = allTests;
exports.__test__ = run;
diff --git a/js/test/Ice/optionalBidir/AMDInitialI.js b/js/test/Ice/optionalBidir/AMDInitialI.js
index 4954f9b3030..1f50ca8acf3 100644
--- a/js/test/Ice/optionalBidir/AMDInitialI.js
+++ b/js/test/Ice/optionalBidir/AMDInitialI.js
@@ -12,8 +12,6 @@
var Ice = require("ice").Ice;
var TestAMD = require("TestAMD").TestAMD;
- var Class = Ice.Class;
-
var test = function(b)
{
if(!b)
@@ -22,17 +20,20 @@
}
};
- var AMDInitialI = Class(TestAMD.Initial, {
- shutdown_async: function(cb, current)
+ class AMDInitialI extends TestAMD.Initial
+ {
+ shutdown_async(cb, current)
{
current.adapter.getCommunicator().shutdown();
cb.ice_response();
- },
- pingPong_async: function(cb, obj, current)
+ }
+
+ pingPong_async(cb, obj, current)
{
cb.ice_response(obj);
- },
- opOptionalException_async: function(cb, a, b, o, current)
+ }
+
+ opOptionalException_async(cb, a, b, o, current)
{
var ex = new TestAMD.OptionalException();
if(a !== undefined)
@@ -52,8 +53,9 @@
ex.o = o;
}
cb.ice_exception(ex);
- },
- opDerivedException_async: function(cb, a, b, o, current)
+ }
+
+ opDerivedException_async(cb, a, b, o, current)
{
var ex = new TestAMD.DerivedException();
if(a !== undefined)
@@ -79,8 +81,9 @@
ex.o2 = o;
}
cb.ice_exception(ex);
- },
- opRequiredException_async: function(cb, a, b, o, current)
+ }
+
+ opRequiredException_async(cb, a, b, o, current)
{
var ex = new TestAMD.RequiredException();
if(a !== undefined)
@@ -102,164 +105,203 @@
ex.o2 = o;
}
cb.ice_exception(ex);
- },
- opByte_async: function(cb, p1, current)
+ }
+
+ opByte_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opBool_async: function(cb, p1, current)
+ }
+
+ opBool_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opShort_async: function(cb, p1, current)
+ }
+
+ opShort_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opInt_async: function(cb, p1, current)
+ }
+
+ opInt_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opLong_async: function(cb, p1, current)
+ }
+
+ opLong_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opFloat_async: function(cb, p1, current)
+ }
+
+ opFloat_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opDouble_async: function(cb, p1, current)
+ }
+
+ opDouble_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opString_async: function(cb, p1, current)
+ }
+
+ opString_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opMyEnum_async: function(cb, p1, current)
+ }
+
+ opMyEnum_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opSmallStruct_async: function(cb, p1, current)
+ }
+
+ opSmallStruct_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opFixedStruct_async: function(cb, p1, current)
+ }
+
+ opFixedStruct_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opVarStruct_async: function(cb, p1, current)
+ }
+
+ opVarStruct_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opOneOptional_async: function(cb, p1, current)
+ }
+
+ opOneOptional_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opOneOptionalProxy_async: function(cb, p1, current)
+ }
+
+ opOneOptionalProxy_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opByteSeq_async: function(cb, p1, current)
+ }
+
+ opByteSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opBoolSeq_async: function(cb, p1, current)
+ }
+
+ opBoolSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opShortSeq_async: function(cb, p1, current)
+ }
+
+ opShortSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opIntSeq_async: function(cb, p1, current)
+ }
+
+ opIntSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opLongSeq_async: function(cb, p1, current)
+ }
+
+ opLongSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opFloatSeq_async: function(cb, p1, current)
+ }
+
+ opFloatSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opDoubleSeq_async: function(cb, p1, current)
+ }
+
+ opDoubleSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opStringSeq_async: function(cb, p1, current)
+ }
+
+ opStringSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opSmallStructSeq_async: function(cb, p1, current)
+ }
+
+ opSmallStructSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opSmallStructList_async: function(cb, p1, current)
+ }
+
+ opSmallStructList_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opFixedStructSeq_async: function(cb, p1, current)
+ }
+
+ opFixedStructSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opFixedStructList_async: function(cb, p1, current)
+ }
+
+ opFixedStructList_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opVarStructSeq_async: function(cb, p1, current)
+ }
+
+ opVarStructSeq_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opSerializable_async: function(cb, p1, current)
+ }
+
+ opSerializable_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opIntIntDict_async: function(cb, p1, current)
+ }
+
+ opIntIntDict_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opStringIntDict_async: function(cb, p1, current)
+ }
+
+ opStringIntDict_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opIntOneOptionalDict_async: function(cb, p1, current)
+ }
+
+ opIntOneOptionalDict_async(cb, p1, current)
{
cb.ice_response(p1, p1);
- },
- opClassAndUnknownOptional_async: function(cb, p, current)
+ }
+
+ opClassAndUnknownOptional_async(cb, p, current)
{
cb.ice_response();
- },
- sendOptionalClass_async: function(cb, req, current)
+ }
+
+ sendOptionalClass_async(cb, req, current)
{
cb.ice_response();
- },
- returnOptionalClass_async: function(cb, req, current)
+ }
+
+ returnOptionalClass_async(cb, req, current)
{
cb.ice_response(new TestAMD.OneOptional(53));
- },
- opG_async: function(cb, g, current)
+ }
+
+ opG_async(cb, g, current)
{
cb.ice_response(g);
- },
- opVoid_async: function(cb, current)
+ }
+
+ opVoid_async(cb, current)
{
cb.ice_response();
- },
- supportsRequiredParams_async: function(cb, current)
+ }
+
+ supportsRequiredParams_async(cb, current)
{
cb.ice_response(false);
- },
- supportsJavaSerializable_async: function(cb, current)
+ }
+
+ supportsJavaSerializable_async(cb, current)
{
cb.ice_response(false);
- },
- supportsCsharpSerializable_async: function(cb, current)
+ }
+
+ supportsCsharpSerializable_async(cb, current)
{
cb.ice_response(false);
}
- });
+ }
exports.AMDInitialI = AMDInitialI;
}
diff --git a/js/test/Ice/optionalBidir/Client.js b/js/test/Ice/optionalBidir/Client.js
index 0e8a55de779..0e237686f25 100644
--- a/js/test/Ice/optionalBidir/Client.js
+++ b/js/test/Ice/optionalBidir/Client.js
@@ -22,14 +22,12 @@
var allTests = function(out, communicator, amd)
{
var base;
- return Promise.try(
- function()
+ return Promise.try(() =>
{
base = communicator.stringToProxy("initial:default -p 12010");
return communicator.createObjectAdapter("");
}
- ).then(
- function(adapter)
+ ).then(adapter =>
{
if(amd)
{
@@ -39,57 +37,39 @@
{
adapter.add(new InitialI(), Ice.stringToIdentity("initial"));
}
- return base.ice_getConnection().then(
- function(conn)
+ return base.ice_getConnection().then(conn =>
{
conn.setAdapter(adapter);
return Client.__clientAllTests__(out, communicator, amd ? TestAMD : Test);
});
- }
- );
+ });
};
var run = function(out, id)
{
var communicator = null;
- return Promise.try(
- function()
+ return Promise.try(() =>
{
communicator = Ice.initialize(id);
out.writeLine("testing bidir callbacks with synchronous dispatch...");
return allTests(out, communicator, false);
}
- ).then(
- function()
- {
- return communicator.destroy();
- }
- ).then(
- function()
+ ).then(() => communicator.destroy()
+ ).then(() =>
{
communicator = Ice.initialize(id);
out.writeLine("testing bidir callbacks with asynchronous dispatch...");
return allTests(out, communicator, true);
}
- ).then(
- function()
- {
- return communicator.destroy();
- }
- ).then(
- function()
+ ).then(() => communicator.destroy()
+ ).then(() =>
{
communicator = Ice.initialize(id);
var base = communicator.stringToProxy("__echo:default -p 12010");
return Test.EchoPrx.checkedCast(base);
}
- ).then(
- function(prx)
- {
- return prx.shutdown();
- }
- ).finally(
- function()
+ ).then(prx => prx.shutdown()
+ ).finally(() =>
{
if(communicator)
{
diff --git a/js/test/Ice/optionalBidir/InitialI.js b/js/test/Ice/optionalBidir/InitialI.js
index 029cde3c42e..d6b502354cc 100644
--- a/js/test/Ice/optionalBidir/InitialI.js
+++ b/js/test/Ice/optionalBidir/InitialI.js
@@ -12,8 +12,6 @@
var Ice = require("ice").Ice;
var Test = require("Test").Test;
- var Class = Ice.Class;
-
var test = function(b)
{
if(!b)
@@ -22,16 +20,19 @@
}
};
- var InitialI = Class(Test.Initial, {
- shutdown: function(current)
+ class InitialI extends Test.Initial
+ {
+ shutdown(current)
{
current.adapter.getCommunicator().shutdown();
- },
- pingPong: function(obj, current)
+ }
+
+ pingPong(obj, current)
{
return obj;
- },
- opOptionalException: function(a, b, o, current)
+ }
+
+ opOptionalException(a, b, o, current)
{
var ex = new Test.OptionalException();
if(a !== undefined)
@@ -51,8 +52,9 @@
ex.o = o;
}
throw ex;
- },
- opDerivedException: function(a, b, o, current)
+ }
+
+ opDerivedException(a, b, o, current)
{
var ex = new Test.DerivedException();
if(a !== undefined)
@@ -78,8 +80,9 @@
ex.o2 = o;
}
throw ex;
- },
- opRequiredException: function(a, b, o, current)
+ }
+
+ opRequiredException(a, b, o, current)
{
var ex = new Test.RequiredException();
if(a !== undefined)
@@ -101,162 +104,200 @@
ex.o2 = o;
}
throw ex;
- },
- opByte: function(p1, current)
+ }
+
+ opByte(p1, current)
{
return [p1, p1];
- },
- opBool: function(p1, current)
+ }
+
+ opBool(p1, current)
{
return [p1, p1];
- },
- opShort: function(p1, current)
+ }
+
+ opShort(p1, current)
{
return [p1, p1];
- },
- opInt: function(p1, current)
+ }
+
+ opInt(p1, current)
{
return [p1, p1];
- },
- opLong: function(p1, current)
+ }
+
+ opLong(p1, current)
{
return [p1, p1];
- },
- opFloat: function(p1, current)
+ }
+
+ opFloat(p1, current)
{
return [p1, p1];
- },
- opDouble: function(p1, current)
+ }
+
+ opDouble(p1, current)
{
return [p1, p1];
- },
- opString: function(p1, current)
+ }
+
+ opString(p1, current)
{
return [p1, p1];
- },
- opMyEnum: function(p1, current)
+ }
+
+ opMyEnum(p1, current)
{
return [p1, p1];
- },
- opSmallStruct: function(p1, current)
+ }
+
+ opSmallStruct(p1, current)
{
return [p1, p1];
- },
- opFixedStruct: function(p1, current)
+ }
+
+ opFixedStruct(p1, current)
{
return [p1, p1];
- },
- opVarStruct: function(p1, current)
+ }
+
+ opVarStruct(p1, current)
{
return [p1, p1];
- },
- opOneOptional: function(p1, current)
+ }
+
+ opOneOptional(p1, current)
{
return [p1, p1];
- },
- opOneOptionalProxy: function(p1, current)
+ }
+
+ opOneOptionalProxy(p1, current)
{
return [p1, p1];
- },
- opByteSeq: function(p1, current)
+ }
+
+ opByteSeq(p1, current)
{
return [p1, p1];
- },
- opBoolSeq: function(p1, current)
+ }
+
+ opBoolSeq(p1, current)
{
return [p1, p1];
- },
- opShortSeq: function(p1, current)
+ }
+
+ opShortSeq(p1, current)
{
return [p1, p1];
- },
- opIntSeq: function(p1, current)
+ }
+
+ opIntSeq(p1, current)
{
return [p1, p1];
- },
- opLongSeq: function(p1, current)
+ }
+
+ opLongSeq(p1, current)
{
return [p1, p1];
- },
- opFloatSeq: function(p1, current)
+ }
+
+ opFloatSeq(p1, current)
{
return [p1, p1];
- },
- opDoubleSeq: function(p1, current)
+ }
+
+ opDoubleSeq(p1, current)
{
return [p1, p1];
- },
- opStringSeq: function(p1, current)
+ }
+
+ opStringSeq(p1, current)
{
return [p1, p1];
- },
- opSmallStructSeq: function(p1, current)
+ }
+
+ opSmallStructSeq(p1, current)
{
return [p1, p1];
- },
- opSmallStructList: function(p1, current)
+ }
+
+ opSmallStructList(p1, current)
{
return [p1, p1];
- },
- opFixedStructSeq: function(p1, current)
+ }
+
+ opFixedStructSeq(p1, current)
{
return [p1, p1];
- },
- opFixedStructList: function(p1, current)
+ }
+
+ opFixedStructList(p1, current)
{
return [p1, p1];
- },
- opVarStructSeq: function(p1, current)
+ }
+
+ opVarStructSeq(p1, current)
{
return [p1, p1];
- },
- opSerializable: function(p1, current)
+ }
+
+ opSerializable(p1, current)
{
return [p1, p1];
- },
- opIntIntDict: function(p1, current)
+ }
+
+ opIntIntDict(p1, current)
{
return [p1, p1];
- },
- opStringIntDict: function(p1, current)
+ }
+
+ opStringIntDict(p1, current)
{
return [p1, p1];
- },
- opIntOneOptionalDict: function(p1, current)
+ }
+
+ opIntOneOptionalDict(p1, current)
{
return [p1, p1];
- },
- opClassAndUnknownOptional: function(p, current)
+ }
+
+ opClassAndUnknownOptional(p, current)
{
- },
- sendOptionalClass: function(req, current)
+ }
+
+ sendOptionalClass(req, current)
{
- },
- opG: function(g, current)
+ }
+
+ opG(g, current)
{
return g;
- },
- opVoid: function()
+ }
+
+ opVoid()
{
- },
- returnOptionalClass: function(req, current)
+ }
+
+ returnOptionalClass(req, current)
{
return new Test.OneOptional(53);
- },
- supportsRequiredParams: function(current)
+ }
+
+ supportsRequiredParams(current)
{
return false;
- },
- supportsJavaSerializable: function(current)
+ }
+
+ supportsJavaSerializable(current)
{
return false;
- },
- supportsCsharpSerializable: function(current)
+ }
+
+ supportsCsharpSerializable(current)
{
return false;
}
- });
-
+ }
exports.InitialI = InitialI;
}
(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
diff --git a/js/test/Ice/promise/.gitignore b/js/test/Ice/promise/.gitignore
deleted file mode 100644
index dcaf71693e4..00000000000
--- a/js/test/Ice/promise/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-index.html
diff --git a/js/test/Ice/promise/Client.js b/js/test/Ice/promise/Client.js
deleted file mode 100644
index 03bb00238ca..00000000000
--- a/js/test/Ice/promise/Client.js
+++ /dev/null
@@ -1,889 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-(function(module, require, exports)
-{
- var Ice = require("ice").Ice;
- var Promise = Ice.Promise;
-
- var test = function(b)
- {
- if(!b)
- {
- throw new Error("test failed");
- }
- };
-
- //
- // Create a new promise object and call function fn with
- // the promise as its first argument, then return the new
- // promise.
- //
- var deferred = function(fn)
- {
- var promise = new Promise();
- fn.call(null, promise);
- return promise;
- };
-
- var run = function(out)
- {
- var p = new Promise();
-
- deferred(
- function(promise)
- {
- out.write("Creating a promise object that is resolved and succeed... ");
- var promise1 = new Promise().succeed(1024);
- promise1.then(
- function(i)
- {
- test(i === 1024);
- test(promise1.succeeded());
- out.writeLine("ok");
- promise.succeed();
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Creating a promise object that is resolved and failed... ");
- var promise1 = new Promise().fail("promise.fail");
- promise1.then(
- function(i)
- {
- promise.fail();
- test(false, i);
- },
- function(e)
- {
- test(e === "promise.fail");
- test(promise1.failed());
- out.writeLine("ok");
- promise.succeed();
- });
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Creating a promise object that is resolved and succeed with multiple arguments... ");
- var promise1 = new Promise().succeed(1024, "Hello World!");
- promise1.then(
- function(i, msg)
- {
- test(i === 1024);
- test(msg === "Hello World!");
- test(promise1.succeeded());
- out.writeLine("ok");
- promise.succeed();
- },
- function(e)
- {
- promise.fail(e);
- test(false, e);
- });
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Creating a promise with a callback that returns a new value... ");
- var promise1 = new Promise().succeed(1024);
- promise1.then(
- function(i)
- {
- test(i === 1024);
- test(promise1.succeeded());
- return "Hello World!";
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- })
- .then(
- function(msg)
- {
- test(msg === "Hello World!");
- out.writeLine("ok");
- promise.succeed();
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- });
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Creating a promise object that recovers from a failure... ");
- var promise1 = new Promise().fail("promise.fail");
- promise1.then(
- function(i)
- {
- promise.fail();
- test(false, "Succeed called.failed expected");
- },
- function(e)
- {
- test(e === "promise.fail");
- test(promise1.failed());
- return "Hello World!";
- })
- .then(
- function(msg)
- {
- test(msg === "Hello World!");
- out.writeLine("ok");
- promise.succeed();
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- });
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Creating a promise object that rethrow a.failure... ");
- var promise1 = new Promise().fail("promise.fail");
- promise1.then(
- function(i)
- {
- promise.fail();
- test(false, i);
- },
- function(e)
- {
- throw e;
- })
- .then(
- function(msg)
- {
- promise.fail();
- test(false, "Succeed called.failed expected");
-
- },
- function(e)
- {
- test(e === "promise.fail");
- test(promise1.failed());
- out.writeLine("ok");
- promise.succeed();
- });
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("A second call to then should produce the same results... ");
- var promise1 = new Promise().succeed(1024);
- promise1.then(
- function(i)
- {
- test(i === 1024);
- test(promise1.succeeded());
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- });
- promise1.then(
- function(i)
- {
- test(i === 1024);
- test(promise1.succeeded());
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- });
-
- promise1 = new Promise().fail("promise.fail");
- promise1.then(
- function(i)
- {
- promise.fail();
- test(false, i);
- },
- function(e)
- {
- test(e === "promise.fail");
- test(promise1.failed());
- });
- promise1.then(
- function(i)
- {
- promise.fail();
- test(false, i);
- },
- function(e)
- {
- test(e === "promise.fail");
- test(promise1.failed());
- out.writeLine("ok");
- promise.succeed();
- });
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Create a promise that is not yet resolved, but will succeed... ");
- var promise1 = new Promise();
- test(!promise1.completed());
- promise1.then(
- function(i)
- {
- test(i === 1024);
- out.writeLine("ok");
- promise.succeed();
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- }
- );
- promise1.succeed(1024);
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Create a promise that is not yet resolved, but will.fail... ");
- var promise1 = new Promise();
- test(!promise1.completed());
- promise1.then(
- function(i)
- {
- promise.fail();
- test(false, "Succeed called.failed expected");
- },
- function(e)
- {
- test(e === "promise.fail");
- test(promise1.failed());
- out.writeLine("ok");
- promise.succeed();
- }
- );
- promise1.fail("promise.fail");
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Create a promise chain that is not yet resolved, but will succeed... ");
- var promise1 = new Promise();
- var promise2 = new Promise();
- var promise3 = new Promise();
- promise1.then(
- function(i)
- {
- test(i === 1);
- return promise2;
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- }
- ).then(
- function(i)
- {
- test(i === 2);
- return promise3;
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- }
- ).then(
- function(i)
- {
- test(i === 3);
- return "Hello World!";
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- }
- ).then(
- function(msg)
- {
- test(promise1.succeeded() && promise2.succeeded() && promise3.succeeded());
- test(msg === "Hello World!");
- out.writeLine("ok");
- promise.succeed();
- },
- function(e)
- {
- promise.fail();
- test(false, e);
- }
- );
- test(!promise1.completed() && !promise2.completed() && !promise3.completed());
-
- promise1.succeed(1);
- promise2.succeed(2);
- promise3.succeed(3);
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Use exception method on a Promise that will.fail... ");
- var promise1 = new Promise().fail("promise.fail");
- promise1.exception(
- function(e)
- {
- test(e === "promise.fail");
- out.writeLine("ok");
- promise.succeed();
- }
- );
- });
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Promise exception propagation in succeed callback... ");
- var promise1 = new Promise().fail("promise.fail");
- promise1.then(
- function()
- {
- promise.fail();
- test(false, "response callback called but exception expected");
- }
- ).then(
- function()
- {
- promise.fail();
- test(false, "response callback called but exception expected");
- }
- ).exception(
- function(e)
- {
- //
- // since no exception handler was passed to the first `.then`, the error propagates.
- //
- test(e === "promise.fail");
- out.writeLine("ok");
- promise.succeed();
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Promise exception propagation in exception callback... ");
- var promise1 = new Promise().fail("promise.fail");
- promise1.then(
- function()
- {
- promise.fail();
- test(false, "response callback called but exception expected");
- },
- function(ex)
- {
- throw "promise.fail";
- }
- ).then(
- function()
- {
- promise.fail();
- test(false, "response callback called but exception expected");
- }
- ).then(
- function()
- {
- promise.fail();
- test(false, "response callback called but exception expected");
- }
- ).exception(
- function(e)
- {
- //
- // since no exception handler was passed to the first `.then`, the error propagates.
- //
- test(e === "promise.fail");
- out.writeLine("ok");
- promise.succeed();
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Use Promise.all to wait for several promises and all succeed... ");
- var promise1 = new Promise();
- var promise2 = new Promise();
- var promise3 = new Promise();
-
- Promise.all(promise1, promise2, promise3).then(
- function(r1, r2, r3)
- {
- test(r1.length === 1);
- test(r1[0] === 1024);
-
- test(r2.length === 2);
- test(r2[0] === 1024);
- test(r2[1] === 2048);
-
- test(r3.length === 3);
- test(r3[0] === 1024);
- test(r3[1] === 2048);
- test(r3[2] === 4096);
-
- promise.succeed();
- },
- function()
- {
- promise.fail();
- test(false);
- }
- );
-
- //
- // Now resolve the promise in the reverse order, all succeed callback
- // will get the result in the right order.
- //
- promise3.succeed(1024, 2048, 4096);
- promise2.succeed(1024, 2048);
- promise1.succeed(1024);
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- //
- // Now try the same using an array of promises
- //
- var promise1 = new Promise();
- var promise2 = new Promise();
- var promise3 = new Promise();
-
- Promise.all([promise1, promise2, promise3]).then(
- function(r1, r2, r3)
- {
- test(r1.length === 1);
- test(r1[0] === 1024);
-
- test(r2.length === 2);
- test(r2[0] === 1024);
- test(r2[1] === 2048);
-
- test(r3.length === 3);
- test(r3[0] === 1024);
- test(r3[1] === 2048);
- test(r3[2] === 4096);
-
- out.writeLine("ok");
- promise.succeed();
- },
- function()
- {
- promise.fail();
- test(false);
- }
- );
-
- //
- // Now resolve the promise in the reverse order, all succeed callback
- // will get the result in the right order.
- //
- promise3.succeed(1024, 2048, 4096);
- promise2.succeed(1024, 2048);
- promise1.succeed(1024);
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Use Promise.all to wait for several promises and one fails... ");
- var promise1 = new Promise();
- var promise2 = new Promise();
- var promise3 = new Promise();
-
- Promise.all(promise1, promise2, promise3).then(
- function(r1, r2, r3)
- {
- promise.fail(new Error());
- },
- function(e)
- {
- test(e === "promise.fail");
- promise.succeed();
- }
- );
-
- //
- // Now resolve the promise in the reverse order.
- //
- promise3.succeed(1024, 2048, 4096);
- promise2.succeed(1024, 2048);
- promise1.fail("promise.fail");
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- //
- // Same as before but using an array of promises.
- var promise1 = new Promise();
- var promise2 = new Promise();
- var promise3 = new Promise();
-
- Promise.all([promise1, promise2, promise3]).then(
- function(r1, r2, r3)
- {
- promise.fail(new Error());
- },
- function(e)
- {
- test(e === "promise.fail");
- out.writeLine("ok");
- promise.succeed();
- }
- );
-
- //
- // Now resolve the promise in the reverse order.
- //
- promise3.succeed(1024, 2048, 4096);
- promise2.succeed(1024, 2048);
- promise1.fail("promise.fail");
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test finally on a succeed promise... ");
-
- var p = new Promise().succeed(1024);
- var called = false;
- p.finally(
- function(i)
- {
- called = true;
- test(i == 1024);
- return 1025;
- }
- ).then(
- function(i)
- {
- test(i == 1024);
- test(called);
- out.writeLine("ok");
- promise.succeed();
- }
- ).exception(
- function(ex)
- {
- promise.fail(ex);
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test finally on a failed promise... ");
-
- var p = new Promise().fail("promise.failed");
- var called = false;
- p.finally(
- function(e)
- {
- called = true;
- test(e == "promise.failed");
- return "foo";
- }
- ).then(
- function(i)
- {
- promise.fail(new Error());
- }
- ).exception(
- function(e)
- {
- test(called);
- test(e == "promise.failed");
- out.writeLine("ok");
- promise.succeed();
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test finally return a succeed promise... ");
-
- var p = new Promise().succeed(1024);
- var called = false;
- p.finally(
- function(e)
- {
- called = true;
- return new Promise().succeed(2048);
- }
- ).then(
- function(i)
- {
- test(called);
- test(i == 1024);
- out.writeLine("ok");
- promise.succeed();
- }
- ).exception(
- function(ex)
- {
- promise.fail(ex);
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test finally return a fail promise... ");
-
- var p = new Promise().succeed(1024);
- var called = false;
- p.finally(
- function(e)
- {
- called = true;
- return new Promise().fail(new Error("error"));
- }
- ).then(
- function(i)
- {
- test(called);
- test(i == 1024);
- out.writeLine("ok");
- promise.succeed();
- }
- ).exception(
- function(ex)
- {
- promise.fail(ex);
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test finally throw an exception... ");
-
- var p = new Promise().succeed(1024);
- var called = false;
- p.finally(
- function(e)
- {
- called = true;
- throw new Error("error");
- }
- ).then(
- function(i)
- {
- test(called);
- test(i == 1024);
- out.writeLine("ok");
- promise.succeed();
- }
- ).exception(
- function(ex)
- {
- promise.fail(ex);
- });
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test Promise.try... ");
-
- Promise.try(
- function()
- {
- out.writeLine("ok");
- promise.succeed();
- }
- ).exception(
- function()
- {
- promise.fail(new Error("test failed"));
- }
- );
- }
- );
- })
- .then(
- function()
- {
- return deferred(
- function(promise)
- {
- out.write("Test promise delay... ");
-
- var p = new Promise();
-
- var start = Date.now();
- p = p.succeed(10).delay(500).then(
- function(i)
- {
- test(i == 10);
- test(Date.now() - start >= 450);
- test(Date.now() - start <= 900);
- }
- ).then(
- function()
- {
- start = Date.now();
- return Promise.delay(10, 500).then(
- function(i)
- {
- test(i == 10);
- test(Date.now() - start >= 450);
- test(Date.now() - start <= 900);
- });
- }
- ).then(
- function()
- {
- var f = new Promise();
- start = Date.now();
- return f.fail("failed").delay(500).then(
- function(i)
- {
- test(false);
- },
- function(ex)
- {
- test(ex == "failed");
- test(Date.now() - start >= 450);
- test(Date.now() - start <= 900);
- out.writeLine("ok");
- promise.succeed();
- });
- }
- ).exception(
- function(ex)
- {
- promise.fail(ex);
- });
- }
- );
- })
- .then(
- function(){
- p.succeed();
- },
- function(ex){
- p.fail(ex);
- }
- );
- return p;
- };
- exports.__test__ = run;
-}
-(typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? module : undefined,
- typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? require : this.Ice.__require,
- typeof(global) !== "undefined" && typeof(global.process) !== "undefined" ? exports : this));
diff --git a/js/test/Ice/promise/run.js b/js/test/Ice/promise/run.js
deleted file mode 100644
index fc8c9a16e7c..00000000000
--- a/js/test/Ice/promise/run.js
+++ /dev/null
@@ -1,10 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-require("../../Common/Common").run(module);
diff --git a/js/test/Ice/promise/run.py b/js/test/Ice/promise/run.py
deleted file mode 100755
index 286e60351b6..00000000000
--- a/js/test/Ice/promise/run.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# **********************************************************************
-#
-# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved.
-#
-# This copy of Ice is licensed to you under the terms described in the
-# ICE_LICENSE file included in this distribution.
-#
-# **********************************************************************
-
-import os, sys
-
-path = [ ".", "..", "../..", "../../..", "../../../.." ]
-head = os.path.dirname(sys.argv[0])
-if len(head) > 0:
- path = [os.path.join(head, p) for p in path]
-path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ]
-if len(path) == 0:
- raise RuntimeError("can't find toplevel directory!")
-sys.path.append(os.path.join(path[0], "scripts"))
-import TestUtil
-
-TestUtil.simpleTest()
diff --git a/js/test/Ice/properties/Client.js b/js/test/Ice/properties/Client.js
index 72e5be40ac4..86adc5287eb 100644
--- a/js/test/Ice/properties/Client.js
+++ b/js/test/Ice/properties/Client.js
@@ -22,8 +22,7 @@
var run = function(out)
{
- return Promise.try(
- function()
+ return Promise.try(() =>
{
out.write("testing configuration file escapes... ");
var props =
@@ -83,30 +82,20 @@
// Use text data type to avoid problems interpreting the data.
//
dataType: "text"
- }).done(
- function(data)
+ }).done(data =>
{
properties.parse(data);
for(var key in props)
{
test(props[key] == properties.getProperty(key));
}
- p.succeed();
- }
- ).fail(
- function()
- {
- p.fail();
- });
+ p.resolve();
+ }).fail(p.reject);
return p;
}
}
}
- ).then(
- function()
- {
- out.writeLine("ok");
- });
+ ).then(() => out.writeLine("ok"));
};
exports.__test__ = run;
}
diff --git a/js/test/Ice/proxy/Client.js b/js/test/Ice/proxy/Client.js
index 9faca3b4160..61d7fe996cc 100644
--- a/js/test/Ice/proxy/Client.js
+++ b/js/test/Ice/proxy/Client.js
@@ -27,7 +27,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -37,8 +37,7 @@
var defaultProtocol = communicator.getProperties().getPropertyWithDefault("Ice.Default.Protocol", "tcp");
- return Promise.try(
- function()
+ return Promise.try(() =>
{
out.write("testing stringToProxy... ");
ref = "test:default -p 12010";
@@ -278,7 +277,7 @@
b1 = communicator.stringToProxy("test -e 1.0");
test(b1.ice_getEncodingVersion().major === 1 && b1.ice_getEncodingVersion().minor === 0);
- b1 = communicator.stringToProxy("test -e 6.5");
+ b1 = communicator.stringToProxy("test -e 6z.5");
test(b1.ice_getEncodingVersion().major === 6 && b1.ice_getEncodingVersion().minor === 5);
b1 = communicator.stringToProxy("test -p 1.0 -e 1.0");
@@ -453,7 +452,6 @@
var proxyProps = communicator.proxyToProperty(b1, "Test");
test(proxyProps.size === 21);
-
test(proxyProps.get("Test") === "test -t -e 1.0");
test(proxyProps.get("Test.CollocationOptimized") === "0");
test(proxyProps.get("Test.ConnectionCached") === "1");
@@ -642,9 +640,9 @@
test(!compObj.ice_router(null).equals(compObj.ice_router(rtr2)));
test(!compObj.ice_router(rtr1).equals(compObj.ice_router(rtr2)));
- var ctx1 = new Ice.HashMap();
+ var ctx1 = new Map();
ctx1.set("ctx1", "v1");
- var ctx2 = new Ice.HashMap();
+ var ctx2 = new Map();
ctx2.set("ctx2", "v2");
test(compObj.ice_context(null).equals(compObj.ice_context(null)));
test(compObj.ice_context(ctx1).equals(compObj.ice_context(ctx1)));
@@ -689,15 +687,13 @@
out.write("testing checked cast... ");
return Test.MyClassPrx.checkedCast(base);
}
- ).then(
- function(prx)
+ ).then(prx =>
{
cl = prx;
test(cl !== null);
return Test.MyDerivedClassPrx.checkedCast(cl);
}
- ).then(
- function(prx)
+ ).then(prx =>
{
derived = prx;
test(derived !== null);
@@ -709,22 +705,16 @@
return cl.getContext();
}
- ).then(
- function(c)
+ ).then(c =>
{
test(c.size === 0);
- c = new Ice.HashMap();
+ c = new Map();
c.set("one", "hello");
c.set("two", "world");
- return Test.MyClassPrx.checkedCast(base, undefined, c).then(
- function(cl)
- {
- return cl.getContext();
- }
- ).then(
- function(c2)
+ return Test.MyClassPrx.checkedCast(base, undefined, c).then(cl => cl.getContext()
+ ).then(c2 =>
{
- test(c.equals(c2));
+ test(Ice.MapUtil.equals(c, c2));
out.writeLine("ok");
out.write("testing encoding versioning... ");
@@ -734,25 +724,16 @@
return cl20.ice_ping();
});
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
test(ex instanceof Ice.UnsupportedEncodingException);
var ref10 = "test -e 1.0:default -p 12010";
cl10 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref10));
return cl10.ice_ping();
}
- ).then(
- function()
- {
- return cl10.ice_encodingVersion(Ice.Encoding_1_0).ice_ping();
- }
- ).then(
- function()
+ ).then(() => cl10.ice_encodingVersion(Ice.Encoding_1_0).ice_ping()
+ ).then(() =>
{
// 1.3 isn't supported but since a 1.3 proxy supports 1.1, the
// call will use the 1.1 encoding
@@ -769,20 +750,15 @@
cl20 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref20));
return cl20.ice_ping();
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
test(ex instanceof Ice.UnsupportedProtocolException);
var ref10 = "test -p 1.0:default -p 12010";
cl10 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref10));
return cl10.ice_ping();
}
- ).then(
- function()
+ ).then(() =>
{
// 1.3 isn't supported but since a 1.3 proxy supports 1.1, the
// call will use the 1.1 encoding
@@ -790,8 +766,7 @@
cl13 = Test.MyClassPrx.uncheckedCast(communicator.stringToProxy(ref13));
return cl13.ice_ping();
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
@@ -975,13 +950,8 @@
// NoEndpointException (or ConnectFailedException when
// running with SSL).
//
- return p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping().then(
- function(r)
- {
- test(false);
- }
- ).exception(
- function(ex)
+ return p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping().then(r => test(false)).catch(
+ ex =>
{
if(ex instanceof Ice.NoEndpointException)
{
@@ -997,8 +967,7 @@
}
return p1;
}
- ).then(
- function(p1)
+ ).then(p1 =>
{
//
// Test that the proxy with an SSL endpoint and a nonsense
@@ -1011,16 +980,14 @@
var derived = Test.MyDerivedClassPrx.uncheckedCast(base);
return derived.echo(p1);
}
- ).then(
- function(p2)
+ ).then(p2 =>
{
var pstr = communicator.proxyToString(p2);
test(pstr === "test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch");
});
}
}
- ).then(
- function()
+ ).then(() =>
{
var p = communicator.stringToProxy("test:default -p 12010");
if(defaultProtocol === "tcp")
@@ -1037,8 +1004,7 @@
}
return p.ice_getConnection();
}
- ).then(
- function(con)
+ ).then(con =>
{
if(defaultProtocol === "tcp")
{
@@ -1053,8 +1019,7 @@
test(con.getInfo() instanceof IceSSL.WSSConnectionInfo);
}
}
- ).then(
- function()
+ ).then(() =>
{
//
// Ensure that non connectable endpoints are skipped.
@@ -1066,8 +1031,7 @@
p = p.ice_endpointSelection(Ice.EndpointSelectionType.Ordered);
return p.ice_ping();
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
var derived = Test.MyDerivedClassPrx.uncheckedCast(communicator.stringToProxy("test:default -p 12010"));
@@ -1078,17 +1042,7 @@
var run = function(out, id)
{
var communicator = Ice.initialize(id);
- return Promise.try(
- function()
- {
- return allTests(communicator, out);
- }
- ).finally(
- function()
- {
- communicator.destroy();
- }
- );
+ return Promise.try(() => allTests(communicator, out)).finally(() => communicator.destroy());
};
exports.__test__ = run;
exports.__runServer__ = true;
diff --git a/js/test/Ice/retry/Client.js b/js/test/Ice/retry/Client.js
index 8c752617fc5..ee6bd556d83 100644
--- a/js/test/Ice/retry/Client.js
+++ b/js/test/Ice/retry/Client.js
@@ -28,14 +28,13 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
};
- Promise.try(
- function()
+ Promise.try(() =>
{
out.write("testing stringToProxy... ");
ref = "retry:default -p 12010";
@@ -47,16 +46,14 @@
out.write("testing checked cast... ");
return Test.RetryPrx.checkedCast(base1);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
retry1 = obj;
test(retry1 !== null);
test(retry1.equals(base1));
return Test.RetryPrx.checkedCast(base2);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
retry2 = obj;
test(retry2 !== null);
@@ -65,19 +62,14 @@
out.write("calling regular operation with first proxy... ");
return retry1.op(false);
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("calling operation to kill connection with second proxy... ");
return retry2.op(true);
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
if(typeof(window) === 'undefined' && typeof(WorkerGlobalScope) === 'undefined') // Nodejs
{
@@ -91,59 +83,39 @@
out.write("calling regular operation with first proxy again... ");
return retry1.op(false);
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing idempotent operation... ");
return retry1.opIdempotent(4);
}
- ).then(
- function(count)
+ ).then(count =>
{
test(count === 4);
out.writeLine("ok");
out.write("testing non-idempotent operation... ");
return retry1.opNotIdempotent();
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
out.writeLine("ok");
out.write("testing invocation timeout and retries... ");
retry2 = Test.RetryPrx.uncheckedCast(communicator2.stringToProxy(retry1.toString()));
return retry2.ice_invocationTimeout(500).opIdempotent(4);
}
- ).then(
- function()
- {
- test(false);
- },
+ ).then(() => test(false),
function(ex)
{
test(ex instanceof Ice.InvocationTimeoutException);
return retry2.opIdempotent(-1);
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
return retry1.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- },
- function(ex)
- {
- p.fail(ex);
- }
- );
+ ).then(p.resolve, p.reject);
return p;
};
@@ -170,18 +142,12 @@
id2.properties.setProperty("Ice.RetryIntervals", "0 1 10000");
var c2 = Ice.initialize(id2);
- return Promise.try(
- function()
- {
- return allTests(out, c, c2);
- }
- ).finally(
- function()
+ return Promise.try(() => allTests(out, c, c2)).finally(
+ () =>
{
c2.destroy();
return c.destroy();
- }
- );
+ });
};
exports.__test__ = run;
exports.__runServer__ = true;
diff --git a/js/test/Ice/slicing/exceptions/Client.js b/js/test/Ice/slicing/exceptions/Client.js
index 5784bf60837..061d406fdf8 100644
--- a/js/test/Ice/slicing/exceptions/Client.js
+++ b/js/test/Ice/slicing/exceptions/Client.js
@@ -28,7 +28,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -36,8 +36,7 @@
var ref, base, prx;
- Promise.try(
- function()
+ Promise.try(() =>
{
out.write("testing stringToProxy... ");
ref = "Test:default -p 12010 -t 10000";
@@ -48,8 +47,7 @@
out.write("testing checked cast... ");
return Test.TestIntfPrx.checkedCast(base);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
prx = obj;
test(prx !== null);
@@ -60,7 +58,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.Base.prototype);
test(ex.b == "Base.b");
@@ -72,7 +70,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.Base.prototype);
test(ex.b == "UnknownDerived.b");
@@ -84,7 +82,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownDerived.prototype);
test(ex.b == "KnownDerived.b");
@@ -97,7 +95,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownDerived.prototype);
test(ex.b == "KnownDerived.b");
@@ -110,7 +108,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.Base.prototype);
test(ex.b == "UnknownIntermediate.b");
@@ -122,7 +120,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype);
test(ex.b == "KnownIntermediate.b");
@@ -135,7 +133,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownMostDerived.prototype);
test(ex.b == "KnownMostDerived.b");
@@ -150,7 +148,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype);
test(ex.b == "KnownIntermediate.b");
@@ -162,7 +160,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownMostDerived.prototype);
test(ex.b == "KnownMostDerived.b");
@@ -176,7 +174,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownMostDerived.prototype);
test(ex.b == "KnownMostDerived.b");
@@ -190,7 +188,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype);
test(ex.b == "UnknownMostDerived1.b");
@@ -202,7 +200,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.KnownIntermediate.prototype);
test(ex.b == "UnknownMostDerived1.b");
@@ -216,7 +214,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(Object.getPrototypeOf(ex) === Test.Base.prototype);
test(ex.b == "UnknownMostDerived2.b");
@@ -229,7 +227,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
if(Object.getPrototypeOf(ex) === Test.Base.prototype)
{
@@ -253,11 +251,7 @@
out.writeLine("ok");
return prx.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- });
+ ).then(p.resolve, p.reject);
return p;
};
diff --git a/js/test/Ice/slicing/objects/Client.js b/js/test/Ice/slicing/objects/Client.js
index 46d44f6b37f..6e9c8d9eef4 100644
--- a/js/test/Ice/slicing/objects/Client.js
+++ b/js/test/Ice/slicing/objects/Client.js
@@ -16,13 +16,14 @@
var allTests = function(out, communicator)
{
- var PreservedI = Ice.Class(Test.Preserved,
+ class PreservedI extends Test.Preserved
{
- __init__: function()
+ constructor()
{
+ super();
++PreservedI.counter;
}
- });
+ }
function PreservedFactoryI(id)
{
@@ -44,7 +45,7 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
@@ -52,8 +53,7 @@
var failCB = function(){ test(false); };
var ref, base, prx;
- Promise.try(
- function()
+ Promise.try(() =>
{
out.write("testing stringToProxy... ");
ref = "Test:default -p 12010 -t 10000";
@@ -64,8 +64,7 @@
out.write("testing checked cast... ");
return Test.TestIntfPrx.checkedCast(base);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
prx = obj;
test(prx !== null);
@@ -74,8 +73,7 @@
out.write("base as Object... ");
return prx.SBaseAsObject();
}
- ).then(
- function(sb)
+ ).then(sb =>
{
test(sb !== null);
test(sb.ice_id() == "::Test::SBase");
@@ -84,16 +82,14 @@
out.write("base as base... ");
return prx.SBaseAsSBase();
}
- ).then(
- function(sb)
+ ).then(sb =>
{
test(sb.sb == "SBase.sb");
out.writeLine("ok");
out.write("base with known derived as base... ");
return prx.SBSKnownDerivedAsSBase();
}
- ).then(
- function(sb)
+ ).then(sb =>
{
test(sb !== null);
test(sb.sb == "SBSKnownDerived.sb");
@@ -102,71 +98,60 @@
out.write("base with known derived as known derived... ");
return prx.SBSKnownDerivedAsSBSKnownDerived();
}
- ).then(
- function(sb)
+ ).then(sb =>
{
test(sb.sbskd == "SBSKnownDerived.sbskd");
out.writeLine("ok");
out.write("base with unknown derived as base... ");
return prx.SBSUnknownDerivedAsSBase();
}
- ).then(
- function(sb)
+ ).then(sb =>
{
test(sb.sb == "SBSUnknownDerived.sb");
var p = new Promise();
if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0))
{
return prx.SBSUnknownDerivedAsSBaseCompact().then(
- function(sb)
- {
- test(sb.sb == "SBSUnknownDerived.sb");
- },
- function(ex)
- {
- test(ex instanceof Ice.OperationNotExistException);
- });
+ sb => test(sb.sb == "SBSUnknownDerived.sb"),
+ ex => test(ex instanceof Ice.OperationNotExistException));
}
else
{
return prx.SBSUnknownDerivedAsSBaseCompact().then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.OperationNotExistException ||
ex instanceof Ice.NoValueFactoryException);
});
}
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("unknown with Object as Object... ");
return prx.SUnknownAsObject();
}
).then(
- function(obj)
+ obj =>
{
test(!prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0));
test(obj instanceof Ice.UnknownSlicedValue);
test(obj.getUnknownTypeId() == "::Test::SUnknown");
return prx.checkSUnknown(obj);
},
- function(ex)
+ ex =>
{
test(ex instanceof Ice.NoValueFactoryException);
test(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0));
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("one-element cycle... ");
return prx.oneElementCycle();
}
- ).then(
- function(b)
+ ).then(b =>
{
test(b !== null);
test(b.ice_id() == "::Test::B");
@@ -176,8 +161,7 @@
out.write("two-element cycle... ");
return prx.twoElementCycle();
}
- ).then(
- function(b1)
+ ).then(b1 =>
{
test(b1 !== null);
test(b1.ice_id() == "::Test::B");
@@ -193,8 +177,7 @@
out.write("known derived pointer slicing as derived... ");
return prx.D1AsD1();
}
- ).then(
- function(d1)
+ ).then(d1 =>
{
test(d1 !== null);
test(d1.ice_id() == "::Test::D1");
@@ -212,8 +195,7 @@
out.write("unknown derived pointer slicing as base... ");
return prx.D2AsB();
}
- ).then(
- function(b2)
+ ).then(b2 =>
{
test(b2 !== null);
test(b2.ice_id() == "::Test::B");
@@ -233,9 +215,9 @@
out.write("param ptr slicing with known first... ");
return prx.paramTest1();
}
- ).then(
- function(b1, b2)
+ ).then(r =>
{
+ var [b1, b2] = r;
test(b1 !== null);
test(b1.ice_id() == "::Test::D1");
test(b1.sb == "D1.sb");
@@ -252,9 +234,9 @@
out.write("param ptr slicing with unknown first... ");
return prx.paramTest2();
}
- ).then(
- function(b2, b1)
+ ).then(r =>
{
+ var [b2, b1] = r;
test(b1 !== null);
test(b1.ice_id() == "::Test::D1");
test(b1.sb == "D1.sb");
@@ -271,18 +253,18 @@
out.write("return value identity with known first... ");
return prx.returnTest1();
}
- ).then(
- function(r, p1, p2)
+ ).then(r =>
{
- test(r === p1);
+ var [ret, p1, p2] = r;
+ test(ret === p1);
out.writeLine("ok");
out.write("return value identity with unknown first... ");
return prx.returnTest2();
}
- ).then(
- function(r, p1, p2)
+ ).then(r =>
{
- test(r == p1);
+ var [ret, p1, p2] = r;
+ test(ret == p1);
out.writeLine("ok");
out.write("return value identity for input params known first... ");
@@ -297,8 +279,7 @@
d1.pb = d3;
d1.pd1 = d3;
- return prx.returnTest3(d1, d3).then(
- function(b1)
+ return prx.returnTest3(d1, d3).then(b1 =>
{
test(b1 !== null);
test(b1.sb == "D1.sb");
@@ -321,8 +302,7 @@
test(b2 !== d3);
});
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("return value identity for input params unknown first... ");
@@ -338,8 +318,7 @@
d1.pb = d3;
d1.pd1 = d3;
- return prx.returnTest3(d3, d1).then(
- function(b1)
+ return prx.returnTest3(d3, d1).then(b1 =>
{
test(b1 !== null);
test(b1.sb == "D3.sb");
@@ -362,16 +341,15 @@
test(b2 !== d3);
});
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("remainder unmarshaling (3 instances)... ");
return prx.paramTest3();
}
- ).then(
- function(ret, p1, p2)
+ ).then(r =>
{
+ var [ret, p1, p2] = r;
test(p1 !== null);
test(p1.sb == "D2.sb (p1 1)");
test(p1.pb === null);
@@ -391,9 +369,9 @@
out.write("remainder unmarshaling (4 instances)... ");
return prx.paramTest4();
}
- ).then(
- function(ret, b)
+ ).then(r =>
{
+ var [ret, b] = r;
test(b !== null);
test(b.sb == "D4.sb (1)");
test(b.pb === null);
@@ -423,8 +401,7 @@
return prx.returnTest3(d3, b2);
}
- ).then(
- function(ret)
+ ).then(ret =>
{
test(ret !== null);
test(ret.ice_id() == "::Test::B");
@@ -453,8 +430,7 @@
return prx.returnTest3(d3, d12);
}
- ).then(
- function(ret)
+ ).then(ret =>
{
test(ret !== null);
test(ret.ice_id() == "::Test::B");
@@ -512,8 +488,7 @@
return prx.sequenceTest(ss1, ss2);
}
- ).then(
- function(ss)
+ ).then(ss =>
{
test(ss.c1 !== null);
var ss1b = ss.c1.s[0];
@@ -557,9 +532,9 @@
}
return prx.dictionaryTest(bin);
}
- ).then(
- function(ret, boutH)
+ ).then(r =>
{
+ var [ret, boutH] = r;
var i, b, s;
test(boutH.size === 10);
for(i = 0; i < 10; ++i)
@@ -592,7 +567,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.BaseException);
test(ex.ice_name() == "Test::BaseException");
@@ -606,7 +581,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.DerivedException);
test(ex.ice_name() == "Test::DerivedException");
@@ -627,7 +602,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.DerivedException);
test(ex.ice_name() == "Test::DerivedException");
@@ -648,7 +623,7 @@
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Test.BaseException);
test(ex.ice_name() == "Test::BaseException");
@@ -661,8 +636,7 @@
out.write("forward-declared class... ");
return prx.useForward();
}
- ).then(
- function(f)
+ ).then(f =>
{
test(f !== null);
out.writeLine("ok");
@@ -688,8 +662,7 @@
return prx.exchangePBase(pd);
}
- ).then(
- function(r)
+ ).then(r =>
{
var p2 = r;
test(p2.pi === 3);
@@ -705,8 +678,7 @@
return prx.exchangePBase(pu);
}
- ).then(
- function(r)
+ ).then(r =>
{
test(!(r instanceof Test.PCUnknown));
test(r.pi == 3);
@@ -721,8 +693,7 @@
return prx.exchangePBase(pcd);
}
- ).then(
- function(r)
+ ).then(r =>
{
if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0))
{
@@ -745,8 +716,7 @@
return prx.exchangePBase(pcd);
}
- ).then(
- function(r)
+ ).then(r =>
{
var p2;
@@ -786,8 +756,7 @@
return prx.exchangePBase(pcd);
}
- ).then(
- function(r)
+ ).then(r =>
{
if(prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0))
{
@@ -817,30 +786,22 @@
//
return prx.PBSUnknownAsPreserved();
}
- ).then(
- function(p)
+ ).then(p =>
{
- return prx.checkPBSUnknown(p).then(
- function(r)
+ return prx.checkPBSUnknown(p).then(r =>
{
if(!prx.ice_getEncodingVersion().equals(Ice.Encoding_1_0))
{
return prx.ice_encodingVersion(Ice.Encoding_1_0).checkPBSUnknown(p);
}
- }
- );
+ });
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
return prx.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- });
+ ).then(p.resolve, p.reject);
return p;
};
@@ -850,8 +811,7 @@
function()
{
var c = Ice.initialize(id);
- return allTests(out, c).finally(
- function()
+ return allTests(out, c).finally(() =>
{
if(c)
{
diff --git a/js/test/Ice/timeout/Client.js b/js/test/Ice/timeout/Client.js
index 533f52560d9..ec20772d85e 100644
--- a/js/test/Ice/timeout/Client.js
+++ b/js/test/Ice/timeout/Client.js
@@ -29,15 +29,14 @@
}
catch(err)
{
- p.fail(err);
+ p.reject(err);
throw err;
}
}
};
var seq;
- Promise.try(
- function()
+ Promise.try(() =>
{
ref = "timeout:default -p 12010";
obj = communicator.stringToProxy(ref);
@@ -49,11 +48,9 @@
{
mult = 4;
}
-
return Test.TimeoutPrx.checkedCast(obj);
}
- ).then(
- function(obj)
+ ).then(obj =>
{
timeout = obj;
test(timeout !== null);
@@ -61,47 +58,23 @@
to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(100 * mult));
return timeout.holdAdapter(1000 * mult);
}
- ).then(
- function()
- {
- return to.ice_getConnection();
- }
- ).then(
- function()
- {
- //
- // Expect ConnectTimeoutException.
- //
- return to.op();
- }
+ ).then(() => to.ice_getConnection()
+ ).then(() => to.op() // Expect ConnectTimeoutException.
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.ConnectTimeoutException);
return timeout.op(); // Ensure adapter is active.
}
- ).then(
- function()
+ ).then(() =>
{
to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(1000 * mult));
return timeout.holdAdapter(500 * mult);
}
- ).then(
- function()
- {
- return to.ice_getConnection();
- }
- ).then(
- function()
- {
- //
- // Expect success.
- //
- return to.op();
- }
- ).then(
- function()
+ ).then(() => to.ice_getConnection()
+ ).then(() => to.op() // Expect success.
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing connection timeout... ");
@@ -109,99 +82,68 @@
seq = Ice.Buffer.createNative(new Array(10000000));
return timeout.holdAdapter(1000 * mult);
}
- ).then(
- function()
- {
- //
- // Expect TimeoutException.
- //
- return to.sendData(seq);
- }
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => to.sendData(seq) // Expect TimeoutException
+ ).then(() => test(false),
+ ex =>
{
test(ex instanceof Ice.TimeoutException);
return timeout.op(); // Ensure adapter is active.
}
- ).then(
- function()
+ ).then(() =>
{
// NOTE: 30s timeout is necessary for Firefox/IE on Windows
to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(30000 * mult));
return timeout.holdAdapter(500 * mult);
}
- ).then(
- function()
- {
- //
- // Expect success.
- //
- return to.sendData(Ice.Buffer.createNative(new Array(5 * 1024)));
- }
- ).then(
- function()
+ ).then(() => to.sendData(Ice.Buffer.createNative(new Array(5 * 1024))) // Expect success.
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing invocation timeout... ");
return obj.ice_getConnection();
}
- ).then(
- function(con)
+ ).then(con =>
{
to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(100));
return to.ice_getConnection();
}
- ).then(
- function(con)
+ ).then(con =>
{
test(to.ice_getCachedConnection() === obj.ice_getCachedConnection());
return to.sleep(750);
}
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.InvocationTimeoutException);
return obj.ice_ping();
}
- ).then(
- function()
+ ).then(() =>
{
to = Test.TimeoutPrx.uncheckedCast(obj.ice_invocationTimeout(500));
return to.ice_getConnection();
}
- ).then(
- function(con)
+ ).then(con =>
{
test(to.ice_getCachedConnection() === obj.ice_getCachedConnection());
return to.sleep(250);
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing close timeout... ");
to = Test.TimeoutPrx.uncheckedCast(obj.ice_timeout(500));
return to.ice_getConnection();
}
- ).then(
- function(con)
+ ).then(con =>
{
connection = con;
return timeout.holdAdapter(1500);
}
- ).then(
- function()
- {
- return connection.close(false);
- }
- ).then(
- function()
+ ).then(() => connection.close(false)
+ ).then(() =>
{
try
{
@@ -212,8 +154,7 @@
test(false);
}
}
- ).delay(1000).then(
- function()
+ ).delay(1000).then(() =>
{
try
{
@@ -226,8 +167,7 @@
}
return timeout.op();
}
- ).then(
- function()
+ ).then(() =>
{
out.writeLine("ok");
out.write("testing timeout overrides... ");
@@ -248,58 +188,34 @@
comm = Ice.initialize(initData);
return Test.TimeoutPrx.checkedCast(comm.stringToProxy(ref));
}
- ).then(
- function(obj)
+ ).then(obj =>
{
to = obj;
return timeout.holdAdapter(750 * 2 * mult);
}
- ).then(
- function()
- {
- //
- // Expect TimeoutException.
- //
- return to.sendData(seq);
- }
+ ).then(() => to.sendData(seq) // Expect TimeoutException.
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.TimeoutException);
return timeout.op(); // Ensure adapter is active.
}
- ).then(
- function()
- {
- //
- // Calling ice_timeout() should have no effect.
- //
- return Test.TimeoutPrx.checkedCast(to.ice_timeout(1000 * mult));
- }
- ).then(
- function(obj)
+ ).then(() => Test.TimeoutPrx.checkedCast(to.ice_timeout(1000 * mult)) // Calling ice_timeout() should have no effect.
+ ).then(obj =>
{
to = obj;
return timeout.holdAdapter(750 * 2 * mult);
}
- ).then(
- function()
- {
- //
- // Expect TimeoutException.
- //
- return to.sendData(seq);
- }
+ ).then(() => to.sendData(seq) // Expect TimeoutException.
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.TimeoutException);
return comm.destroy();
}
- ).then(
- function()
+ ).then(() =>
{
//
// Test Ice.Override.ConnectTimeout.
@@ -318,25 +234,16 @@
to = Test.TimeoutPrx.uncheckedCast(comm.stringToProxy(ref));
return timeout.holdAdapter(750 * mult);
}
- ).then(
- function()
- {
- return to.op();
- }
+ ).then(() => to.op()
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.ConnectTimeoutException);
return timeout.op(); // Ensure adapter is active.
}
- ).then(
- function()
- {
- return timeout.holdAdapter(750 * mult);
- }
- ).then(
- function()
+ ).then(() => timeout.holdAdapter(750 * mult)
+ ).then(() =>
{
//
// Calling ice_timeout() should have no effect on the connect timeout.
@@ -344,41 +251,27 @@
to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(1000 * mult));
return to.op();
}
- ).then(
- function()
- {
- test(false);
- },
- function(ex)
+ ).then(() => test(false),
+ ex =>
{
test(ex instanceof Ice.ConnectTimeoutException);
return timeout.op(); // Ensure adapter is active.
}
- ).then(
- function()
+ ).then(() =>
{
to = Test.TimeoutPrx.uncheckedCast(to.ice_timeout(100 * mult));
return to.ice_getConnection(); // Force connection.
}
- ).then(
- function(obj)
- {
- return timeout.holdAdapter(750 * mult);
- }
- ).then(
- function()
- {
- return to.sendData(seq);
- }
+ ).then(obj => timeout.holdAdapter(750 * mult)
+ ).then(() => to.sendData(seq)
).then(
failCB,
- function(ex)
+ ex =>
{
test(ex instanceof Ice.TimeoutException);
return comm.destroy();
}
- ).then(
- function()
+ ).then(() =>
{
//
// Test Ice.Override.CloseTimeout.
@@ -389,30 +282,20 @@
comm = Ice.initialize(initData);
return comm.stringToProxy(ref).ice_getConnection();
}
- ).then(
- function(con)
- {
- return timeout.holdAdapter(500);
- }
- ).then(
- function()
+ ).then(() => timeout.holdAdapter(500)
+ ).then(() =>
{
now = Date.now();
return comm.destroy();
}
- ).then(
- function()
+ ).then(() =>
{
var t = Date.now();
test(t - now < 400);
out.writeLine("ok");
return timeout.shutdown();
}
- ).then(
- function()
- {
- p.succeed();
- });
+ ).then(p.resolve, p.reject);
return p;
};
@@ -435,8 +318,7 @@
id.properties.setProperty("Ice.MessageSizeMax", "10000");
var c = Ice.initialize(id);
- return Promise.try(
- function()
+ return Promise.try(() =>
{
if(typeof(navigator) !== 'undefined' && isSafari() && isWorker())
{
@@ -448,12 +330,7 @@
return allTests(out, c);
}
}
- ).finally(
- function()
- {
- return c.destroy();
- }
- );
+ ).finally(() => c.destroy());
};
exports.__test__ = run;
exports.__runServer__ = true;