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