Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/IDBKeyRangeBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM IDBKeyRange.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "IDBKeyRange.h"
4
#include "IDBKeyRangeBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/DOMJSClass.h"
9
#include "mozilla/dom/IDBKeyRange.h"
10
#include "mozilla/dom/NonRefcountedDOMObject.h"
11
#include "mozilla/dom/PrimitiveConversions.h"
12
#include "mozilla/dom/XrayExpandoClass.h"
13
14
namespace mozilla {
15
namespace dom {
16
17
namespace binding_detail {}; // Just to make sure it's known as a namespace
18
using namespace mozilla::dom::binding_detail;
19
20
21
namespace IDBKeyRange_Binding {
22
23
MOZ_CAN_RUN_SCRIPT static bool
24
get_lower(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBKeyRange* self, JSJitGetterCallArgs args)
25
0
{
26
0
  AUTO_PROFILER_LABEL_FAST("get IDBKeyRange.lower", DOM, cx);
27
0
28
0
  FastErrorResult rv;
29
0
  JS::Rooted<JS::Value> result(cx);
30
0
  self->GetLower(cx, &result, rv);
31
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
32
0
    return false;
33
0
  }
34
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
35
0
  JS::ExposeValueToActiveJS(result);
36
0
  args.rval().set(result);
37
0
  if (!MaybeWrapValue(cx, args.rval())) {
38
0
    return false;
39
0
  }
40
0
  return true;
41
0
}
42
43
static const JSJitInfo lower_getterinfo = {
44
  { (JSJitGetterOp)get_lower },
45
  { prototypes::id::IDBKeyRange },
46
  { PrototypeTraits<prototypes::id::IDBKeyRange>::Depth },
47
  JSJitInfo::Getter,
48
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
49
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
50
  false,  /* isInfallible. False in setters. */
51
  false,  /* isMovable.  Not relevant for setters. */
52
  false, /* isEliminatable.  Not relevant for setters. */
53
  false, /* isAlwaysInSlot.  Only relevant for getters. */
54
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
55
  false,  /* isTypedMethod.  Only relevant for methods. */
56
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
57
};
58
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
59
static_assert(0 < 1, "There is no slot for us");
60
61
MOZ_CAN_RUN_SCRIPT static bool
62
get_upper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBKeyRange* self, JSJitGetterCallArgs args)
63
0
{
64
0
  AUTO_PROFILER_LABEL_FAST("get IDBKeyRange.upper", DOM, cx);
65
0
66
0
  FastErrorResult rv;
67
0
  JS::Rooted<JS::Value> result(cx);
68
0
  self->GetUpper(cx, &result, rv);
69
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
70
0
    return false;
71
0
  }
72
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
73
0
  JS::ExposeValueToActiveJS(result);
74
0
  args.rval().set(result);
75
0
  if (!MaybeWrapValue(cx, args.rval())) {
76
0
    return false;
77
0
  }
78
0
  return true;
79
0
}
80
81
static const JSJitInfo upper_getterinfo = {
82
  { (JSJitGetterOp)get_upper },
83
  { prototypes::id::IDBKeyRange },
84
  { PrototypeTraits<prototypes::id::IDBKeyRange>::Depth },
85
  JSJitInfo::Getter,
86
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
87
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
88
  false,  /* isInfallible. False in setters. */
89
  false,  /* isMovable.  Not relevant for setters. */
90
  false, /* isEliminatable.  Not relevant for setters. */
91
  false, /* isAlwaysInSlot.  Only relevant for getters. */
92
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
93
  false,  /* isTypedMethod.  Only relevant for methods. */
94
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
95
};
96
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
97
static_assert(0 < 1, "There is no slot for us");
98
99
MOZ_CAN_RUN_SCRIPT static bool
100
get_lowerOpen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBKeyRange* self, JSJitGetterCallArgs args)
101
0
{
102
0
  AUTO_PROFILER_LABEL_FAST("get IDBKeyRange.lowerOpen", DOM, cx);
103
0
104
0
  bool result(self->LowerOpen());
105
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
106
0
  args.rval().setBoolean(result);
107
0
  return true;
108
0
}
109
110
static const JSJitInfo lowerOpen_getterinfo = {
111
  { (JSJitGetterOp)get_lowerOpen },
112
  { prototypes::id::IDBKeyRange },
113
  { PrototypeTraits<prototypes::id::IDBKeyRange>::Depth },
114
  JSJitInfo::Getter,
115
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
116
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
117
  true,  /* isInfallible. False in setters. */
118
  true,  /* isMovable.  Not relevant for setters. */
119
  true, /* isEliminatable.  Not relevant for setters. */
120
  false, /* isAlwaysInSlot.  Only relevant for getters. */
121
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
122
  false,  /* isTypedMethod.  Only relevant for methods. */
123
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
124
};
125
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
126
static_assert(0 < 1, "There is no slot for us");
127
128
MOZ_CAN_RUN_SCRIPT static bool
129
get_upperOpen(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBKeyRange* self, JSJitGetterCallArgs args)
130
0
{
131
0
  AUTO_PROFILER_LABEL_FAST("get IDBKeyRange.upperOpen", DOM, cx);
132
0
133
0
  bool result(self->UpperOpen());
134
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
135
0
  args.rval().setBoolean(result);
136
0
  return true;
137
0
}
138
139
static const JSJitInfo upperOpen_getterinfo = {
140
  { (JSJitGetterOp)get_upperOpen },
141
  { prototypes::id::IDBKeyRange },
142
  { PrototypeTraits<prototypes::id::IDBKeyRange>::Depth },
143
  JSJitInfo::Getter,
144
  JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
145
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
146
  true,  /* isInfallible. False in setters. */
147
  true,  /* isMovable.  Not relevant for setters. */
148
  true, /* isEliminatable.  Not relevant for setters. */
149
  false, /* isAlwaysInSlot.  Only relevant for getters. */
150
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
151
  false,  /* isTypedMethod.  Only relevant for methods. */
152
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
153
};
154
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
155
static_assert(0 < 1, "There is no slot for us");
156
157
MOZ_CAN_RUN_SCRIPT static bool
158
includes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBKeyRange* self, const JSJitMethodCallArgs& args)
159
0
{
160
0
  AUTO_PROFILER_LABEL_FAST("IDBKeyRange.includes", DOM, cx);
161
0
162
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
163
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBKeyRange.includes");
164
0
  }
