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