Coverage Report

Created: 2018-09-25 14:53

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