165
0
  JS::Rooted<JS::Value> arg0(cx);
166
0
  arg0 = args[0];
167
0
  FastErrorResult rv;
168
0
  bool result(self->Includes(cx, arg0, rv));
169
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
170
0
    return false;
171
0
  }
172
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
173
0
  args.rval().setBoolean(result);
174
0
  return true;
175
0
}
176
177
static const JSJitInfo includes_methodinfo = {
178
  { (JSJitGetterOp)includes },
179
  { prototypes::id::IDBKeyRange },
180
  { PrototypeTraits<prototypes::id::IDBKeyRange>::Depth },
181
  JSJitInfo::Method,
182
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
183
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
184
  false,  /* isInfallible. False in setters. */
185
  false,  /* isMovable.  Not relevant for setters. */
186
  false, /* isEliminatable.  Not relevant for setters. */
187
  false, /* isAlwaysInSlot.  Only relevant for getters. */
188
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
189
  false,  /* isTypedMethod.  Only relevant for methods. */
190
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
191
};
192
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
193
static_assert(0 < 1, "There is no slot for us");
194
195
static bool
196
only(JSContext* cx, unsigned argc, JS::Value* vp)
197
0
{
198
0
  AUTO_PROFILER_LABEL_FAST("IDBKeyRange.only", DOM, cx);
199
0
200
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
201
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
202
0
203
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
204
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBKeyRange.only");
205
0
  }
206
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
207
0
  if (global.Failed()) {
208
0
    return false;
209
0
  }
210
0
211
0
  JS::Rooted<JS::Value> arg0(cx);
212
0
  arg0 = args[0];
213
0
  FastErrorResult rv;
214
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBKeyRange>(mozilla::dom::IDBKeyRange::Only(global, arg0, rv)));
215
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
216
0
    return false;
