Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/HeadersBinding.h
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Headers.webidl BY Codegen.py - DO NOT EDIT */
2
3
#ifndef mozilla_dom_HeadersBinding_h
4
#define mozilla_dom_HeadersBinding_h
5
6
#include "GeckoProfiler.h"
7
#include "js/RootingAPI.h"
8
#include "jspubtd.h"
9
#include "mozilla/ErrorResult.h"
10
#include "mozilla/dom/BindingDeclarations.h"
11
#include "mozilla/dom/FakeString.h"
12
#include "mozilla/dom/IterableIterator.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/PrototypeList.h"
15
#include "mozilla/dom/Record.h"
16
#include "mozilla/dom/UnionMember.h"
17
18
namespace mozilla {
19
namespace dom {
20
21
class Headers;
22
struct HeadersAtoms;
23
struct NativePropertyHooks;
24
class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord;
25
class ProtoAndIfaceCache;
26
27
} // namespace dom
28
} // namespace mozilla
29
30
namespace mozilla {
31
namespace dom {
32
33
enum class HeadersGuardEnum : uint8_t {
34
  None,
35
  Request,
36
  Request_no_cors,
37
  Response,
38
  Immutable,
39
  EndGuard_
40
};
41
42
namespace HeadersGuardEnumValues {
43
extern const EnumEntry strings[6];
44
} // namespace HeadersGuardEnumValues
45
46
bool
47
ToJSValue(JSContext* aCx, HeadersGuardEnum aArgument, JS::MutableHandle<JS::Value> aValue);
48
49
50
void
51
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aUnion, const char* aName, uint32_t aFlags = 0);
52
53
54
void
55
ImplCycleCollectionUnlink(OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aUnion);
56
57
58
class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord
59
{
60
  friend class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecordArgument;
61
  enum Type
62
  {
63
    eUninitialized,
64
    eHeaders,
65
    eByteStringSequenceSequence,
66
    eByteStringByteStringRecord
67
  };
68
69
  union Value
70
  {
71
    UnionMember<NonNull<mozilla::dom::Headers> > mHeaders;
72
    UnionMember<binding_detail::AutoSequence<Sequence<nsCString>> > mByteStringSequenceSequence;
73
    UnionMember<Record<nsCString, nsCString> > mByteStringByteStringRecord;
74
75
  };
76
77
  Type mType;
78
  Value mValue;
79
80
  HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord(const HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
81
  HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& operator=(const HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
82
public:
83
  explicit inline HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
84
    : mType(eUninitialized)
85
0
  {
86
0
  }
87
88
  inline ~HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
89
0
  {
90
0
    Uninit();
91
0
  }
92
93
  inline NonNull<mozilla::dom::Headers>&
94
  RawSetAsHeaders()
95
0
  {
96
0
    if (mType == eHeaders) {
97
0
      return mValue.mHeaders.Value();
98
0
    }
99
0
    MOZ_ASSERT(mType == eUninitialized);
100
0
    mType = eHeaders;
101
0
    return mValue.mHeaders.SetValue();
102
0
  }
103
104
  inline NonNull<mozilla::dom::Headers>&
105
  SetAsHeaders()
106
0
  {
107
0
    if (mType == eHeaders) {
108
0
      return mValue.mHeaders.Value();
109
0
    }
110
0
    Uninit();
111
0
    mType = eHeaders;
112
0
    return mValue.mHeaders.SetValue();
113
0
  }
114
115
  inline bool
116
  IsHeaders() const
117
0
  {
118
0
    return mType == eHeaders;
119
0
  }
120
121
  inline NonNull<mozilla::dom::Headers>&
122
  GetAsHeaders()
123
0
  {
124
0
    MOZ_ASSERT(IsHeaders(), "Wrong type!");
125
0
    return mValue.mHeaders.Value();
126
0
  }
127
128
  inline mozilla::dom::Headers&
129
  GetAsHeaders() const
130
0
  {
131
0
    MOZ_ASSERT(IsHeaders(), "Wrong type!");
132
0
    return mValue.mHeaders.Value();
133
0
  }
134
135
  inline binding_detail::AutoSequence<Sequence<nsCString>>&
136
  RawSetAsByteStringSequenceSequence()
137
0
  {
138
0
    if (mType == eByteStringSequenceSequence) {
139
0
      return mValue.mByteStringSequenceSequence.Value();
140
0
    }
141
0
    MOZ_ASSERT(mType == eUninitialized);
142
0
    mType = eByteStringSequenceSequence;
143
0
    return mValue.mByteStringSequenceSequence.SetValue();
144
0
  }
145
146
  inline binding_detail::AutoSequence<Sequence<nsCString>>&
147
  SetAsByteStringSequenceSequence()
148
0
  {
149
0
    if (mType == eByteStringSequenceSequence) {
150
0
      return mValue.mByteStringSequenceSequence.Value();
151
0
    }
152
0
    Uninit();
153
0
    mType = eByteStringSequenceSequence;
154
0
    return mValue.mByteStringSequenceSequence.SetValue();
155
0
  }
156
157
  inline bool
158
  IsByteStringSequenceSequence() const
159
0
  {
160
0
    return mType == eByteStringSequenceSequence;
161
0
  }
162
163
  inline binding_detail::AutoSequence<Sequence<nsCString>>&
164
  GetAsByteStringSequenceSequence()
165
0
  {
166
0
    MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
167
0
    return mValue.mByteStringSequenceSequence.Value();
168
0
  }
169
170
  inline const Sequence<Sequence<nsCString>>&
171
  GetAsByteStringSequenceSequence() const
172
0
  {
173
0
    MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
174
0
    return mValue.mByteStringSequenceSequence.Value();
175
0
  }
176
177
  inline Record<nsCString, nsCString>&
178
  RawSetAsByteStringByteStringRecord()
179
0
  {
180
0
    if (mType == eByteStringByteStringRecord) {
181
0
      return mValue.mByteStringByteStringRecord.Value();
182
0
    }
183
0
    MOZ_ASSERT(mType == eUninitialized);
184
0
    mType = eByteStringByteStringRecord;
185
0
    return mValue.mByteStringByteStringRecord.SetValue();
186
0
  }
187
188
  inline Record<nsCString, nsCString>&
189
  SetAsByteStringByteStringRecord()
190
0
  {
191
0
    if (mType == eByteStringByteStringRecord) {
192
0
      return mValue.mByteStringByteStringRecord.Value();
193
0
    }
194
0
    Uninit();
195
0
    mType = eByteStringByteStringRecord;
196
0
    return mValue.mByteStringByteStringRecord.SetValue();
197
0
  }
198
199
  inline bool
200
  IsByteStringByteStringRecord() const
201
0
  {
202
0
    return mType == eByteStringByteStringRecord;
203
0
  }
204
205
  inline Record<nsCString, nsCString>&
206
  GetAsByteStringByteStringRecord()
207
0
  {
208
0
    MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
209
0
    return mValue.mByteStringByteStringRecord.Value();
210
0
  }
211
212
  inline const Record<nsCString, nsCString>&
213
  GetAsByteStringByteStringRecord() const
214
0
  {
215
0
    MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
216
0
    return mValue.mByteStringByteStringRecord.Value();
217
0
  }
218
219
  inline void
220
  Uninit()
221
  {
222
    switch (mType) {
223
      case eUninitialized: {
224
        break;
225
      }
226
      case eHeaders: {
227
        DestroyHeaders();
228
        break;
229
      }
230
      case eByteStringSequenceSequence: {
231
        DestroyByteStringSequenceSequence();
232
        break;
233
      }
234
      case eByteStringByteStringRecord: {
235
        DestroyByteStringByteStringRecord();
236
        break;
237
      }
238
    }
239
  }
240
241
  bool
242
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
243
244
private:
245
  inline void
246
  DestroyHeaders()
247
0
  {
248
0
    MOZ_ASSERT(IsHeaders(), "Wrong type!");
249
0
    mValue.mHeaders.Destroy();
250
0
    mType = eUninitialized;
251
0
  }
252
253
  inline void
254
  DestroyByteStringSequenceSequence()
255
0
  {
256
0
    MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
257
0
    mValue.mByteStringSequenceSequence.Destroy();
258
0
    mType = eUninitialized;
259
0
  }
260
261
  inline void
262
  DestroyByteStringByteStringRecord()
263
0
  {
264
0
    MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
265
0
    mValue.mByteStringByteStringRecord.Destroy();
266
0
    mType = eUninitialized;
267
0
  }
268
};
269
270
271
class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord : public AllOwningUnionBase
272
{
273
  friend void ImplCycleCollectionUnlink(OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aUnion);
274
  enum Type
275
  {
276
    eUninitialized,
277
    eHeaders,
278
    eByteStringSequenceSequence,
279
    eByteStringByteStringRecord
280
  };
281
282
  union Value
283
  {
284
    UnionMember<OwningNonNull<mozilla::dom::Headers> > mHeaders;
285
    UnionMember<Sequence<Sequence<nsCString>> > mByteStringSequenceSequence;
286
    UnionMember<Record<nsCString, nsCString> > mByteStringByteStringRecord;
287
288
  };
289
290
  Type mType;
291
  Value mValue;
292
293
  OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord(const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
294
  OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& operator=(const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
295
public:
296
  explicit inline OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
297
    : mType(eUninitialized)
298
0
  {
299
0
  }
300
301
  inline ~OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
302
0
  {
303
0
    Uninit();
304
0
  }
305
306
  OwningNonNull<mozilla::dom::Headers>&
307
  RawSetAsHeaders();
308
309
  OwningNonNull<mozilla::dom::Headers>&
310
  SetAsHeaders();
311
312
  bool
313
  TrySetToHeaders(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
314
315
  inline bool
316
  IsHeaders() const
317
0
  {
318
0
    return mType == eHeaders;
319
0
  }
320
321
  inline OwningNonNull<mozilla::dom::Headers>&
322
  GetAsHeaders()
323
0
  {
324
0
    MOZ_ASSERT(IsHeaders(), "Wrong type!");
325
0
    return mValue.mHeaders.Value();
326
0
  }
327
328
  inline OwningNonNull<mozilla::dom::Headers> const &
329
  GetAsHeaders() const
330
0
  {
331
0
    MOZ_ASSERT(IsHeaders(), "Wrong type!");
332
0
    return mValue.mHeaders.Value();
333
0
  }
334
335
  Sequence<Sequence<nsCString>>&
336
  RawSetAsByteStringSequenceSequence();
337
338
  Sequence<Sequence<nsCString>>&
339
  SetAsByteStringSequenceSequence();
340
341
  bool
342
  TrySetToByteStringSequenceSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
343
344
  inline bool
345
  IsByteStringSequenceSequence() const
346
0
  {
347
0
    return mType == eByteStringSequenceSequence;
348
0
  }
349
350
  inline Sequence<Sequence<nsCString>>&
351
  GetAsByteStringSequenceSequence()
352
0
  {
353
0
    MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
354
0
    return mValue.mByteStringSequenceSequence.Value();
355
0
  }
356
357
  inline Sequence<Sequence<nsCString>> const &
358
  GetAsByteStringSequenceSequence() const
359
0
  {
360
0
    MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
361
0
    return mValue.mByteStringSequenceSequence.Value();
362
0
  }
363
364
  Record<nsCString, nsCString>&
365
  RawSetAsByteStringByteStringRecord();
366
367
  Record<nsCString, nsCString>&
368
  SetAsByteStringByteStringRecord();
369
370
  bool
371
  TrySetToByteStringByteStringRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
372
373
  inline bool
374
  IsByteStringByteStringRecord() const
375
0
  {
376
0
    return mType == eByteStringByteStringRecord;
377
0
  }
378
379
  inline Record<nsCString, nsCString>&
380
  GetAsByteStringByteStringRecord()
381
0
  {
382
0
    MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
383
0
    return mValue.mByteStringByteStringRecord.Value();
384
0
  }
385
386
  inline Record<nsCString, nsCString> const &
387
  GetAsByteStringByteStringRecord() const
388
0
  {
389
0
    MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
390
0
    return mValue.mByteStringByteStringRecord.Value();
391
0
  }
392
393
  void
394
  Uninit();
395
396
  bool
397
  ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
398
399
  void
400
  TraceUnion(JSTracer* trc);
401
402
private:
403
  void
404
  DestroyHeaders();
405
406
  void
407
  DestroyByteStringSequenceSequence();
408
409
  void
410
  DestroyByteStringByteStringRecord();
411
};
412
413
414
namespace Headers_Binding {
415
416
  typedef mozilla::dom::Headers NativeType;
417
418
  const JSClass*
419
  GetJSClass();
420
421
  bool
422
  Wrap(JSContext* aCx, mozilla::dom::Headers* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
423
424
  template <class T>
425
  inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
426
0
  {
427
0
    JS::Rooted<JSObject*> reflector(aCx);
428
0
    return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
429
0
  }
430
431
  // We declare this as an array so that retrieving a pointer to this
432
  // binding's property hooks only requires compile/link-time resolvable
433
  // address arithmetic.  Declaring it as a pointer instead would require
434
  // doing a run-time load to fetch a pointer to this binding's property
435
  // hooks.  And then structures which embedded a pointer to this structure
436
  // would require a run-time load for proper initialization, which would
437
  // then induce static constructors.  Lots of static constructors.
438
  extern const NativePropertyHooks sNativePropertyHooks[];
439
440
  void
441
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
442
443
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
444
0
  {
445
0
    /* Get the interface prototype object for this class.  This will create the
446
0
       object as needed. */
447
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::Headers,
448
0
                                       &CreateInterfaceObjects,
449
0
                                       /* aDefineOnGlobal = */ true);
450
0
451
0
  }
452
453
  inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true)
454
0
  {
455
0
    /* Get the interface object for this class.  This will create the object as
456
0
       needed. */
457
0
458
0
    return GetPerInterfaceObjectHandle(aCx, constructors::id::Headers,
459
0
                                       &CreateInterfaceObjects,
460
0
                                       aDefineOnGlobal);
461
0
  }
462
463
  JSObject*
464
  GetConstructorObject(JSContext* aCx);
465
466
} // namespace Headers_Binding
467
468
469
470
namespace HeadersIterator_Binding {
471
472
  typedef mozilla::dom::IterableIterator<mozilla::dom::Headers> NativeType;
473
474
  const JSClass*
475
  GetJSClass();
476
477
  bool
478
  Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::Headers>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
479
480
  // We declare this as an array so that retrieving a pointer to this
481
  // binding's property hooks only requires compile/link-time resolvable
482
  // address arithmetic.  Declaring it as a pointer instead would require
483
  // doing a run-time load to fetch a pointer to this binding's property
484
  // hooks.  And then structures which embedded a pointer to this structure
485
  // would require a run-time load for proper initialization, which would
486
  // then induce static constructors.  Lots of static constructors.
487
  extern const NativePropertyHooks sNativePropertyHooks[];
488
489
  void
490
  CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
491
492
  inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx)
493
0
  {
494
0
    /* Get the interface prototype object for this class.  This will create the
495
0
       object as needed. */
496
0
    return GetPerInterfaceObjectHandle(aCx, prototypes::id::HeadersIterator,
497
0
                                       &CreateInterfaceObjects,
498
0
                                       /* aDefineOnGlobal = */ true);
499
0
500
0
  }
501
502
} // namespace HeadersIterator_Binding
503
504
505
506
} // namespace dom
507
} // namespace mozilla
508
509
#endif // mozilla_dom_HeadersBinding_h