Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM TestInterfaceJSMaplikeSetlikeIterable.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_TestInterfaceJSMaplikeSetlikeIterableBinding_h
4 : #define mozilla_dom_TestInterfaceJSMaplikeSetlikeIterableBinding_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/CallbackInterface.h"
11 : #include "mozilla/dom/FakeString.h"
12 : #include "mozilla/dom/IterableIterator.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/ToJSValue.h"
15 : #include "mozilla/dom/UnionMember.h"
16 : #include "nsWeakReference.h"
17 :
18 : class nsINode;
19 :
20 : namespace mozilla {
21 : namespace dom {
22 :
23 : struct NativePropertyHooks;
24 : class OwningStringOrLong;
25 : class ProtoAndIfaceCache;
26 : class StringOrLong;
27 : class TestInterfaceIterableDouble;
28 : struct TestInterfaceIterableDoubleAtoms;
29 : class TestInterfaceIterableDoubleUnion;
30 : struct TestInterfaceIterableDoubleUnionAtoms;
31 : class TestInterfaceIterableSingle;
32 : struct TestInterfaceIterableSingleAtoms;
33 : class TestInterfaceJSMaplike;
34 : struct TestInterfaceJSMaplikeAtoms;
35 : class TestInterfaceMaplike;
36 : struct TestInterfaceMaplikeAtoms;
37 : class TestInterfaceMaplikeObject;
38 : struct TestInterfaceMaplikeObjectAtoms;
39 : class TestInterfaceSetlike;
40 : struct TestInterfaceSetlikeAtoms;
41 : class TestInterfaceSetlikeNode;
42 : struct TestInterfaceSetlikeNodeAtoms;
43 :
44 : } // namespace dom
45 : } // namespace mozilla
46 :
47 : namespace mozilla {
48 : namespace dom {
49 :
50 : class StringOrLong
51 : {
52 : friend class StringOrLongArgument;
53 : enum Type
54 : {
55 : eUninitialized,
56 : eString,
57 : eLong
58 : };
59 :
60 : union Value
61 : {
62 : UnionMember<binding_detail::FakeString > mString;
63 : UnionMember<int32_t > mLong;
64 :
65 : };
66 :
67 : Type mType;
68 : Value mValue;
69 :
70 : StringOrLong(const StringOrLong&) = delete;
71 : StringOrLong& operator=(const StringOrLong&) = delete;
72 : public:
73 : explicit inline StringOrLong()
74 : : mType(eUninitialized)
75 : {
76 : }
77 :
78 : inline ~StringOrLong()
79 : {
80 : Uninit();
81 : }
82 :
83 : inline binding_detail::FakeString&
84 : RawSetAsString()
85 : {
86 : if (mType == eString) {
87 : return mValue.mString.Value();
88 : }
89 : MOZ_ASSERT(mType == eUninitialized);
90 : mType = eString;
91 : return mValue.mString.SetValue();
92 : }
93 :
94 : inline binding_detail::FakeString&
95 : SetAsString()
96 : {
97 : if (mType == eString) {
98 : return mValue.mString.Value();
99 : }
100 : Uninit();
101 : mType = eString;
102 : return mValue.mString.SetValue();
103 : }
104 :
105 : inline bool
106 : IsString() const
107 : {
108 : return mType == eString;
109 : }
110 :
111 : inline binding_detail::FakeString&
112 : GetAsString()
113 : {
114 : MOZ_ASSERT(IsString(), "Wrong type!");
115 : return mValue.mString.Value();
116 : }
117 :
118 : inline const nsAString&
119 : GetAsString() const
120 : {
121 : MOZ_ASSERT(IsString(), "Wrong type!");
122 : return mValue.mString.Value();
123 : }
124 :
125 : inline int32_t&
126 : RawSetAsLong()
127 : {
128 : if (mType == eLong) {
129 : return mValue.mLong.Value();
130 : }
131 : MOZ_ASSERT(mType == eUninitialized);
132 : mType = eLong;
133 : return mValue.mLong.SetValue();
134 : }
135 :
136 : inline int32_t&
137 : SetAsLong()
138 : {
139 : if (mType == eLong) {
140 : return mValue.mLong.Value();
141 : }
142 : Uninit();
143 : mType = eLong;
144 : return mValue.mLong.SetValue();
145 : }
146 :
147 : inline bool
148 : IsLong() const
149 : {
150 : return mType == eLong;
151 : }
152 :
153 : inline int32_t&
154 : GetAsLong()
155 : {
156 : MOZ_ASSERT(IsLong(), "Wrong type!");
157 : return mValue.mLong.Value();
158 : }
159 :
160 : inline int32_t
161 : GetAsLong() const
162 : {
163 : MOZ_ASSERT(IsLong(), "Wrong type!");
164 : return mValue.mLong.Value();
165 : }
166 :
167 : inline void
168 : Uninit()
169 : {
170 : switch (mType) {
171 : case eUninitialized: {
172 : break;
173 : }
174 : case eString: {
175 : DestroyString();
176 : break;
177 : }
178 : case eLong: {
179 : DestroyLong();
180 : break;
181 : }
182 : }
183 : }
184 :
185 : bool
186 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
187 :
188 : private:
189 : inline void
190 : DestroyString()
191 : {
192 : MOZ_ASSERT(IsString(), "Wrong type!");
193 : mValue.mString.Destroy();
194 : mType = eUninitialized;
195 : }
196 :
197 : inline void
198 : DestroyLong()
199 : {
200 : MOZ_ASSERT(IsLong(), "Wrong type!");
201 : mValue.mLong.Destroy();
202 : mType = eUninitialized;
203 : }
204 : };
205 :
206 :
207 : class OwningStringOrLong : public AllOwningUnionBase
208 : {
209 : friend void ImplCycleCollectionUnlink(OwningStringOrLong& aUnion);
210 : enum Type
211 : {
212 : eUninitialized,
213 : eString,
214 : eLong
215 : };
216 :
217 0 : union Value
218 : {
219 : UnionMember<nsString > mString;
220 : UnionMember<int32_t > mLong;
221 :
222 : };
223 :
224 : Type mType;
225 : Value mValue;
226 :
227 : public:
228 0 : explicit inline OwningStringOrLong()
229 0 : : mType(eUninitialized)
230 : {
231 0 : }
232 :
233 0 : explicit inline OwningStringOrLong(const OwningStringOrLong& aOther)
234 0 : : mType(eUninitialized)
235 : {
236 0 : *this = aOther;
237 0 : }
238 :
239 0 : inline ~OwningStringOrLong()
240 0 : {
241 0 : Uninit();
242 0 : }
243 :
244 : nsString&
245 : RawSetAsString();
246 :
247 : nsString&
248 : SetAsString();
249 :
250 : bool
251 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
252 :
253 : inline void
254 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
255 : {
256 : RawSetAsString().Assign(aData, aLength);
257 : }
258 :
259 : inline bool
260 0 : IsString() const
261 : {
262 0 : return mType == eString;
263 : }
264 :
265 : inline nsString&
266 : GetAsString()
267 : {
268 : MOZ_ASSERT(IsString(), "Wrong type!");
269 : return mValue.mString.Value();
270 : }
271 :
272 : inline nsString const &
273 0 : GetAsString() const
274 : {
275 0 : MOZ_ASSERT(IsString(), "Wrong type!");
276 0 : return mValue.mString.Value();
277 : }
278 :
279 : int32_t&
280 : RawSetAsLong();
281 :
282 : int32_t&
283 : SetAsLong();
284 :
285 : bool
286 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
287 :
288 : inline bool
289 0 : IsLong() const
290 : {
291 0 : return mType == eLong;
292 : }
293 :
294 : inline int32_t&
295 : GetAsLong()
296 : {
297 : MOZ_ASSERT(IsLong(), "Wrong type!");
298 : return mValue.mLong.Value();
299 : }
300 :
301 : inline int32_t const &
302 0 : GetAsLong() const
303 : {
304 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
305 0 : return mValue.mLong.Value();
306 : }
307 :
308 : void
309 : Uninit();
310 :
311 : bool
312 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
313 :
314 : void
315 : TraceUnion(JSTracer* trc);
316 :
317 : OwningStringOrLong&
318 : operator=(const OwningStringOrLong& aOther);
319 :
320 : private:
321 : void
322 : DestroyString();
323 :
324 : void
325 : DestroyLong();
326 : };
327 :
328 :
329 : namespace TestInterfaceIterableDoubleBinding {
330 :
331 : typedef mozilla::dom::TestInterfaceIterableDouble NativeType;
332 :
333 : bool
334 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
335 :
336 : JSObject*
337 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
338 :
339 : const JSClass*
340 : GetJSClass();
341 :
342 : bool
343 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceIterableDouble* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
344 :
345 : template <class T>
346 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
347 : {
348 0 : JS::Rooted<JSObject*> reflector(aCx);
349 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
350 : }
351 :
352 : // We declare this as an array so that retrieving a pointer to this
353 : // binding's property hooks only requires compile/link-time resolvable
354 : // address arithmetic. Declaring it as a pointer instead would require
355 : // doing a run-time load to fetch a pointer to this binding's property
356 : // hooks. And then structures which embedded a pointer to this structure
357 : // would require a run-time load for proper initialization, which would
358 : // then induce static constructors. Lots of static constructors.
359 : extern const NativePropertyHooks sNativePropertyHooks[];
360 :
361 : void
362 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
363 :
364 : JS::Handle<JSObject*>
365 : GetProtoObjectHandle(JSContext* aCx);
366 :
367 : JS::Handle<JSObject*>
368 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
369 :
370 : JSObject*
371 : GetConstructorObject(JSContext* aCx);
372 :
373 : } // namespace TestInterfaceIterableDoubleBinding
374 :
375 :
376 :
377 : namespace TestInterfaceIterableDoubleIteratorBinding {
378 :
379 : typedef mozilla::dom::IterableIterator<mozilla::dom::TestInterfaceIterableDouble> NativeType;
380 :
381 : const JSClass*
382 : GetJSClass();
383 :
384 : bool
385 : Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::TestInterfaceIterableDouble>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
386 :
387 : // We declare this as an array so that retrieving a pointer to this
388 : // binding's property hooks only requires compile/link-time resolvable
389 : // address arithmetic. Declaring it as a pointer instead would require
390 : // doing a run-time load to fetch a pointer to this binding's property
391 : // hooks. And then structures which embedded a pointer to this structure
392 : // would require a run-time load for proper initialization, which would
393 : // then induce static constructors. Lots of static constructors.
394 : extern const NativePropertyHooks sNativePropertyHooks[];
395 :
396 : void
397 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
398 :
399 : JS::Handle<JSObject*>
400 : GetProtoObjectHandle(JSContext* aCx);
401 :
402 : } // namespace TestInterfaceIterableDoubleIteratorBinding
403 :
404 :
405 :
406 : namespace TestInterfaceIterableDoubleUnionBinding {
407 :
408 : typedef mozilla::dom::TestInterfaceIterableDoubleUnion NativeType;
409 :
410 : bool
411 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
412 :
413 : JSObject*
414 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
415 :
416 : const JSClass*
417 : GetJSClass();
418 :
419 : bool
420 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceIterableDoubleUnion* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
421 :
422 : template <class T>
423 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
424 : {
425 0 : JS::Rooted<JSObject*> reflector(aCx);
426 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
427 : }
428 :
429 : // We declare this as an array so that retrieving a pointer to this
430 : // binding's property hooks only requires compile/link-time resolvable
431 : // address arithmetic. Declaring it as a pointer instead would require
432 : // doing a run-time load to fetch a pointer to this binding's property
433 : // hooks. And then structures which embedded a pointer to this structure
434 : // would require a run-time load for proper initialization, which would
435 : // then induce static constructors. Lots of static constructors.
436 : extern const NativePropertyHooks sNativePropertyHooks[];
437 :
438 : void
439 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
440 :
441 : JS::Handle<JSObject*>
442 : GetProtoObjectHandle(JSContext* aCx);
443 :
444 : JS::Handle<JSObject*>
445 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
446 :
447 : JSObject*
448 : GetConstructorObject(JSContext* aCx);
449 :
450 : } // namespace TestInterfaceIterableDoubleUnionBinding
451 :
452 :
453 :
454 : namespace TestInterfaceIterableDoubleUnionIteratorBinding {
455 :
456 : typedef mozilla::dom::IterableIterator<mozilla::dom::TestInterfaceIterableDoubleUnion> NativeType;
457 :
458 : const JSClass*
459 : GetJSClass();
460 :
461 : bool
462 : Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::TestInterfaceIterableDoubleUnion>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
463 :
464 : // We declare this as an array so that retrieving a pointer to this
465 : // binding's property hooks only requires compile/link-time resolvable
466 : // address arithmetic. Declaring it as a pointer instead would require
467 : // doing a run-time load to fetch a pointer to this binding's property
468 : // hooks. And then structures which embedded a pointer to this structure
469 : // would require a run-time load for proper initialization, which would
470 : // then induce static constructors. Lots of static constructors.
471 : extern const NativePropertyHooks sNativePropertyHooks[];
472 :
473 : void
474 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
475 :
476 : JS::Handle<JSObject*>
477 : GetProtoObjectHandle(JSContext* aCx);
478 :
479 : } // namespace TestInterfaceIterableDoubleUnionIteratorBinding
480 :
481 :
482 :
483 : namespace TestInterfaceIterableSingleBinding {
484 :
485 : typedef mozilla::dom::TestInterfaceIterableSingle NativeType;
486 :
487 : bool
488 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
489 :
490 : JSObject*
491 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
492 :
493 : bool
494 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceIterableSingle* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
495 :
496 : template <class T>
497 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
498 : {
499 0 : JS::Rooted<JSObject*> reflector(aCx);
500 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
501 : }
502 :
503 : // We declare this as an array so that retrieving a pointer to this
504 : // binding's property hooks only requires compile/link-time resolvable
505 : // address arithmetic. Declaring it as a pointer instead would require
506 : // doing a run-time load to fetch a pointer to this binding's property
507 : // hooks. And then structures which embedded a pointer to this structure
508 : // would require a run-time load for proper initialization, which would
509 : // then induce static constructors. Lots of static constructors.
510 : extern const NativePropertyHooks sNativePropertyHooks[];
511 :
512 : void
513 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
514 :
515 : JS::Handle<JSObject*>
516 : GetProtoObjectHandle(JSContext* aCx);
517 :
518 : JS::Handle<JSObject*>
519 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
520 :
521 : JSObject*
522 : GetConstructorObject(JSContext* aCx);
523 :
524 : } // namespace TestInterfaceIterableSingleBinding
525 :
526 :
527 :
528 : namespace TestInterfaceJSMaplikeBinding {
529 :
530 : typedef mozilla::dom::TestInterfaceJSMaplike NativeType;
531 :
532 : namespace MaplikeHelpers {
533 : void
534 : Clear(mozilla::dom::TestInterfaceJSMaplike* self, ErrorResult& aRv);
535 : bool
536 : Delete(mozilla::dom::TestInterfaceJSMaplike* self, const nsAString& aKey, ErrorResult& aRv);
537 : bool
538 : Has(mozilla::dom::TestInterfaceJSMaplike* self, const nsAString& aKey, ErrorResult& aRv);
539 : void
540 : Set(mozilla::dom::TestInterfaceJSMaplike* self, const nsAString& aKey, int32_t aValue, ErrorResult& aRv);
541 : } // namespace MaplikeHelpers
542 :
543 : bool
544 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
545 :
546 : JSObject*
547 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
548 :
549 : const JSClass*
550 : GetJSClass();
551 :
552 : bool
553 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceJSMaplike* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
554 :
555 : template <class T>
556 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
557 : {
558 0 : JS::Rooted<JSObject*> reflector(aCx);
559 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
560 : }
561 :
562 : // We declare this as an array so that retrieving a pointer to this
563 : // binding's property hooks only requires compile/link-time resolvable
564 : // address arithmetic. Declaring it as a pointer instead would require
565 : // doing a run-time load to fetch a pointer to this binding's property
566 : // hooks. And then structures which embedded a pointer to this structure
567 : // would require a run-time load for proper initialization, which would
568 : // then induce static constructors. Lots of static constructors.
569 : extern const NativePropertyHooks sNativePropertyHooks[];
570 :
571 : void
572 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
573 :
574 : JS::Handle<JSObject*>
575 : GetProtoObjectHandle(JSContext* aCx);
576 :
577 : JS::Handle<JSObject*>
578 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
579 :
580 : JSObject*
581 : GetConstructorObject(JSContext* aCx);
582 :
583 : } // namespace TestInterfaceJSMaplikeBinding
584 :
585 :
586 :
587 : namespace TestInterfaceMaplikeBinding {
588 :
589 : typedef mozilla::dom::TestInterfaceMaplike NativeType;
590 :
591 : namespace MaplikeHelpers {
592 : void
593 : Clear(mozilla::dom::TestInterfaceMaplike* self, ErrorResult& aRv);
594 : bool
595 : Delete(mozilla::dom::TestInterfaceMaplike* self, const nsAString& aKey, ErrorResult& aRv);
596 : bool
597 : Has(mozilla::dom::TestInterfaceMaplike* self, const nsAString& aKey, ErrorResult& aRv);
598 : void
599 : Set(mozilla::dom::TestInterfaceMaplike* self, const nsAString& aKey, int32_t aValue, ErrorResult& aRv);
600 : } // namespace MaplikeHelpers
601 :
602 : bool
603 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
604 :
605 : JSObject*
606 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
607 :
608 : const JSClass*
609 : GetJSClass();
610 :
611 : bool
612 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceMaplike* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
613 :
614 : template <class T>
615 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
616 : {
617 0 : JS::Rooted<JSObject*> reflector(aCx);
618 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
619 : }
620 :
621 : // We declare this as an array so that retrieving a pointer to this
622 : // binding's property hooks only requires compile/link-time resolvable
623 : // address arithmetic. Declaring it as a pointer instead would require
624 : // doing a run-time load to fetch a pointer to this binding's property
625 : // hooks. And then structures which embedded a pointer to this structure
626 : // would require a run-time load for proper initialization, which would
627 : // then induce static constructors. Lots of static constructors.
628 : extern const NativePropertyHooks sNativePropertyHooks[];
629 :
630 : void
631 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
632 :
633 : JS::Handle<JSObject*>
634 : GetProtoObjectHandle(JSContext* aCx);
635 :
636 : JS::Handle<JSObject*>
637 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
638 :
639 : JSObject*
640 : GetConstructorObject(JSContext* aCx);
641 :
642 : } // namespace TestInterfaceMaplikeBinding
643 :
644 :
645 :
646 : namespace TestInterfaceMaplikeObjectBinding {
647 :
648 : typedef mozilla::dom::TestInterfaceMaplikeObject NativeType;
649 :
650 : namespace MaplikeHelpers {
651 : void
652 : Clear(mozilla::dom::TestInterfaceMaplikeObject* self, ErrorResult& aRv);
653 : bool
654 : Delete(mozilla::dom::TestInterfaceMaplikeObject* self, const nsAString& aKey, ErrorResult& aRv);
655 : bool
656 : Has(mozilla::dom::TestInterfaceMaplikeObject* self, const nsAString& aKey, ErrorResult& aRv);
657 : void
658 : Set(mozilla::dom::TestInterfaceMaplikeObject* self, const nsAString& aKey, TestInterfaceMaplike& aValue, ErrorResult& aRv);
659 : } // namespace MaplikeHelpers
660 :
661 : bool
662 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
663 :
664 : JSObject*
665 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
666 :
667 : const JSClass*
668 : GetJSClass();
669 :
670 : bool
671 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceMaplikeObject* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
672 :
673 : template <class T>
674 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
675 : {
676 0 : JS::Rooted<JSObject*> reflector(aCx);
677 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
678 : }
679 :
680 : // We declare this as an array so that retrieving a pointer to this
681 : // binding's property hooks only requires compile/link-time resolvable
682 : // address arithmetic. Declaring it as a pointer instead would require
683 : // doing a run-time load to fetch a pointer to this binding's property
684 : // hooks. And then structures which embedded a pointer to this structure
685 : // would require a run-time load for proper initialization, which would
686 : // then induce static constructors. Lots of static constructors.
687 : extern const NativePropertyHooks sNativePropertyHooks[];
688 :
689 : void
690 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
691 :
692 : JS::Handle<JSObject*>
693 : GetProtoObjectHandle(JSContext* aCx);
694 :
695 : JS::Handle<JSObject*>
696 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
697 :
698 : JSObject*
699 : GetConstructorObject(JSContext* aCx);
700 :
701 : } // namespace TestInterfaceMaplikeObjectBinding
702 :
703 :
704 :
705 : namespace TestInterfaceSetlikeBinding {
706 :
707 : typedef mozilla::dom::TestInterfaceSetlike NativeType;
708 :
709 : namespace SetlikeHelpers {
710 : void
711 : Clear(mozilla::dom::TestInterfaceSetlike* self, ErrorResult& aRv);
712 : bool
713 : Delete(mozilla::dom::TestInterfaceSetlike* self, const nsAString& aKey, ErrorResult& aRv);
714 : bool
715 : Has(mozilla::dom::TestInterfaceSetlike* self, const nsAString& aKey, ErrorResult& aRv);
716 : void
717 : Add(mozilla::dom::TestInterfaceSetlike* self, const nsAString& aKey, ErrorResult& aRv);
718 : } // namespace SetlikeHelpers
719 :
720 : bool
721 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
722 :
723 : JSObject*
724 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
725 :
726 : const JSClass*
727 : GetJSClass();
728 :
729 : bool
730 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceSetlike* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
731 :
732 : template <class T>
733 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
734 : {
735 0 : JS::Rooted<JSObject*> reflector(aCx);
736 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
737 : }
738 :
739 : // We declare this as an array so that retrieving a pointer to this
740 : // binding's property hooks only requires compile/link-time resolvable
741 : // address arithmetic. Declaring it as a pointer instead would require
742 : // doing a run-time load to fetch a pointer to this binding's property
743 : // hooks. And then structures which embedded a pointer to this structure
744 : // would require a run-time load for proper initialization, which would
745 : // then induce static constructors. Lots of static constructors.
746 : extern const NativePropertyHooks sNativePropertyHooks[];
747 :
748 : void
749 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
750 :
751 : JS::Handle<JSObject*>
752 : GetProtoObjectHandle(JSContext* aCx);
753 :
754 : JS::Handle<JSObject*>
755 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
756 :
757 : JSObject*
758 : GetConstructorObject(JSContext* aCx);
759 :
760 : } // namespace TestInterfaceSetlikeBinding
761 :
762 :
763 :
764 : namespace TestInterfaceSetlikeNodeBinding {
765 :
766 : typedef mozilla::dom::TestInterfaceSetlikeNode NativeType;
767 :
768 : namespace SetlikeHelpers {
769 : void
770 : Clear(mozilla::dom::TestInterfaceSetlikeNode* self, ErrorResult& aRv);
771 : bool
772 : Delete(mozilla::dom::TestInterfaceSetlikeNode* self, nsINode& aKey, ErrorResult& aRv);
773 : bool
774 : Has(mozilla::dom::TestInterfaceSetlikeNode* self, nsINode& aKey, ErrorResult& aRv);
775 : void
776 : Add(mozilla::dom::TestInterfaceSetlikeNode* self, nsINode& aKey, ErrorResult& aRv);
777 : } // namespace SetlikeHelpers
778 :
779 : bool
780 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
781 :
782 : JSObject*
783 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
784 :
785 : const JSClass*
786 : GetJSClass();
787 :
788 : bool
789 : Wrap(JSContext* aCx, mozilla::dom::TestInterfaceSetlikeNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
790 :
791 : template <class T>
792 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
793 : {
794 0 : JS::Rooted<JSObject*> reflector(aCx);
795 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
796 : }
797 :
798 : // We declare this as an array so that retrieving a pointer to this
799 : // binding's property hooks only requires compile/link-time resolvable
800 : // address arithmetic. Declaring it as a pointer instead would require
801 : // doing a run-time load to fetch a pointer to this binding's property
802 : // hooks. And then structures which embedded a pointer to this structure
803 : // would require a run-time load for proper initialization, which would
804 : // then induce static constructors. Lots of static constructors.
805 : extern const NativePropertyHooks sNativePropertyHooks[];
806 :
807 : void
808 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
809 :
810 : JS::Handle<JSObject*>
811 : GetProtoObjectHandle(JSContext* aCx);
812 :
813 : JS::Handle<JSObject*>
814 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
815 :
816 : JSObject*
817 : GetConstructorObject(JSContext* aCx);
818 :
819 : } // namespace TestInterfaceSetlikeNodeBinding
820 :
821 :
822 :
823 0 : class TestInterfaceJSMaplikeJSImpl : public CallbackInterface
824 : {
825 : public:
826 0 : explicit inline TestInterfaceJSMaplikeJSImpl(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
827 0 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
828 : {
829 0 : }
830 :
831 : explicit inline TestInterfaceJSMaplikeJSImpl(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
832 : : CallbackInterface(aCallback, FastCallbackConstructor())
833 : {
834 : }
835 :
836 : explicit inline TestInterfaceJSMaplikeJSImpl(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
837 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
838 : {
839 : }
840 :
841 : void SetInternal(const nsAString& aKey, int32_t aValue, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
842 :
843 : void ClearInternal(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
844 :
845 : bool DeleteInternal(const nsAString& aKey, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
846 :
847 : void Entries(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
848 :
849 : void Keys(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
850 :
851 : void Values(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
852 :
853 : void ForEach(JS::Handle<JSObject*> callback, JS::Handle<JS::Value> thisArg, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
854 :
855 : bool Has(const nsAString& key, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
856 :
857 : void __clear(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
858 :
859 : bool __delete(const nsAString& key, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
860 :
861 : void Get(const nsAString& key, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
862 :
863 : void __set(const nsAString& key, int32_t value, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
864 :
865 : void __Init(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
866 :
867 : inline bool
868 : operator==(const TestInterfaceJSMaplikeJSImpl& aOther) const
869 : {
870 : return CallbackInterface::operator==(aOther);
871 : }
872 :
873 : uint32_t GetSize(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
874 :
875 : private:
876 : static bool
877 : InitIds(JSContext* cx, TestInterfaceJSMaplikeAtoms* atomsCache);
878 : };
879 :
880 :
881 : class TestInterfaceJSMaplike final : public nsSupportsWeakReference,
882 : public nsWrapperCache
883 : {
884 : public:
885 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
886 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(TestInterfaceJSMaplike)
887 :
888 : private:
889 : RefPtr<TestInterfaceJSMaplikeJSImpl> mImpl;
890 : nsCOMPtr<nsISupports> mParent;
891 :
892 : public:
893 : TestInterfaceJSMaplike(JS::Handle<JSObject*> aJSImplObject, nsIGlobalObject* aParent);
894 :
895 : private:
896 : ~TestInterfaceJSMaplike();
897 :
898 : public:
899 : nsISupports* GetParentObject() const;
900 :
901 : virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
902 :
903 : static already_AddRefed<TestInterfaceJSMaplike> Constructor(const GlobalObject& global, JSContext* cx, ErrorResult& aRv);
904 :
905 : void SetInternal(const nsAString& aKey, int32_t aValue, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
906 :
907 : void ClearInternal(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
908 :
909 : bool DeleteInternal(const nsAString& aKey, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
910 :
911 : uint32_t GetSize(ErrorResult& aRv, JSCompartment* aCompartment = nullptr) const;
912 :
913 : void Entries(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
914 :
915 : void Keys(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
916 :
917 : void Values(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
918 :
919 : void ForEach(JS::Handle<JSObject*> callback, JS::Handle<JS::Value> thisArg, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
920 :
921 : bool Has(const nsAString& key, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
922 :
923 : void __clear(ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
924 :
925 : bool __delete(const nsAString& key, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
926 :
927 : void Get(const nsAString& key, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
928 :
929 : void __set(const nsAString& key, int32_t value, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, JSCompartment* aCompartment = nullptr);
930 :
931 : static bool
932 : _Create(JSContext* cx, unsigned argc, JS::Value* vp);
933 : };
934 :
935 :
936 : } // namespace dom
937 : } // namespace mozilla
938 :
939 : #endif // mozilla_dom_TestInterfaceJSMaplikeSetlikeIterableBinding_h
|