217
0
  }
218
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
219
0
  static_assert(!IsPointer<decltype(result)>::value,
220
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
221
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
222
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
223
0
    return false;
224
0
  }
225
0
  return true;
226
0
}
227
228
static bool
229
lowerBound(JSContext* cx, unsigned argc, JS::Value* vp)
230
0
{
231
0
  AUTO_PROFILER_LABEL_FAST("IDBKeyRange.lowerBound", DOM, cx);
232
0
233
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
234
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
235
0
236
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
237
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBKeyRange.lowerBound");
238
0
  }
239
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
240
0
  if (global.Failed()) {
241
0
    return false;
242
0
  }
243
0
244
0
  JS::Rooted<JS::Value> arg0(cx);
245
0
  arg0 = args[0];
246
0
  bool arg1;
247
0
  if (args.hasDefined(1)) {
248
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
249
0
      return false;
250
0
    }
251
0
  } else {
252
0
    arg1 = false;
253
0
  }
254
0
  FastErrorResult rv;
255
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBKeyRange>(mozilla::dom::IDBKeyRange::LowerBound(global, arg0, arg1, rv)));
256
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
257
0
    return false;
258
0
  }
259
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
260
0
  static_assert(!IsPointer<decltype(result)>::value,
261
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
262
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
263
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
264
0
    return false;
265
0
  }
266
0
  return true;
267
0
}
268
269
static bool
270
upperBound(JSContext* cx, unsigned argc, JS::Value* vp)
271
0
{
272
0
  AUTO_PROFILER_LABEL_FAST("IDBKeyRange.upperBound", DOM, cx);
273
0
274
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
275
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
276
0
277
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
278
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBKeyRange.upperBound");
279
0
  }
280
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
281
0
  if (global.Failed()) {
282
0
    return false;
283
0
  }
284
0
285
0
  JS::Rooted<JS::Value> arg0(cx);
286
0
  arg0 = args[0];
287
0
  bool arg1;
288
0
  if (args.hasDefined(1)) {
289
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[1], &arg1)) {
290
0
      return false;
291
0
    }
292
0
  } else {
293
0
    arg1 = false;
294
0
  }
295
0
  FastErrorResult rv;
296
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBKeyRange>(mozilla::dom::IDBKeyRange::UpperBound(global, arg0, arg1, rv)));
297
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
298
0
    return false;
299
0
  }
300
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
301
0
  static_assert(!IsPointer<decltype(result)>::value,
302
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
303
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
304
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
305
0
    return false;
306
0
  }
307
0
  return true;
308
0
}
309
310
static bool
311
bound(JSContext* cx, unsigned argc, JS::Value* vp)
312
0
{
313
0
  AUTO_PROFILER_LABEL_FAST("IDBKeyRange.bound", DOM, cx);
314
0
315
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
316
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
317
0
318
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
319
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBKeyRange.bound");
320
0
  }
321
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
322
0
  if (global.Failed()) {
323
0
    return false;
324
0
  }
325
0
326
0
  JS::Rooted<JS::Value> arg0(cx);
327
0
  arg0 = args[0];
328
0
  JS::Rooted<JS::Value> arg1(cx);
329
0
  arg1 = args[1];
330
0
  bool arg2;
331
0
  if (args.hasDefined(2)) {
332
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
333
0
      return false;
334
0
    }
335
0
  } else {
336
0
    arg2 = false;
337
0
  }
338
0
  bool arg3;
339
0
  if (args.hasDefined(3)) {
340
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3)) {
341
0
      return false;
342
0
    }
343
0
  } else {
344
0
    arg3 = false;
345
0
  }
346
0
  FastErrorResult rv;
347
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBKeyRange>(mozilla::dom::IDBKeyRange::Bound(global, arg0, arg1, arg2, arg3, rv)));
348
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
349
0
    return false;
350
0
  }
351
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
352
0
  static_assert(!IsPointer<decltype(result)>::value,
353
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
354
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
355
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
356
0
    return false;
357
0
  }
358
0
  return true;
