Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/ipc/ipdl/PBrowserOrId.cpp
Line
Count
Source (jump to first uncovered line)
1
//
2
// Automatically generated by ipdlc.
3
// Edit at your own risk
4
//
5
6
7
#include "mozilla/dom/PBrowserParent.h"
8
#include "mozilla/dom/PBrowserChild.h"
9
#include "mozilla/dom/PBrowserOrId.h"
10
11
12
//-----------------------------------------------------------------------------
13
// Method definitions for the IPDL type |union PBrowserOrId|
14
//
15
namespace mozilla {
16
namespace dom {
17
auto PBrowserOrId::MaybeDestroy(Type aNewType) -> bool
18
0
{
19
0
    if ((mType) == (T__None)) {
20
0
        return true;
21
0
    }
22
0
    if ((mType) == (aNewType)) {
23
0
        return false;
24
0
    }
25
0
    switch (mType) {
26
0
    case TPBrowserParent:
27
0
        {
28
0
            (ptr_PBrowserParent())->~PBrowserParent__tdef();
29
0
            break;
30
0
        }
31
0
    case TPBrowserChild:
32
0
        {
33
0
            (ptr_PBrowserChild())->~PBrowserChild__tdef();
34
0
            break;
35
0
        }
36
0
    case TTabId:
37
0
        {
38
0
            (ptr_TabId())->~TabId__tdef();
39
0
            break;
40
0
        }
41
0
    default:
42
0
        {
43
0
            mozilla::ipc::LogicError("not reached");
44
0
            break;
45
0
        }
46
0
    }
47
0
    return true;
48
0
}
49
50
MOZ_IMPLICIT PBrowserOrId::PBrowserOrId(PBrowserParent* aOther)
51
0
{
52
0
    new (mozilla::KnownNotNull, ptr_PBrowserParent()) PBrowserParent*(const_cast<PBrowserParent*>(aOther));
53
0
    mType = TPBrowserParent;
54
0
}
55
56
MOZ_IMPLICIT PBrowserOrId::PBrowserOrId(PBrowserChild* aOther)
57
0
{
58
0
    new (mozilla::KnownNotNull, ptr_PBrowserChild()) PBrowserChild*(const_cast<PBrowserChild*>(aOther));
59
0
    mType = TPBrowserChild;
60
0
}
61
62
MOZ_IMPLICIT PBrowserOrId::PBrowserOrId(const TabId& aOther)
63
0
{
64
0
    new (mozilla::KnownNotNull, ptr_TabId()) TabId(aOther);
65
0
    mType = TTabId;
66
0
}
67
68
MOZ_IMPLICIT PBrowserOrId::PBrowserOrId(TabId&& aOther)
69
0
{
70
0
    new (mozilla::KnownNotNull, ptr_TabId()) TabId(std::move(aOther));
71
0
    mType = TTabId;
72
0
}
73
74
MOZ_IMPLICIT PBrowserOrId::PBrowserOrId(const PBrowserOrId& aOther)
75
0
{
76
0
    (aOther).AssertSanity();
77
0
    switch ((aOther).type()) {
78
0
    case TPBrowserParent:
79
0
        {
80
0
            new (mozilla::KnownNotNull, ptr_PBrowserParent()) PBrowserParent*(const_cast<PBrowserParent*>((aOther).get_PBrowserParent()));
81
0
            break;
82
0
        }
83
0
    case TPBrowserChild:
84
0
        {
85
0
            new (mozilla::KnownNotNull, ptr_PBrowserChild()) PBrowserChild*(const_cast<PBrowserChild*>((aOther).get_PBrowserChild()));
86
0
            break;
87
0
        }
88
0
    case TTabId:
89
0
        {
90
0
            new (mozilla::KnownNotNull, ptr_TabId()) TabId((aOther).get_TabId());
91
0
            break;
92
0
        }
93
0
    case T__None:
94
0
        {
95
0
            break;
96
0
        }
97
0
    default:
98
0
        {
99
0
            mozilla::ipc::LogicError("unreached");
100
0
            return;
101
0
        }
102
0
    }
103
0
    mType = (aOther).type();
104
0
}
105
106
MOZ_IMPLICIT PBrowserOrId::PBrowserOrId(PBrowserOrId&& aOther)
107
0
{
108
0
    (aOther).AssertSanity();
109
0
    Type t = (aOther).type();
110
0
    switch (t) {
111
0
    case TPBrowserParent:
112
0
        {
113
0
            new (mozilla::KnownNotNull, ptr_PBrowserParent()) PBrowserParent*(const_cast<PBrowserParent*>(std::move((aOther).get_PBrowserParent())));
114
0
            static_cast<void>((aOther).MaybeDestroy(T__None));
115
0
            break;
116
0
        }
117
0
    case TPBrowserChild:
118
0
        {
119
0
            new (mozilla::KnownNotNull, ptr_PBrowserChild()) PBrowserChild*(const_cast<PBrowserChild*>(std::move((aOther).get_PBrowserChild())));
120
0
            static_cast<void>((aOther).MaybeDestroy(T__None));
121
0
            break;
122
0
        }
123
0
    case TTabId:
124
0
        {
125
0
            new (mozilla::KnownNotNull, ptr_TabId()) TabId(std::move((aOther).get_TabId()));
126
0
            static_cast<void>((aOther).MaybeDestroy(T__None));
127
0
            break;
128
0
        }
129
0
    case T__None:
130
0
        {
131
0
            break;
132
0
        }
133
0
    default:
134
0
        {
135
0
            mozilla::ipc::LogicError("unreached");
136
0
            return;
137
0
        }
138
0
    }
139
0
    (aOther).mType = T__None;
140
0
    mType = t;
141
0
}
142
143
PBrowserOrId::~PBrowserOrId()
144
0
{
145
0
    static_cast<void>(MaybeDestroy(T__None));
146
0
}
147
148
auto PBrowserOrId::operator=(PBrowserParent* aRhs) -> PBrowserOrId&
149
0
{
150
0
    if (MaybeDestroy(TPBrowserParent)) {
151
0
        new (mozilla::KnownNotNull, ptr_PBrowserParent()) PBrowserParent*;
152
0
    }
153
0
    (*(ptr_PBrowserParent())) = const_cast<PBrowserParent*>(aRhs);
154
0
    mType = TPBrowserParent;
155
0
    return (*(this));
156
0
}
157
158
auto PBrowserOrId::operator=(PBrowserChild* aRhs) -> PBrowserOrId&
159
0
{
160
0
    if (MaybeDestroy(TPBrowserChild)) {
161
0
        new (mozilla::KnownNotNull, ptr_PBrowserChild()) PBrowserChild*;
162
0
    }
163
0
    (*(ptr_PBrowserChild())) = const_cast<PBrowserChild*>(aRhs);
164
0
    mType = TPBrowserChild;
165
0
    return (*(this));
166
0
}
167
168
auto PBrowserOrId::operator=(const TabId& aRhs) -> PBrowserOrId&
169
0
{
170
0
    if (MaybeDestroy(TTabId)) {
171
0
        new (mozilla::KnownNotNull, ptr_TabId()) TabId;
172
0
    }
173
0
    (*(ptr_TabId())) = aRhs;
174
0
    mType = TTabId;
175
0
    return (*(this));
176
0
}
177
178
auto PBrowserOrId::operator=(TabId&& aRhs) -> PBrowserOrId&
179
0
{
180
0
    if (MaybeDestroy(TTabId)) {
181
0
        new (mozilla::KnownNotNull, ptr_TabId()) TabId;
182
0
    }
183
0
    (*(ptr_TabId())) = std::move(aRhs);
184
0
    mType = TTabId;
185
0
    return (*(this));
186
0
}
187
188
auto PBrowserOrId::operator=(const PBrowserOrId& aRhs) -> PBrowserOrId&
189
0
{
190
0
    (aRhs).AssertSanity();
191
0
    Type t = (aRhs).type();
192
0
    switch (t) {
193
0
    case TPBrowserParent:
194
0
        {
195
0
            if (MaybeDestroy(t)) {
196
0
                new (mozilla::KnownNotNull, ptr_PBrowserParent()) PBrowserParent*;
197
0
            }
198
0
            (*(ptr_PBrowserParent())) = const_cast<PBrowserParent*>((aRhs).get_PBrowserParent());
199
0
            break;
200
0
        }
201
0
    case TPBrowserChild:
202
0
        {
203
0
            if (MaybeDestroy(t)) {
204
0
                new (mozilla::KnownNotNull, ptr_PBrowserChild()) PBrowserChild*;
205
0
            }
206
0
            (*(ptr_PBrowserChild())) = const_cast<PBrowserChild*>((aRhs).get_PBrowserChild());
207
0
            break;
208
0
        }
209
0
    case TTabId:
210
0
        {
211
0
            if (MaybeDestroy(t)) {
212
0
                new (mozilla::KnownNotNull, ptr_TabId()) TabId;
213
0
            }
214
0
            (*(ptr_TabId())) = (aRhs).get_TabId();
215
0
            break;
216
0
        }
217
0
    case T__None:
218
0
        {
219
0
            static_cast<void>(MaybeDestroy(t));
220
0
            break;
221
0
        }
222
0
    default:
223
0
        {
224
0
            mozilla::ipc::LogicError("unreached");
225
0
            break;
226
0
        }
227
0
    }
228
0
    mType = t;
229
0
    return (*(this));
230
0
}
231
232
auto PBrowserOrId::operator=(PBrowserOrId&& aRhs) -> PBrowserOrId&
233
0
{
234
0
    (aRhs).AssertSanity();
235
0
    Type t = (aRhs).type();
236
0
    switch (t) {
237
0
    case TPBrowserParent:
238
0
        {
239
0
            if (MaybeDestroy(t)) {
240
0
                new (mozilla::KnownNotNull, ptr_PBrowserParent()) PBrowserParent*;
241
0
            }
242
0
            (*(ptr_PBrowserParent())) = const_cast<PBrowserParent*>(std::move((aRhs).get_PBrowserParent()));
243
0
            static_cast<void>((aRhs).MaybeDestroy(T__None));
244
0
            break;
245
0
        }
246
0
    case TPBrowserChild:
247
0
        {
248
0
            if (MaybeDestroy(t)) {
249
0
                new (mozilla::KnownNotNull, ptr_PBrowserChild()) PBrowserChild*;
250
0
            }
251
0
            (*(ptr_PBrowserChild())) = const_cast<PBrowserChild*>(std::move((aRhs).get_PBrowserChild()));
252
0
            static_cast<void>((aRhs).MaybeDestroy(T__None));
253
0
            break;
254
0
        }
255
0
    case TTabId:
256
0
        {
257
0
            if (MaybeDestroy(t)) {
258
0
                new (mozilla::KnownNotNull, ptr_TabId()) TabId;
259
0
            }
260
0
            (*(ptr_TabId())) = std::move((aRhs).get_TabId());
261
0
            static_cast<void>((aRhs).MaybeDestroy(T__None));
262
0
            break;
263
0
        }
264
0
    case T__None:
265
0
        {
266
0
            static_cast<void>(MaybeDestroy(t));
267
0
            break;
268
0
        }
269
0
    default:
270
0
        {
271
0
            mozilla::ipc::LogicError("unreached");
272
0
            break;
273
0
        }
274
0
    }
275
0
    (aRhs).mType = T__None;
276
0
    mType = t;
277
0
    return (*(this));
278
0
}
279
280
auto PBrowserOrId::operator==(PBrowserParent* aRhs) const -> bool
281
0
{
282
0
    return (get_PBrowserParent()) == (aRhs);
283
0
}
284
285
auto PBrowserOrId::operator==(PBrowserChild* aRhs) const -> bool
286
0
{
287
0
    return (get_PBrowserChild()) == (aRhs);
288
0
}
289
290
auto PBrowserOrId::operator==(const TabId& aRhs) const -> bool
291
0
{
292
0
    return (get_TabId()) == (aRhs);
293
0
}
294
295
auto PBrowserOrId::operator==(const PBrowserOrId& aRhs) const -> bool
296
0
{
297
0
    if ((type()) != ((aRhs).type())) {
298
0
        return false;
299
0
    }
300
0
301
0
    switch (type()) {
302
0
    case TPBrowserParent:
303
0
        {
304
0
            return (get_PBrowserParent()) == ((aRhs).get_PBrowserParent());
305
0
        }
306
0
    case TPBrowserChild:
307
0
        {
308
0
            return (get_PBrowserChild()) == ((aRhs).get_PBrowserChild());
309
0
        }
310
0
    case TTabId:
311
0
        {
312
0
            return (get_TabId()) == ((aRhs).get_TabId());
313
0
        }
314
0
    default:
315
0
        {
316
0
            mozilla::ipc::LogicError("unreached");
317
0
            return false;
318
0
        }
319
0
    }
320
0
}
321
322
auto PBrowserOrId::get(PBrowserParent** aOutValue) const -> void
323
0
{
324
0
    (*(aOutValue)) = get_PBrowserParent();
325
0
}
326
327
auto PBrowserOrId::get(PBrowserChild** aOutValue) const -> void
328
0
{
329
0
    (*(aOutValue)) = get_PBrowserChild();
330
0
}
331
332
auto PBrowserOrId::get(TabId* aOutValue) const -> void
333
0
{
334
0
    (*(aOutValue)) = get_TabId();
335
0
}
336
337
} // namespace dom
338
} // namespace mozilla
339
340
namespace mozilla {
341
namespace ipc {
342
auto IPDLParamTraits<mozilla::dom::PBrowserOrId>::Write(
343
        IPC::Message* aMsg,
344
        mozilla::ipc::IProtocol* aActor,
345
        const paramType& aVar) -> void
346
0
{
347
0
    typedef mozilla::dom::PBrowserOrId union__;
348
0
    int type;
349
0
    type = (aVar).type();
350
0
    WriteIPDLParam(aMsg, aActor, type);
351
0
    // Sentinel = 'PBrowserOrId'
352
0
    (aMsg)->WriteSentinel(1715137324);
353
0
354
0
    switch (type) {
355
0
    case union__::TPBrowserParent:
356
0
        {
357
0
            if ((mozilla::ipc::ParentSide) == ((aActor)->GetSide())) {
358
0
                WriteIPDLParam(aMsg, aActor, (aVar).get_PBrowserParent());
359
0
                // Sentinel = 'TPBrowserParent'
360
0
                (aMsg)->WriteSentinel(3996262243);
361
0
            }
362
0
            else {
363
0
                (aActor)->FatalError("wrong side!");
364
0
            }
365
0
            return;
366
0
        }
367
0
    case union__::TPBrowserChild:
368
0
        {
369
0
            if ((mozilla::ipc::ChildSide) == ((aActor)->GetSide())) {
370
0
                WriteIPDLParam(aMsg, aActor, (aVar).get_PBrowserChild());
371
0
                // Sentinel = 'TPBrowserChild'
372
0
                (aMsg)->WriteSentinel(2417584432);
373
0
            }
374
0
            else {
375
0
                (aActor)->FatalError("wrong side!");
376
0
            }
377
0
            return;
378
0
        }
379
0
    case union__::TTabId:
380
0
        {
381
0
            WriteIPDLParam(aMsg, aActor, (aVar).get_TabId());
382
0
            // Sentinel = 'TTabId'
383
0
            (aMsg)->WriteSentinel(1071104628);
384
0
            return;
385
0
        }
386
0
    default:
387
0
        {
388
0
            (aActor)->FatalError("unknown union type");
389
0
            return;
390
0
        }
391
0
    }
392
0
}
393
394
auto IPDLParamTraits<mozilla::dom::PBrowserOrId>::Read(
395
        const IPC::Message* aMsg,
396
        PickleIterator* aIter,
397
        mozilla::ipc::IProtocol* aActor,
398
        paramType* aVar) -> bool
399
0
{
400
0
    typedef mozilla::dom::PBrowserOrId union__;
401
0
    int type;
402
0
    if ((!(ReadIPDLParam(aMsg, aIter, aActor, (&(type)))))) {
403
0
        (aActor)->FatalError("Error deserializing type of union PBrowserOrId");
404
0
        return false;
405
0
    }
406
0
    // Sentinel = 'PBrowserOrId'
407
0
    if ((!((aMsg)->ReadSentinel(aIter, 1715137324)))) {
408
0
        mozilla::ipc::SentinelReadError("Error deserializing type of union PBrowserOrId");
409
0
        return false;
410
0
    }
411
0
412
0
    switch (type) {
413
0
    case union__::TPBrowserParent:
414
0
        {
415
0
            if ((mozilla::ipc::ParentSide) == ((aActor)->GetSide())) {
416
0
                {
417
0
                    (aActor)->FatalError("wrong side!");
418
0
                    return false;
419
0
                }
420
0
            }
421
0
            mozilla::dom::PBrowserChild* tmp = nullptr;
422
0
            (*(aVar)) = tmp;
423
0
            if ((!(ReadIPDLParam(aMsg, aIter, aActor, (&((aVar)->get_PBrowserChild())))))) {
424
0
                (aActor)->FatalError("Error deserializing variant TPBrowserParent of union PBrowserOrId");
425
0
                return false;
426
0
            }
427
0
            // Sentinel = 'TPBrowserParent'
428
0
            if ((!((aMsg)->ReadSentinel(aIter, 3996262243)))) {
429
0
                mozilla::ipc::SentinelReadError("Error deserializing variant TPBrowserParent of union PBrowserOrId");
430
0
                return false;
431
0
            }
432
0
            return true;
433
0
        }
434
0
    case union__::TPBrowserChild:
435
0
        {
436
0
            if ((mozilla::ipc::ChildSide) == ((aActor)->GetSide())) {
437
0
                {
438
0
                    (aActor)->FatalError("wrong side!");
439
0
                    return false;
440
0
                }
441
0
            }
442
0
            mozilla::dom::PBrowserParent* tmp = nullptr;
443
0
            (*(aVar)) = tmp;
444
0
            if ((!(ReadIPDLParam(aMsg, aIter, aActor, (&((aVar)->get_PBrowserParent())))))) {
445
0
                (aActor)->FatalError("Error deserializing variant TPBrowserChild of union PBrowserOrId");
446
0
                return false;
447
0
            }
448
0
            // Sentinel = 'TPBrowserChild'
449
0
            if ((!((aMsg)->ReadSentinel(aIter, 2417584432)))) {
450
0
                mozilla::ipc::SentinelReadError("Error deserializing variant TPBrowserChild of union PBrowserOrId");
451
0
                return false;
452
0
            }
453
0
            return true;
454
0
        }
455
0
    case union__::TTabId:
456
0
        {
457
0
            mozilla::dom::TabId tmp = mozilla::dom::TabId();
458
0
            (*(aVar)) = tmp;
459
0
            if ((!(ReadIPDLParam(aMsg, aIter, aActor, (&((aVar)->get_TabId())))))) {
460
0
                (aActor)->FatalError("Error deserializing variant TTabId of union PBrowserOrId");
461
0
                return false;
462
0
            }
463
0
            // Sentinel = 'TTabId'
464
0
            if ((!((aMsg)->ReadSentinel(aIter, 1071104628)))) {
465
0
                mozilla::ipc::SentinelReadError("Error deserializing variant TTabId of union PBrowserOrId");
466
0
                return false;
467
0
            }
468
0
            return true;
469
0
        }
470
0
    default:
471
0
        {
472
0
            (aActor)->FatalError("unknown union type");
473
0
            return false;
474
0
        }
475
0
    }
476
0
}
477
478
} // namespace ipc
479
} // namespace mozilla