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