359
0
}
360
361
static void
362
_finalize(js::FreeOp* fop, JSObject* obj)
363
0
{
364
0
  mozilla::dom::IDBKeyRange* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBKeyRange>(obj);
365
0
  if (self) {
366
0
    AddForDeferredFinalization<mozilla::dom::IDBKeyRange>(self);
367
0
  }
368
0
}
369
370
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
371
#if defined(__clang__)
372
#pragma clang diagnostic push
373
#pragma clang diagnostic ignored "-Wmissing-braces"
374
#endif
375
static const JSFunctionSpec sStaticMethods_specs[] = {
376
  JS_FNSPEC("only", only, nullptr, 1, JSPROP_ENUMERATE, nullptr),
377
  JS_FNSPEC("lowerBound", lowerBound, nullptr, 1, JSPROP_ENUMERATE, nullptr),
378
  JS_FNSPEC("upperBound", upperBound, nullptr, 1, JSPROP_ENUMERATE, nullptr),
379
  JS_FNSPEC("bound", bound, nullptr, 2, JSPROP_ENUMERATE, nullptr),
380
  JS_FS_END
381
};
382
#if defined(__clang__)
383
#pragma clang diagnostic pop
384
#endif
385
386
387
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
388
  { nullptr, &sStaticMethods_specs[0] },
389
  { nullptr, nullptr }
390
};
391
392
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
393
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
394
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
395
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
396
397
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
398
#if defined(__clang__)
399
#pragma clang diagnostic push
400
#pragma clang diagnostic ignored "-Wmissing-braces"
401
#endif
402
static const JSFunctionSpec sMethods_specs[] = {
403
  JS_FNSPEC("includes", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&includes_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
404
  JS_FS_END
405
};
406
#if defined(__clang__)
407
#pragma clang diagnostic pop
408
#endif
409
410
411
static const Prefable<const JSFunctionSpec> sMethods[] = {
412
  { nullptr, &sMethods_specs[0] },
413
  { nullptr, nullptr }
414
};
415
416
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
417
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
418
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
419
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
420
421
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
422
#if defined(__clang__)
423
#pragma clang diagnostic push
424
#pragma clang diagnostic ignored "-Wmissing-braces"
425
#endif
426
static const JSPropertySpec sAttributes_specs[] = {
427
  { "lower", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lower_getterinfo, nullptr, nullptr },
428
  { "upper", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &upper_getterinfo, nullptr, nullptr },
429
  { "lowerOpen", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lowerOpen_getterinfo, nullptr, nullptr },
430
  { "upperOpen", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &upperOpen_getterinfo, nullptr, nullptr },
431
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
432
};
433
#if defined(__clang__)
434
#pragma clang diagnostic pop
435
#endif
436
437
438
static const Prefable<const JSPropertySpec> sAttributes[] = {
439
  { nullptr, &sAttributes_specs[0] },
440
  { nullptr, nullptr }
441
};
442
443
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
444
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
445
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
446
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
447
448
449
static uint16_t sNativeProperties_sortedPropertyIndices[9];
450
static PropertyInfo sNativeProperties_propertyInfos[9];
451
452
static const NativePropertiesN<3> sNativeProperties = {
453
  true,  0 /* sStaticMethods */,
454
  false, 0,
455
  true,  1 /* sMethods */,
456
  true,  2 /* sAttributes */,
457
  false, 0,
458
  false, 0,
459
  false, 0,
460
  -1,
461
  9,
462
  sNativeProperties_sortedPropertyIndices,
463
  {
464
    { sStaticMethods, &sNativeProperties_propertyInfos[0] },
465
    { sMethods, &sNativeProperties_propertyInfos[4] },
466
    { sAttributes, &sNativeProperties_propertyInfos[5] }
467
  }
468
};
469
static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
470
    "We have a property info count that is oversized");
471
472
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
473
  {
474
    "Function",
475
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
476
    &sBoringInterfaceObjectClassClassOps,
477
    JS_NULL_CLASS_SPEC,
478
    JS_NULL_CLASS_EXT,
479
    &sInterfaceObjectClassObjectOps
480
  },
481
  eInterface,
482
  true,
483
  prototypes::id::IDBKeyRange,
484
  PrototypeTraits<prototypes::id::IDBKeyRange>::Depth,
