summaryrefslogtreecommitdiff
path: root/js/src/Ice/Object.js
blob: d7e27c866f2b47f822e7fed07802112e000452bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

//
// Ice.Object
//
// Using IceObject in this file to avoid collisions with the native Object.
//
const Ice = require("../Ice/ModuleRegistry").Ice;

require("../Ice/Exception");
require("../Ice/FormatType");
require("../Ice/OptionalFormat");
require("../Ice/StreamHelpers");

Ice.Object = class
{
    ice_isA(s, current)
    {
        return this._iceMostDerivedType()._iceIds.indexOf(s) >= 0;
    }

    ice_ping(current)
    {
    }

    ice_ids(current)
    {
        return this._iceMostDerivedType()._iceIds;
    }

    ice_id(current)
    {
        return this._iceMostDerivedType()._iceId;
    }

    toString()
    {
        return "[object " + this.ice_id() + "]";
    }

    //
    // _iceMostDerivedType returns 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, 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()
    {
        return Ice.Object;
    }

    //
    // The default implementation of equals compare references.
    //
    equals(other)
    {
        return this === other;
    }

    static get _iceImplements()
    {
        return [];
    }
};

module.exports.Ice = Ice;