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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
import Ice
import PromiseKit
public class BI: B {
public override func ice_preMarshal() {
preMarshalInvoked = true
}
public override func ice_postUnmarshal() {
postUnmarshalInvoked = true
}
}
public class CI: C {
public override func ice_preMarshal() {
preMarshalInvoked = true
}
public override func ice_postUnmarshal() {
postUnmarshalInvoked = true
}
}
public class DI: D {
public override func ice_preMarshal() {
preMarshalInvoked = true
}
public override func ice_postUnmarshal() {
postUnmarshalInvoked = true
}
}
public class EI: E {
public required init() {
super.init(i: 1, s: "hello")
}
public func checkValues() -> Bool {
return i == 1 && s == "hello"
}
}
public class FI: F {
public required init() {
super.init()
}
public init(e: E) {
super.init(e1: e, e2: e)
}
public func checkValues() -> Bool {
return e1 !== nil && e1 === e2
}
}
public class HI: H {}
public class II: Ice.InterfaceByValue {
public required init() {
super.init(id: "::Test::I")
}
}
public class JI: Ice.InterfaceByValue {
public required init() {
super.init(id: "::Test::J")
}
}
class InitialI: Initial {
var _adapter: Ice.ObjectAdapter
var _b1: B
var _b2: B
var _c: C
var _d: D
var _e: E
var _f: F
init(_ adapter: Ice.ObjectAdapter) {
_adapter = adapter
_b1 = BI()
_b2 = BI()
_c = CI()
_d = DI()
_e = EI()
_f = FI(e: _e)
_b1.theA = _b2 // Cyclic reference to another B
_b1.theB = _b1 // Self reference.
_b1.theC = nil // Null reference.
_b2.theA = _b2 // Self reference, using base.
_b2.theB = _b1 // Cyclic reference to another B
_b2.theC = _c // Cyclic reference to a C.
_c.theB = _b2 // Cyclic reference to a B.
_d.theA = _b1 // Reference to a B.
_d.theB = _b2 // Reference to a B.
_d.theC = nil // Reference to a C.
}
func getAll(current _: Ice.Current) throws -> (b1: B?, b2: B?, theC: C?, theD: D?) {
return (_b1, _b2, _c, _d)
}
func getMB(current _: Current) throws -> B? {
return _b1
}
func getB1(current _: Ice.Current) throws -> B? {
return _b1
}
func getB2(current _: Ice.Current) throws -> B? {
return _b2
}
func getC(current _: Ice.Current) throws -> C? {
return _c
}
func getD(current _: Ice.Current) throws -> D? {
return _d
}
func getE(current _: Ice.Current) throws -> E? {
return _e
}
func getF(current _: Ice.Current) throws -> F? {
return _f
}
func getI(current _: Ice.Current) throws -> Ice.Value? {
return II()
}
func getJ(current _: Ice.Current) throws -> Ice.Value? {
return JI()
}
func getH(current _: Ice.Current) throws -> Ice.Value? {
return HI()
}
func getK(current _: Ice.Current) throws -> K? {
return K(value: L(data: "l"))
}
func opValue(v1: Ice.Value?, current _: Ice.Current) throws -> (returnValue: Ice.Value?, v2: Ice.Value?) {
return (v1, v1)
}
func opValueSeq(v1: [Ice.Value?], current _: Ice.Current) throws -> (returnValue: [Ice.Value?], v2: [Ice.Value?]) {
return (v1, v1)
}
func opValueMap(v1: [String: Ice.Value?],
current _: Ice.Current) throws -> (returnValue: [String: Ice.Value?],
v2: [String: Ice.Value?]) {
return (v1, v1)
}
func setRecursive(p _: Recursive?, current _: Ice.Current) {}
func supportsClassGraphDepthMax(current _: Ice.Current) throws -> Bool {
return true
}
func setCycle(r: Recursive?, current _: Ice.Current) {
precondition(r != nil)
precondition(r!.v === r)
// break the cycle
r!.v = nil
}
func acceptsClassCycles(current: Ice.Current) throws -> Bool {
let properties = current.adapter!.getCommunicator().getProperties()
return properties.getPropertyAsIntWithDefault(key: "Ice.AcceptClassCycles", value: 0) > 0
}
func getD1(d1: D1?, current _: Ice.Current) throws -> D1? {
return d1
}
func throwEDerived(current _: Ice.Current) throws {
throw EDerived(a1: A1(name: "a1"),
a2: A1(name: "a2"),
a3: A1(name: "a3"),
a4: A1(name: "a4"))
}
func setG(theG _: G?, current _: Ice.Current) throws {}
func setI(theI _: Ice.Value?, current _: Ice.Current) throws {}
func opBaseSeq(inSeq: [Base?], current _: Ice.Current) throws -> (returnValue: [Base?], outSeq: [Base?]) {
return (inSeq, inSeq)
}
func getCompact(current _: Ice.Current) throws -> Compact? {
return CompactExt()
}
func shutdown(current _: Ice.Current) throws {
_b1.theA = nil // Break cyclic reference.
_b1.theB = nil // Break cyclic reference.
_b2.theA = nil // Break cyclic reference.
_b2.theB = nil // Break cyclic reference.
_b2.theC = nil // Break cyclic reference.
_c.theB = nil // Break cyclic reference.
_d.theA = nil // Break cyclic reference.
_d.theB = nil // Break cyclic reference.
_d.theC = nil // Break cyclic reference.
_adapter.getCommunicator().shutdown()
}
func getInnerA(current _: Ice.Current) throws -> InnerA? {
return InnerA(theA: _b1)
}
func getInnerSubA(current _: Ice.Current) throws -> InnerSubA? {
return InnerSubA(theA: InnerA(theA: _b1))
}
func throwInnerEx(current _: Ice.Current) throws {
throw InnerEx(reason: "Inner::Ex")
}
func throwInnerSubEx(current _: Ice.Current) throws {
throw InnerSubEx(reason: "Inner::Sub::Ex")
}
func getAMDMBAsync(current _: Ice.Current) -> Promise<B?> {
return Promise<B?> { seal in
seal.fulfill(_b1)
}
}
func opM(v1: M?, current _: Ice.Current) throws -> (returnValue: M?, v2: M?) {
return (v1, v1)
}
func opF1(f11: F1?, current _: Ice.Current) throws -> (returnValue: F1?, f12: F1?) {
return (f11, F1(name: "F12"))
}
func opF2(f21: F2Prx?, current: Current) throws -> (returnValue: F2Prx?, f22: F2Prx?) {
let prx = try current.adapter!.getCommunicator().stringToProxy("F22")!
return (f21, uncheckedCast(prx: prx, type: F2Prx.self))
}
func opF3(f31: F3?, current: Current) throws -> (returnValue: F3?, f32: F3?) {
let prx = try current.adapter!.getCommunicator().stringToProxy("F22")!
return (f31, F3(f1: F1(name: "F12"), f2: uncheckedCast(prx: prx, type: F2Prx.self)))
}
func hasF3(current _: Current) throws -> Bool {
return true
}
}
class F2I: F2 {
func op(current _: Current) throws {}
}
class UnexpectedObjectExceptionTestI: Ice.Blobject {
func ice_invoke(inEncaps _: Data, current: Ice.Current) throws -> (ok: Bool, outParams: Data) {
let communicator = current.adapter!.getCommunicator()
let ostr = Ice.OutputStream(communicator: communicator)
ostr.startEncapsulation(encoding: current.encoding, format: .DefaultFormat)
let ae = AlsoEmpty()
ostr.write(ae)
ostr.writePendingValues()
ostr.endEncapsulation()
return (true, ostr.finished())
}
}
|