485
  sNativePropertyHooks,
486
  "function IDBKeyRange() {\n    [native code]\n}",
487
  JS::GetRealmFunctionPrototype
488
};
489
490
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
491
  {
492
    "IDBKeyRangePrototype",
493
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
494
    JS_NULL_CLASS_OPS,
495
    JS_NULL_CLASS_SPEC,
496
    JS_NULL_CLASS_EXT,
497
    JS_NULL_OBJECT_OPS
498
  },
499
  eInterfacePrototype,
500
  false,
501
  prototypes::id::IDBKeyRange,
502
  PrototypeTraits<prototypes::id::IDBKeyRange>::Depth,
503
  sNativePropertyHooks,
504
  "[object IDBKeyRangePrototype]",
505
  JS::GetRealmObjectPrototype
506
};
507
508
static const js::ClassOps sClassOps = {
509
  nullptr, /* addProperty */
510
  nullptr,               /* delProperty */
511
  nullptr,               /* enumerate */
512
  nullptr, /* newEnumerate */
513
  nullptr, /* resolve */
514
  nullptr, /* mayResolve */
515
  _finalize, /* finalize */
516
  nullptr, /* call */
517
  nullptr,               /* hasInstance */
518
  nullptr,               /* construct */
519
  nullptr, /* trace */
520
};
521
522
static const js::ClassExtension sClassExtension = {
523
  nullptr, /* weakmapKeyDelegateOp */
524
  nullptr /* objectMovedOp */
525
};
526
527
static const DOMJSClass sClass = {
528
  { "IDBKeyRange",
529
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
530
    &sClassOps,
531
    JS_NULL_CLASS_SPEC,
532
    &sClassExtension,
533
    JS_NULL_OBJECT_OPS
534
  },
535
  { prototypes::id::IDBKeyRange, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
536
  IsBaseOf<nsISupports, mozilla::dom::IDBKeyRange >::value,
537
  sNativePropertyHooks,
538
  FindAssociatedGlobalForNative<mozilla::dom::IDBKeyRange>::Get,
539
  GetProtoObjectHandle,
540
  GetCCParticipant<mozilla::dom::IDBKeyRange>::Get()
541
};
542
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
543
              "Must have the right minimal number of reserved slots.");
544
static_assert(1 >= 1,
545
              "Must have enough reserved slots.");
546
547
const JSClass*
548
GetJSClass()
549
0
{
550
0
  return sClass.ToJSClass();
551
0
}
552
553
bool
554
Wrap(JSContext* aCx, mozilla::dom::IDBKeyRange* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
555
0
{
556
0
  MOZ_ASSERT(static_cast<mozilla::dom::IDBKeyRange*>(aObject) ==
557
0
             reinterpret_cast<mozilla::dom::IDBKeyRange*>(aObject),
558
0
             "Multiple inheritance for mozilla::dom::IDBKeyRange is broken.");
559
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
560
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
561
0
562
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
563
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
564
0
  if (!canonicalProto) {
565
0
    return false;
566
0
  }
567
0
  JS::Rooted<JSObject*> proto(aCx);
568
0
  if (aGivenProto) {
569
0
    proto = aGivenProto;
570
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
571
0
    // coming in, we changed compartments to that of "parent" so may need
572
0
    // to wrap the proto here.
573
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
574
0
      if (!JS_WrapObject(aCx, &proto)) {
575
0
        return false;
576
0
      }
577
0
    }
578
0
  } else {
579
0
    proto = canonicalProto;
580
0
  }
581
0
582
0
  BindingJSObjectCreator<mozilla::dom::IDBKeyRange> creator(aCx);
583
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
584
0
  if (!aReflector) {
585
0
    return false;
586
0
  }
587
0
588
0
589
0
590
0
  creator.InitializationSucceeded();
591
0
  return true;
592
0
}
593
594
const NativePropertyHooks sNativePropertyHooks[] = { {
595
  nullptr,
596
  nullptr,
597
  nullptr,
598
  { sNativeProperties.Upcast(), nullptr },
599
  prototypes::id::IDBKeyRange,
600
  constructors::id::IDBKeyRange,
601
  nullptr,
602
  &DefaultXrayExpandoObjectClass
603
} };
604
605
void
606
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
607
0
{
608
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
609
0
  if (!parentProto) {
610
0
    return;
611
0
  }
612
0
613
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
614
0
  if (!constructorProto) {
615
0
    return;
616
0
  }
617
0
618
0
  static bool sIdsInited = false;
619
0
  if (!sIdsInited && NS_IsMainThread()) {
620
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
621
0
      return;
622
0
    }
623
0
    sIdsInited = true;
624
0
  }
