Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM IDBObjectStore.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "IDBIndexBinding.h"
5 : #include "IDBObjectStoreBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/DOMStringList.h"
11 : #include "mozilla/dom/IDBIndex.h"
12 : #include "mozilla/dom/IDBObjectStore.h"
13 : #include "mozilla/dom/IDBRequest.h"
14 : #include "mozilla/dom/IDBTransaction.h"
15 : #include "mozilla/dom/NonRefcountedDOMObject.h"
16 : #include "mozilla/dom/PrimitiveConversions.h"
17 : #include "mozilla/dom/ScriptSettings.h"
18 : #include "mozilla/dom/SimpleGlobalObject.h"
19 : #include "mozilla/dom/UnionConversions.h"
20 : #include "mozilla/dom/UnionTypes.h"
21 : #include "mozilla/dom/XrayExpandoClass.h"
22 :
23 : namespace mozilla {
24 : namespace dom {
25 :
26 :
27 0 : IDBObjectStoreParameters::IDBObjectStoreParameters()
28 : {
29 : // Safe to pass a null context if we pass a null value
30 0 : Init(nullptr, JS::NullHandleValue);
31 0 : }
32 :
33 :
34 :
35 : bool
36 0 : IDBObjectStoreParameters::InitIds(JSContext* cx, IDBObjectStoreParametersAtoms* atomsCache)
37 : {
38 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
39 :
40 : // Initialize these in reverse order so that any failure leaves the first one
41 : // uninitialized.
42 0 : if (!atomsCache->keyPath_id.init(cx, "keyPath") ||
43 0 : !atomsCache->autoIncrement_id.init(cx, "autoIncrement")) {
44 0 : return false;
45 : }
46 0 : return true;
47 : }
48 :
49 : bool
50 0 : IDBObjectStoreParameters::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
51 : {
52 : // Passing a null JSContext is OK only if we're initing from null,
53 : // Since in that case we will not have to do any property gets
54 : // Also evaluate isNullOrUndefined in order to avoid false-positive
55 : // checkers by static analysis tools
56 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
57 0 : IDBObjectStoreParametersAtoms* atomsCache = nullptr;
58 0 : if (cx) {
59 0 : atomsCache = GetAtomCache<IDBObjectStoreParametersAtoms>(cx);
60 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
61 0 : return false;
62 : }
63 : }
64 :
65 0 : if (!IsConvertibleToDictionary(val)) {
66 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
67 : }
68 :
69 0 : bool isNull = val.isNullOrUndefined();
70 : // We only need these if !isNull, in which case we have |cx|.
71 0 : Maybe<JS::Rooted<JSObject *> > object;
72 0 : Maybe<JS::Rooted<JS::Value> > temp;
73 0 : if (!isNull) {
74 0 : MOZ_ASSERT(cx);
75 0 : object.emplace(cx, &val.toObject());
76 0 : temp.emplace(cx);
77 : }
78 0 : if (!isNull) {
79 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->autoIncrement_id, temp.ptr())) {
80 0 : return false;
81 : }
82 : }
83 0 : if (!isNull && !temp->isUndefined()) {
84 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAutoIncrement)) {
85 0 : return false;
86 : }
87 : } else {
88 0 : mAutoIncrement = false;
89 : }
90 0 : mIsAnyMemberPresent = true;
91 :
92 0 : if (!isNull) {
93 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->keyPath_id, temp.ptr())) {
94 0 : return false;
95 : }
96 : }
97 0 : if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
98 0 : mKeyPath.SetNull();
99 : } else {
100 : {
101 0 : bool done = false, failed = false, tryNext;
102 0 : if (temp.ref().isObject()) {
103 0 : done = (failed = !mKeyPath.SetValue().TrySetToStringSequence(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext;
104 : }
105 0 : if (!done) {
106 : do {
107 0 : done = (failed = !mKeyPath.SetValue().TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
108 0 : break;
109 : } while (0);
110 : }
111 0 : if (failed) {
112 0 : return false;
113 : }
114 0 : if (!done) {
115 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'keyPath' member of IDBObjectStoreParameters", "StringSequence");
116 0 : return false;
117 : }
118 : }
119 : }
120 0 : mIsAnyMemberPresent = true;
121 0 : return true;
122 : }
123 :
124 : bool
125 0 : IDBObjectStoreParameters::Init(const nsAString& aJSON)
126 : {
127 0 : AutoJSAPI jsapi;
128 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
129 0 : if (!cleanGlobal) {
130 0 : return false;
131 : }
132 0 : if (!jsapi.Init(cleanGlobal)) {
133 0 : return false;
134 : }
135 0 : JSContext* cx = jsapi.cx();
136 0 : JS::Rooted<JS::Value> json(cx);
137 0 : bool ok = ParseJSON(cx, aJSON, &json);
138 0 : NS_ENSURE_TRUE(ok, false);
139 0 : return Init(cx, json);
140 : }
141 :
142 : bool
143 0 : IDBObjectStoreParameters::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
144 : {
145 0 : IDBObjectStoreParametersAtoms* atomsCache = GetAtomCache<IDBObjectStoreParametersAtoms>(cx);
146 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
147 0 : return false;
148 : }
149 :
150 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
151 0 : if (!obj) {
152 0 : return false;
153 : }
154 0 : rval.set(JS::ObjectValue(*obj));
155 :
156 : do {
157 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
158 0 : JS::Rooted<JS::Value> temp(cx);
159 0 : bool const & currentValue = mAutoIncrement;
160 0 : temp.setBoolean(currentValue);
161 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->autoIncrement_id, temp, JSPROP_ENUMERATE)) {
162 0 : return false;
163 : }
164 0 : break;
165 : } while(0);
166 :
167 : do {
168 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
169 0 : JS::Rooted<JS::Value> temp(cx);
170 0 : Nullable<OwningStringOrStringSequence > const & currentValue = mKeyPath;
171 0 : if (currentValue.IsNull()) {
172 0 : temp.setNull();
173 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->keyPath_id, temp, JSPROP_ENUMERATE)) {
174 0 : return false;
175 : }
176 0 : break;
177 : }
178 0 : if (!currentValue.Value().ToJSVal(cx, obj, &temp)) {
179 0 : return false;
180 : }
181 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->keyPath_id, temp, JSPROP_ENUMERATE)) {
182 0 : return false;
183 : }
184 0 : break;
185 : } while(0);
186 :
187 0 : return true;
188 : }
189 :
190 : bool
191 0 : IDBObjectStoreParameters::ToJSON(nsAString& aJSON) const
192 : {
193 0 : AutoJSAPI jsapi;
194 0 : jsapi.Init();
195 0 : JSContext *cx = jsapi.cx();
196 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
197 : // because we'll only be creating objects, in ways that have no
198 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
199 : // which likewise guarantees no side-effects for the sorts of
200 : // things we will pass it.
201 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
202 0 : JS::Rooted<JS::Value> val(cx);
203 0 : if (!ToObjectInternal(cx, &val)) {
204 0 : return false;
205 : }
206 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
207 0 : return StringifyToJSON(cx, obj, aJSON);
208 : }
209 :
210 : void
211 0 : IDBObjectStoreParameters::TraceDictionary(JSTracer* trc)
212 : {
213 0 : }
214 :
215 : IDBObjectStoreParameters&
216 0 : IDBObjectStoreParameters::operator=(const IDBObjectStoreParameters& aOther)
217 : {
218 0 : mAutoIncrement = aOther.mAutoIncrement;
219 0 : mKeyPath = aOther.mKeyPath;
220 0 : return *this;
221 : }
222 :
223 : namespace binding_detail {
224 : } // namespace binding_detail
225 :
226 :
227 : namespace IDBObjectStoreBinding {
228 :
229 : static bool
230 0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, JSJitGetterCallArgs args)
231 : {
232 0 : DOMString result;
233 0 : self->GetName(result);
234 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
235 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
236 0 : return false;
237 : }
238 0 : return true;
239 : }
240 :
241 : static bool
242 0 : set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, JSJitSetterCallArgs args)
243 : {
244 0 : binding_detail::FakeString arg0;
245 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
246 0 : return false;
247 : }
248 0 : binding_detail::FastErrorResult rv;
249 0 : self->SetName(NonNullHelper(Constify(arg0)), rv);
250 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
251 0 : return false;
252 : }
253 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
254 :
255 0 : return true;
256 : }
257 :
258 : static const JSJitInfo name_getterinfo = {
259 : { (JSJitGetterOp)get_name },
260 : { prototypes::id::IDBObjectStore },
261 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
262 : JSJitInfo::Getter,
263 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
264 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
265 : false, /* isInfallible. False in setters. */
266 : false, /* isMovable. Not relevant for setters. */
267 : false, /* isEliminatable. Not relevant for setters. */
268 : false, /* isAlwaysInSlot. Only relevant for getters. */
269 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
270 : false, /* isTypedMethod. Only relevant for methods. */
271 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
272 : };
273 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
274 : static_assert(0 < 1, "There is no slot for us");
275 : static const JSJitInfo name_setterinfo = {
276 : { (JSJitGetterOp)set_name },
277 : { prototypes::id::IDBObjectStore },
278 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
279 : JSJitInfo::Setter,
280 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
281 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
282 : false, /* isInfallible. False in setters. */
283 : false, /* isMovable. Not relevant for setters. */
284 : false, /* isEliminatable. Not relevant for setters. */
285 : false, /* isAlwaysInSlot. Only relevant for getters. */
286 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
287 : false, /* isTypedMethod. Only relevant for methods. */
288 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
289 : };
290 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
291 : static_assert(0 < 1, "There is no slot for us");
292 :
293 : static bool
294 0 : get_keyPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, JSJitGetterCallArgs args)
295 : {
296 0 : binding_detail::FastErrorResult rv;
297 0 : JS::Rooted<JS::Value> result(cx);
298 0 : self->GetKeyPath(cx, &result, rv);
299 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
300 0 : return false;
301 : }
302 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
303 0 : JS::ExposeValueToActiveJS(result);
304 0 : args.rval().set(result);
305 0 : if (!MaybeWrapValue(cx, args.rval())) {
306 0 : return false;
307 : }
308 0 : return true;
309 : }
310 :
311 : static const JSJitInfo keyPath_getterinfo = {
312 : { (JSJitGetterOp)get_keyPath },
313 : { prototypes::id::IDBObjectStore },
314 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
315 : JSJitInfo::Getter,
316 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
317 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
318 : false, /* isInfallible. False in setters. */
319 : false, /* isMovable. Not relevant for setters. */
320 : false, /* isEliminatable. Not relevant for setters. */
321 : false, /* isAlwaysInSlot. Only relevant for getters. */
322 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
323 : false, /* isTypedMethod. Only relevant for methods. */
324 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
325 : };
326 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
327 : static_assert(0 < 1, "There is no slot for us");
328 :
329 : static bool
330 0 : get_indexNames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, JSJitGetterCallArgs args)
331 : {
332 0 : auto result(StrongOrRawPtr<mozilla::dom::DOMStringList>(self->IndexNames()));
333 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
334 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
335 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
336 0 : return false;
337 : }
338 0 : return true;
339 : }
340 :
341 : static const JSJitInfo indexNames_getterinfo = {
342 : { (JSJitGetterOp)get_indexNames },
343 : { prototypes::id::IDBObjectStore },
344 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
345 : JSJitInfo::Getter,
346 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
347 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
348 : false, /* isInfallible. False in setters. */
349 : false, /* isMovable. Not relevant for setters. */
350 : false, /* isEliminatable. Not relevant for setters. */
351 : false, /* isAlwaysInSlot. Only relevant for getters. */
352 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
353 : false, /* isTypedMethod. Only relevant for methods. */
354 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
355 : };
356 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
357 : static_assert(0 < 1, "There is no slot for us");
358 :
359 : static bool
360 0 : get_transaction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, JSJitGetterCallArgs args)
361 : {
362 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBTransaction>(self->Transaction()));
363 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
364 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
365 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
366 0 : return false;
367 : }
368 0 : return true;
369 : }
370 :
371 : static const JSJitInfo transaction_getterinfo = {
372 : { (JSJitGetterOp)get_transaction },
373 : { prototypes::id::IDBObjectStore },
374 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
375 : JSJitInfo::Getter,
376 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
377 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
378 : false, /* isInfallible. False in setters. */
379 : false, /* isMovable. Not relevant for setters. */
380 : false, /* isEliminatable. Not relevant for setters. */
381 : false, /* isAlwaysInSlot. Only relevant for getters. */
382 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
383 : false, /* isTypedMethod. Only relevant for methods. */
384 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
385 : };
386 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
387 : static_assert(0 < 1, "There is no slot for us");
388 :
389 : static bool
390 0 : get_autoIncrement(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, JSJitGetterCallArgs args)
391 : {
392 0 : bool result(self->AutoIncrement());
393 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
394 0 : args.rval().setBoolean(result);
395 0 : return true;
396 : }
397 :
398 : static const JSJitInfo autoIncrement_getterinfo = {
399 : { (JSJitGetterOp)get_autoIncrement },
400 : { prototypes::id::IDBObjectStore },
401 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
402 : JSJitInfo::Getter,
403 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
404 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
405 : true, /* isInfallible. False in setters. */
406 : false, /* isMovable. Not relevant for setters. */
407 : false, /* isEliminatable. Not relevant for setters. */
408 : false, /* isAlwaysInSlot. Only relevant for getters. */
409 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
410 : false, /* isTypedMethod. Only relevant for methods. */
411 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
412 : };
413 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
414 : static_assert(0 < 1, "There is no slot for us");
415 :
416 : static bool
417 0 : put(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
418 : {
419 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
420 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.put");
421 : }
422 0 : JS::Rooted<JS::Value> arg0(cx);
423 0 : arg0 = args[0];
424 0 : JS::Rooted<JS::Value> arg1(cx);
425 0 : if (args.hasDefined(1)) {
426 0 : arg1 = args[1];
427 : } else {
428 0 : arg1 = JS::UndefinedValue();
429 : }
430 0 : binding_detail::FastErrorResult rv;
431 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Put(cx, arg0, arg1, rv)));
432 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
433 0 : return false;
434 : }
435 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
436 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
437 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
438 0 : return false;
439 : }
440 0 : return true;
441 : }
442 :
443 : static const JSJitInfo put_methodinfo = {
444 : { (JSJitGetterOp)put },
445 : { prototypes::id::IDBObjectStore },
446 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
447 : JSJitInfo::Method,
448 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
449 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
450 : false, /* isInfallible. False in setters. */
451 : false, /* isMovable. Not relevant for setters. */
452 : false, /* isEliminatable. Not relevant for setters. */
453 : false, /* isAlwaysInSlot. Only relevant for getters. */
454 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
455 : false, /* isTypedMethod. Only relevant for methods. */
456 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
457 : };
458 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
459 : static_assert(0 < 1, "There is no slot for us");
460 :
461 : static bool
462 0 : add(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
463 : {
464 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
465 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.add");
466 : }
467 0 : JS::Rooted<JS::Value> arg0(cx);
468 0 : arg0 = args[0];
469 0 : JS::Rooted<JS::Value> arg1(cx);
470 0 : if (args.hasDefined(1)) {
471 0 : arg1 = args[1];
472 : } else {
473 0 : arg1 = JS::UndefinedValue();
474 : }
475 0 : binding_detail::FastErrorResult rv;
476 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Add(cx, arg0, arg1, rv)));
477 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
478 0 : return false;
479 : }
480 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
481 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
482 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
483 0 : return false;
484 : }
485 0 : return true;
486 : }
487 :
488 : static const JSJitInfo add_methodinfo = {
489 : { (JSJitGetterOp)add },
490 : { prototypes::id::IDBObjectStore },
491 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
492 : JSJitInfo::Method,
493 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
494 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
495 : false, /* isInfallible. False in setters. */
496 : false, /* isMovable. Not relevant for setters. */
497 : false, /* isEliminatable. Not relevant for setters. */
498 : false, /* isAlwaysInSlot. Only relevant for getters. */
499 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
500 : false, /* isTypedMethod. Only relevant for methods. */
501 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
502 : };
503 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
504 : static_assert(0 < 1, "There is no slot for us");
505 :
506 : static bool
507 0 : _delete_(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
508 : {
509 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
510 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.delete");
511 : }
512 0 : JS::Rooted<JS::Value> arg0(cx);
513 0 : arg0 = args[0];
514 0 : binding_detail::FastErrorResult rv;
515 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Delete(cx, arg0, rv)));
516 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
517 0 : return false;
518 : }
519 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
520 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
521 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
522 0 : return false;
523 : }
524 0 : return true;
525 : }
526 :
527 : static const JSJitInfo delete_methodinfo = {
528 : { (JSJitGetterOp)_delete_ },
529 : { prototypes::id::IDBObjectStore },
530 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
531 : JSJitInfo::Method,
532 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
533 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
534 : false, /* isInfallible. False in setters. */
535 : false, /* isMovable. Not relevant for setters. */
536 : false, /* isEliminatable. Not relevant for setters. */
537 : false, /* isAlwaysInSlot. Only relevant for getters. */
538 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
539 : false, /* isTypedMethod. Only relevant for methods. */
540 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
541 : };
542 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
543 : static_assert(0 < 1, "There is no slot for us");
544 :
545 : static bool
546 0 : get(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
547 : {
548 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
549 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.get");
550 : }
551 0 : JS::Rooted<JS::Value> arg0(cx);
552 0 : arg0 = args[0];
553 0 : binding_detail::FastErrorResult rv;
554 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Get(cx, arg0, rv)));
555 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
556 0 : return false;
557 : }
558 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
559 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
560 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
561 0 : return false;
562 : }
563 0 : return true;
564 : }
565 :
566 : static const JSJitInfo get_methodinfo = {
567 : { (JSJitGetterOp)get },
568 : { prototypes::id::IDBObjectStore },
569 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
570 : JSJitInfo::Method,
571 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
572 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
573 : false, /* isInfallible. False in setters. */
574 : false, /* isMovable. Not relevant for setters. */
575 : false, /* isEliminatable. Not relevant for setters. */
576 : false, /* isAlwaysInSlot. Only relevant for getters. */
577 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
578 : false, /* isTypedMethod. Only relevant for methods. */
579 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
580 : };
581 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
582 : static_assert(0 < 1, "There is no slot for us");
583 :
584 : static bool
585 0 : getKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
586 : {
587 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
588 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.getKey");
589 : }
590 0 : JS::Rooted<JS::Value> arg0(cx);
591 0 : arg0 = args[0];
592 0 : binding_detail::FastErrorResult rv;
593 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetKey(cx, arg0, rv)));
594 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
595 0 : return false;
596 : }
597 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
598 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
599 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
600 0 : return false;
601 : }
602 0 : return true;
603 : }
604 :
605 : static const JSJitInfo getKey_methodinfo = {
606 : { (JSJitGetterOp)getKey },
607 : { prototypes::id::IDBObjectStore },
608 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
609 : JSJitInfo::Method,
610 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
611 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
612 : false, /* isInfallible. False in setters. */
613 : false, /* isMovable. Not relevant for setters. */
614 : false, /* isEliminatable. Not relevant for setters. */
615 : false, /* isAlwaysInSlot. Only relevant for getters. */
616 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
617 : false, /* isTypedMethod. Only relevant for methods. */
618 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
619 : };
620 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
621 : static_assert(0 < 1, "There is no slot for us");
622 :
623 : static bool
624 0 : clear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
625 : {
626 0 : binding_detail::FastErrorResult rv;
627 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Clear(cx, rv)));
628 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
629 0 : return false;
630 : }
631 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
632 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
633 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
634 0 : return false;
635 : }
636 0 : return true;
637 : }
638 :
639 : static const JSJitInfo clear_methodinfo = {
640 : { (JSJitGetterOp)clear },
641 : { prototypes::id::IDBObjectStore },
642 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
643 : JSJitInfo::Method,
644 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
645 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
646 : false, /* isInfallible. False in setters. */
647 : false, /* isMovable. Not relevant for setters. */
648 : false, /* isEliminatable. Not relevant for setters. */
649 : false, /* isAlwaysInSlot. Only relevant for getters. */
650 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
651 : false, /* isTypedMethod. Only relevant for methods. */
652 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
653 : };
654 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
655 : static_assert(0 < 1, "There is no slot for us");
656 :
657 : static bool
658 0 : openCursor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
659 : {
660 0 : JS::Rooted<JS::Value> arg0(cx);
661 0 : if (args.hasDefined(0)) {
662 0 : arg0 = args[0];
663 : } else {
664 0 : arg0 = JS::UndefinedValue();
665 : }
666 : IDBCursorDirection arg1;
667 0 : if (args.hasDefined(1)) {
668 : {
669 : int index;
670 0 : if (!FindEnumStringIndex<true>(cx, args[1], IDBCursorDirectionValues::strings, "IDBCursorDirection", "Argument 2 of IDBObjectStore.openCursor", &index)) {
671 0 : return false;
672 : }
673 0 : MOZ_ASSERT(index >= 0);
674 0 : arg1 = static_cast<IDBCursorDirection>(index);
675 : }
676 : } else {
677 0 : arg1 = IDBCursorDirection::Next;
678 : }
679 0 : binding_detail::FastErrorResult rv;
680 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->OpenCursor(cx, arg0, arg1, rv)));
681 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
682 0 : return false;
683 : }
684 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
685 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
686 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
687 0 : return false;
688 : }
689 0 : return true;
690 : }
691 :
692 : static const JSJitInfo openCursor_methodinfo = {
693 : { (JSJitGetterOp)openCursor },
694 : { prototypes::id::IDBObjectStore },
695 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
696 : JSJitInfo::Method,
697 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
698 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
699 : false, /* isInfallible. False in setters. */
700 : false, /* isMovable. Not relevant for setters. */
701 : false, /* isEliminatable. Not relevant for setters. */
702 : false, /* isAlwaysInSlot. Only relevant for getters. */
703 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
704 : false, /* isTypedMethod. Only relevant for methods. */
705 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
706 : };
707 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
708 : static_assert(0 < 1, "There is no slot for us");
709 :
710 : static bool
711 0 : createIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
712 : {
713 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
714 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.createIndex");
715 : }
716 0 : binding_detail::FakeString arg0;
717 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
718 0 : return false;
719 : }
720 0 : StringOrStringSequence arg1;
721 0 : StringOrStringSequenceArgument arg1_holder(arg1);
722 : {
723 0 : bool done = false, failed = false, tryNext;
724 0 : if (args[1].isObject()) {
725 0 : done = (failed = !arg1_holder.TrySetToStringSequence(cx, args[1], tryNext, false)) || !tryNext;
726 : }
727 0 : if (!done) {
728 : do {
729 0 : done = (failed = !arg1_holder.TrySetToString(cx, args[1], tryNext)) || !tryNext;
730 0 : break;
731 : } while (0);
732 : }
733 0 : if (failed) {
734 0 : return false;
735 : }
736 0 : if (!done) {
737 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 2 of IDBObjectStore.createIndex", "StringSequence");
738 0 : return false;
739 : }
740 : }
741 0 : binding_detail::FastIDBIndexParameters arg2;
742 0 : if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of IDBObjectStore.createIndex", false)) {
743 0 : return false;
744 : }
745 0 : binding_detail::FastErrorResult rv;
746 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBIndex>(self->CreateIndex(NonNullHelper(Constify(arg0)), Constify(arg1), Constify(arg2), rv)));
747 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
748 0 : return false;
749 : }
750 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
751 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
752 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
753 0 : return false;
754 : }
755 0 : return true;
756 : }
757 :
758 : static const JSJitInfo createIndex_methodinfo = {
759 : { (JSJitGetterOp)createIndex },
760 : { prototypes::id::IDBObjectStore },
761 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
762 : JSJitInfo::Method,
763 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
764 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
765 : false, /* isInfallible. False in setters. */
766 : false, /* isMovable. Not relevant for setters. */
767 : false, /* isEliminatable. Not relevant for setters. */
768 : false, /* isAlwaysInSlot. Only relevant for getters. */
769 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
770 : false, /* isTypedMethod. Only relevant for methods. */
771 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
772 : };
773 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
774 : static_assert(0 < 1, "There is no slot for us");
775 :
776 : static bool
777 0 : index(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
778 : {
779 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
780 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.index");
781 : }
782 0 : binding_detail::FakeString arg0;
783 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
784 0 : return false;
785 : }
786 0 : binding_detail::FastErrorResult rv;
787 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBIndex>(self->Index(NonNullHelper(Constify(arg0)), rv)));
788 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
789 0 : return false;
790 : }
791 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
792 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
793 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
794 0 : return false;
795 : }
796 0 : return true;
797 : }
798 :
799 : static const JSJitInfo index_methodinfo = {
800 : { (JSJitGetterOp)index },
801 : { prototypes::id::IDBObjectStore },
802 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
803 : JSJitInfo::Method,
804 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
805 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
806 : false, /* isInfallible. False in setters. */
807 : false, /* isMovable. Not relevant for setters. */
808 : false, /* isEliminatable. Not relevant for setters. */
809 : false, /* isAlwaysInSlot. Only relevant for getters. */
810 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
811 : false, /* isTypedMethod. Only relevant for methods. */
812 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
813 : };
814 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
815 : static_assert(0 < 1, "There is no slot for us");
816 :
817 : static bool
818 0 : deleteIndex(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
819 : {
820 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
821 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBObjectStore.deleteIndex");
822 : }
823 0 : binding_detail::FakeString arg0;
824 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
825 0 : return false;
826 : }
827 0 : binding_detail::FastErrorResult rv;
828 0 : self->DeleteIndex(NonNullHelper(Constify(arg0)), rv);
829 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
830 0 : return false;
831 : }
832 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
833 0 : args.rval().setUndefined();
834 0 : return true;
835 : }
836 :
837 : static const JSJitInfo deleteIndex_methodinfo = {
838 : { (JSJitGetterOp)deleteIndex },
839 : { prototypes::id::IDBObjectStore },
840 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
841 : JSJitInfo::Method,
842 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
843 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
844 : false, /* isInfallible. False in setters. */
845 : false, /* isMovable. Not relevant for setters. */
846 : false, /* isEliminatable. Not relevant for setters. */
847 : false, /* isAlwaysInSlot. Only relevant for getters. */
848 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
849 : false, /* isTypedMethod. Only relevant for methods. */
850 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
851 : };
852 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
853 : static_assert(0 < 1, "There is no slot for us");
854 :
855 : static bool
856 0 : count(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
857 : {
858 0 : JS::Rooted<JS::Value> arg0(cx);
859 0 : if (args.hasDefined(0)) {
860 0 : arg0 = args[0];
861 : } else {
862 0 : arg0 = JS::UndefinedValue();
863 : }
864 0 : binding_detail::FastErrorResult rv;
865 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Count(cx, arg0, rv)));
866 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
867 0 : return false;
868 : }
869 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
870 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
871 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
872 0 : return false;
873 : }
874 0 : return true;
875 : }
876 :
877 : static const JSJitInfo count_methodinfo = {
878 : { (JSJitGetterOp)count },
879 : { prototypes::id::IDBObjectStore },
880 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
881 : JSJitInfo::Method,
882 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
883 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
884 : false, /* isInfallible. False in setters. */
885 : false, /* isMovable. Not relevant for setters. */
886 : false, /* isEliminatable. Not relevant for setters. */
887 : false, /* isAlwaysInSlot. Only relevant for getters. */
888 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
889 : false, /* isTypedMethod. Only relevant for methods. */
890 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
891 : };
892 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
893 : static_assert(0 < 1, "There is no slot for us");
894 :
895 : static bool
896 0 : mozGetAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
897 : {
898 0 : JS::Rooted<JS::Value> arg0(cx);
899 0 : if (args.hasDefined(0)) {
900 0 : arg0 = args[0];
901 : } else {
902 0 : arg0 = JS::UndefinedValue();
903 : }
904 0 : Optional<uint32_t> arg1;
905 0 : if (args.hasDefined(1)) {
906 0 : arg1.Construct();
907 0 : if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
908 0 : return false;
909 : }
910 : }
911 0 : binding_detail::FastErrorResult rv;
912 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAll(cx, arg0, Constify(arg1), rv)));
913 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
914 0 : return false;
915 : }
916 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
917 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
918 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
919 0 : return false;
920 : }
921 0 : return true;
922 : }
923 :
924 : static const JSJitInfo mozGetAll_methodinfo = {
925 : { (JSJitGetterOp)mozGetAll },
926 : { prototypes::id::IDBObjectStore },
927 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
928 : JSJitInfo::Method,
929 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
930 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
931 : false, /* isInfallible. False in setters. */
932 : false, /* isMovable. Not relevant for setters. */
933 : false, /* isEliminatable. Not relevant for setters. */
934 : false, /* isAlwaysInSlot. Only relevant for getters. */
935 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
936 : false, /* isTypedMethod. Only relevant for methods. */
937 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
938 : };
939 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
940 : static_assert(0 < 1, "There is no slot for us");
941 :
942 : static bool
943 0 : getAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
944 : {
945 0 : JS::Rooted<JS::Value> arg0(cx);
946 0 : if (args.hasDefined(0)) {
947 0 : arg0 = args[0];
948 : } else {
949 0 : arg0 = JS::UndefinedValue();
950 : }
951 0 : Optional<uint32_t> arg1;
952 0 : if (args.hasDefined(1)) {
953 0 : arg1.Construct();
954 0 : if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
955 0 : return false;
956 : }
957 : }
958 0 : binding_detail::FastErrorResult rv;
959 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAll(cx, arg0, Constify(arg1), rv)));
960 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
961 0 : return false;
962 : }
963 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
964 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
965 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
966 0 : return false;
967 : }
968 0 : return true;
969 : }
970 :
971 : static const JSJitInfo getAll_methodinfo = {
972 : { (JSJitGetterOp)getAll },
973 : { prototypes::id::IDBObjectStore },
974 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
975 : JSJitInfo::Method,
976 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
977 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
978 : false, /* isInfallible. False in setters. */
979 : false, /* isMovable. Not relevant for setters. */
980 : false, /* isEliminatable. Not relevant for setters. */
981 : false, /* isAlwaysInSlot. Only relevant for getters. */
982 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
983 : false, /* isTypedMethod. Only relevant for methods. */
984 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
985 : };
986 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
987 : static_assert(0 < 1, "There is no slot for us");
988 :
989 : static bool
990 0 : getAllKeys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
991 : {
992 0 : JS::Rooted<JS::Value> arg0(cx);
993 0 : if (args.hasDefined(0)) {
994 0 : arg0 = args[0];
995 : } else {
996 0 : arg0 = JS::UndefinedValue();
997 : }
998 0 : Optional<uint32_t> arg1;
999 0 : if (args.hasDefined(1)) {
1000 0 : arg1.Construct();
1001 0 : if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
1002 0 : return false;
1003 : }
1004 : }
1005 0 : binding_detail::FastErrorResult rv;
1006 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAllKeys(cx, arg0, Constify(arg1), rv)));
1007 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1008 0 : return false;
1009 : }
1010 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1011 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1012 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1013 0 : return false;
1014 : }
1015 0 : return true;
1016 : }
1017 :
1018 : static const JSJitInfo getAllKeys_methodinfo = {
1019 : { (JSJitGetterOp)getAllKeys },
1020 : { prototypes::id::IDBObjectStore },
1021 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
1022 : JSJitInfo::Method,
1023 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1024 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1025 : false, /* isInfallible. False in setters. */
1026 : false, /* isMovable. Not relevant for setters. */
1027 : false, /* isEliminatable. Not relevant for setters. */
1028 : false, /* isAlwaysInSlot. Only relevant for getters. */
1029 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1030 : false, /* isTypedMethod. Only relevant for methods. */
1031 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1032 : };
1033 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1034 : static_assert(0 < 1, "There is no slot for us");
1035 :
1036 : static bool
1037 0 : openKeyCursor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBObjectStore* self, const JSJitMethodCallArgs& args)
1038 : {
1039 0 : JS::Rooted<JS::Value> arg0(cx);
1040 0 : if (args.hasDefined(0)) {
1041 0 : arg0 = args[0];
1042 : } else {
1043 0 : arg0 = JS::UndefinedValue();
1044 : }
1045 : IDBCursorDirection arg1;
1046 0 : if (args.hasDefined(1)) {
1047 : {
1048 : int index;
1049 0 : if (!FindEnumStringIndex<true>(cx, args[1], IDBCursorDirectionValues::strings, "IDBCursorDirection", "Argument 2 of IDBObjectStore.openKeyCursor", &index)) {
1050 0 : return false;
1051 : }
1052 0 : MOZ_ASSERT(index >= 0);
1053 0 : arg1 = static_cast<IDBCursorDirection>(index);
1054 : }
1055 : } else {
1056 0 : arg1 = IDBCursorDirection::Next;
1057 : }
1058 0 : binding_detail::FastErrorResult rv;
1059 0 : auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->OpenKeyCursor(cx, arg0, arg1, rv)));
1060 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1061 0 : return false;
1062 : }
1063 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1064 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1065 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1066 0 : return false;
1067 : }
1068 0 : return true;
1069 : }
1070 :
1071 : static const JSJitInfo openKeyCursor_methodinfo = {
1072 : { (JSJitGetterOp)openKeyCursor },
1073 : { prototypes::id::IDBObjectStore },
1074 : { PrototypeTraits<prototypes::id::IDBObjectStore>::Depth },
1075 : JSJitInfo::Method,
1076 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1077 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1078 : false, /* isInfallible. False in setters. */
1079 : false, /* isMovable. Not relevant for setters. */
1080 : false, /* isEliminatable. Not relevant for setters. */
1081 : false, /* isAlwaysInSlot. Only relevant for getters. */
1082 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1083 : false, /* isTypedMethod. Only relevant for methods. */
1084 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1085 : };
1086 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1087 : static_assert(0 < 1, "There is no slot for us");
1088 :
1089 : static bool
1090 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1091 : {
1092 0 : mozilla::dom::IDBObjectStore* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBObjectStore>(obj);
1093 : // We don't want to preserve if we don't have a wrapper, and we
1094 : // obviously can't preserve if we're not initialized.
1095 0 : if (self && self->GetWrapperPreserveColor()) {
1096 0 : PreserveWrapper(self);
1097 : }
1098 0 : return true;
1099 : }
1100 :
1101 : static void
1102 0 : _finalize(js::FreeOp* fop, JSObject* obj)
1103 : {
1104 0 : mozilla::dom::IDBObjectStore* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBObjectStore>(obj);
1105 0 : if (self) {
1106 0 : ClearWrapper(self, self, obj);
1107 0 : AddForDeferredFinalization<mozilla::dom::IDBObjectStore>(self);
1108 : }
1109 0 : }
1110 :
1111 : static void
1112 0 : _objectMoved(JSObject* obj, const JSObject* old)
1113 : {
1114 0 : mozilla::dom::IDBObjectStore* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBObjectStore>(obj);
1115 0 : if (self) {
1116 0 : UpdateWrapper(self, self, obj, old);
1117 : }
1118 0 : }
1119 :
1120 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1121 : #if defined(__clang__)
1122 : #pragma clang diagnostic push
1123 : #pragma clang diagnostic ignored "-Wmissing-braces"
1124 : #endif
1125 : static const JSFunctionSpec sMethods_specs[] = {
1126 : JS_FNSPEC("put", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&put_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1127 : JS_FNSPEC("add", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&add_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1128 : JS_FNSPEC("delete", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&delete_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1129 : JS_FNSPEC("get", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&get_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1130 : JS_FNSPEC("getKey", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getKey_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1131 : JS_FNSPEC("clear", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&clear_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1132 : JS_FNSPEC("openCursor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&openCursor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1133 : JS_FNSPEC("createIndex", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createIndex_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1134 : JS_FNSPEC("index", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&index_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1135 : JS_FNSPEC("deleteIndex", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&deleteIndex_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1136 : JS_FNSPEC("count", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&count_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1137 : JS_FNSPEC("mozGetAll", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozGetAll_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1138 : JS_FNSPEC("getAll", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAll_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1139 : JS_FNSPEC("getAllKeys", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAllKeys_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1140 : JS_FNSPEC("openKeyCursor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&openKeyCursor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1141 : JS_FS_END
1142 : };
1143 : #if defined(__clang__)
1144 : #pragma clang diagnostic pop
1145 : #endif
1146 :
1147 :
1148 : // Can't be const because the pref-enabled boolean needs to be writable
1149 : static Prefable<const JSFunctionSpec> sMethods[] = {
1150 : { nullptr, &sMethods_specs[0] },
1151 : { nullptr, nullptr }
1152 : };
1153 :
1154 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1155 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1156 : static_assert(15 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1157 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1158 :
1159 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1160 : #if defined(__clang__)
1161 : #pragma clang diagnostic push
1162 : #pragma clang diagnostic ignored "-Wmissing-braces"
1163 : #endif
1164 : static const JSPropertySpec sAttributes_specs[] = {
1165 : { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, GenericBindingSetter, &name_setterinfo },
1166 : { "keyPath", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &keyPath_getterinfo, nullptr, nullptr },
1167 : { "indexNames", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &indexNames_getterinfo, nullptr, nullptr },
1168 : { "transaction", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &transaction_getterinfo, nullptr, nullptr },
1169 : { "autoIncrement", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &autoIncrement_getterinfo, nullptr, nullptr },
1170 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1171 : };
1172 : #if defined(__clang__)
1173 : #pragma clang diagnostic pop
1174 : #endif
1175 :
1176 :
1177 : // Can't be const because the pref-enabled boolean needs to be writable
1178 : static Prefable<const JSPropertySpec> sAttributes[] = {
1179 : { nullptr, &sAttributes_specs[0] },
1180 : { nullptr, nullptr }
1181 : };
1182 :
1183 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1184 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1185 : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1186 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1187 :
1188 :
1189 : static uint16_t sNativeProperties_sortedPropertyIndices[20];
1190 : static PropertyInfo sNativeProperties_propertyInfos[20];
1191 :
1192 : static const NativePropertiesN<2> sNativeProperties = {
1193 : false, 0,
1194 : false, 0,
1195 : true, 0 /* sMethods */,
1196 : true, 1 /* sAttributes */,
1197 : false, 0,
1198 : false, 0,
1199 : false, 0,
1200 : -1,
1201 : 20,
1202 : sNativeProperties_sortedPropertyIndices,
1203 : {
1204 : { sMethods, &sNativeProperties_propertyInfos[0] },
1205 : { sAttributes, &sNativeProperties_propertyInfos[15] }
1206 : }
1207 : };
1208 : static_assert(20 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1209 : "We have a property info count that is oversized");
1210 :
1211 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1212 : {
1213 : "Function",
1214 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1215 : &sBoringInterfaceObjectClassClassOps,
1216 : JS_NULL_CLASS_SPEC,
1217 : JS_NULL_CLASS_EXT,
1218 : &sInterfaceObjectClassObjectOps
1219 : },
1220 : eInterface,
1221 : true,
1222 : prototypes::id::IDBObjectStore,
1223 : PrototypeTraits<prototypes::id::IDBObjectStore>::Depth,
1224 : sNativePropertyHooks,
1225 : "function IDBObjectStore() {\n [native code]\n}",
1226 : JS::GetRealmFunctionPrototype
1227 : };
1228 :
1229 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1230 : {
1231 : "IDBObjectStorePrototype",
1232 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1233 : JS_NULL_CLASS_OPS,
1234 : JS_NULL_CLASS_SPEC,
1235 : JS_NULL_CLASS_EXT,
1236 : JS_NULL_OBJECT_OPS
1237 : },
1238 : eInterfacePrototype,
1239 : false,
1240 : prototypes::id::IDBObjectStore,
1241 : PrototypeTraits<prototypes::id::IDBObjectStore>::Depth,
1242 : sNativePropertyHooks,
1243 : "[object IDBObjectStorePrototype]",
1244 : JS::GetRealmObjectPrototype
1245 : };
1246 :
1247 : JSObject*
1248 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1249 : {
1250 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1251 : }
1252 :
1253 : static const js::ClassOps sClassOps = {
1254 : _addProperty, /* addProperty */
1255 : nullptr, /* delProperty */
1256 : nullptr, /* getProperty */
1257 : nullptr, /* setProperty */
1258 : nullptr, /* enumerate */
1259 : nullptr, /* newEnumerate */
1260 : nullptr, /* resolve */
1261 : nullptr, /* mayResolve */
1262 : _finalize, /* finalize */
1263 : nullptr, /* call */
1264 : nullptr, /* hasInstance */
1265 : nullptr, /* construct */
1266 : nullptr, /* trace */
1267 : };
1268 :
1269 : static const js::ClassExtension sClassExtension = {
1270 : nullptr, /* weakmapKeyDelegateOp */
1271 : _objectMoved /* objectMovedOp */
1272 : };
1273 :
1274 : static const DOMJSClass sClass = {
1275 : { "IDBObjectStore",
1276 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1277 : &sClassOps,
1278 : JS_NULL_CLASS_SPEC,
1279 : &sClassExtension,
1280 : JS_NULL_OBJECT_OPS
1281 : },
1282 : { prototypes::id::IDBObjectStore, 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 },
1283 : IsBaseOf<nsISupports, mozilla::dom::IDBObjectStore >::value,
1284 : sNativePropertyHooks,
1285 : FindAssociatedGlobalForNative<mozilla::dom::IDBObjectStore>::Get,
1286 : GetProtoObjectHandle,
1287 : GetCCParticipant<mozilla::dom::IDBObjectStore>::Get()
1288 : };
1289 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1290 : "Must have the right minimal number of reserved slots.");
1291 : static_assert(1 >= 1,
1292 : "Must have enough reserved slots.");
1293 :
1294 : const JSClass*
1295 0 : GetJSClass()
1296 : {
1297 0 : return sClass.ToJSClass();
1298 : }
1299 :
1300 : bool
1301 0 : Wrap(JSContext* aCx, mozilla::dom::IDBObjectStore* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1302 : {
1303 : MOZ_ASSERT(static_cast<mozilla::dom::IDBObjectStore*>(aObject) ==
1304 : reinterpret_cast<mozilla::dom::IDBObjectStore*>(aObject),
1305 : "Multiple inheritance for mozilla::dom::IDBObjectStore is broken.");
1306 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1307 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1308 0 : MOZ_ASSERT(!aCache->GetWrapper(),
1309 : "You should probably not be using Wrap() directly; use "
1310 : "GetOrCreateDOMReflector instead");
1311 :
1312 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1313 : "nsISupports must be on our primary inheritance chain");
1314 :
1315 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1316 0 : if (!global) {
1317 0 : return false;
1318 : }
1319 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
1320 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1321 :
1322 : // That might have ended up wrapping us already, due to the wonders
1323 : // of XBL. Check for that, and bail out as needed.
1324 0 : aReflector.set(aCache->GetWrapper());
1325 0 : if (aReflector) {
1326 : #ifdef DEBUG
1327 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1328 : #endif // DEBUG
1329 0 : return true;
1330 : }
1331 :
1332 0 : JSAutoCompartment ac(aCx, global);
1333 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1334 0 : if (!canonicalProto) {
1335 0 : return false;
1336 : }
1337 0 : JS::Rooted<JSObject*> proto(aCx);
1338 0 : if (aGivenProto) {
1339 0 : proto = aGivenProto;
1340 : // Unfortunately, while aGivenProto was in the compartment of aCx
1341 : // coming in, we changed compartments to that of "parent" so may need
1342 : // to wrap the proto here.
1343 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1344 0 : if (!JS_WrapObject(aCx, &proto)) {
1345 0 : return false;
1346 : }
1347 : }
1348 : } else {
1349 0 : proto = canonicalProto;
1350 : }
1351 :
1352 0 : BindingJSObjectCreator<mozilla::dom::IDBObjectStore> creator(aCx);
1353 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1354 0 : if (!aReflector) {
1355 0 : return false;
1356 : }
1357 :
1358 0 : aCache->SetWrapper(aReflector);
1359 0 : creator.InitializationSucceeded();
1360 :
1361 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1362 : aCache->GetWrapperPreserveColor() == aReflector);
1363 : // If proto != canonicalProto, we have to preserve our wrapper;
1364 : // otherwise we won't be able to properly recreate it later, since
1365 : // we won't know what proto to use. Note that we don't check
1366 : // aGivenProto here, since it's entirely possible (and even
1367 : // somewhat common) to have a non-null aGivenProto which is the
1368 : // same as canonicalProto.
1369 0 : if (proto != canonicalProto) {
1370 0 : PreserveWrapper(aObject);
1371 : }
1372 :
1373 0 : return true;
1374 : }
1375 :
1376 : const NativePropertyHooks sNativePropertyHooks[] = { {
1377 : nullptr,
1378 : nullptr,
1379 : nullptr,
1380 : { sNativeProperties.Upcast(), nullptr },
1381 : prototypes::id::IDBObjectStore,
1382 : constructors::id::IDBObjectStore,
1383 : nullptr,
1384 : &DefaultXrayExpandoObjectClass
1385 : } };
1386 :
1387 : void
1388 15 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1389 : {
1390 30 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1391 15 : if (!parentProto) {
1392 0 : return;
1393 : }
1394 :
1395 30 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1396 15 : if (!constructorProto) {
1397 0 : return;
1398 : }
1399 :
1400 : static bool sIdsInited = false;
1401 15 : if (!sIdsInited && NS_IsMainThread()) {
1402 1 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1403 0 : return;
1404 : }
1405 1 : sIdsInited = true;
1406 : }
1407 :
1408 15 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBObjectStore);
1409 15 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBObjectStore);
1410 30 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1411 : &sPrototypeClass.mBase, protoCache,
1412 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1413 : interfaceCache,
1414 : sNativeProperties.Upcast(),
1415 : nullptr,
1416 : "IDBObjectStore", aDefineOnGlobal,
1417 : nullptr,
1418 15 : false);
1419 : }
1420 :
1421 : JS::Handle<JSObject*>
1422 0 : GetProtoObjectHandle(JSContext* aCx)
1423 : {
1424 : /* Get the interface prototype object for this class. This will create the
1425 : object as needed. */
1426 0 : bool aDefineOnGlobal = true;
1427 :
1428 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1429 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1430 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1431 0 : return nullptr;
1432 : }
1433 :
1434 : /* Check to see whether the interface objects are already installed */
1435 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1436 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::IDBObjectStore)) {
1437 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1438 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1439 : }
1440 :
1441 : /*
1442 : * The object might _still_ be null, but that's OK.
1443 : *
1444 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1445 : * traced by TraceProtoAndIfaceCache() and its contents are never
1446 : * changed after they have been set.
1447 : *
1448 : * Calling address() avoids the read read barrier that does gray
1449 : * unmarking, but it's not possible for the object to be gray here.
1450 : */
1451 :
1452 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::IDBObjectStore);
1453 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1454 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1455 : }
1456 :
1457 : JS::Handle<JSObject*>
1458 15 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1459 : {
1460 : /* Get the interface object for this class. This will create the object as
1461 : needed. */
1462 :
1463 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1464 15 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1465 15 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1466 0 : return nullptr;
1467 : }
1468 :
1469 : /* Check to see whether the interface objects are already installed */
1470 15 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1471 15 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::IDBObjectStore)) {
1472 30 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1473 15 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1474 : }
1475 :
1476 : /*
1477 : * The object might _still_ be null, but that's OK.
1478 : *
1479 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1480 : * traced by TraceProtoAndIfaceCache() and its contents are never
1481 : * changed after they have been set.
1482 : *
1483 : * Calling address() avoids the read read barrier that does gray
1484 : * unmarking, but it's not possible for the object to be gray here.
1485 : */
1486 :
1487 15 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::IDBObjectStore);
1488 15 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1489 15 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1490 : }
1491 :
1492 : JSObject*
1493 15 : GetConstructorObject(JSContext* aCx)
1494 : {
1495 15 : return GetConstructorObjectHandle(aCx);
1496 : }
1497 :
1498 : } // namespace IDBObjectStoreBinding
1499 :
1500 :
1501 :
1502 : } // namespace dom
1503 : } // namespace mozilla
|