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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
//
// Ice.Value
//
const Ice = require("../Ice/ModuleRegistry").Ice;
Ice._ModuleRegistry.require(module,
[
"../Ice/Exception",
"../Ice/FormatType",
"../Ice/StreamHelpers",
"../Ice/OptionalFormat"
]);
Ice.Value = class
{
ice_preMarshal()
{
}
ice_postUnmarshal()
{
}
ice_getSlicedData()
{
return null;
}
_iceWrite(os)
{
os.startValue(null);
writeImpl(this, os, this._iceMostDerivedType());
os.endValue();
}
_iceRead(is)
{
is.startValue();
readImpl(this, is, this._iceMostDerivedType());
is.endValue(false);
}
//
// 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;
}
};
Ice.InterfaceByValue = class extends Ice.Value
{
constructor(id)
{
super();
this._id = id;
}
ice_id()
{
return this._id;
}
_iceWrite(os)
{
os.startValue(null);
os.startSlice(this.ice_id(), -1, true);
os.endSlice();
os.endValue();
}
_iceRead(is)
{
is.startValue();
is.startSlice();
is.endSlice();
is.endValue(false);
}
};
//
// 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.Value)
{
return; // Don't marshal anything for Ice.Value
}
os.startSlice(type.ice_staticId(),
Object.prototype.hasOwnProperty.call(type, '_iceCompactId') ? type._iceCompactId : -1,
Object.getPrototypeOf(type) === Ice.Value);
if(type.prototype.hasOwnProperty('_iceWriteMemberImpl'))
{
type.prototype._iceWriteMemberImpl.call(obj, os);
}
os.endSlice();
writeImpl(obj, os, Object.getPrototypeOf(type));
};
const readImpl = function(obj, is, type)
{
//
// The readImpl method is a recursive method that goes down the
// class hierarchy to unmarshal each slice of the class using the
// generated _iceReadMemberImpl method.
//
if(type === undefined || type === Ice.Value)
{
return; // Don't unmarshal anything for Ice.Value
}
is.startSlice();
if(type.prototype.hasOwnProperty('_iceReadMemberImpl'))
{
type.prototype._iceReadMemberImpl.call(obj, is);
}
is.endSlice();
readImpl(obj, is, Object.getPrototypeOf(type));
};
function writePreserved(os)
{
//
// For Slice classes which are marked "preserved", the implementation of this method
// replaces the Ice.Value.prototype._iceWrite method.
//
os.startValue(this._iceSlicedData);
writeImpl(this, os, this._iceMostDerivedType());
os.endValue();
}
function readPreserved(is)
{
//
// For Slice classes which are marked "preserved", the implementation of this method
// replaces the Ice.Value.prototype._iceRead method.
//
is.startValue();
readImpl(this, is, this._iceMostDerivedType());
this._iceSlicedData = is.endValue(true);
}
function ice_getSlicedData()
{
return this._iceSlicedData;
}
const Slice = Ice.Slice;
Slice.defineValue = function(valueType, id, preserved, compactId = 0)
{
valueType.prototype.ice_id = function()
{
return id;
};
valueType.prototype._iceMostDerivedType = function()
{
return valueType;
};
valueType.ice_staticId = function()
{
return id;
};
if(preserved)
{
valueType.prototype.ice_getSlicedData = ice_getSlicedData;
valueType.prototype._iceWrite = writePreserved;
valueType.prototype._iceRead = readPreserved;
}
if(compactId > 0)
{
Ice.CompactIdRegistry.set(compactId, id);
}
};
Slice.defineValue(Ice.Value, "::Ice::Object");
module.exports.Ice = Ice;
|