625
0
626
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBKeyRange);
627
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBKeyRange);
628
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
629
0
                              &sPrototypeClass.mBase, protoCache,
630
0
                              nullptr,
631
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
632
0
                              interfaceCache,
633
0
                              sNativeProperties.Upcast(),
634
0
                              nullptr,
635
0
                              "IDBKeyRange", aDefineOnGlobal,
636
0
                              nullptr,
637
0
                              false);
638
0
}
639
640
JSObject*
641
GetProtoObject(JSContext* aCx)
642
0
{
643
0
  return GetProtoObjectHandle(aCx);
644
0
}
645
646
JSObject*
647
GetConstructorObject(JSContext* aCx)
648
0
{
649
0
  return GetConstructorObjectHandle(aCx);
650
0
}
651
652
} // namespace IDBKeyRange_Binding
653
654
655
656
namespace IDBLocaleAwareKeyRange_Binding {
657
658
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<IDBKeyRange_Binding::NativeType>::value,
659
              "Can't inherit from an interface with a different ownership model.");
660
661
static bool
662
bound(JSContext* cx, unsigned argc, JS::Value* vp)
663
0
{
664
0
  AUTO_PROFILER_LABEL_FAST("IDBLocaleAwareKeyRange.bound", DOM, cx);
665
0
666
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
667
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
668
0
669
0
  if (MOZ_UNLIKELY(args.length() < 2)) {
670
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBLocaleAwareKeyRange.bound");
671
0
  }
672
0
  GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
673
0
  if (global.Failed()) {
674
0
    return false;
675
0
  }
676
0
677
0
  JS::Rooted<JS::Value> arg0(cx);
678
0
  arg0 = args[0];
679
0
  JS::Rooted<JS::Value> arg1(cx);
680
0
  arg1 = args[1];
681
0
  bool arg2;
682
0
  if (args.hasDefined(2)) {
683
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[2], &arg2)) {
684
0
      return false;
685
0
    }
686
0
  } else {
687
0
    arg2 = false;
688
0
  }
689
0
  bool arg3;
690
0
  if (args.hasDefined(3)) {
691
0
    if (!ValueToPrimitive<bool, eDefault>(cx, args[3], &arg3)) {
692
0
      return false;
693
0
    }
694
0
  } else {
695
0
    arg3 = false;
696
0
  }
697
0
  FastErrorResult rv;
698
0
  auto result(StrongOrRawPtr<mozilla::dom::IDBLocaleAwareKeyRange>(mozilla::dom::IDBLocaleAwareKeyRange::Bound(global, arg0, arg1, arg2, arg3, rv)));
699
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
700
0
    return false;
701
0
  }
702
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
703
0
  static_assert(!IsPointer<decltype(result)>::value,
704
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
705
0
  if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) {
706
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
707
0
    return false;
708
0
  }
709
0
  return true;
