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