summaryrefslogtreecommitdiff
path: root/js/src/Ice/EndpointFactoryManager.js
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2014-09-02 14:22:34 +0200
committerJose <jose@zeroc.com>2014-09-02 14:22:34 +0200
commitfef794cdd1f8eb698fa3ccfe6f4cacba88030e9d (patch)
tree8e0c3c353dbbaa57d60a1da49c13b4153e918763 /js/src/Ice/EndpointFactoryManager.js
parentFix (ICE-3445) - consider not installing internal header files (diff)
downloadice-fef794cdd1f8eb698fa3ccfe6f4cacba88030e9d.tar.bz2
ice-fef794cdd1f8eb698fa3ccfe6f4cacba88030e9d.tar.xz
ice-fef794cdd1f8eb698fa3ccfe6f4cacba88030e9d.zip
Fixed (ICE-5654) - Update JS mapping to not use global types in NodeJS
Diffstat (limited to 'js/src/Ice/EndpointFactoryManager.js')
-rw-r--r--js/src/Ice/EndpointFactoryManager.js220
1 files changed, 110 insertions, 110 deletions
diff --git a/js/src/Ice/EndpointFactoryManager.js b/js/src/Ice/EndpointFactoryManager.js
index 881c9cd998c..877a17aec3f 100644
--- a/js/src/Ice/EndpointFactoryManager.js
+++ b/js/src/Ice/EndpointFactoryManager.js
@@ -7,140 +7,140 @@
//
// **********************************************************************
-(function(global){
- require("Ice/Class");
- require("Ice/BasicStream");
- require("Ice/Debug");
- require("Ice/OpaqueEndpointI");
- require("Ice/Protocol");
- require("Ice/LocalException");
+var Ice = require("../Ice/ModuleRegistry").Ice;
+Ice.__M.require(module, "Ice",
+ [
+ "../Ice/Class",
+ "../Ice/BasicStream",
+ "../Ice/Debug",
+ "../Ice/OpaqueEndpointI",
+ "../Ice/Protocol",
+ "../Ice/LocalException"
+ ]);
- var Ice = global.Ice || {};
-
- //
- // Local aliases.
- //
- var Debug = Ice.Debug;
- var BasicStream = Ice.BasicStream;
- var EndpointParseException = Ice.EndpointParseException;
- var OpaqueEndpointI = Ice.OpaqueEndpointI;
- var Protocol = Ice.Protocol;
+//
+// Local aliases.
+//
+var Debug = Ice.Debug;
+var BasicStream = Ice.BasicStream;
+var EndpointParseException = Ice.EndpointParseException;
+var OpaqueEndpointI = Ice.OpaqueEndpointI;
+var Protocol = Ice.Protocol;
- var EndpointFactoryManager = Ice.Class({
- __init__: function(instance)
+var EndpointFactoryManager = Ice.Class({
+ __init__: function(instance)
+ {
+ this._instance = instance;
+ this._factories = [];
+ },
+ add: function(factory)
+ {
+ for(var i = 0; i < this._factories.length; ++i)
{
- this._instance = instance;
- this._factories = [];
- },
- add: function(factory)
+ Debug.assert(this._factories[i].type() != factory.type());
+ }
+
+ this._factories.push(factory);
+ },
+ get: function(type)
+ {
+ for(var i = 0; i < this._factories.length; ++i)
{
- for(var i = 0; i < this._factories.length; ++i)
+ if(this._factories[i].type() === type)
{
- Debug.assert(this._factories[i].type() != factory.type());
+ return this._factories[i];
}
+ }
+ return null;
+ },
+ create: function(str, oaEndpoint)
+ {
+ var s = str.trim();
+ if(s.length === 0)
+ {
+ throw new EndpointParseException("value has no non-whitespace characters");
+ }
- this._factories.push(factory);
- },
- get: function(type)
+ var protocol;
+ var rest = "";
+ var i, length;
+ var pos = s.search(/[ \t\n\r]+/);
+ if(pos === -1)
{
- 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)
+ protocol = s;
+ }
+ else
{
- var s = str.trim();
- if(s.length === 0)
+ protocol = s.substring(0, pos);
+ if(pos < s.length)
{
- throw new EndpointParseException("value has no non-whitespace characters");
+ rest = s.substring(pos);
}
+ }
- var protocol;
- var rest = "";
- var i, length;
- var pos = s.search(/[ \t\n\r]+/);
- if(pos === -1)
- {
- protocol = s;
- }
- else
- {
- protocol = s.substring(0, pos);
- if(pos < s.length)
- {
- rest = s.substring(pos);
- }
- }
+ if(protocol === "default")
+ {
+ protocol = this._instance.defaultsAndOverrides().defaultProtocol;
+ }
- if(protocol === "default")
+ for(i = 0, length = this._factories.length; i < length; ++i)
+ {
+ if(this._factories[i].protocol() === protocol)
{
- protocol = this._instance.defaultsAndOverrides().defaultProtocol;
+ return this._factories[i].create(rest, oaEndpoint);
}
+ }
- for(i = 0, length = this._factories.length; i < length; ++i)
+ //
+ // If the stringified endpoint is opaque, create an unknown endpoint,
+ // then see whether the type matches one of the known endpoints.
+ //
+ if(protocol === "opaque")
+ {
+ var ue = OpaqueEndpointI.fromString(rest);
+ for(i = 0, length = this._factories.length; i < length; ++i)
{
- if(this._factories[i].protocol() === protocol)
+ if(this._factories[i].type() == ue.type())
{
- return this._factories[i].create(rest, oaEndpoint);
+ //
+ // Make a temporary stream, write the opaque endpoint data into the stream,
+ // and ask the factory to read the endpoint data from that stream to create
+ // the actual endpoint.
+ //
+ var bs = new BasicStream(this._instance, Protocol.currentProtocolEncoding, true);
+ ue.streamWrite(bs);
+ bs.pos = 0;
+ bs.readShort(); // type
+ return this._factories[i].read(bs);
}
}
+ return ue; // Endpoint is opaque, but we don't have a factory for its type.
+ }
- //
- // If the stringified endpoint is opaque, create an unknown endpoint,
- // then see whether the type matches one of the known endpoints.
- //
- if(protocol === "opaque")
- {
- var ue = OpaqueEndpointI.fromString(rest);
- for(i = 0, length = this._factories.length; i < length; ++i)
- {
- if(this._factories[i].type() == ue.type())
- {
- //
- // Make a temporary stream, write the opaque endpoint data into the stream,
- // and ask the factory to read the endpoint data from that stream to create
- // the actual endpoint.
- //
- var bs = new BasicStream(this._instance, Protocol.currentProtocolEncoding, true);
- ue.streamWrite(bs);
- bs.pos = 0;
- bs.readShort(); // type
- return this._factories[i].read(bs);
- }
- }
- return ue; // Endpoint is opaque, but we don't have a factory for its type.
- }
+ return null;
+ },
+ read: function(s)
+ {
+ var type = s.readShort();
- return null;
- },
- read: function(s)
+ for(var i = 0; i < this._factories.length; ++i)
{
- var type = s.readShort();
-
- for(var i = 0; i < this._factories.length; ++i)
+ if(this._factories[i].type() == type)
{
- if(this._factories[i].type() == type)
- {
- return this._factories[i].read(s);
- }
+ return this._factories[i].read(s);
}
- return OpaqueEndpointI.fromStream(type, s);
- },
- destroy: function()
+ }
+ return OpaqueEndpointI.fromStream(type, s);
+ },
+ destroy: function()
+ {
+ for(var i = 0; i < this._factories.length; ++i)
{
- for(var i = 0; i < this._factories.length; ++i)
- {
- this._factories[i].destroy();
- }
- this._factories = [];
+ this._factories[i].destroy();
}
- });
-
- Ice.EndpointFactoryManager = EndpointFactoryManager;
- global.Ice = Ice;
-}(typeof (global) === "undefined" ? window : global));
+ this._factories = [];
+ }
+});
+
+Ice.EndpointFactoryManager = EndpointFactoryManager;
+module.exports.Ice = Ice;