710
0
}
711
712
static void
713
_finalize(js::FreeOp* fop, JSObject* obj)
714
0
{
715
0
  mozilla::dom::IDBLocaleAwareKeyRange* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBLocaleAwareKeyRange>(obj);
716
0
  if (self) {
717
0
    AddForDeferredFinalization<mozilla::dom::IDBLocaleAwareKeyRange>(self);
718
0
  }
719
0
}
720
721
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
722
#if defined(__clang__)
723
#pragma clang diagnostic push
724
#pragma clang diagnostic ignored "-Wmissing-braces"
725
#endif
726
static const JSFunctionSpec sStaticMethods_specs[] = {
727
  JS_FNSPEC("bound", bound, nullptr, 2, JSPROP_ENUMERATE, nullptr),
728
  JS_FS_END
729
};
730
#if defined(__clang__)
731
#pragma clang diagnostic pop
732
#endif
733
734
735
static const Prefable<const JSFunctionSpec> sStaticMethods[] = {
736
  { nullptr, &sStaticMethods_specs[0] },
737
  { nullptr, nullptr }
738
};
739
740
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
741
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
742
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
743
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
744
745
746
static uint16_t sNativeProperties_sortedPropertyIndices[1];
747
static PropertyInfo sNativeProperties_propertyInfos[1];
748
749
static const NativePropertiesN<1> sNativeProperties = {
750
  true,  0 /* sStaticMethods */,
751
  false, 0,
752
  false, 0,
753
  false, 0,
754
  false, 0,
755
  false, 0,
756
  false, 0,
757
  -1,
758
  1,
759
  sNativeProperties_sortedPropertyIndices,
760
  {
761
    { sStaticMethods, &sNativeProperties_propertyInfos[0] }
762
  }
763
};
764
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
765
    "We have a property info count that is oversized");
766
767
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
768
  {
769
    "Function",
770
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
771
    &sBoringInterfaceObjectClassClassOps,
772
    JS_NULL_CLASS_SPEC,
773
    JS_NULL_CLASS_EXT,
774
    &sInterfaceObjectClassObjectOps
775
  },
776
  eInterface,
777
  true,
778
  prototypes::id::IDBLocaleAwareKeyRange,
779
  PrototypeTraits<prototypes::id::IDBLocaleAwareKeyRange>::Depth,
780
  sNativePropertyHooks,
781
  "function IDBLocaleAwareKeyRange() {\n    [native code]\n}",
782
  IDBKeyRange_Binding::GetConstructorObject
783
};
784
785
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
786
  {
787
    "IDBLocaleAwareKeyRangePrototype",
788
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
789
    JS_NULL_CLASS_OPS,
790
    JS_NULL_CLASS_SPEC,
791
    JS_NULL_CLASS_EXT,
792
    JS_NULL_OBJECT_OPS
793
  },
794
  eInterfacePrototype,
795
  false,
796
  prototypes::id::IDBLocaleAwareKeyRange,
797
  PrototypeTraits<prototypes::id::IDBLocaleAwareKeyRange>::Depth,
798
  sNativePropertyHooks,
799
  "[object IDBLocaleAwareKeyRangePrototype]",
800
  IDBKeyRange_Binding::GetProtoObject
801
};
802
803
bool
804
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
805
0
{
806
0
  return mozilla::dom::IndexedDatabaseManager::ExperimentalFeaturesEnabled(aCx, aObj);
807
0
}
808
809
static const js::ClassOps sClassOps = {
810
  nullptr, /* addProperty */
811
  nullptr,               /* delProperty */
812
  nullptr,               /* enumerate */
813
  nullptr, /* newEnumerate */
814
  nullptr, /* resolve */
815
  nullptr, /* mayResolve */
816
  _finalize, /* finalize */
817
  nullptr, /* call */
818
  nullptr,               /* hasInstance */
819
  nullptr,               /* construct */
820
  nullptr, /* trace */
821
};
822
823
static const js::ClassExtension sClassExtension = {
824
  nullptr, /* weakmapKeyDelegateOp */
825
  nullptr /* objectMovedOp */
826
};
827
828
static const DOMJSClass sClass = {
829
  { "IDBLocaleAwareKeyRange",
830
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
831
    &sClassOps,
832
    JS_NULL_CLASS_SPEC,
833
    &sClassExtension,
834
    JS_NULL_OBJECT_OPS
835
  },
836
  { prototypes::id::IDBKeyRange, prototypes::id::IDBLocaleAwareKeyRange, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
837
  IsBaseOf<nsISupports, mozilla::dom::IDBLocaleAwareKeyRange >::value,
838
  sNativePropertyHooks,
839
  FindAssociatedGlobalForNative<mozilla::dom::IDBLocaleAwareKeyRange>::Get,
840
  GetProtoObjectHandle,
841
  GetCCParticipant<mozilla::dom::IDBLocaleAwareKeyRange>::Get()
842
};
843
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
844
              "Must have the right minimal number of reserved slots.");
