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