summaryrefslogtreecommitdiff
path: root/js/src/Ice/Object.js
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2016-12-28 10:50:12 +0100
committerJose <jose@zeroc.com>2016-12-28 10:50:12 +0100
commitc7943b32df74f525013c8b7e17c92a032d74c868 (patch)
tree0ce9bc34394de9929696ab18aae84623778e3eb0 /js/src/Ice/Object.js
parentBumped timeout for server shutdown (diff)
downloadice-c7943b32df74f525013c8b7e17c92a032d74c868.tar.bz2
ice-c7943b32df74f525013c8b7e17c92a032d74c868.tar.xz
ice-c7943b32df74f525013c8b7e17c92a032d74c868.zip
Port Ice.Value to JavaScript mapping
Diffstat (limited to 'js/src/Ice/Object.js')
-rw-r--r--js/src/Ice/Object.js201
1 files changed, 4 insertions, 197 deletions
diff --git a/js/src/Ice/Object.js b/js/src/Ice/Object.js
index f25dcd8d980..b804349c557 100644
--- a/js/src/Ice/Object.js
+++ b/js/src/Ice/Object.js
@@ -21,23 +21,10 @@ Ice._ModuleRegistry.require(module,
"../Ice/OptionalFormat"
]);
-let nextAddress = 0;
-
const ids = ["::Ice::Object"];
Ice.Object = class
{
- constructor()
- {
- // Fake Address used as the hashCode for this object instance.
- this._iceAddress = nextAddress++;
- }
-
- hashCode()
- {
- return this._iceAddress;
- }
-
ice_isA(s, current)
{
return this._iceMostDerivedType()._iceIds.indexOf(s) >= 0;
@@ -62,51 +49,13 @@ Ice.Object = class
return "[object " + this.ice_id() + "]";
}
- ice_preMarshal()
- {
- }
-
- ice_postUnmarshal()
- {
- }
-
- _iceWrite(os)
- {
- os.startValue(null);
- writeImpl(this, os, this._iceMostDerivedType());
- os.endValue();
- }
-
- _iceRead(is)
- {
- is.startValue();
- readImpl(this, is, this._iceMostDerivedType());
- is.endValue(false);
- }
-
- ice_instanceof(T)
- {
- if(T)
- {
- if(this instanceof T)
- {
- return true;
- }
- return this._iceMostDerivedType()._iceInstanceof(T);
- }
- return false;
- }
-
//
// _iceMostDerivedType returns the the most derived Ice generated class. This is
// necessary because the user might extend Slice generated classes. The user
- // class extensions don't have _iceId, _iceIds, _iceInstanceof etc static members so
- // the implementation of ice_id, ice_ids and ice_instanceof would fail trying
- // to access those members of the user defined class. Instead, ice_id, ice_ids
- // and ice_instanceof call _iceMostDerivedType to get the most derived Ice class.
- //
- // The _iceMostDerivedType is overriden by each Slice generated class, see the
- // Slice.defineObject method implementation for details.
+ // class extensions don't have _iceId, _iceIds, etc static members so the implementation
+ // of ice_id and ice_ids would fail trying to access those members of the user
+ // defined class. Instead, ice_id, ice_ids and ice_instanceof call _iceMostDerivedType
+ // to get the most derived Ice class.
//
_iceMostDerivedType()
{
@@ -121,152 +70,10 @@ Ice.Object = class
return this === other;
}
- //
- // These methods are used for object parameters.
- //
- static write(os, v)
- {
- os.writeValue(v);
- }
-
- static writeOptional(os, tag, v)
- {
- os.writeOptionalValue(tag, v);
- }
-
- static read(is)
- {
- const v = { value: null };
- is.readValue(o => v.value = o, this);
- return v;
- }
-
- static readOptional(is, tag)
- {
- const v = { value: undefined };
- is.readOptionalValue(tag, o => v.value = o, this);
- return v;
- }
-
- static ice_staticId()
- {
- return this._iceId;
- }
-
- static _iceInstanceof(T)
- {
- if(T === this)
- {
- return true;
- }
-
- if(this._iceImplements.some(i => i._iceInstanceof(T)))
- {
- return true;
- }
-
- if(this._iceParent)
- {
- return this._iceParent._iceInstanceof(T);
- }
- return false;
- }
-
- static get _iceIds()
- {
- return ids;
- }
-
- static get _iceId()
- {
- return ids[0];
- }
-
static get _iceImplements()
{
return [];
}
};
-//
-// Private methods
-//
-
-const writeImpl = function(obj, os, type)
-{
- //
- // The writeImpl method is a recursive method that goes down the
- // class hierarchy to marshal each slice of the class using the
- // generated _iceWriteMemberImpl method.
- //
-
- if(type === undefined || type === Ice.Object)
- {
- return; // Don't marshal anything for Ice.Object
- }
-
- os.startSlice(type._iceId,
- Object.prototype.hasOwnProperty.call(type, '_iceCompactId') ? type._iceCompactId : -1 ,
- type._iceParent === Ice.Object);
- if(type.prototype._iceWriteMemberImpl)
- {
- type.prototype._iceWriteMemberImpl.call(obj, os);
- }
- os.endSlice();
- writeImpl(obj, os, type._iceParent);
-};
-
-const readImpl = function(obj, is, type)
-{
- //
- // The readImpl method is a recursive method that goes down the
- // class hierarchy to marshal each slice of the class using the
- // generated _iceReadMemberImpl method.
- //
-
- if(type === undefined || type === Ice.Object)
- {
- return; // Don't marshal anything for Ice.Object
- }
-
- is.startSlice();
- if(type.prototype._iceReadMemberImpl)
- {
- type.prototype._iceReadMemberImpl.call(obj, is);
- }
- is.endSlice();
- readImpl(obj, is, type._iceParent);
-};
-
-const writePreserved = function(os)
-{
- //
- // For Slice classes which are marked "preserved", the implementation of this method
- // replaces the Ice.Object.prototype._iceWrite method.
- //
- os.startValue(this._iceSlicedData);
- writeImpl(this, os, this._iceMostDerivedType());
- os.endValue();
-};
-
-const readPreserved = function(is)
-{
- //
- // For Slice classes which are marked "preserved", the implementation of this method
- // replaces the Ice.Object.prototype._iceRead method.
- //
- is.startValue();
- readImpl(this, is, this._iceMostDerivedType());
- this._iceSlicedData = is.endValue(true);
-};
-
-
-const Slice = Ice.Slice;
-
-Slice.PreservedObject = function(obj)
-{
- obj.prototype._iceWrite = writePreserved;
- obj.prototype._iceRead = readPreserved;
-};
-
module.exports.Ice = Ice;