845
static_assert(1 >= 1,
846
              "Must have enough reserved slots.");
847
848
const JSClass*
849
GetJSClass()
850
0
{
851
0
  return sClass.ToJSClass();
852
0
}
853
854
bool
855
Wrap(JSContext* aCx, mozilla::dom::IDBLocaleAwareKeyRange* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
856
0
{
857
0
  MOZ_ASSERT(static_cast<mozilla::dom::IDBLocaleAwareKeyRange*>(aObject) ==
858
0
             reinterpret_cast<mozilla::dom::IDBLocaleAwareKeyRange*>(aObject),
859
0
             "Multiple inheritance for mozilla::dom::IDBLocaleAwareKeyRange is broken.");
860
0
  MOZ_ASSERT(static_cast<mozilla::dom::IDBKeyRange*>(aObject) ==
861
0
             reinterpret_cast<mozilla::dom::IDBKeyRange*>(aObject),
862
0
             "Multiple inheritance for mozilla::dom::IDBKeyRange is broken.");
863
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
864
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
865
0
866
0
  JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
867
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
868
0
  if (!canonicalProto) {
869
0
    return false;
870
0
  }
871
0
  JS::Rooted<JSObject*> proto(aCx);
872
0
  if (aGivenProto) {
873
0
    proto = aGivenProto;
874
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
875
0
    // coming in, we changed compartments to that of "parent" so may need
876
0
    // to wrap the proto here.
877
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
878
0
      if (!JS_WrapObject(aCx, &proto)) {
879
0
        return false;
880
0
      }
881
0
    }
882
0
  } else {
883
0
    proto = canonicalProto;
884
0
  }
885
0
886
0
  BindingJSObjectCreator<mozilla::dom::IDBLocaleAwareKeyRange> creator(aCx);
887
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
888
0
  if (!aReflector) {
889
0
    return false;
890
0
  }
891
0
892
0
893
0
894
0
  creator.InitializationSucceeded();
895
0
  return true;
896
0
}
897
898
const NativePropertyHooks sNativePropertyHooks[] = { {
899
  nullptr,
900
  nullptr,
901
  nullptr,
902
  { sNativeProperties.Upcast(), nullptr },
903
  prototypes::id::IDBLocaleAwareKeyRange,
904
  constructors::id::IDBLocaleAwareKeyRange,
905
  IDBKeyRange_Binding::sNativePropertyHooks,
906
  &DefaultXrayExpandoObjectClass
907
} };
908
909
void
910
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
911
0
{
912
0
  JS::Handle<JSObject*> parentProto(IDBKeyRange_Binding::GetProtoObjectHandle(aCx));
913
0
  if (!parentProto) {
914
0
    return;
915
0
  }
916
0
917
0
  JS::Handle<JSObject*> constructorProto(IDBKeyRange_Binding::GetConstructorObjectHandle(aCx));
918
0
  if (!constructorProto) {
919
0
    return;
920
0
  }
921
0
922
0
  static bool sIdsInited = false;
923
0
  if (!sIdsInited && NS_IsMainThread()) {
924
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
925
0
      return;
926
0
    }
927
0
    sIdsInited = true;
928
0
  }
929
0
930
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBLocaleAwareKeyRange);
931
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBLocaleAwareKeyRange);
932
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
933
0
                              &sPrototypeClass.mBase, protoCache,
934
0
                              nullptr,
935
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
936
0
                              interfaceCache,
937
0
                              sNativeProperties.Upcast(),
938
0
                              nullptr,
939
0
                              "IDBLocaleAwareKeyRange", aDefineOnGlobal,
940
0
                              nullptr,
941
0
                              false);
942
0
}
943
944
JSObject*
945
GetConstructorObject(JSContext* aCx)
946
0
{
947
0
  return GetConstructorObjectHandle(aCx);
948
0
}
949
950
} // namespace IDBLocaleAwareKeyRange_Binding
951
952
953
954
} // namespace dom
955
} // namespace mozilla