diff options
Diffstat (limited to 'js/src/Ice/Protocol.js')
-rw-r--r-- | js/src/Ice/Protocol.js | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/js/src/Ice/Protocol.js b/js/src/Ice/Protocol.js index 43e6874f940..032e5bea36b 100644 --- a/js/src/Ice/Protocol.js +++ b/js/src/Ice/Protocol.js @@ -7,8 +7,8 @@ // // ********************************************************************** -var Ice = require("../Ice/ModuleRegistry").Ice; -Ice.__M.require(module, +const Ice = require("../Ice/ModuleRegistry").Ice; +Ice._ModuleRegistry.require(module, [ "../Ice/StringUtil", "../Ice/LocalException", @@ -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); @@ -253,61 +253,62 @@ Ice.encodingVersionToString = function(v) return majorMinorToString(v.major, v.minor); }; +Protocol.OPTIONAL_END_MARKER = 0xFF; +Protocol.FLAG_HAS_TYPE_ID_STRING = (1<<0); +Protocol.FLAG_HAS_TYPE_ID_INDEX = (1<<1); +Protocol.FLAG_HAS_TYPE_ID_COMPACT = (1<<1 | 1<<0); +Protocol.FLAG_HAS_OPTIONAL_MEMBERS = (1<<2); +Protocol.FLAG_HAS_INDIRECTION_TABLE = (1<<3); +Protocol.FLAG_HAS_SLICE_SIZE = (1<<4); +Protocol.FLAG_IS_LAST_SLICE = (1<<5); + Ice.Protocol = Protocol; 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) |