summaryrefslogtreecommitdiff
path: root/js/src/Ice/Struct.js
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-08-19 21:25:18 +0200
committerJose <jose@zeroc.com>2016-08-19 21:25:18 +0200
commitc8d32e04873be7938915c606027c84c8ab832f6b (patch)
treef862751cfaddcf5bb7b82a7c04a299d471f948d4 /js/src/Ice/Struct.js
parentFix ICE-7278 (diff)
downloadice-c8d32e04873be7938915c606027c84c8ab832f6b.tar.bz2
ice-c8d32e04873be7938915c606027c84c8ab832f6b.tar.xz
ice-c8d32e04873be7938915c606027c84c8ab832f6b.zip
ES6 mapping updates
Diffstat (limited to 'js/src/Ice/Struct.js')
-rw-r--r--js/src/Ice/Struct.js64
1 files changed, 28 insertions, 36 deletions
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;