Line data Source code
1 : #ifndef mozilla_dom_UnionTypes_h
2 : #define mozilla_dom_UnionTypes_h
3 :
4 : #include "CustomEventBinding.h"
5 : #include "DOMParserBinding.h"
6 : #include "EventBinding.h"
7 : #include "EventHandlerBinding.h"
8 : #include "jsfriendapi.h"
9 : #include "mozilla/OwningNonNull.h"
10 : #include "mozilla/dom/BindingDeclarations.h"
11 : #include "mozilla/dom/BindingUtils.h"
12 : #include "mozilla/dom/ImageData.h"
13 : #include "mozilla/dom/Record.h"
14 : #include "mozilla/dom/RootedDictionary.h"
15 : #include "mozilla/dom/TypedArray.h"
16 : #include "mozilla/dom/UnionMember.h"
17 :
18 : class nsGenericHTMLElement;
19 : class nsINode;
20 :
21 : namespace mozilla {
22 : namespace dom {
23 :
24 : class CanvasGradient;
25 : class CanvasPattern;
26 : class Directory;
27 : class File;
28 : class HTMLOptGroupElement;
29 : class HTMLOptionElement;
30 : class OwningCanvasPatternOrCanvasGradient;
31 : class OwningCanvasPatternOrNullOrCanvasGradient;
32 : class OwningEventHandlerNonNullOrNullOrLong;
33 : class OwningFileOrDirectory;
34 : class OwningHTMLElementOrLong;
35 : class OwningHTMLOptionElementOrHTMLOptGroupElement;
36 : class OwningImageDataOrNullSequenceOrLong;
37 : class OwningImageDataOrNullSequenceSequenceOrLong;
38 : class OwningImageDataSequenceOrLong;
39 : class OwningImageDataSequenceSequenceOrLong;
40 : class OwningNodeOrLongOrBoolean;
41 : class OwningNodeOrString;
42 :
43 : } // namespace dom
44 : } // namespace mozilla
45 :
46 : namespace mozilla {
47 : namespace dom {
48 : void
49 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningCanvasPatternOrCanvasGradient& aUnion, const char* aName, uint32_t aFlags = 0);
50 :
51 : void
52 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningCanvasPatternOrNullOrCanvasGradient& aUnion, const char* aName, uint32_t aFlags = 0);
53 :
54 : void
55 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningEventHandlerNonNullOrNullOrLong& aUnion, const char* aName, uint32_t aFlags = 0);
56 :
57 : void
58 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningFileOrDirectory& aUnion, const char* aName, uint32_t aFlags = 0);
59 :
60 : void
61 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHTMLElementOrLong& aUnion, const char* aName, uint32_t aFlags = 0);
62 :
63 : void
64 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHTMLOptionElementOrHTMLOptGroupElement& aUnion, const char* aName, uint32_t aFlags = 0);
65 :
66 : void
67 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningImageDataOrNullSequenceOrLong& aUnion, const char* aName, uint32_t aFlags = 0);
68 :
69 : void
70 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningImageDataOrNullSequenceSequenceOrLong& aUnion, const char* aName, uint32_t aFlags = 0);
71 :
72 : void
73 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningImageDataSequenceOrLong& aUnion, const char* aName, uint32_t aFlags = 0);
74 :
75 : void
76 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningImageDataSequenceSequenceOrLong& aUnion, const char* aName, uint32_t aFlags = 0);
77 :
78 : void
79 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningNodeOrLongOrBoolean& aUnion, const char* aName, uint32_t aFlags = 0);
80 :
81 : void
82 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningNodeOrString& aUnion, const char* aName, uint32_t aFlags = 0);
83 :
84 : void
85 : ImplCycleCollectionUnlink(OwningCanvasPatternOrCanvasGradient& aUnion);
86 :
87 : void
88 : ImplCycleCollectionUnlink(OwningCanvasPatternOrNullOrCanvasGradient& aUnion);
89 :
90 : void
91 : ImplCycleCollectionUnlink(OwningEventHandlerNonNullOrNullOrLong& aUnion);
92 :
93 : void
94 : ImplCycleCollectionUnlink(OwningFileOrDirectory& aUnion);
95 :
96 : void
97 : ImplCycleCollectionUnlink(OwningHTMLElementOrLong& aUnion);
98 :
99 : void
100 : ImplCycleCollectionUnlink(OwningHTMLOptionElementOrHTMLOptGroupElement& aUnion);
101 :
102 : void
103 : ImplCycleCollectionUnlink(OwningImageDataOrNullSequenceOrLong& aUnion);
104 :
105 : void
106 : ImplCycleCollectionUnlink(OwningImageDataOrNullSequenceSequenceOrLong& aUnion);
107 :
108 : void
109 : ImplCycleCollectionUnlink(OwningImageDataSequenceOrLong& aUnion);
110 :
111 : void
112 : ImplCycleCollectionUnlink(OwningImageDataSequenceSequenceOrLong& aUnion);
113 :
114 : void
115 : ImplCycleCollectionUnlink(OwningNodeOrLongOrBoolean& aUnion);
116 :
117 : void
118 : ImplCycleCollectionUnlink(OwningNodeOrString& aUnion);
119 :
120 : class ArrayBufferOrLong
121 : {
122 : friend class ArrayBufferOrLongArgument;
123 : enum Type
124 : {
125 : eUninitialized,
126 : eArrayBuffer,
127 : eLong
128 : };
129 :
130 : union Value
131 : {
132 : UnionMember<RootedTypedArray<ArrayBuffer> > mArrayBuffer;
133 : UnionMember<int32_t > mLong;
134 :
135 : };
136 :
137 : Type mType;
138 : Value mValue;
139 :
140 : ArrayBufferOrLong(const ArrayBufferOrLong&) = delete;
141 : ArrayBufferOrLong& operator=(const ArrayBufferOrLong&) = delete;
142 : public:
143 : explicit inline ArrayBufferOrLong()
144 : : mType(eUninitialized)
145 : {
146 : }
147 :
148 : inline ~ArrayBufferOrLong()
149 : {
150 : Uninit();
151 : }
152 :
153 : inline RootedTypedArray<ArrayBuffer>&
154 : RawSetAsArrayBuffer(JSContext* cx)
155 : {
156 : if (mType == eArrayBuffer) {
157 : return mValue.mArrayBuffer.Value();
158 : }
159 : MOZ_ASSERT(mType == eUninitialized);
160 : mType = eArrayBuffer;
161 : return mValue.mArrayBuffer.SetValue(cx);
162 : }
163 :
164 : inline RootedTypedArray<ArrayBuffer>&
165 : SetAsArrayBuffer(JSContext* cx)
166 : {
167 : if (mType == eArrayBuffer) {
168 : return mValue.mArrayBuffer.Value();
169 : }
170 : Uninit();
171 : mType = eArrayBuffer;
172 : return mValue.mArrayBuffer.SetValue(cx);
173 : }
174 :
175 : inline bool
176 : IsArrayBuffer() const
177 : {
178 : return mType == eArrayBuffer;
179 : }
180 :
181 : inline RootedTypedArray<ArrayBuffer>&
182 : GetAsArrayBuffer()
183 : {
184 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
185 : return mValue.mArrayBuffer.Value();
186 : }
187 :
188 : inline ArrayBuffer const &
189 : GetAsArrayBuffer() const
190 : {
191 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
192 : return mValue.mArrayBuffer.Value();
193 : }
194 :
195 : inline int32_t&
196 : RawSetAsLong()
197 : {
198 : if (mType == eLong) {
199 : return mValue.mLong.Value();
200 : }
201 : MOZ_ASSERT(mType == eUninitialized);
202 : mType = eLong;
203 : return mValue.mLong.SetValue();
204 : }
205 :
206 : inline int32_t&
207 : SetAsLong()
208 : {
209 : if (mType == eLong) {
210 : return mValue.mLong.Value();
211 : }
212 : Uninit();
213 : mType = eLong;
214 : return mValue.mLong.SetValue();
215 : }
216 :
217 : inline bool
218 : IsLong() const
219 : {
220 : return mType == eLong;
221 : }
222 :
223 : inline int32_t&
224 : GetAsLong()
225 : {
226 : MOZ_ASSERT(IsLong(), "Wrong type!");
227 : return mValue.mLong.Value();
228 : }
229 :
230 : inline int32_t
231 : GetAsLong() const
232 : {
233 : MOZ_ASSERT(IsLong(), "Wrong type!");
234 : return mValue.mLong.Value();
235 : }
236 :
237 : inline void
238 : Uninit()
239 : {
240 : switch (mType) {
241 : case eUninitialized: {
242 : break;
243 : }
244 : case eArrayBuffer: {
245 : DestroyArrayBuffer();
246 : break;
247 : }
248 : case eLong: {
249 : DestroyLong();
250 : break;
251 : }
252 : }
253 : }
254 :
255 : bool
256 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
257 :
258 : private:
259 : inline void
260 : DestroyArrayBuffer()
261 : {
262 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
263 : mValue.mArrayBuffer.Destroy();
264 : mType = eUninitialized;
265 : }
266 :
267 : inline void
268 : DestroyLong()
269 : {
270 : MOZ_ASSERT(IsLong(), "Wrong type!");
271 : mValue.mLong.Destroy();
272 : mType = eUninitialized;
273 : }
274 : };
275 :
276 : class ArrayBufferViewOrArrayBuffer
277 : {
278 : friend class ArrayBufferViewOrArrayBufferArgument;
279 : enum Type
280 : {
281 : eUninitialized,
282 : eArrayBufferView,
283 : eArrayBuffer
284 : };
285 :
286 0 : union Value
287 : {
288 : UnionMember<RootedTypedArray<ArrayBufferView> > mArrayBufferView;
289 : UnionMember<RootedTypedArray<ArrayBuffer> > mArrayBuffer;
290 :
291 : };
292 :
293 : Type mType;
294 : Value mValue;
295 :
296 : ArrayBufferViewOrArrayBuffer(const ArrayBufferViewOrArrayBuffer&) = delete;
297 : ArrayBufferViewOrArrayBuffer& operator=(const ArrayBufferViewOrArrayBuffer&) = delete;
298 : public:
299 0 : explicit inline ArrayBufferViewOrArrayBuffer()
300 0 : : mType(eUninitialized)
301 : {
302 0 : }
303 :
304 0 : inline ~ArrayBufferViewOrArrayBuffer()
305 0 : {
306 0 : Uninit();
307 0 : }
308 :
309 : inline RootedTypedArray<ArrayBufferView>&
310 : RawSetAsArrayBufferView(JSContext* cx)
311 : {
312 : if (mType == eArrayBufferView) {
313 : return mValue.mArrayBufferView.Value();
314 : }
315 : MOZ_ASSERT(mType == eUninitialized);
316 : mType = eArrayBufferView;
317 : return mValue.mArrayBufferView.SetValue(cx);
318 : }
319 :
320 : inline RootedTypedArray<ArrayBufferView>&
321 : SetAsArrayBufferView(JSContext* cx)
322 : {
323 : if (mType == eArrayBufferView) {
324 : return mValue.mArrayBufferView.Value();
325 : }
326 : Uninit();
327 : mType = eArrayBufferView;
328 : return mValue.mArrayBufferView.SetValue(cx);
329 : }
330 :
331 : inline bool
332 0 : IsArrayBufferView() const
333 : {
334 0 : return mType == eArrayBufferView;
335 : }
336 :
337 : inline RootedTypedArray<ArrayBufferView>&
338 : GetAsArrayBufferView()
339 : {
340 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
341 : return mValue.mArrayBufferView.Value();
342 : }
343 :
344 : inline ArrayBufferView const &
345 0 : GetAsArrayBufferView() const
346 : {
347 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
348 0 : return mValue.mArrayBufferView.Value();
349 : }
350 :
351 : inline RootedTypedArray<ArrayBuffer>&
352 : RawSetAsArrayBuffer(JSContext* cx)
353 : {
354 : if (mType == eArrayBuffer) {
355 : return mValue.mArrayBuffer.Value();
356 : }
357 : MOZ_ASSERT(mType == eUninitialized);
358 : mType = eArrayBuffer;
359 : return mValue.mArrayBuffer.SetValue(cx);
360 : }
361 :
362 : inline RootedTypedArray<ArrayBuffer>&
363 0 : SetAsArrayBuffer(JSContext* cx)
364 : {
365 0 : if (mType == eArrayBuffer) {
366 0 : return mValue.mArrayBuffer.Value();
367 : }
368 0 : Uninit();
369 0 : mType = eArrayBuffer;
370 0 : return mValue.mArrayBuffer.SetValue(cx);
371 : }
372 :
373 : inline bool
374 0 : IsArrayBuffer() const
375 : {
376 0 : return mType == eArrayBuffer;
377 : }
378 :
379 : inline RootedTypedArray<ArrayBuffer>&
380 : GetAsArrayBuffer()
381 : {
382 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
383 : return mValue.mArrayBuffer.Value();
384 : }
385 :
386 : inline ArrayBuffer const &
387 0 : GetAsArrayBuffer() const
388 : {
389 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
390 0 : return mValue.mArrayBuffer.Value();
391 : }
392 :
393 : inline void
394 0 : Uninit()
395 : {
396 0 : switch (mType) {
397 : case eUninitialized: {
398 0 : break;
399 : }
400 : case eArrayBufferView: {
401 0 : DestroyArrayBufferView();
402 0 : break;
403 : }
404 : case eArrayBuffer: {
405 0 : DestroyArrayBuffer();
406 0 : break;
407 : }
408 : }
409 0 : }
410 :
411 : bool
412 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
413 :
414 : private:
415 : inline void
416 0 : DestroyArrayBufferView()
417 : {
418 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
419 0 : mValue.mArrayBufferView.Destroy();
420 0 : mType = eUninitialized;
421 0 : }
422 :
423 : inline void
424 0 : DestroyArrayBuffer()
425 : {
426 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
427 0 : mValue.mArrayBuffer.Destroy();
428 0 : mType = eUninitialized;
429 0 : }
430 : };
431 :
432 : class ByteStringOrLong
433 : {
434 : friend class ByteStringOrLongArgument;
435 : enum Type
436 : {
437 : eUninitialized,
438 : eByteString,
439 : eLong
440 : };
441 :
442 : union Value
443 : {
444 : UnionMember<nsCString > mByteString;
445 : UnionMember<int32_t > mLong;
446 :
447 : };
448 :
449 : Type mType;
450 : Value mValue;
451 :
452 : ByteStringOrLong(const ByteStringOrLong&) = delete;
453 : ByteStringOrLong& operator=(const ByteStringOrLong&) = delete;
454 : public:
455 : explicit inline ByteStringOrLong()
456 : : mType(eUninitialized)
457 : {
458 : }
459 :
460 : inline ~ByteStringOrLong()
461 : {
462 : Uninit();
463 : }
464 :
465 : inline nsCString&
466 : RawSetAsByteString()
467 : {
468 : if (mType == eByteString) {
469 : return mValue.mByteString.Value();
470 : }
471 : MOZ_ASSERT(mType == eUninitialized);
472 : mType = eByteString;
473 : return mValue.mByteString.SetValue();
474 : }
475 :
476 : inline nsCString&
477 : SetAsByteString()
478 : {
479 : if (mType == eByteString) {
480 : return mValue.mByteString.Value();
481 : }
482 : Uninit();
483 : mType = eByteString;
484 : return mValue.mByteString.SetValue();
485 : }
486 :
487 : inline bool
488 : IsByteString() const
489 : {
490 : return mType == eByteString;
491 : }
492 :
493 : inline nsCString&
494 : GetAsByteString()
495 : {
496 : MOZ_ASSERT(IsByteString(), "Wrong type!");
497 : return mValue.mByteString.Value();
498 : }
499 :
500 : inline const nsCString&
501 : GetAsByteString() const
502 : {
503 : MOZ_ASSERT(IsByteString(), "Wrong type!");
504 : return mValue.mByteString.Value();
505 : }
506 :
507 : inline int32_t&
508 : RawSetAsLong()
509 : {
510 : if (mType == eLong) {
511 : return mValue.mLong.Value();
512 : }
513 : MOZ_ASSERT(mType == eUninitialized);
514 : mType = eLong;
515 : return mValue.mLong.SetValue();
516 : }
517 :
518 : inline int32_t&
519 : SetAsLong()
520 : {
521 : if (mType == eLong) {
522 : return mValue.mLong.Value();
523 : }
524 : Uninit();
525 : mType = eLong;
526 : return mValue.mLong.SetValue();
527 : }
528 :
529 : inline bool
530 : IsLong() const
531 : {
532 : return mType == eLong;
533 : }
534 :
535 : inline int32_t&
536 : GetAsLong()
537 : {
538 : MOZ_ASSERT(IsLong(), "Wrong type!");
539 : return mValue.mLong.Value();
540 : }
541 :
542 : inline int32_t
543 : GetAsLong() const
544 : {
545 : MOZ_ASSERT(IsLong(), "Wrong type!");
546 : return mValue.mLong.Value();
547 : }
548 :
549 : inline void
550 : Uninit()
551 : {
552 : switch (mType) {
553 : case eUninitialized: {
554 : break;
555 : }
556 : case eByteString: {
557 : DestroyByteString();
558 : break;
559 : }
560 : case eLong: {
561 : DestroyLong();
562 : break;
563 : }
564 : }
565 : }
566 :
567 : bool
568 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
569 :
570 : private:
571 : inline void
572 : DestroyByteString()
573 : {
574 : MOZ_ASSERT(IsByteString(), "Wrong type!");
575 : mValue.mByteString.Destroy();
576 : mType = eUninitialized;
577 : }
578 :
579 : inline void
580 : DestroyLong()
581 : {
582 : MOZ_ASSERT(IsLong(), "Wrong type!");
583 : mValue.mLong.Destroy();
584 : mType = eUninitialized;
585 : }
586 : };
587 :
588 : class CanvasPatternOrCanvasGradient
589 : {
590 : friend class CanvasPatternOrCanvasGradientArgument;
591 : enum Type
592 : {
593 : eUninitialized,
594 : eCanvasPattern,
595 : eCanvasGradient
596 : };
597 :
598 : union Value
599 : {
600 : UnionMember<NonNull<mozilla::dom::CanvasPattern> > mCanvasPattern;
601 : UnionMember<NonNull<mozilla::dom::CanvasGradient> > mCanvasGradient;
602 :
603 : };
604 :
605 : Type mType;
606 : Value mValue;
607 :
608 : CanvasPatternOrCanvasGradient(const CanvasPatternOrCanvasGradient&) = delete;
609 : CanvasPatternOrCanvasGradient& operator=(const CanvasPatternOrCanvasGradient&) = delete;
610 : public:
611 : explicit inline CanvasPatternOrCanvasGradient()
612 : : mType(eUninitialized)
613 : {
614 : }
615 :
616 : inline ~CanvasPatternOrCanvasGradient()
617 : {
618 : Uninit();
619 : }
620 :
621 : inline NonNull<mozilla::dom::CanvasPattern>&
622 : RawSetAsCanvasPattern()
623 : {
624 : if (mType == eCanvasPattern) {
625 : return mValue.mCanvasPattern.Value();
626 : }
627 : MOZ_ASSERT(mType == eUninitialized);
628 : mType = eCanvasPattern;
629 : return mValue.mCanvasPattern.SetValue();
630 : }
631 :
632 : inline NonNull<mozilla::dom::CanvasPattern>&
633 : SetAsCanvasPattern()
634 : {
635 : if (mType == eCanvasPattern) {
636 : return mValue.mCanvasPattern.Value();
637 : }
638 : Uninit();
639 : mType = eCanvasPattern;
640 : return mValue.mCanvasPattern.SetValue();
641 : }
642 :
643 : inline bool
644 : IsCanvasPattern() const
645 : {
646 : return mType == eCanvasPattern;
647 : }
648 :
649 : inline NonNull<mozilla::dom::CanvasPattern>&
650 : GetAsCanvasPattern()
651 : {
652 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
653 : return mValue.mCanvasPattern.Value();
654 : }
655 :
656 : inline mozilla::dom::CanvasPattern&
657 : GetAsCanvasPattern() const
658 : {
659 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
660 : return mValue.mCanvasPattern.Value();
661 : }
662 :
663 : inline NonNull<mozilla::dom::CanvasGradient>&
664 : RawSetAsCanvasGradient()
665 : {
666 : if (mType == eCanvasGradient) {
667 : return mValue.mCanvasGradient.Value();
668 : }
669 : MOZ_ASSERT(mType == eUninitialized);
670 : mType = eCanvasGradient;
671 : return mValue.mCanvasGradient.SetValue();
672 : }
673 :
674 : inline NonNull<mozilla::dom::CanvasGradient>&
675 : SetAsCanvasGradient()
676 : {
677 : if (mType == eCanvasGradient) {
678 : return mValue.mCanvasGradient.Value();
679 : }
680 : Uninit();
681 : mType = eCanvasGradient;
682 : return mValue.mCanvasGradient.SetValue();
683 : }
684 :
685 : inline bool
686 : IsCanvasGradient() const
687 : {
688 : return mType == eCanvasGradient;
689 : }
690 :
691 : inline NonNull<mozilla::dom::CanvasGradient>&
692 : GetAsCanvasGradient()
693 : {
694 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
695 : return mValue.mCanvasGradient.Value();
696 : }
697 :
698 : inline mozilla::dom::CanvasGradient&
699 : GetAsCanvasGradient() const
700 : {
701 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
702 : return mValue.mCanvasGradient.Value();
703 : }
704 :
705 : inline void
706 : Uninit()
707 : {
708 : switch (mType) {
709 : case eUninitialized: {
710 : break;
711 : }
712 : case eCanvasPattern: {
713 : DestroyCanvasPattern();
714 : break;
715 : }
716 : case eCanvasGradient: {
717 : DestroyCanvasGradient();
718 : break;
719 : }
720 : }
721 : }
722 :
723 : bool
724 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
725 :
726 : private:
727 : inline void
728 : DestroyCanvasPattern()
729 : {
730 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
731 : mValue.mCanvasPattern.Destroy();
732 : mType = eUninitialized;
733 : }
734 :
735 : inline void
736 : DestroyCanvasGradient()
737 : {
738 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
739 : mValue.mCanvasGradient.Destroy();
740 : mType = eUninitialized;
741 : }
742 : };
743 :
744 : class CanvasPatternOrNullOrCanvasGradient
745 : {
746 : friend class CanvasPatternOrNullOrCanvasGradientArgument;
747 : enum Type
748 : {
749 : eUninitialized,
750 : eNull,
751 : eCanvasPattern,
752 : eCanvasGradient
753 : };
754 :
755 : union Value
756 : {
757 : UnionMember<NonNull<mozilla::dom::CanvasPattern> > mCanvasPattern;
758 : UnionMember<NonNull<mozilla::dom::CanvasGradient> > mCanvasGradient;
759 :
760 : };
761 :
762 : Type mType;
763 : Value mValue;
764 :
765 : CanvasPatternOrNullOrCanvasGradient(const CanvasPatternOrNullOrCanvasGradient&) = delete;
766 : CanvasPatternOrNullOrCanvasGradient& operator=(const CanvasPatternOrNullOrCanvasGradient&) = delete;
767 : public:
768 : explicit inline CanvasPatternOrNullOrCanvasGradient()
769 : : mType(eUninitialized)
770 : {
771 : }
772 :
773 : inline ~CanvasPatternOrNullOrCanvasGradient()
774 : {
775 : Uninit();
776 : }
777 :
778 : inline bool
779 : IsNull() const
780 : {
781 : return mType == eNull;
782 : }
783 :
784 : inline void
785 : SetNull()
786 : {
787 : Uninit();
788 : mType = eNull;
789 : }
790 :
791 : inline NonNull<mozilla::dom::CanvasPattern>&
792 : RawSetAsCanvasPattern()
793 : {
794 : if (mType == eCanvasPattern) {
795 : return mValue.mCanvasPattern.Value();
796 : }
797 : MOZ_ASSERT(mType == eUninitialized);
798 : mType = eCanvasPattern;
799 : return mValue.mCanvasPattern.SetValue();
800 : }
801 :
802 : inline NonNull<mozilla::dom::CanvasPattern>&
803 : SetAsCanvasPattern()
804 : {
805 : if (mType == eCanvasPattern) {
806 : return mValue.mCanvasPattern.Value();
807 : }
808 : Uninit();
809 : mType = eCanvasPattern;
810 : return mValue.mCanvasPattern.SetValue();
811 : }
812 :
813 : inline bool
814 : IsCanvasPattern() const
815 : {
816 : return mType == eCanvasPattern;
817 : }
818 :
819 : inline NonNull<mozilla::dom::CanvasPattern>&
820 : GetAsCanvasPattern()
821 : {
822 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
823 : return mValue.mCanvasPattern.Value();
824 : }
825 :
826 : inline mozilla::dom::CanvasPattern&
827 : GetAsCanvasPattern() const
828 : {
829 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
830 : return mValue.mCanvasPattern.Value();
831 : }
832 :
833 : inline NonNull<mozilla::dom::CanvasGradient>&
834 : RawSetAsCanvasGradient()
835 : {
836 : if (mType == eCanvasGradient) {
837 : return mValue.mCanvasGradient.Value();
838 : }
839 : MOZ_ASSERT(mType == eUninitialized);
840 : mType = eCanvasGradient;
841 : return mValue.mCanvasGradient.SetValue();
842 : }
843 :
844 : inline NonNull<mozilla::dom::CanvasGradient>&
845 : SetAsCanvasGradient()
846 : {
847 : if (mType == eCanvasGradient) {
848 : return mValue.mCanvasGradient.Value();
849 : }
850 : Uninit();
851 : mType = eCanvasGradient;
852 : return mValue.mCanvasGradient.SetValue();
853 : }
854 :
855 : inline bool
856 : IsCanvasGradient() const
857 : {
858 : return mType == eCanvasGradient;
859 : }
860 :
861 : inline NonNull<mozilla::dom::CanvasGradient>&
862 : GetAsCanvasGradient()
863 : {
864 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
865 : return mValue.mCanvasGradient.Value();
866 : }
867 :
868 : inline mozilla::dom::CanvasGradient&
869 : GetAsCanvasGradient() const
870 : {
871 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
872 : return mValue.mCanvasGradient.Value();
873 : }
874 :
875 : inline void
876 : Uninit()
877 : {
878 : switch (mType) {
879 : case eUninitialized: {
880 : break;
881 : }
882 : case eNull: {
883 : break;
884 : }
885 : case eCanvasPattern: {
886 : DestroyCanvasPattern();
887 : break;
888 : }
889 : case eCanvasGradient: {
890 : DestroyCanvasGradient();
891 : break;
892 : }
893 : }
894 : }
895 :
896 : bool
897 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
898 :
899 : private:
900 : inline void
901 : DestroyCanvasPattern()
902 : {
903 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
904 : mValue.mCanvasPattern.Destroy();
905 : mType = eUninitialized;
906 : }
907 :
908 : inline void
909 : DestroyCanvasGradient()
910 : {
911 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
912 : mValue.mCanvasGradient.Destroy();
913 : mType = eUninitialized;
914 : }
915 : };
916 :
917 : class CustomEventInitOrLong
918 : {
919 : friend class CustomEventInitOrLongArgument;
920 : enum Type
921 : {
922 : eUninitialized,
923 : eCustomEventInit,
924 : eLong
925 : };
926 :
927 : union Value
928 : {
929 : UnionMember<RootedDictionary<binding_detail::FastCustomEventInit> > mCustomEventInit;
930 : UnionMember<int32_t > mLong;
931 :
932 : };
933 :
934 : Type mType;
935 : Value mValue;
936 :
937 : CustomEventInitOrLong(const CustomEventInitOrLong&) = delete;
938 : CustomEventInitOrLong& operator=(const CustomEventInitOrLong&) = delete;
939 : public:
940 : explicit inline CustomEventInitOrLong()
941 : : mType(eUninitialized)
942 : {
943 : }
944 :
945 : inline ~CustomEventInitOrLong()
946 : {
947 : Uninit();
948 : }
949 :
950 : inline RootedDictionary<binding_detail::FastCustomEventInit>&
951 : RawSetAsCustomEventInit(JSContext* cx)
952 : {
953 : if (mType == eCustomEventInit) {
954 : return mValue.mCustomEventInit.Value();
955 : }
956 : MOZ_ASSERT(mType == eUninitialized);
957 : mType = eCustomEventInit;
958 : return mValue.mCustomEventInit.SetValue(cx);
959 : }
960 :
961 : inline RootedDictionary<binding_detail::FastCustomEventInit>&
962 : SetAsCustomEventInit(JSContext* cx)
963 : {
964 : if (mType == eCustomEventInit) {
965 : return mValue.mCustomEventInit.Value();
966 : }
967 : Uninit();
968 : mType = eCustomEventInit;
969 : return mValue.mCustomEventInit.SetValue(cx);
970 : }
971 :
972 : inline bool
973 : IsCustomEventInit() const
974 : {
975 : return mType == eCustomEventInit;
976 : }
977 :
978 : inline RootedDictionary<binding_detail::FastCustomEventInit>&
979 : GetAsCustomEventInit()
980 : {
981 : MOZ_ASSERT(IsCustomEventInit(), "Wrong type!");
982 : return mValue.mCustomEventInit.Value();
983 : }
984 :
985 : inline const CustomEventInit&
986 : GetAsCustomEventInit() const
987 : {
988 : MOZ_ASSERT(IsCustomEventInit(), "Wrong type!");
989 : return mValue.mCustomEventInit.Value();
990 : }
991 :
992 : inline int32_t&
993 : RawSetAsLong()
994 : {
995 : if (mType == eLong) {
996 : return mValue.mLong.Value();
997 : }
998 : MOZ_ASSERT(mType == eUninitialized);
999 : mType = eLong;
1000 : return mValue.mLong.SetValue();
1001 : }
1002 :
1003 : inline int32_t&
1004 : SetAsLong()
1005 : {
1006 : if (mType == eLong) {
1007 : return mValue.mLong.Value();
1008 : }
1009 : Uninit();
1010 : mType = eLong;
1011 : return mValue.mLong.SetValue();
1012 : }
1013 :
1014 : inline bool
1015 : IsLong() const
1016 : {
1017 : return mType == eLong;
1018 : }
1019 :
1020 : inline int32_t&
1021 : GetAsLong()
1022 : {
1023 : MOZ_ASSERT(IsLong(), "Wrong type!");
1024 : return mValue.mLong.Value();
1025 : }
1026 :
1027 : inline int32_t
1028 : GetAsLong() const
1029 : {
1030 : MOZ_ASSERT(IsLong(), "Wrong type!");
1031 : return mValue.mLong.Value();
1032 : }
1033 :
1034 : inline void
1035 : Uninit()
1036 : {
1037 : switch (mType) {
1038 : case eUninitialized: {
1039 : break;
1040 : }
1041 : case eCustomEventInit: {
1042 : DestroyCustomEventInit();
1043 : break;
1044 : }
1045 : case eLong: {
1046 : DestroyLong();
1047 : break;
1048 : }
1049 : }
1050 : }
1051 :
1052 : bool
1053 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1054 :
1055 : private:
1056 : inline void
1057 : DestroyCustomEventInit()
1058 : {
1059 : MOZ_ASSERT(IsCustomEventInit(), "Wrong type!");
1060 : mValue.mCustomEventInit.Destroy();
1061 : mType = eUninitialized;
1062 : }
1063 :
1064 : inline void
1065 : DestroyLong()
1066 : {
1067 : MOZ_ASSERT(IsLong(), "Wrong type!");
1068 : mValue.mLong.Destroy();
1069 : mType = eUninitialized;
1070 : }
1071 : };
1072 :
1073 : class DoubleOrByteString
1074 : {
1075 : friend class DoubleOrByteStringArgument;
1076 : enum Type
1077 : {
1078 : eUninitialized,
1079 : eDouble,
1080 : eByteString
1081 : };
1082 :
1083 : union Value
1084 : {
1085 : UnionMember<double > mDouble;
1086 : UnionMember<nsCString > mByteString;
1087 :
1088 : };
1089 :
1090 : Type mType;
1091 : Value mValue;
1092 :
1093 : DoubleOrByteString(const DoubleOrByteString&) = delete;
1094 : DoubleOrByteString& operator=(const DoubleOrByteString&) = delete;
1095 : public:
1096 : explicit inline DoubleOrByteString()
1097 : : mType(eUninitialized)
1098 : {
1099 : }
1100 :
1101 : inline ~DoubleOrByteString()
1102 : {
1103 : Uninit();
1104 : }
1105 :
1106 : inline double&
1107 : RawSetAsDouble()
1108 : {
1109 : if (mType == eDouble) {
1110 : return mValue.mDouble.Value();
1111 : }
1112 : MOZ_ASSERT(mType == eUninitialized);
1113 : mType = eDouble;
1114 : return mValue.mDouble.SetValue();
1115 : }
1116 :
1117 : inline double&
1118 : SetAsDouble()
1119 : {
1120 : if (mType == eDouble) {
1121 : return mValue.mDouble.Value();
1122 : }
1123 : Uninit();
1124 : mType = eDouble;
1125 : return mValue.mDouble.SetValue();
1126 : }
1127 :
1128 : inline bool
1129 : IsDouble() const
1130 : {
1131 : return mType == eDouble;
1132 : }
1133 :
1134 : inline double&
1135 : GetAsDouble()
1136 : {
1137 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1138 : return mValue.mDouble.Value();
1139 : }
1140 :
1141 : inline double
1142 : GetAsDouble() const
1143 : {
1144 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1145 : return mValue.mDouble.Value();
1146 : }
1147 :
1148 : inline nsCString&
1149 : RawSetAsByteString()
1150 : {
1151 : if (mType == eByteString) {
1152 : return mValue.mByteString.Value();
1153 : }
1154 : MOZ_ASSERT(mType == eUninitialized);
1155 : mType = eByteString;
1156 : return mValue.mByteString.SetValue();
1157 : }
1158 :
1159 : inline nsCString&
1160 : SetAsByteString()
1161 : {
1162 : if (mType == eByteString) {
1163 : return mValue.mByteString.Value();
1164 : }
1165 : Uninit();
1166 : mType = eByteString;
1167 : return mValue.mByteString.SetValue();
1168 : }
1169 :
1170 : inline bool
1171 : IsByteString() const
1172 : {
1173 : return mType == eByteString;
1174 : }
1175 :
1176 : inline nsCString&
1177 : GetAsByteString()
1178 : {
1179 : MOZ_ASSERT(IsByteString(), "Wrong type!");
1180 : return mValue.mByteString.Value();
1181 : }
1182 :
1183 : inline const nsCString&
1184 : GetAsByteString() const
1185 : {
1186 : MOZ_ASSERT(IsByteString(), "Wrong type!");
1187 : return mValue.mByteString.Value();
1188 : }
1189 :
1190 : inline void
1191 : Uninit()
1192 : {
1193 : switch (mType) {
1194 : case eUninitialized: {
1195 : break;
1196 : }
1197 : case eDouble: {
1198 : DestroyDouble();
1199 : break;
1200 : }
1201 : case eByteString: {
1202 : DestroyByteString();
1203 : break;
1204 : }
1205 : }
1206 : }
1207 :
1208 : bool
1209 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1210 :
1211 : private:
1212 : inline void
1213 : DestroyDouble()
1214 : {
1215 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1216 : mValue.mDouble.Destroy();
1217 : mType = eUninitialized;
1218 : }
1219 :
1220 : inline void
1221 : DestroyByteString()
1222 : {
1223 : MOZ_ASSERT(IsByteString(), "Wrong type!");
1224 : mValue.mByteString.Destroy();
1225 : mType = eUninitialized;
1226 : }
1227 : };
1228 :
1229 : class DoubleOrString
1230 : {
1231 : friend class DoubleOrStringArgument;
1232 : enum Type
1233 : {
1234 : eUninitialized,
1235 : eDouble,
1236 : eString
1237 : };
1238 :
1239 : union Value
1240 : {
1241 : UnionMember<double > mDouble;
1242 : UnionMember<binding_detail::FakeString > mString;
1243 :
1244 : };
1245 :
1246 : Type mType;
1247 : Value mValue;
1248 :
1249 : DoubleOrString(const DoubleOrString&) = delete;
1250 : DoubleOrString& operator=(const DoubleOrString&) = delete;
1251 : public:
1252 : explicit inline DoubleOrString()
1253 : : mType(eUninitialized)
1254 : {
1255 : }
1256 :
1257 : inline ~DoubleOrString()
1258 : {
1259 : Uninit();
1260 : }
1261 :
1262 : inline double&
1263 : RawSetAsDouble()
1264 : {
1265 : if (mType == eDouble) {
1266 : return mValue.mDouble.Value();
1267 : }
1268 : MOZ_ASSERT(mType == eUninitialized);
1269 : mType = eDouble;
1270 : return mValue.mDouble.SetValue();
1271 : }
1272 :
1273 : inline double&
1274 : SetAsDouble()
1275 : {
1276 : if (mType == eDouble) {
1277 : return mValue.mDouble.Value();
1278 : }
1279 : Uninit();
1280 : mType = eDouble;
1281 : return mValue.mDouble.SetValue();
1282 : }
1283 :
1284 : inline bool
1285 : IsDouble() const
1286 : {
1287 : return mType == eDouble;
1288 : }
1289 :
1290 : inline double&
1291 : GetAsDouble()
1292 : {
1293 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1294 : return mValue.mDouble.Value();
1295 : }
1296 :
1297 : inline double
1298 : GetAsDouble() const
1299 : {
1300 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1301 : return mValue.mDouble.Value();
1302 : }
1303 :
1304 : inline binding_detail::FakeString&
1305 : RawSetAsString()
1306 : {
1307 : if (mType == eString) {
1308 : return mValue.mString.Value();
1309 : }
1310 : MOZ_ASSERT(mType == eUninitialized);
1311 : mType = eString;
1312 : return mValue.mString.SetValue();
1313 : }
1314 :
1315 : inline binding_detail::FakeString&
1316 : SetAsString()
1317 : {
1318 : if (mType == eString) {
1319 : return mValue.mString.Value();
1320 : }
1321 : Uninit();
1322 : mType = eString;
1323 : return mValue.mString.SetValue();
1324 : }
1325 :
1326 : inline bool
1327 : IsString() const
1328 : {
1329 : return mType == eString;
1330 : }
1331 :
1332 : inline binding_detail::FakeString&
1333 : GetAsString()
1334 : {
1335 : MOZ_ASSERT(IsString(), "Wrong type!");
1336 : return mValue.mString.Value();
1337 : }
1338 :
1339 : inline const nsAString&
1340 : GetAsString() const
1341 : {
1342 : MOZ_ASSERT(IsString(), "Wrong type!");
1343 : return mValue.mString.Value();
1344 : }
1345 :
1346 : inline void
1347 : Uninit()
1348 : {
1349 : switch (mType) {
1350 : case eUninitialized: {
1351 : break;
1352 : }
1353 : case eDouble: {
1354 : DestroyDouble();
1355 : break;
1356 : }
1357 : case eString: {
1358 : DestroyString();
1359 : break;
1360 : }
1361 : }
1362 : }
1363 :
1364 : bool
1365 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1366 :
1367 : private:
1368 : inline void
1369 : DestroyDouble()
1370 : {
1371 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1372 : mValue.mDouble.Destroy();
1373 : mType = eUninitialized;
1374 : }
1375 :
1376 : inline void
1377 : DestroyString()
1378 : {
1379 : MOZ_ASSERT(IsString(), "Wrong type!");
1380 : mValue.mString.Destroy();
1381 : mType = eUninitialized;
1382 : }
1383 : };
1384 :
1385 : class DoubleOrSupportedType
1386 : {
1387 : friend class DoubleOrSupportedTypeArgument;
1388 : enum Type
1389 : {
1390 : eUninitialized,
1391 : eDouble,
1392 : eSupportedType
1393 : };
1394 :
1395 : union Value
1396 : {
1397 : UnionMember<double > mDouble;
1398 : UnionMember<SupportedType > mSupportedType;
1399 :
1400 : };
1401 :
1402 : Type mType;
1403 : Value mValue;
1404 :
1405 : DoubleOrSupportedType(const DoubleOrSupportedType&) = delete;
1406 : DoubleOrSupportedType& operator=(const DoubleOrSupportedType&) = delete;
1407 : public:
1408 : explicit inline DoubleOrSupportedType()
1409 : : mType(eUninitialized)
1410 : {
1411 : }
1412 :
1413 : inline ~DoubleOrSupportedType()
1414 : {
1415 : Uninit();
1416 : }
1417 :
1418 : inline double&
1419 : RawSetAsDouble()
1420 : {
1421 : if (mType == eDouble) {
1422 : return mValue.mDouble.Value();
1423 : }
1424 : MOZ_ASSERT(mType == eUninitialized);
1425 : mType = eDouble;
1426 : return mValue.mDouble.SetValue();
1427 : }
1428 :
1429 : inline double&
1430 : SetAsDouble()
1431 : {
1432 : if (mType == eDouble) {
1433 : return mValue.mDouble.Value();
1434 : }
1435 : Uninit();
1436 : mType = eDouble;
1437 : return mValue.mDouble.SetValue();
1438 : }
1439 :
1440 : inline bool
1441 : IsDouble() const
1442 : {
1443 : return mType == eDouble;
1444 : }
1445 :
1446 : inline double&
1447 : GetAsDouble()
1448 : {
1449 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1450 : return mValue.mDouble.Value();
1451 : }
1452 :
1453 : inline double
1454 : GetAsDouble() const
1455 : {
1456 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1457 : return mValue.mDouble.Value();
1458 : }
1459 :
1460 : inline SupportedType&
1461 : RawSetAsSupportedType()
1462 : {
1463 : if (mType == eSupportedType) {
1464 : return mValue.mSupportedType.Value();
1465 : }
1466 : MOZ_ASSERT(mType == eUninitialized);
1467 : mType = eSupportedType;
1468 : return mValue.mSupportedType.SetValue();
1469 : }
1470 :
1471 : inline SupportedType&
1472 : SetAsSupportedType()
1473 : {
1474 : if (mType == eSupportedType) {
1475 : return mValue.mSupportedType.Value();
1476 : }
1477 : Uninit();
1478 : mType = eSupportedType;
1479 : return mValue.mSupportedType.SetValue();
1480 : }
1481 :
1482 : inline bool
1483 : IsSupportedType() const
1484 : {
1485 : return mType == eSupportedType;
1486 : }
1487 :
1488 : inline SupportedType&
1489 : GetAsSupportedType()
1490 : {
1491 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
1492 : return mValue.mSupportedType.Value();
1493 : }
1494 :
1495 : inline SupportedType
1496 : GetAsSupportedType() const
1497 : {
1498 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
1499 : return mValue.mSupportedType.Value();
1500 : }
1501 :
1502 : inline void
1503 : Uninit()
1504 : {
1505 : switch (mType) {
1506 : case eUninitialized: {
1507 : break;
1508 : }
1509 : case eDouble: {
1510 : DestroyDouble();
1511 : break;
1512 : }
1513 : case eSupportedType: {
1514 : DestroySupportedType();
1515 : break;
1516 : }
1517 : }
1518 : }
1519 :
1520 : bool
1521 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1522 :
1523 : private:
1524 : inline void
1525 : DestroyDouble()
1526 : {
1527 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1528 : mValue.mDouble.Destroy();
1529 : mType = eUninitialized;
1530 : }
1531 :
1532 : inline void
1533 : DestroySupportedType()
1534 : {
1535 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
1536 : mValue.mSupportedType.Destroy();
1537 : mType = eUninitialized;
1538 : }
1539 : };
1540 :
1541 : class DoubleOrUSVString
1542 : {
1543 : friend class DoubleOrUSVStringArgument;
1544 : enum Type
1545 : {
1546 : eUninitialized,
1547 : eDouble,
1548 : eUSVString
1549 : };
1550 :
1551 : union Value
1552 : {
1553 : UnionMember<double > mDouble;
1554 : UnionMember<binding_detail::FakeString > mUSVString;
1555 :
1556 : };
1557 :
1558 : Type mType;
1559 : Value mValue;
1560 :
1561 : DoubleOrUSVString(const DoubleOrUSVString&) = delete;
1562 : DoubleOrUSVString& operator=(const DoubleOrUSVString&) = delete;
1563 : public:
1564 : explicit inline DoubleOrUSVString()
1565 : : mType(eUninitialized)
1566 : {
1567 : }
1568 :
1569 : inline ~DoubleOrUSVString()
1570 : {
1571 : Uninit();
1572 : }
1573 :
1574 : inline double&
1575 : RawSetAsDouble()
1576 : {
1577 : if (mType == eDouble) {
1578 : return mValue.mDouble.Value();
1579 : }
1580 : MOZ_ASSERT(mType == eUninitialized);
1581 : mType = eDouble;
1582 : return mValue.mDouble.SetValue();
1583 : }
1584 :
1585 : inline double&
1586 : SetAsDouble()
1587 : {
1588 : if (mType == eDouble) {
1589 : return mValue.mDouble.Value();
1590 : }
1591 : Uninit();
1592 : mType = eDouble;
1593 : return mValue.mDouble.SetValue();
1594 : }
1595 :
1596 : inline bool
1597 : IsDouble() const
1598 : {
1599 : return mType == eDouble;
1600 : }
1601 :
1602 : inline double&
1603 : GetAsDouble()
1604 : {
1605 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1606 : return mValue.mDouble.Value();
1607 : }
1608 :
1609 : inline double
1610 : GetAsDouble() const
1611 : {
1612 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1613 : return mValue.mDouble.Value();
1614 : }
1615 :
1616 : inline binding_detail::FakeString&
1617 : RawSetAsUSVString()
1618 : {
1619 : if (mType == eUSVString) {
1620 : return mValue.mUSVString.Value();
1621 : }
1622 : MOZ_ASSERT(mType == eUninitialized);
1623 : mType = eUSVString;
1624 : return mValue.mUSVString.SetValue();
1625 : }
1626 :
1627 : inline binding_detail::FakeString&
1628 : SetAsUSVString()
1629 : {
1630 : if (mType == eUSVString) {
1631 : return mValue.mUSVString.Value();
1632 : }
1633 : Uninit();
1634 : mType = eUSVString;
1635 : return mValue.mUSVString.SetValue();
1636 : }
1637 :
1638 : inline bool
1639 : IsUSVString() const
1640 : {
1641 : return mType == eUSVString;
1642 : }
1643 :
1644 : inline binding_detail::FakeString&
1645 : GetAsUSVString()
1646 : {
1647 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
1648 : return mValue.mUSVString.Value();
1649 : }
1650 :
1651 : inline const nsAString&
1652 : GetAsUSVString() const
1653 : {
1654 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
1655 : return mValue.mUSVString.Value();
1656 : }
1657 :
1658 : inline void
1659 : Uninit()
1660 : {
1661 : switch (mType) {
1662 : case eUninitialized: {
1663 : break;
1664 : }
1665 : case eDouble: {
1666 : DestroyDouble();
1667 : break;
1668 : }
1669 : case eUSVString: {
1670 : DestroyUSVString();
1671 : break;
1672 : }
1673 : }
1674 : }
1675 :
1676 : bool
1677 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1678 :
1679 : private:
1680 : inline void
1681 : DestroyDouble()
1682 : {
1683 : MOZ_ASSERT(IsDouble(), "Wrong type!");
1684 : mValue.mDouble.Destroy();
1685 : mType = eUninitialized;
1686 : }
1687 :
1688 : inline void
1689 : DestroyUSVString()
1690 : {
1691 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
1692 : mValue.mUSVString.Destroy();
1693 : mType = eUninitialized;
1694 : }
1695 : };
1696 :
1697 : class EventHandlerNonNullOrNullOrLong
1698 : {
1699 : friend class EventHandlerNonNullOrNullOrLongArgument;
1700 : enum Type
1701 : {
1702 : eUninitialized,
1703 : eNull,
1704 : eEventHandlerNonNull,
1705 : eLong
1706 : };
1707 :
1708 : union Value
1709 : {
1710 : UnionMember<RootedCallback<OwningNonNull<binding_detail::FastEventHandlerNonNull>> > mEventHandlerNonNull;
1711 : UnionMember<int32_t > mLong;
1712 :
1713 : };
1714 :
1715 : Type mType;
1716 : Value mValue;
1717 :
1718 : EventHandlerNonNullOrNullOrLong(const EventHandlerNonNullOrNullOrLong&) = delete;
1719 : EventHandlerNonNullOrNullOrLong& operator=(const EventHandlerNonNullOrNullOrLong&) = delete;
1720 : public:
1721 : explicit inline EventHandlerNonNullOrNullOrLong()
1722 : : mType(eUninitialized)
1723 : {
1724 : }
1725 :
1726 : inline ~EventHandlerNonNullOrNullOrLong()
1727 : {
1728 : Uninit();
1729 : }
1730 :
1731 : inline bool
1732 : IsNull() const
1733 : {
1734 : return mType == eNull;
1735 : }
1736 :
1737 : inline void
1738 : SetNull()
1739 : {
1740 : Uninit();
1741 : mType = eNull;
1742 : }
1743 :
1744 : inline RootedCallback<OwningNonNull<binding_detail::FastEventHandlerNonNull>>&
1745 : RawSetAsEventHandlerNonNull(JSContext* cx)
1746 : {
1747 : if (mType == eEventHandlerNonNull) {
1748 : return mValue.mEventHandlerNonNull.Value();
1749 : }
1750 : MOZ_ASSERT(mType == eUninitialized);
1751 : mType = eEventHandlerNonNull;
1752 : return mValue.mEventHandlerNonNull.SetValue(cx);
1753 : }
1754 :
1755 : inline RootedCallback<OwningNonNull<binding_detail::FastEventHandlerNonNull>>&
1756 : SetAsEventHandlerNonNull(JSContext* cx)
1757 : {
1758 : if (mType == eEventHandlerNonNull) {
1759 : return mValue.mEventHandlerNonNull.Value();
1760 : }
1761 : Uninit();
1762 : mType = eEventHandlerNonNull;
1763 : return mValue.mEventHandlerNonNull.SetValue(cx);
1764 : }
1765 :
1766 : inline bool
1767 : IsEventHandlerNonNull() const
1768 : {
1769 : return mType == eEventHandlerNonNull;
1770 : }
1771 :
1772 : inline RootedCallback<OwningNonNull<binding_detail::FastEventHandlerNonNull>>&
1773 : GetAsEventHandlerNonNull()
1774 : {
1775 : MOZ_ASSERT(IsEventHandlerNonNull(), "Wrong type!");
1776 : return mValue.mEventHandlerNonNull.Value();
1777 : }
1778 :
1779 : inline EventHandlerNonNull&
1780 : GetAsEventHandlerNonNull() const
1781 : {
1782 : MOZ_ASSERT(IsEventHandlerNonNull(), "Wrong type!");
1783 : return mValue.mEventHandlerNonNull.Value();
1784 : }
1785 :
1786 : inline int32_t&
1787 : RawSetAsLong()
1788 : {
1789 : if (mType == eLong) {
1790 : return mValue.mLong.Value();
1791 : }
1792 : MOZ_ASSERT(mType == eUninitialized);
1793 : mType = eLong;
1794 : return mValue.mLong.SetValue();
1795 : }
1796 :
1797 : inline int32_t&
1798 : SetAsLong()
1799 : {
1800 : if (mType == eLong) {
1801 : return mValue.mLong.Value();
1802 : }
1803 : Uninit();
1804 : mType = eLong;
1805 : return mValue.mLong.SetValue();
1806 : }
1807 :
1808 : inline bool
1809 : IsLong() const
1810 : {
1811 : return mType == eLong;
1812 : }
1813 :
1814 : inline int32_t&
1815 : GetAsLong()
1816 : {
1817 : MOZ_ASSERT(IsLong(), "Wrong type!");
1818 : return mValue.mLong.Value();
1819 : }
1820 :
1821 : inline int32_t
1822 : GetAsLong() const
1823 : {
1824 : MOZ_ASSERT(IsLong(), "Wrong type!");
1825 : return mValue.mLong.Value();
1826 : }
1827 :
1828 : inline void
1829 : Uninit()
1830 : {
1831 : switch (mType) {
1832 : case eUninitialized: {
1833 : break;
1834 : }
1835 : case eNull: {
1836 : break;
1837 : }
1838 : case eEventHandlerNonNull: {
1839 : DestroyEventHandlerNonNull();
1840 : break;
1841 : }
1842 : case eLong: {
1843 : DestroyLong();
1844 : break;
1845 : }
1846 : }
1847 : }
1848 :
1849 : bool
1850 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1851 :
1852 : private:
1853 : inline void
1854 : DestroyEventHandlerNonNull()
1855 : {
1856 : MOZ_ASSERT(IsEventHandlerNonNull(), "Wrong type!");
1857 : mValue.mEventHandlerNonNull.Destroy();
1858 : mType = eUninitialized;
1859 : }
1860 :
1861 : inline void
1862 : DestroyLong()
1863 : {
1864 : MOZ_ASSERT(IsLong(), "Wrong type!");
1865 : mValue.mLong.Destroy();
1866 : mType = eUninitialized;
1867 : }
1868 : };
1869 :
1870 : class EventInitOrLong
1871 : {
1872 : friend class EventInitOrLongArgument;
1873 : enum Type
1874 : {
1875 : eUninitialized,
1876 : eEventInit,
1877 : eLong
1878 : };
1879 :
1880 : union Value
1881 : {
1882 : UnionMember<binding_detail::FastEventInit > mEventInit;
1883 : UnionMember<int32_t > mLong;
1884 :
1885 : };
1886 :
1887 : Type mType;
1888 : Value mValue;
1889 :
1890 : EventInitOrLong(const EventInitOrLong&) = delete;
1891 : EventInitOrLong& operator=(const EventInitOrLong&) = delete;
1892 : public:
1893 : explicit inline EventInitOrLong()
1894 : : mType(eUninitialized)
1895 : {
1896 : }
1897 :
1898 : inline ~EventInitOrLong()
1899 : {
1900 : Uninit();
1901 : }
1902 :
1903 : inline binding_detail::FastEventInit&
1904 : RawSetAsEventInit()
1905 : {
1906 : if (mType == eEventInit) {
1907 : return mValue.mEventInit.Value();
1908 : }
1909 : MOZ_ASSERT(mType == eUninitialized);
1910 : mType = eEventInit;
1911 : return mValue.mEventInit.SetValue();
1912 : }
1913 :
1914 : inline binding_detail::FastEventInit&
1915 : SetAsEventInit()
1916 : {
1917 : if (mType == eEventInit) {
1918 : return mValue.mEventInit.Value();
1919 : }
1920 : Uninit();
1921 : mType = eEventInit;
1922 : return mValue.mEventInit.SetValue();
1923 : }
1924 :
1925 : inline bool
1926 : IsEventInit() const
1927 : {
1928 : return mType == eEventInit;
1929 : }
1930 :
1931 : inline binding_detail::FastEventInit&
1932 : GetAsEventInit()
1933 : {
1934 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
1935 : return mValue.mEventInit.Value();
1936 : }
1937 :
1938 : inline const EventInit&
1939 : GetAsEventInit() const
1940 : {
1941 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
1942 : return mValue.mEventInit.Value();
1943 : }
1944 :
1945 : inline int32_t&
1946 : RawSetAsLong()
1947 : {
1948 : if (mType == eLong) {
1949 : return mValue.mLong.Value();
1950 : }
1951 : MOZ_ASSERT(mType == eUninitialized);
1952 : mType = eLong;
1953 : return mValue.mLong.SetValue();
1954 : }
1955 :
1956 : inline int32_t&
1957 : SetAsLong()
1958 : {
1959 : if (mType == eLong) {
1960 : return mValue.mLong.Value();
1961 : }
1962 : Uninit();
1963 : mType = eLong;
1964 : return mValue.mLong.SetValue();
1965 : }
1966 :
1967 : inline bool
1968 : IsLong() const
1969 : {
1970 : return mType == eLong;
1971 : }
1972 :
1973 : inline int32_t&
1974 : GetAsLong()
1975 : {
1976 : MOZ_ASSERT(IsLong(), "Wrong type!");
1977 : return mValue.mLong.Value();
1978 : }
1979 :
1980 : inline int32_t
1981 : GetAsLong() const
1982 : {
1983 : MOZ_ASSERT(IsLong(), "Wrong type!");
1984 : return mValue.mLong.Value();
1985 : }
1986 :
1987 : inline void
1988 : Uninit()
1989 : {
1990 : switch (mType) {
1991 : case eUninitialized: {
1992 : break;
1993 : }
1994 : case eEventInit: {
1995 : DestroyEventInit();
1996 : break;
1997 : }
1998 : case eLong: {
1999 : DestroyLong();
2000 : break;
2001 : }
2002 : }
2003 : }
2004 :
2005 : bool
2006 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2007 :
2008 : private:
2009 : inline void
2010 : DestroyEventInit()
2011 : {
2012 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
2013 : mValue.mEventInit.Destroy();
2014 : mType = eUninitialized;
2015 : }
2016 :
2017 : inline void
2018 : DestroyLong()
2019 : {
2020 : MOZ_ASSERT(IsLong(), "Wrong type!");
2021 : mValue.mLong.Destroy();
2022 : mType = eUninitialized;
2023 : }
2024 : };
2025 :
2026 : class EventInitOrStringSequence
2027 : {
2028 : friend class EventInitOrStringSequenceArgument;
2029 : enum Type
2030 : {
2031 : eUninitialized,
2032 : eEventInit,
2033 : eStringSequence
2034 : };
2035 :
2036 : union Value
2037 : {
2038 : UnionMember<binding_detail::FastEventInit > mEventInit;
2039 : UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence;
2040 :
2041 : };
2042 :
2043 : Type mType;
2044 : Value mValue;
2045 :
2046 : EventInitOrStringSequence(const EventInitOrStringSequence&) = delete;
2047 : EventInitOrStringSequence& operator=(const EventInitOrStringSequence&) = delete;
2048 : public:
2049 : explicit inline EventInitOrStringSequence()
2050 : : mType(eUninitialized)
2051 : {
2052 : }
2053 :
2054 : inline ~EventInitOrStringSequence()
2055 : {
2056 : Uninit();
2057 : }
2058 :
2059 : inline binding_detail::FastEventInit&
2060 : RawSetAsEventInit()
2061 : {
2062 : if (mType == eEventInit) {
2063 : return mValue.mEventInit.Value();
2064 : }
2065 : MOZ_ASSERT(mType == eUninitialized);
2066 : mType = eEventInit;
2067 : return mValue.mEventInit.SetValue();
2068 : }
2069 :
2070 : inline binding_detail::FastEventInit&
2071 : SetAsEventInit()
2072 : {
2073 : if (mType == eEventInit) {
2074 : return mValue.mEventInit.Value();
2075 : }
2076 : Uninit();
2077 : mType = eEventInit;
2078 : return mValue.mEventInit.SetValue();
2079 : }
2080 :
2081 : inline bool
2082 : IsEventInit() const
2083 : {
2084 : return mType == eEventInit;
2085 : }
2086 :
2087 : inline binding_detail::FastEventInit&
2088 : GetAsEventInit()
2089 : {
2090 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
2091 : return mValue.mEventInit.Value();
2092 : }
2093 :
2094 : inline const EventInit&
2095 : GetAsEventInit() const
2096 : {
2097 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
2098 : return mValue.mEventInit.Value();
2099 : }
2100 :
2101 : inline binding_detail::AutoSequence<nsString>&
2102 : RawSetAsStringSequence()
2103 : {
2104 : if (mType == eStringSequence) {
2105 : return mValue.mStringSequence.Value();
2106 : }
2107 : MOZ_ASSERT(mType == eUninitialized);
2108 : mType = eStringSequence;
2109 : return mValue.mStringSequence.SetValue();
2110 : }
2111 :
2112 : inline binding_detail::AutoSequence<nsString>&
2113 : SetAsStringSequence()
2114 : {
2115 : if (mType == eStringSequence) {
2116 : return mValue.mStringSequence.Value();
2117 : }
2118 : Uninit();
2119 : mType = eStringSequence;
2120 : return mValue.mStringSequence.SetValue();
2121 : }
2122 :
2123 : inline bool
2124 : IsStringSequence() const
2125 : {
2126 : return mType == eStringSequence;
2127 : }
2128 :
2129 : inline binding_detail::AutoSequence<nsString>&
2130 : GetAsStringSequence()
2131 : {
2132 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
2133 : return mValue.mStringSequence.Value();
2134 : }
2135 :
2136 : inline const Sequence<nsString>&
2137 : GetAsStringSequence() const
2138 : {
2139 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
2140 : return mValue.mStringSequence.Value();
2141 : }
2142 :
2143 : inline void
2144 : Uninit()
2145 : {
2146 : switch (mType) {
2147 : case eUninitialized: {
2148 : break;
2149 : }
2150 : case eEventInit: {
2151 : DestroyEventInit();
2152 : break;
2153 : }
2154 : case eStringSequence: {
2155 : DestroyStringSequence();
2156 : break;
2157 : }
2158 : }
2159 : }
2160 :
2161 : bool
2162 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2163 :
2164 : private:
2165 : inline void
2166 : DestroyEventInit()
2167 : {
2168 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
2169 : mValue.mEventInit.Destroy();
2170 : mType = eUninitialized;
2171 : }
2172 :
2173 : inline void
2174 : DestroyStringSequence()
2175 : {
2176 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
2177 : mValue.mStringSequence.Destroy();
2178 : mType = eUninitialized;
2179 : }
2180 : };
2181 :
2182 : class FileOrDirectory
2183 : {
2184 : friend class FileOrDirectoryArgument;
2185 : enum Type
2186 : {
2187 : eUninitialized,
2188 : eFile,
2189 : eDirectory
2190 : };
2191 :
2192 : union Value
2193 : {
2194 : UnionMember<NonNull<mozilla::dom::File> > mFile;
2195 : UnionMember<NonNull<mozilla::dom::Directory> > mDirectory;
2196 :
2197 : };
2198 :
2199 : Type mType;
2200 : Value mValue;
2201 :
2202 : FileOrDirectory(const FileOrDirectory&) = delete;
2203 : FileOrDirectory& operator=(const FileOrDirectory&) = delete;
2204 : public:
2205 : explicit inline FileOrDirectory()
2206 : : mType(eUninitialized)
2207 : {
2208 : }
2209 :
2210 : inline ~FileOrDirectory()
2211 : {
2212 : Uninit();
2213 : }
2214 :
2215 : inline NonNull<mozilla::dom::File>&
2216 : RawSetAsFile()
2217 : {
2218 : if (mType == eFile) {
2219 : return mValue.mFile.Value();
2220 : }
2221 : MOZ_ASSERT(mType == eUninitialized);
2222 : mType = eFile;
2223 : return mValue.mFile.SetValue();
2224 : }
2225 :
2226 : inline NonNull<mozilla::dom::File>&
2227 : SetAsFile()
2228 : {
2229 : if (mType == eFile) {
2230 : return mValue.mFile.Value();
2231 : }
2232 : Uninit();
2233 : mType = eFile;
2234 : return mValue.mFile.SetValue();
2235 : }
2236 :
2237 : inline bool
2238 : IsFile() const
2239 : {
2240 : return mType == eFile;
2241 : }
2242 :
2243 : inline NonNull<mozilla::dom::File>&
2244 : GetAsFile()
2245 : {
2246 : MOZ_ASSERT(IsFile(), "Wrong type!");
2247 : return mValue.mFile.Value();
2248 : }
2249 :
2250 : inline mozilla::dom::File&
2251 : GetAsFile() const
2252 : {
2253 : MOZ_ASSERT(IsFile(), "Wrong type!");
2254 : return mValue.mFile.Value();
2255 : }
2256 :
2257 : inline NonNull<mozilla::dom::Directory>&
2258 : RawSetAsDirectory()
2259 : {
2260 : if (mType == eDirectory) {
2261 : return mValue.mDirectory.Value();
2262 : }
2263 : MOZ_ASSERT(mType == eUninitialized);
2264 : mType = eDirectory;
2265 : return mValue.mDirectory.SetValue();
2266 : }
2267 :
2268 : inline NonNull<mozilla::dom::Directory>&
2269 : SetAsDirectory()
2270 : {
2271 : if (mType == eDirectory) {
2272 : return mValue.mDirectory.Value();
2273 : }
2274 : Uninit();
2275 : mType = eDirectory;
2276 : return mValue.mDirectory.SetValue();
2277 : }
2278 :
2279 : inline bool
2280 : IsDirectory() const
2281 : {
2282 : return mType == eDirectory;
2283 : }
2284 :
2285 : inline NonNull<mozilla::dom::Directory>&
2286 : GetAsDirectory()
2287 : {
2288 : MOZ_ASSERT(IsDirectory(), "Wrong type!");
2289 : return mValue.mDirectory.Value();
2290 : }
2291 :
2292 : inline mozilla::dom::Directory&
2293 : GetAsDirectory() const
2294 : {
2295 : MOZ_ASSERT(IsDirectory(), "Wrong type!");
2296 : return mValue.mDirectory.Value();
2297 : }
2298 :
2299 : inline void
2300 : Uninit()
2301 : {
2302 : switch (mType) {
2303 : case eUninitialized: {
2304 : break;
2305 : }
2306 : case eFile: {
2307 : DestroyFile();
2308 : break;
2309 : }
2310 : case eDirectory: {
2311 : DestroyDirectory();
2312 : break;
2313 : }
2314 : }
2315 : }
2316 :
2317 : bool
2318 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2319 :
2320 : private:
2321 : inline void
2322 : DestroyFile()
2323 : {
2324 : MOZ_ASSERT(IsFile(), "Wrong type!");
2325 : mValue.mFile.Destroy();
2326 : mType = eUninitialized;
2327 : }
2328 :
2329 : inline void
2330 : DestroyDirectory()
2331 : {
2332 : MOZ_ASSERT(IsDirectory(), "Wrong type!");
2333 : mValue.mDirectory.Destroy();
2334 : mType = eUninitialized;
2335 : }
2336 : };
2337 :
2338 : class FloatOrString
2339 : {
2340 : friend class FloatOrStringArgument;
2341 : enum Type
2342 : {
2343 : eUninitialized,
2344 : eFloat,
2345 : eString
2346 : };
2347 :
2348 : union Value
2349 : {
2350 : UnionMember<float > mFloat;
2351 : UnionMember<binding_detail::FakeString > mString;
2352 :
2353 : };
2354 :
2355 : Type mType;
2356 : Value mValue;
2357 :
2358 : FloatOrString(const FloatOrString&) = delete;
2359 : FloatOrString& operator=(const FloatOrString&) = delete;
2360 : public:
2361 : explicit inline FloatOrString()
2362 : : mType(eUninitialized)
2363 : {
2364 : }
2365 :
2366 : inline ~FloatOrString()
2367 : {
2368 : Uninit();
2369 : }
2370 :
2371 : inline float&
2372 : RawSetAsFloat()
2373 : {
2374 : if (mType == eFloat) {
2375 : return mValue.mFloat.Value();
2376 : }
2377 : MOZ_ASSERT(mType == eUninitialized);
2378 : mType = eFloat;
2379 : return mValue.mFloat.SetValue();
2380 : }
2381 :
2382 : inline float&
2383 : SetAsFloat()
2384 : {
2385 : if (mType == eFloat) {
2386 : return mValue.mFloat.Value();
2387 : }
2388 : Uninit();
2389 : mType = eFloat;
2390 : return mValue.mFloat.SetValue();
2391 : }
2392 :
2393 : inline bool
2394 : IsFloat() const
2395 : {
2396 : return mType == eFloat;
2397 : }
2398 :
2399 : inline float&
2400 : GetAsFloat()
2401 : {
2402 : MOZ_ASSERT(IsFloat(), "Wrong type!");
2403 : return mValue.mFloat.Value();
2404 : }
2405 :
2406 : inline float
2407 : GetAsFloat() const
2408 : {
2409 : MOZ_ASSERT(IsFloat(), "Wrong type!");
2410 : return mValue.mFloat.Value();
2411 : }
2412 :
2413 : inline binding_detail::FakeString&
2414 : RawSetAsString()
2415 : {
2416 : if (mType == eString) {
2417 : return mValue.mString.Value();
2418 : }
2419 : MOZ_ASSERT(mType == eUninitialized);
2420 : mType = eString;
2421 : return mValue.mString.SetValue();
2422 : }
2423 :
2424 : inline binding_detail::FakeString&
2425 : SetAsString()
2426 : {
2427 : if (mType == eString) {
2428 : return mValue.mString.Value();
2429 : }
2430 : Uninit();
2431 : mType = eString;
2432 : return mValue.mString.SetValue();
2433 : }
2434 :
2435 : inline bool
2436 : IsString() const
2437 : {
2438 : return mType == eString;
2439 : }
2440 :
2441 : inline binding_detail::FakeString&
2442 : GetAsString()
2443 : {
2444 : MOZ_ASSERT(IsString(), "Wrong type!");
2445 : return mValue.mString.Value();
2446 : }
2447 :
2448 : inline const nsAString&
2449 : GetAsString() const
2450 : {
2451 : MOZ_ASSERT(IsString(), "Wrong type!");
2452 : return mValue.mString.Value();
2453 : }
2454 :
2455 : inline void
2456 : Uninit()
2457 : {
2458 : switch (mType) {
2459 : case eUninitialized: {
2460 : break;
2461 : }
2462 : case eFloat: {
2463 : DestroyFloat();
2464 : break;
2465 : }
2466 : case eString: {
2467 : DestroyString();
2468 : break;
2469 : }
2470 : }
2471 : }
2472 :
2473 : bool
2474 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2475 :
2476 : private:
2477 : inline void
2478 : DestroyFloat()
2479 : {
2480 : MOZ_ASSERT(IsFloat(), "Wrong type!");
2481 : mValue.mFloat.Destroy();
2482 : mType = eUninitialized;
2483 : }
2484 :
2485 : inline void
2486 : DestroyString()
2487 : {
2488 : MOZ_ASSERT(IsString(), "Wrong type!");
2489 : mValue.mString.Destroy();
2490 : mType = eUninitialized;
2491 : }
2492 : };
2493 :
2494 : class HTMLElementOrLong
2495 : {
2496 : friend class HTMLElementOrLongArgument;
2497 : enum Type
2498 : {
2499 : eUninitialized,
2500 : eHTMLElement,
2501 : eLong
2502 : };
2503 :
2504 0 : union Value
2505 : {
2506 : UnionMember<NonNull<nsGenericHTMLElement> > mHTMLElement;
2507 : UnionMember<int32_t > mLong;
2508 :
2509 : };
2510 :
2511 : Type mType;
2512 : Value mValue;
2513 :
2514 : HTMLElementOrLong(const HTMLElementOrLong&) = delete;
2515 : HTMLElementOrLong& operator=(const HTMLElementOrLong&) = delete;
2516 : public:
2517 0 : explicit inline HTMLElementOrLong()
2518 0 : : mType(eUninitialized)
2519 : {
2520 0 : }
2521 :
2522 0 : inline ~HTMLElementOrLong()
2523 0 : {
2524 0 : Uninit();
2525 0 : }
2526 :
2527 : inline NonNull<nsGenericHTMLElement>&
2528 : RawSetAsHTMLElement()
2529 : {
2530 : if (mType == eHTMLElement) {
2531 : return mValue.mHTMLElement.Value();
2532 : }
2533 : MOZ_ASSERT(mType == eUninitialized);
2534 : mType = eHTMLElement;
2535 : return mValue.mHTMLElement.SetValue();
2536 : }
2537 :
2538 : inline NonNull<nsGenericHTMLElement>&
2539 : SetAsHTMLElement()
2540 : {
2541 : if (mType == eHTMLElement) {
2542 : return mValue.mHTMLElement.Value();
2543 : }
2544 : Uninit();
2545 : mType = eHTMLElement;
2546 : return mValue.mHTMLElement.SetValue();
2547 : }
2548 :
2549 : inline bool
2550 0 : IsHTMLElement() const
2551 : {
2552 0 : return mType == eHTMLElement;
2553 : }
2554 :
2555 : inline NonNull<nsGenericHTMLElement>&
2556 : GetAsHTMLElement()
2557 : {
2558 : MOZ_ASSERT(IsHTMLElement(), "Wrong type!");
2559 : return mValue.mHTMLElement.Value();
2560 : }
2561 :
2562 : inline nsGenericHTMLElement&
2563 0 : GetAsHTMLElement() const
2564 : {
2565 0 : MOZ_ASSERT(IsHTMLElement(), "Wrong type!");
2566 0 : return mValue.mHTMLElement.Value();
2567 : }
2568 :
2569 : inline int32_t&
2570 : RawSetAsLong()
2571 : {
2572 : if (mType == eLong) {
2573 : return mValue.mLong.Value();
2574 : }
2575 : MOZ_ASSERT(mType == eUninitialized);
2576 : mType = eLong;
2577 : return mValue.mLong.SetValue();
2578 : }
2579 :
2580 : inline int32_t&
2581 : SetAsLong()
2582 : {
2583 : if (mType == eLong) {
2584 : return mValue.mLong.Value();
2585 : }
2586 : Uninit();
2587 : mType = eLong;
2588 : return mValue.mLong.SetValue();
2589 : }
2590 :
2591 : inline bool
2592 0 : IsLong() const
2593 : {
2594 0 : return mType == eLong;
2595 : }
2596 :
2597 : inline int32_t&
2598 : GetAsLong()
2599 : {
2600 : MOZ_ASSERT(IsLong(), "Wrong type!");
2601 : return mValue.mLong.Value();
2602 : }
2603 :
2604 : inline int32_t
2605 0 : GetAsLong() const
2606 : {
2607 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
2608 0 : return mValue.mLong.Value();
2609 : }
2610 :
2611 : inline void
2612 0 : Uninit()
2613 : {
2614 0 : switch (mType) {
2615 : case eUninitialized: {
2616 0 : break;
2617 : }
2618 : case eHTMLElement: {
2619 0 : DestroyHTMLElement();
2620 0 : break;
2621 : }
2622 : case eLong: {
2623 0 : DestroyLong();
2624 0 : break;
2625 : }
2626 : }
2627 0 : }
2628 :
2629 : bool
2630 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2631 :
2632 : private:
2633 : inline void
2634 0 : DestroyHTMLElement()
2635 : {
2636 0 : MOZ_ASSERT(IsHTMLElement(), "Wrong type!");
2637 0 : mValue.mHTMLElement.Destroy();
2638 0 : mType = eUninitialized;
2639 0 : }
2640 :
2641 : inline void
2642 0 : DestroyLong()
2643 : {
2644 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
2645 0 : mValue.mLong.Destroy();
2646 0 : mType = eUninitialized;
2647 0 : }
2648 : };
2649 :
2650 : class HTMLOptionElementOrHTMLOptGroupElement
2651 : {
2652 : friend class HTMLOptionElementOrHTMLOptGroupElementArgument;
2653 : enum Type
2654 : {
2655 : eUninitialized,
2656 : eHTMLOptionElement,
2657 : eHTMLOptGroupElement
2658 : };
2659 :
2660 0 : union Value
2661 : {
2662 : UnionMember<NonNull<mozilla::dom::HTMLOptionElement> > mHTMLOptionElement;
2663 : UnionMember<NonNull<mozilla::dom::HTMLOptGroupElement> > mHTMLOptGroupElement;
2664 :
2665 : };
2666 :
2667 : Type mType;
2668 : Value mValue;
2669 :
2670 : HTMLOptionElementOrHTMLOptGroupElement(const HTMLOptionElementOrHTMLOptGroupElement&) = delete;
2671 : HTMLOptionElementOrHTMLOptGroupElement& operator=(const HTMLOptionElementOrHTMLOptGroupElement&) = delete;
2672 : public:
2673 0 : explicit inline HTMLOptionElementOrHTMLOptGroupElement()
2674 0 : : mType(eUninitialized)
2675 : {
2676 0 : }
2677 :
2678 0 : inline ~HTMLOptionElementOrHTMLOptGroupElement()
2679 0 : {
2680 0 : Uninit();
2681 0 : }
2682 :
2683 : inline NonNull<mozilla::dom::HTMLOptionElement>&
2684 : RawSetAsHTMLOptionElement()
2685 : {
2686 : if (mType == eHTMLOptionElement) {
2687 : return mValue.mHTMLOptionElement.Value();
2688 : }
2689 : MOZ_ASSERT(mType == eUninitialized);
2690 : mType = eHTMLOptionElement;
2691 : return mValue.mHTMLOptionElement.SetValue();
2692 : }
2693 :
2694 : inline NonNull<mozilla::dom::HTMLOptionElement>&
2695 : SetAsHTMLOptionElement()
2696 : {
2697 : if (mType == eHTMLOptionElement) {
2698 : return mValue.mHTMLOptionElement.Value();
2699 : }
2700 : Uninit();
2701 : mType = eHTMLOptionElement;
2702 : return mValue.mHTMLOptionElement.SetValue();
2703 : }
2704 :
2705 : inline bool
2706 0 : IsHTMLOptionElement() const
2707 : {
2708 0 : return mType == eHTMLOptionElement;
2709 : }
2710 :
2711 : inline NonNull<mozilla::dom::HTMLOptionElement>&
2712 : GetAsHTMLOptionElement()
2713 : {
2714 : MOZ_ASSERT(IsHTMLOptionElement(), "Wrong type!");
2715 : return mValue.mHTMLOptionElement.Value();
2716 : }
2717 :
2718 : inline mozilla::dom::HTMLOptionElement&
2719 0 : GetAsHTMLOptionElement() const
2720 : {
2721 0 : MOZ_ASSERT(IsHTMLOptionElement(), "Wrong type!");
2722 0 : return mValue.mHTMLOptionElement.Value();
2723 : }
2724 :
2725 : inline NonNull<mozilla::dom::HTMLOptGroupElement>&
2726 : RawSetAsHTMLOptGroupElement()
2727 : {
2728 : if (mType == eHTMLOptGroupElement) {
2729 : return mValue.mHTMLOptGroupElement.Value();
2730 : }
2731 : MOZ_ASSERT(mType == eUninitialized);
2732 : mType = eHTMLOptGroupElement;
2733 : return mValue.mHTMLOptGroupElement.SetValue();
2734 : }
2735 :
2736 : inline NonNull<mozilla::dom::HTMLOptGroupElement>&
2737 : SetAsHTMLOptGroupElement()
2738 : {
2739 : if (mType == eHTMLOptGroupElement) {
2740 : return mValue.mHTMLOptGroupElement.Value();
2741 : }
2742 : Uninit();
2743 : mType = eHTMLOptGroupElement;
2744 : return mValue.mHTMLOptGroupElement.SetValue();
2745 : }
2746 :
2747 : inline bool
2748 0 : IsHTMLOptGroupElement() const
2749 : {
2750 0 : return mType == eHTMLOptGroupElement;
2751 : }
2752 :
2753 : inline NonNull<mozilla::dom::HTMLOptGroupElement>&
2754 : GetAsHTMLOptGroupElement()
2755 : {
2756 : MOZ_ASSERT(IsHTMLOptGroupElement(), "Wrong type!");
2757 : return mValue.mHTMLOptGroupElement.Value();
2758 : }
2759 :
2760 : inline mozilla::dom::HTMLOptGroupElement&
2761 0 : GetAsHTMLOptGroupElement() const
2762 : {
2763 0 : MOZ_ASSERT(IsHTMLOptGroupElement(), "Wrong type!");
2764 0 : return mValue.mHTMLOptGroupElement.Value();
2765 : }
2766 :
2767 : inline void
2768 0 : Uninit()
2769 : {
2770 0 : switch (mType) {
2771 : case eUninitialized: {
2772 0 : break;
2773 : }
2774 : case eHTMLOptionElement: {
2775 0 : DestroyHTMLOptionElement();
2776 0 : break;
2777 : }
2778 : case eHTMLOptGroupElement: {
2779 0 : DestroyHTMLOptGroupElement();
2780 0 : break;
2781 : }
2782 : }
2783 0 : }
2784 :
2785 : bool
2786 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2787 :
2788 : private:
2789 : inline void
2790 0 : DestroyHTMLOptionElement()
2791 : {
2792 0 : MOZ_ASSERT(IsHTMLOptionElement(), "Wrong type!");
2793 0 : mValue.mHTMLOptionElement.Destroy();
2794 0 : mType = eUninitialized;
2795 0 : }
2796 :
2797 : inline void
2798 0 : DestroyHTMLOptGroupElement()
2799 : {
2800 0 : MOZ_ASSERT(IsHTMLOptGroupElement(), "Wrong type!");
2801 0 : mValue.mHTMLOptGroupElement.Destroy();
2802 0 : mType = eUninitialized;
2803 0 : }
2804 : };
2805 :
2806 : class ImageDataOrNullSequenceOrLong
2807 : {
2808 : friend class ImageDataOrNullSequenceOrLongArgument;
2809 : enum Type
2810 : {
2811 : eUninitialized,
2812 : eImageDataOrNullSequence,
2813 : eLong
2814 : };
2815 :
2816 : union Value
2817 : {
2818 : UnionMember<binding_detail::AutoSequence<RefPtr<mozilla::dom::ImageData>> > mImageDataOrNullSequence;
2819 : UnionMember<int32_t > mLong;
2820 :
2821 : };
2822 :
2823 : Type mType;
2824 : Value mValue;
2825 :
2826 : ImageDataOrNullSequenceOrLong(const ImageDataOrNullSequenceOrLong&) = delete;
2827 : ImageDataOrNullSequenceOrLong& operator=(const ImageDataOrNullSequenceOrLong&) = delete;
2828 : public:
2829 : explicit inline ImageDataOrNullSequenceOrLong()
2830 : : mType(eUninitialized)
2831 : {
2832 : }
2833 :
2834 : inline ~ImageDataOrNullSequenceOrLong()
2835 : {
2836 : Uninit();
2837 : }
2838 :
2839 : inline binding_detail::AutoSequence<RefPtr<mozilla::dom::ImageData>>&
2840 : RawSetAsImageDataOrNullSequence()
2841 : {
2842 : if (mType == eImageDataOrNullSequence) {
2843 : return mValue.mImageDataOrNullSequence.Value();
2844 : }
2845 : MOZ_ASSERT(mType == eUninitialized);
2846 : mType = eImageDataOrNullSequence;
2847 : return mValue.mImageDataOrNullSequence.SetValue();
2848 : }
2849 :
2850 : inline binding_detail::AutoSequence<RefPtr<mozilla::dom::ImageData>>&
2851 : SetAsImageDataOrNullSequence()
2852 : {
2853 : if (mType == eImageDataOrNullSequence) {
2854 : return mValue.mImageDataOrNullSequence.Value();
2855 : }
2856 : Uninit();
2857 : mType = eImageDataOrNullSequence;
2858 : return mValue.mImageDataOrNullSequence.SetValue();
2859 : }
2860 :
2861 : inline bool
2862 : IsImageDataOrNullSequence() const
2863 : {
2864 : return mType == eImageDataOrNullSequence;
2865 : }
2866 :
2867 : inline binding_detail::AutoSequence<RefPtr<mozilla::dom::ImageData>>&
2868 : GetAsImageDataOrNullSequence()
2869 : {
2870 : MOZ_ASSERT(IsImageDataOrNullSequence(), "Wrong type!");
2871 : return mValue.mImageDataOrNullSequence.Value();
2872 : }
2873 :
2874 : inline const Sequence<RefPtr<mozilla::dom::ImageData>>&
2875 : GetAsImageDataOrNullSequence() const
2876 : {
2877 : MOZ_ASSERT(IsImageDataOrNullSequence(), "Wrong type!");
2878 : return mValue.mImageDataOrNullSequence.Value();
2879 : }
2880 :
2881 : inline int32_t&
2882 : RawSetAsLong()
2883 : {
2884 : if (mType == eLong) {
2885 : return mValue.mLong.Value();
2886 : }
2887 : MOZ_ASSERT(mType == eUninitialized);
2888 : mType = eLong;
2889 : return mValue.mLong.SetValue();
2890 : }
2891 :
2892 : inline int32_t&
2893 : SetAsLong()
2894 : {
2895 : if (mType == eLong) {
2896 : return mValue.mLong.Value();
2897 : }
2898 : Uninit();
2899 : mType = eLong;
2900 : return mValue.mLong.SetValue();
2901 : }
2902 :
2903 : inline bool
2904 : IsLong() const
2905 : {
2906 : return mType == eLong;
2907 : }
2908 :
2909 : inline int32_t&
2910 : GetAsLong()
2911 : {
2912 : MOZ_ASSERT(IsLong(), "Wrong type!");
2913 : return mValue.mLong.Value();
2914 : }
2915 :
2916 : inline int32_t
2917 : GetAsLong() const
2918 : {
2919 : MOZ_ASSERT(IsLong(), "Wrong type!");
2920 : return mValue.mLong.Value();
2921 : }
2922 :
2923 : inline void
2924 : Uninit()
2925 : {
2926 : switch (mType) {
2927 : case eUninitialized: {
2928 : break;
2929 : }
2930 : case eImageDataOrNullSequence: {
2931 : DestroyImageDataOrNullSequence();
2932 : break;
2933 : }
2934 : case eLong: {
2935 : DestroyLong();
2936 : break;
2937 : }
2938 : }
2939 : }
2940 :
2941 : bool
2942 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
2943 :
2944 : private:
2945 : inline void
2946 : DestroyImageDataOrNullSequence()
2947 : {
2948 : MOZ_ASSERT(IsImageDataOrNullSequence(), "Wrong type!");
2949 : mValue.mImageDataOrNullSequence.Destroy();
2950 : mType = eUninitialized;
2951 : }
2952 :
2953 : inline void
2954 : DestroyLong()
2955 : {
2956 : MOZ_ASSERT(IsLong(), "Wrong type!");
2957 : mValue.mLong.Destroy();
2958 : mType = eUninitialized;
2959 : }
2960 : };
2961 :
2962 : class ImageDataOrNullSequenceSequenceOrLong
2963 : {
2964 : friend class ImageDataOrNullSequenceSequenceOrLongArgument;
2965 : enum Type
2966 : {
2967 : eUninitialized,
2968 : eImageDataOrNullSequenceSequence,
2969 : eLong
2970 : };
2971 :
2972 : union Value
2973 : {
2974 : UnionMember<binding_detail::AutoSequence<Sequence<RefPtr<mozilla::dom::ImageData>>> > mImageDataOrNullSequenceSequence;
2975 : UnionMember<int32_t > mLong;
2976 :
2977 : };
2978 :
2979 : Type mType;
2980 : Value mValue;
2981 :
2982 : ImageDataOrNullSequenceSequenceOrLong(const ImageDataOrNullSequenceSequenceOrLong&) = delete;
2983 : ImageDataOrNullSequenceSequenceOrLong& operator=(const ImageDataOrNullSequenceSequenceOrLong&) = delete;
2984 : public:
2985 : explicit inline ImageDataOrNullSequenceSequenceOrLong()
2986 : : mType(eUninitialized)
2987 : {
2988 : }
2989 :
2990 : inline ~ImageDataOrNullSequenceSequenceOrLong()
2991 : {
2992 : Uninit();
2993 : }
2994 :
2995 : inline binding_detail::AutoSequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
2996 : RawSetAsImageDataOrNullSequenceSequence()
2997 : {
2998 : if (mType == eImageDataOrNullSequenceSequence) {
2999 : return mValue.mImageDataOrNullSequenceSequence.Value();
3000 : }
3001 : MOZ_ASSERT(mType == eUninitialized);
3002 : mType = eImageDataOrNullSequenceSequence;
3003 : return mValue.mImageDataOrNullSequenceSequence.SetValue();
3004 : }
3005 :
3006 : inline binding_detail::AutoSequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
3007 : SetAsImageDataOrNullSequenceSequence()
3008 : {
3009 : if (mType == eImageDataOrNullSequenceSequence) {
3010 : return mValue.mImageDataOrNullSequenceSequence.Value();
3011 : }
3012 : Uninit();
3013 : mType = eImageDataOrNullSequenceSequence;
3014 : return mValue.mImageDataOrNullSequenceSequence.SetValue();
3015 : }
3016 :
3017 : inline bool
3018 : IsImageDataOrNullSequenceSequence() const
3019 : {
3020 : return mType == eImageDataOrNullSequenceSequence;
3021 : }
3022 :
3023 : inline binding_detail::AutoSequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
3024 : GetAsImageDataOrNullSequenceSequence()
3025 : {
3026 : MOZ_ASSERT(IsImageDataOrNullSequenceSequence(), "Wrong type!");
3027 : return mValue.mImageDataOrNullSequenceSequence.Value();
3028 : }
3029 :
3030 : inline const Sequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
3031 : GetAsImageDataOrNullSequenceSequence() const
3032 : {
3033 : MOZ_ASSERT(IsImageDataOrNullSequenceSequence(), "Wrong type!");
3034 : return mValue.mImageDataOrNullSequenceSequence.Value();
3035 : }
3036 :
3037 : inline int32_t&
3038 : RawSetAsLong()
3039 : {
3040 : if (mType == eLong) {
3041 : return mValue.mLong.Value();
3042 : }
3043 : MOZ_ASSERT(mType == eUninitialized);
3044 : mType = eLong;
3045 : return mValue.mLong.SetValue();
3046 : }
3047 :
3048 : inline int32_t&
3049 : SetAsLong()
3050 : {
3051 : if (mType == eLong) {
3052 : return mValue.mLong.Value();
3053 : }
3054 : Uninit();
3055 : mType = eLong;
3056 : return mValue.mLong.SetValue();
3057 : }
3058 :
3059 : inline bool
3060 : IsLong() const
3061 : {
3062 : return mType == eLong;
3063 : }
3064 :
3065 : inline int32_t&
3066 : GetAsLong()
3067 : {
3068 : MOZ_ASSERT(IsLong(), "Wrong type!");
3069 : return mValue.mLong.Value();
3070 : }
3071 :
3072 : inline int32_t
3073 : GetAsLong() const
3074 : {
3075 : MOZ_ASSERT(IsLong(), "Wrong type!");
3076 : return mValue.mLong.Value();
3077 : }
3078 :
3079 : inline void
3080 : Uninit()
3081 : {
3082 : switch (mType) {
3083 : case eUninitialized: {
3084 : break;
3085 : }
3086 : case eImageDataOrNullSequenceSequence: {
3087 : DestroyImageDataOrNullSequenceSequence();
3088 : break;
3089 : }
3090 : case eLong: {
3091 : DestroyLong();
3092 : break;
3093 : }
3094 : }
3095 : }
3096 :
3097 : bool
3098 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
3099 :
3100 : private:
3101 : inline void
3102 : DestroyImageDataOrNullSequenceSequence()
3103 : {
3104 : MOZ_ASSERT(IsImageDataOrNullSequenceSequence(), "Wrong type!");
3105 : mValue.mImageDataOrNullSequenceSequence.Destroy();
3106 : mType = eUninitialized;
3107 : }
3108 :
3109 : inline void
3110 : DestroyLong()
3111 : {
3112 : MOZ_ASSERT(IsLong(), "Wrong type!");
3113 : mValue.mLong.Destroy();
3114 : mType = eUninitialized;
3115 : }
3116 : };
3117 :
3118 : class ImageDataSequenceOrLong
3119 : {
3120 : friend class ImageDataSequenceOrLongArgument;
3121 : enum Type
3122 : {
3123 : eUninitialized,
3124 : eImageDataSequence,
3125 : eLong
3126 : };
3127 :
3128 : union Value
3129 : {
3130 : UnionMember<binding_detail::AutoSequence<OwningNonNull<mozilla::dom::ImageData>> > mImageDataSequence;
3131 : UnionMember<int32_t > mLong;
3132 :
3133 : };
3134 :
3135 : Type mType;
3136 : Value mValue;
3137 :
3138 : ImageDataSequenceOrLong(const ImageDataSequenceOrLong&) = delete;
3139 : ImageDataSequenceOrLong& operator=(const ImageDataSequenceOrLong&) = delete;
3140 : public:
3141 : explicit inline ImageDataSequenceOrLong()
3142 : : mType(eUninitialized)
3143 : {
3144 : }
3145 :
3146 : inline ~ImageDataSequenceOrLong()
3147 : {
3148 : Uninit();
3149 : }
3150 :
3151 : inline binding_detail::AutoSequence<OwningNonNull<mozilla::dom::ImageData>>&
3152 : RawSetAsImageDataSequence()
3153 : {
3154 : if (mType == eImageDataSequence) {
3155 : return mValue.mImageDataSequence.Value();
3156 : }
3157 : MOZ_ASSERT(mType == eUninitialized);
3158 : mType = eImageDataSequence;
3159 : return mValue.mImageDataSequence.SetValue();
3160 : }
3161 :
3162 : inline binding_detail::AutoSequence<OwningNonNull<mozilla::dom::ImageData>>&
3163 : SetAsImageDataSequence()
3164 : {
3165 : if (mType == eImageDataSequence) {
3166 : return mValue.mImageDataSequence.Value();
3167 : }
3168 : Uninit();
3169 : mType = eImageDataSequence;
3170 : return mValue.mImageDataSequence.SetValue();
3171 : }
3172 :
3173 : inline bool
3174 : IsImageDataSequence() const
3175 : {
3176 : return mType == eImageDataSequence;
3177 : }
3178 :
3179 : inline binding_detail::AutoSequence<OwningNonNull<mozilla::dom::ImageData>>&
3180 : GetAsImageDataSequence()
3181 : {
3182 : MOZ_ASSERT(IsImageDataSequence(), "Wrong type!");
3183 : return mValue.mImageDataSequence.Value();
3184 : }
3185 :
3186 : inline const Sequence<OwningNonNull<mozilla::dom::ImageData>>&
3187 : GetAsImageDataSequence() const
3188 : {
3189 : MOZ_ASSERT(IsImageDataSequence(), "Wrong type!");
3190 : return mValue.mImageDataSequence.Value();
3191 : }
3192 :
3193 : inline int32_t&
3194 : RawSetAsLong()
3195 : {
3196 : if (mType == eLong) {
3197 : return mValue.mLong.Value();
3198 : }
3199 : MOZ_ASSERT(mType == eUninitialized);
3200 : mType = eLong;
3201 : return mValue.mLong.SetValue();
3202 : }
3203 :
3204 : inline int32_t&
3205 : SetAsLong()
3206 : {
3207 : if (mType == eLong) {
3208 : return mValue.mLong.Value();
3209 : }
3210 : Uninit();
3211 : mType = eLong;
3212 : return mValue.mLong.SetValue();
3213 : }
3214 :
3215 : inline bool
3216 : IsLong() const
3217 : {
3218 : return mType == eLong;
3219 : }
3220 :
3221 : inline int32_t&
3222 : GetAsLong()
3223 : {
3224 : MOZ_ASSERT(IsLong(), "Wrong type!");
3225 : return mValue.mLong.Value();
3226 : }
3227 :
3228 : inline int32_t
3229 : GetAsLong() const
3230 : {
3231 : MOZ_ASSERT(IsLong(), "Wrong type!");
3232 : return mValue.mLong.Value();
3233 : }
3234 :
3235 : inline void
3236 : Uninit()
3237 : {
3238 : switch (mType) {
3239 : case eUninitialized: {
3240 : break;
3241 : }
3242 : case eImageDataSequence: {
3243 : DestroyImageDataSequence();
3244 : break;
3245 : }
3246 : case eLong: {
3247 : DestroyLong();
3248 : break;
3249 : }
3250 : }
3251 : }
3252 :
3253 : bool
3254 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
3255 :
3256 : private:
3257 : inline void
3258 : DestroyImageDataSequence()
3259 : {
3260 : MOZ_ASSERT(IsImageDataSequence(), "Wrong type!");
3261 : mValue.mImageDataSequence.Destroy();
3262 : mType = eUninitialized;
3263 : }
3264 :
3265 : inline void
3266 : DestroyLong()
3267 : {
3268 : MOZ_ASSERT(IsLong(), "Wrong type!");
3269 : mValue.mLong.Destroy();
3270 : mType = eUninitialized;
3271 : }
3272 : };
3273 :
3274 : class ImageDataSequenceSequenceOrLong
3275 : {
3276 : friend class ImageDataSequenceSequenceOrLongArgument;
3277 : enum Type
3278 : {
3279 : eUninitialized,
3280 : eImageDataSequenceSequence,
3281 : eLong
3282 : };
3283 :
3284 : union Value
3285 : {
3286 : UnionMember<binding_detail::AutoSequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>> > mImageDataSequenceSequence;
3287 : UnionMember<int32_t > mLong;
3288 :
3289 : };
3290 :
3291 : Type mType;
3292 : Value mValue;
3293 :
3294 : ImageDataSequenceSequenceOrLong(const ImageDataSequenceSequenceOrLong&) = delete;
3295 : ImageDataSequenceSequenceOrLong& operator=(const ImageDataSequenceSequenceOrLong&) = delete;
3296 : public:
3297 : explicit inline ImageDataSequenceSequenceOrLong()
3298 : : mType(eUninitialized)
3299 : {
3300 : }
3301 :
3302 : inline ~ImageDataSequenceSequenceOrLong()
3303 : {
3304 : Uninit();
3305 : }
3306 :
3307 : inline binding_detail::AutoSequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
3308 : RawSetAsImageDataSequenceSequence()
3309 : {
3310 : if (mType == eImageDataSequenceSequence) {
3311 : return mValue.mImageDataSequenceSequence.Value();
3312 : }
3313 : MOZ_ASSERT(mType == eUninitialized);
3314 : mType = eImageDataSequenceSequence;
3315 : return mValue.mImageDataSequenceSequence.SetValue();
3316 : }
3317 :
3318 : inline binding_detail::AutoSequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
3319 : SetAsImageDataSequenceSequence()
3320 : {
3321 : if (mType == eImageDataSequenceSequence) {
3322 : return mValue.mImageDataSequenceSequence.Value();
3323 : }
3324 : Uninit();
3325 : mType = eImageDataSequenceSequence;
3326 : return mValue.mImageDataSequenceSequence.SetValue();
3327 : }
3328 :
3329 : inline bool
3330 : IsImageDataSequenceSequence() const
3331 : {
3332 : return mType == eImageDataSequenceSequence;
3333 : }
3334 :
3335 : inline binding_detail::AutoSequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
3336 : GetAsImageDataSequenceSequence()
3337 : {
3338 : MOZ_ASSERT(IsImageDataSequenceSequence(), "Wrong type!");
3339 : return mValue.mImageDataSequenceSequence.Value();
3340 : }
3341 :
3342 : inline const Sequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
3343 : GetAsImageDataSequenceSequence() const
3344 : {
3345 : MOZ_ASSERT(IsImageDataSequenceSequence(), "Wrong type!");
3346 : return mValue.mImageDataSequenceSequence.Value();
3347 : }
3348 :
3349 : inline int32_t&
3350 : RawSetAsLong()
3351 : {
3352 : if (mType == eLong) {
3353 : return mValue.mLong.Value();
3354 : }
3355 : MOZ_ASSERT(mType == eUninitialized);
3356 : mType = eLong;
3357 : return mValue.mLong.SetValue();
3358 : }
3359 :
3360 : inline int32_t&
3361 : SetAsLong()
3362 : {
3363 : if (mType == eLong) {
3364 : return mValue.mLong.Value();
3365 : }
3366 : Uninit();
3367 : mType = eLong;
3368 : return mValue.mLong.SetValue();
3369 : }
3370 :
3371 : inline bool
3372 : IsLong() const
3373 : {
3374 : return mType == eLong;
3375 : }
3376 :
3377 : inline int32_t&
3378 : GetAsLong()
3379 : {
3380 : MOZ_ASSERT(IsLong(), "Wrong type!");
3381 : return mValue.mLong.Value();
3382 : }
3383 :
3384 : inline int32_t
3385 : GetAsLong() const
3386 : {
3387 : MOZ_ASSERT(IsLong(), "Wrong type!");
3388 : return mValue.mLong.Value();
3389 : }
3390 :
3391 : inline void
3392 : Uninit()
3393 : {
3394 : switch (mType) {
3395 : case eUninitialized: {
3396 : break;
3397 : }
3398 : case eImageDataSequenceSequence: {
3399 : DestroyImageDataSequenceSequence();
3400 : break;
3401 : }
3402 : case eLong: {
3403 : DestroyLong();
3404 : break;
3405 : }
3406 : }
3407 : }
3408 :
3409 : bool
3410 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
3411 :
3412 : private:
3413 : inline void
3414 : DestroyImageDataSequenceSequence()
3415 : {
3416 : MOZ_ASSERT(IsImageDataSequenceSequence(), "Wrong type!");
3417 : mValue.mImageDataSequenceSequence.Destroy();
3418 : mType = eUninitialized;
3419 : }
3420 :
3421 : inline void
3422 : DestroyLong()
3423 : {
3424 : MOZ_ASSERT(IsLong(), "Wrong type!");
3425 : mValue.mLong.Destroy();
3426 : mType = eUninitialized;
3427 : }
3428 : };
3429 :
3430 : class LongOrBoolean
3431 : {
3432 : friend class LongOrBooleanArgument;
3433 : enum Type
3434 : {
3435 : eUninitialized,
3436 : eLong,
3437 : eBoolean
3438 : };
3439 :
3440 : union Value
3441 : {
3442 : UnionMember<int32_t > mLong;
3443 : UnionMember<bool > mBoolean;
3444 :
3445 : };
3446 :
3447 : Type mType;
3448 : Value mValue;
3449 :
3450 : LongOrBoolean(const LongOrBoolean&) = delete;
3451 : LongOrBoolean& operator=(const LongOrBoolean&) = delete;
3452 : public:
3453 : explicit inline LongOrBoolean()
3454 : : mType(eUninitialized)
3455 : {
3456 : }
3457 :
3458 : inline ~LongOrBoolean()
3459 : {
3460 : Uninit();
3461 : }
3462 :
3463 : inline int32_t&
3464 : RawSetAsLong()
3465 : {
3466 : if (mType == eLong) {
3467 : return mValue.mLong.Value();
3468 : }
3469 : MOZ_ASSERT(mType == eUninitialized);
3470 : mType = eLong;
3471 : return mValue.mLong.SetValue();
3472 : }
3473 :
3474 : inline int32_t&
3475 : SetAsLong()
3476 : {
3477 : if (mType == eLong) {
3478 : return mValue.mLong.Value();
3479 : }
3480 : Uninit();
3481 : mType = eLong;
3482 : return mValue.mLong.SetValue();
3483 : }
3484 :
3485 : inline bool
3486 : IsLong() const
3487 : {
3488 : return mType == eLong;
3489 : }
3490 :
3491 : inline int32_t&
3492 : GetAsLong()
3493 : {
3494 : MOZ_ASSERT(IsLong(), "Wrong type!");
3495 : return mValue.mLong.Value();
3496 : }
3497 :
3498 : inline int32_t
3499 : GetAsLong() const
3500 : {
3501 : MOZ_ASSERT(IsLong(), "Wrong type!");
3502 : return mValue.mLong.Value();
3503 : }
3504 :
3505 : inline bool&
3506 : RawSetAsBoolean()
3507 : {
3508 : if (mType == eBoolean) {
3509 : return mValue.mBoolean.Value();
3510 : }
3511 : MOZ_ASSERT(mType == eUninitialized);
3512 : mType = eBoolean;
3513 : return mValue.mBoolean.SetValue();
3514 : }
3515 :
3516 : inline bool&
3517 : SetAsBoolean()
3518 : {
3519 : if (mType == eBoolean) {
3520 : return mValue.mBoolean.Value();
3521 : }
3522 : Uninit();
3523 : mType = eBoolean;
3524 : return mValue.mBoolean.SetValue();
3525 : }
3526 :
3527 : inline bool
3528 : IsBoolean() const
3529 : {
3530 : return mType == eBoolean;
3531 : }
3532 :
3533 : inline bool&
3534 : GetAsBoolean()
3535 : {
3536 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
3537 : return mValue.mBoolean.Value();
3538 : }
3539 :
3540 : inline bool
3541 : GetAsBoolean() const
3542 : {
3543 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
3544 : return mValue.mBoolean.Value();
3545 : }
3546 :
3547 : inline void
3548 : Uninit()
3549 : {
3550 : switch (mType) {
3551 : case eUninitialized: {
3552 : break;
3553 : }
3554 : case eLong: {
3555 : DestroyLong();
3556 : break;
3557 : }
3558 : case eBoolean: {
3559 : DestroyBoolean();
3560 : break;
3561 : }
3562 : }
3563 : }
3564 :
3565 : bool
3566 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
3567 :
3568 : private:
3569 : inline void
3570 : DestroyLong()
3571 : {
3572 : MOZ_ASSERT(IsLong(), "Wrong type!");
3573 : mValue.mLong.Destroy();
3574 : mType = eUninitialized;
3575 : }
3576 :
3577 : inline void
3578 : DestroyBoolean()
3579 : {
3580 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
3581 : mValue.mBoolean.Destroy();
3582 : mType = eUninitialized;
3583 : }
3584 : };
3585 :
3586 : class LongOrStringAnyRecord
3587 : {
3588 : friend class LongOrStringAnyRecordArgument;
3589 : enum Type
3590 : {
3591 : eUninitialized,
3592 : eLong,
3593 : eStringAnyRecord
3594 : };
3595 :
3596 : union Value
3597 : {
3598 : UnionMember<int32_t > mLong;
3599 : UnionMember<Record<nsString, JS::Value> > mStringAnyRecord;
3600 :
3601 : };
3602 :
3603 : Type mType;
3604 : Value mValue;
3605 :
3606 : LongOrStringAnyRecord(const LongOrStringAnyRecord&) = delete;
3607 : LongOrStringAnyRecord& operator=(const LongOrStringAnyRecord&) = delete;
3608 : public:
3609 : explicit inline LongOrStringAnyRecord()
3610 : : mType(eUninitialized)
3611 : {
3612 : }
3613 :
3614 : inline ~LongOrStringAnyRecord()
3615 : {
3616 : Uninit();
3617 : }
3618 :
3619 : inline int32_t&
3620 : RawSetAsLong()
3621 : {
3622 : if (mType == eLong) {
3623 : return mValue.mLong.Value();
3624 : }
3625 : MOZ_ASSERT(mType == eUninitialized);
3626 : mType = eLong;
3627 : return mValue.mLong.SetValue();
3628 : }
3629 :
3630 : inline int32_t&
3631 : SetAsLong()
3632 : {
3633 : if (mType == eLong) {
3634 : return mValue.mLong.Value();
3635 : }
3636 : Uninit();
3637 : mType = eLong;
3638 : return mValue.mLong.SetValue();
3639 : }
3640 :
3641 : inline bool
3642 : IsLong() const
3643 : {
3644 : return mType == eLong;
3645 : }
3646 :
3647 : inline int32_t&
3648 : GetAsLong()
3649 : {
3650 : MOZ_ASSERT(IsLong(), "Wrong type!");
3651 : return mValue.mLong.Value();
3652 : }
3653 :
3654 : inline int32_t
3655 : GetAsLong() const
3656 : {
3657 : MOZ_ASSERT(IsLong(), "Wrong type!");
3658 : return mValue.mLong.Value();
3659 : }
3660 :
3661 : inline Record<nsString, JS::Value>&
3662 : RawSetAsStringAnyRecord()
3663 : {
3664 : if (mType == eStringAnyRecord) {
3665 : return mValue.mStringAnyRecord.Value();
3666 : }
3667 : MOZ_ASSERT(mType == eUninitialized);
3668 : mType = eStringAnyRecord;
3669 : return mValue.mStringAnyRecord.SetValue();
3670 : }
3671 :
3672 : inline Record<nsString, JS::Value>&
3673 : SetAsStringAnyRecord()
3674 : {
3675 : if (mType == eStringAnyRecord) {
3676 : return mValue.mStringAnyRecord.Value();
3677 : }
3678 : Uninit();
3679 : mType = eStringAnyRecord;
3680 : return mValue.mStringAnyRecord.SetValue();
3681 : }
3682 :
3683 : inline bool
3684 : IsStringAnyRecord() const
3685 : {
3686 : return mType == eStringAnyRecord;
3687 : }
3688 :
3689 : inline Record<nsString, JS::Value>&
3690 : GetAsStringAnyRecord()
3691 : {
3692 : MOZ_ASSERT(IsStringAnyRecord(), "Wrong type!");
3693 : return mValue.mStringAnyRecord.Value();
3694 : }
3695 :
3696 : inline const Record<nsString, JS::Value>&
3697 : GetAsStringAnyRecord() const
3698 : {
3699 : MOZ_ASSERT(IsStringAnyRecord(), "Wrong type!");
3700 : return mValue.mStringAnyRecord.Value();
3701 : }
3702 :
3703 : inline void
3704 : Uninit()
3705 : {
3706 : switch (mType) {
3707 : case eUninitialized: {
3708 : break;
3709 : }
3710 : case eLong: {
3711 : DestroyLong();
3712 : break;
3713 : }
3714 : case eStringAnyRecord: {
3715 : DestroyStringAnyRecord();
3716 : break;
3717 : }
3718 : }
3719 : }
3720 :
3721 : bool
3722 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
3723 :
3724 : private:
3725 : inline void
3726 : DestroyLong()
3727 : {
3728 : MOZ_ASSERT(IsLong(), "Wrong type!");
3729 : mValue.mLong.Destroy();
3730 : mType = eUninitialized;
3731 : }
3732 :
3733 : inline void
3734 : DestroyStringAnyRecord()
3735 : {
3736 : MOZ_ASSERT(IsStringAnyRecord(), "Wrong type!");
3737 : mValue.mStringAnyRecord.Destroy();
3738 : mType = eUninitialized;
3739 : }
3740 : };
3741 :
3742 : class LongSequenceOrLong
3743 : {
3744 : friend class LongSequenceOrLongArgument;
3745 : enum Type
3746 : {
3747 : eUninitialized,
3748 : eLongSequence,
3749 : eLong
3750 : };
3751 :
3752 : union Value
3753 : {
3754 : UnionMember<binding_detail::AutoSequence<int32_t> > mLongSequence;
3755 : UnionMember<int32_t > mLong;
3756 :
3757 : };
3758 :
3759 : Type mType;
3760 : Value mValue;
3761 :
3762 : LongSequenceOrLong(const LongSequenceOrLong&) = delete;
3763 : LongSequenceOrLong& operator=(const LongSequenceOrLong&) = delete;
3764 : public:
3765 : explicit inline LongSequenceOrLong()
3766 : : mType(eUninitialized)
3767 : {
3768 : }
3769 :
3770 : inline ~LongSequenceOrLong()
3771 : {
3772 : Uninit();
3773 : }
3774 :
3775 : inline binding_detail::AutoSequence<int32_t>&
3776 : RawSetAsLongSequence()
3777 : {
3778 : if (mType == eLongSequence) {
3779 : return mValue.mLongSequence.Value();
3780 : }
3781 : MOZ_ASSERT(mType == eUninitialized);
3782 : mType = eLongSequence;
3783 : return mValue.mLongSequence.SetValue();
3784 : }
3785 :
3786 : inline binding_detail::AutoSequence<int32_t>&
3787 : SetAsLongSequence()
3788 : {
3789 : if (mType == eLongSequence) {
3790 : return mValue.mLongSequence.Value();
3791 : }
3792 : Uninit();
3793 : mType = eLongSequence;
3794 : return mValue.mLongSequence.SetValue();
3795 : }
3796 :
3797 : inline bool
3798 : IsLongSequence() const
3799 : {
3800 : return mType == eLongSequence;
3801 : }
3802 :
3803 : inline binding_detail::AutoSequence<int32_t>&
3804 : GetAsLongSequence()
3805 : {
3806 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
3807 : return mValue.mLongSequence.Value();
3808 : }
3809 :
3810 : inline const Sequence<int32_t>&
3811 : GetAsLongSequence() const
3812 : {
3813 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
3814 : return mValue.mLongSequence.Value();
3815 : }
3816 :
3817 : inline int32_t&
3818 : RawSetAsLong()
3819 : {
3820 : if (mType == eLong) {
3821 : return mValue.mLong.Value();
3822 : }
3823 : MOZ_ASSERT(mType == eUninitialized);
3824 : mType = eLong;
3825 : return mValue.mLong.SetValue();
3826 : }
3827 :
3828 : inline int32_t&
3829 : SetAsLong()
3830 : {
3831 : if (mType == eLong) {
3832 : return mValue.mLong.Value();
3833 : }
3834 : Uninit();
3835 : mType = eLong;
3836 : return mValue.mLong.SetValue();
3837 : }
3838 :
3839 : inline bool
3840 : IsLong() const
3841 : {
3842 : return mType == eLong;
3843 : }
3844 :
3845 : inline int32_t&
3846 : GetAsLong()
3847 : {
3848 : MOZ_ASSERT(IsLong(), "Wrong type!");
3849 : return mValue.mLong.Value();
3850 : }
3851 :
3852 : inline int32_t
3853 : GetAsLong() const
3854 : {
3855 : MOZ_ASSERT(IsLong(), "Wrong type!");
3856 : return mValue.mLong.Value();
3857 : }
3858 :
3859 : inline void
3860 : Uninit()
3861 : {
3862 : switch (mType) {
3863 : case eUninitialized: {
3864 : break;
3865 : }
3866 : case eLongSequence: {
3867 : DestroyLongSequence();
3868 : break;
3869 : }
3870 : case eLong: {
3871 : DestroyLong();
3872 : break;
3873 : }
3874 : }
3875 : }
3876 :
3877 : bool
3878 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
3879 :
3880 : private:
3881 : inline void
3882 : DestroyLongSequence()
3883 : {
3884 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
3885 : mValue.mLongSequence.Destroy();
3886 : mType = eUninitialized;
3887 : }
3888 :
3889 : inline void
3890 : DestroyLong()
3891 : {
3892 : MOZ_ASSERT(IsLong(), "Wrong type!");
3893 : mValue.mLong.Destroy();
3894 : mType = eUninitialized;
3895 : }
3896 : };
3897 :
3898 : class LongSequenceOrNullOrLong
3899 : {
3900 : friend class LongSequenceOrNullOrLongArgument;
3901 : enum Type
3902 : {
3903 : eUninitialized,
3904 : eNull,
3905 : eLongSequence,
3906 : eLong
3907 : };
3908 :
3909 : union Value
3910 : {
3911 : UnionMember<binding_detail::AutoSequence<int32_t> > mLongSequence;
3912 : UnionMember<int32_t > mLong;
3913 :
3914 : };
3915 :
3916 : Type mType;
3917 : Value mValue;
3918 :
3919 : LongSequenceOrNullOrLong(const LongSequenceOrNullOrLong&) = delete;
3920 : LongSequenceOrNullOrLong& operator=(const LongSequenceOrNullOrLong&) = delete;
3921 : public:
3922 : explicit inline LongSequenceOrNullOrLong()
3923 : : mType(eUninitialized)
3924 : {
3925 : }
3926 :
3927 : inline ~LongSequenceOrNullOrLong()
3928 : {
3929 : Uninit();
3930 : }
3931 :
3932 : inline bool
3933 : IsNull() const
3934 : {
3935 : return mType == eNull;
3936 : }
3937 :
3938 : inline void
3939 : SetNull()
3940 : {
3941 : Uninit();
3942 : mType = eNull;
3943 : }
3944 :
3945 : inline binding_detail::AutoSequence<int32_t>&
3946 : RawSetAsLongSequence()
3947 : {
3948 : if (mType == eLongSequence) {
3949 : return mValue.mLongSequence.Value();
3950 : }
3951 : MOZ_ASSERT(mType == eUninitialized);
3952 : mType = eLongSequence;
3953 : return mValue.mLongSequence.SetValue();
3954 : }
3955 :
3956 : inline binding_detail::AutoSequence<int32_t>&
3957 : SetAsLongSequence()
3958 : {
3959 : if (mType == eLongSequence) {
3960 : return mValue.mLongSequence.Value();
3961 : }
3962 : Uninit();
3963 : mType = eLongSequence;
3964 : return mValue.mLongSequence.SetValue();
3965 : }
3966 :
3967 : inline bool
3968 : IsLongSequence() const
3969 : {
3970 : return mType == eLongSequence;
3971 : }
3972 :
3973 : inline binding_detail::AutoSequence<int32_t>&
3974 : GetAsLongSequence()
3975 : {
3976 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
3977 : return mValue.mLongSequence.Value();
3978 : }
3979 :
3980 : inline const Sequence<int32_t>&
3981 : GetAsLongSequence() const
3982 : {
3983 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
3984 : return mValue.mLongSequence.Value();
3985 : }
3986 :
3987 : inline int32_t&
3988 : RawSetAsLong()
3989 : {
3990 : if (mType == eLong) {
3991 : return mValue.mLong.Value();
3992 : }
3993 : MOZ_ASSERT(mType == eUninitialized);
3994 : mType = eLong;
3995 : return mValue.mLong.SetValue();
3996 : }
3997 :
3998 : inline int32_t&
3999 : SetAsLong()
4000 : {
4001 : if (mType == eLong) {
4002 : return mValue.mLong.Value();
4003 : }
4004 : Uninit();
4005 : mType = eLong;
4006 : return mValue.mLong.SetValue();
4007 : }
4008 :
4009 : inline bool
4010 : IsLong() const
4011 : {
4012 : return mType == eLong;
4013 : }
4014 :
4015 : inline int32_t&
4016 : GetAsLong()
4017 : {
4018 : MOZ_ASSERT(IsLong(), "Wrong type!");
4019 : return mValue.mLong.Value();
4020 : }
4021 :
4022 : inline int32_t
4023 : GetAsLong() const
4024 : {
4025 : MOZ_ASSERT(IsLong(), "Wrong type!");
4026 : return mValue.mLong.Value();
4027 : }
4028 :
4029 : inline void
4030 : Uninit()
4031 : {
4032 : switch (mType) {
4033 : case eUninitialized: {
4034 : break;
4035 : }
4036 : case eNull: {
4037 : break;
4038 : }
4039 : case eLongSequence: {
4040 : DestroyLongSequence();
4041 : break;
4042 : }
4043 : case eLong: {
4044 : DestroyLong();
4045 : break;
4046 : }
4047 : }
4048 : }
4049 :
4050 : bool
4051 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
4052 :
4053 : private:
4054 : inline void
4055 : DestroyLongSequence()
4056 : {
4057 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
4058 : mValue.mLongSequence.Destroy();
4059 : mType = eUninitialized;
4060 : }
4061 :
4062 : inline void
4063 : DestroyLong()
4064 : {
4065 : MOZ_ASSERT(IsLong(), "Wrong type!");
4066 : mValue.mLong.Destroy();
4067 : mType = eUninitialized;
4068 : }
4069 : };
4070 :
4071 : class NodeOrLongOrBoolean
4072 : {
4073 : friend class NodeOrLongOrBooleanArgument;
4074 : enum Type
4075 : {
4076 : eUninitialized,
4077 : eNode,
4078 : eLong,
4079 : eBoolean
4080 : };
4081 :
4082 : union Value
4083 : {
4084 : UnionMember<NonNull<nsINode> > mNode;
4085 : UnionMember<int32_t > mLong;
4086 : UnionMember<bool > mBoolean;
4087 :
4088 : };
4089 :
4090 : Type mType;
4091 : Value mValue;
4092 :
4093 : NodeOrLongOrBoolean(const NodeOrLongOrBoolean&) = delete;
4094 : NodeOrLongOrBoolean& operator=(const NodeOrLongOrBoolean&) = delete;
4095 : public:
4096 : explicit inline NodeOrLongOrBoolean()
4097 : : mType(eUninitialized)
4098 : {
4099 : }
4100 :
4101 : inline ~NodeOrLongOrBoolean()
4102 : {
4103 : Uninit();
4104 : }
4105 :
4106 : inline NonNull<nsINode>&
4107 : RawSetAsNode()
4108 : {
4109 : if (mType == eNode) {
4110 : return mValue.mNode.Value();
4111 : }
4112 : MOZ_ASSERT(mType == eUninitialized);
4113 : mType = eNode;
4114 : return mValue.mNode.SetValue();
4115 : }
4116 :
4117 : inline NonNull<nsINode>&
4118 : SetAsNode()
4119 : {
4120 : if (mType == eNode) {
4121 : return mValue.mNode.Value();
4122 : }
4123 : Uninit();
4124 : mType = eNode;
4125 : return mValue.mNode.SetValue();
4126 : }
4127 :
4128 : inline bool
4129 : IsNode() const
4130 : {
4131 : return mType == eNode;
4132 : }
4133 :
4134 : inline NonNull<nsINode>&
4135 : GetAsNode()
4136 : {
4137 : MOZ_ASSERT(IsNode(), "Wrong type!");
4138 : return mValue.mNode.Value();
4139 : }
4140 :
4141 : inline nsINode&
4142 : GetAsNode() const
4143 : {
4144 : MOZ_ASSERT(IsNode(), "Wrong type!");
4145 : return mValue.mNode.Value();
4146 : }
4147 :
4148 : inline int32_t&
4149 : RawSetAsLong()
4150 : {
4151 : if (mType == eLong) {
4152 : return mValue.mLong.Value();
4153 : }
4154 : MOZ_ASSERT(mType == eUninitialized);
4155 : mType = eLong;
4156 : return mValue.mLong.SetValue();
4157 : }
4158 :
4159 : inline int32_t&
4160 : SetAsLong()
4161 : {
4162 : if (mType == eLong) {
4163 : return mValue.mLong.Value();
4164 : }
4165 : Uninit();
4166 : mType = eLong;
4167 : return mValue.mLong.SetValue();
4168 : }
4169 :
4170 : inline bool
4171 : IsLong() const
4172 : {
4173 : return mType == eLong;
4174 : }
4175 :
4176 : inline int32_t&
4177 : GetAsLong()
4178 : {
4179 : MOZ_ASSERT(IsLong(), "Wrong type!");
4180 : return mValue.mLong.Value();
4181 : }
4182 :
4183 : inline int32_t
4184 : GetAsLong() const
4185 : {
4186 : MOZ_ASSERT(IsLong(), "Wrong type!");
4187 : return mValue.mLong.Value();
4188 : }
4189 :
4190 : inline bool&
4191 : RawSetAsBoolean()
4192 : {
4193 : if (mType == eBoolean) {
4194 : return mValue.mBoolean.Value();
4195 : }
4196 : MOZ_ASSERT(mType == eUninitialized);
4197 : mType = eBoolean;
4198 : return mValue.mBoolean.SetValue();
4199 : }
4200 :
4201 : inline bool&
4202 : SetAsBoolean()
4203 : {
4204 : if (mType == eBoolean) {
4205 : return mValue.mBoolean.Value();
4206 : }
4207 : Uninit();
4208 : mType = eBoolean;
4209 : return mValue.mBoolean.SetValue();
4210 : }
4211 :
4212 : inline bool
4213 : IsBoolean() const
4214 : {
4215 : return mType == eBoolean;
4216 : }
4217 :
4218 : inline bool&
4219 : GetAsBoolean()
4220 : {
4221 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4222 : return mValue.mBoolean.Value();
4223 : }
4224 :
4225 : inline bool
4226 : GetAsBoolean() const
4227 : {
4228 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4229 : return mValue.mBoolean.Value();
4230 : }
4231 :
4232 : inline void
4233 : Uninit()
4234 : {
4235 : switch (mType) {
4236 : case eUninitialized: {
4237 : break;
4238 : }
4239 : case eNode: {
4240 : DestroyNode();
4241 : break;
4242 : }
4243 : case eLong: {
4244 : DestroyLong();
4245 : break;
4246 : }
4247 : case eBoolean: {
4248 : DestroyBoolean();
4249 : break;
4250 : }
4251 : }
4252 : }
4253 :
4254 : bool
4255 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
4256 :
4257 : private:
4258 : inline void
4259 : DestroyNode()
4260 : {
4261 : MOZ_ASSERT(IsNode(), "Wrong type!");
4262 : mValue.mNode.Destroy();
4263 : mType = eUninitialized;
4264 : }
4265 :
4266 : inline void
4267 : DestroyLong()
4268 : {
4269 : MOZ_ASSERT(IsLong(), "Wrong type!");
4270 : mValue.mLong.Destroy();
4271 : mType = eUninitialized;
4272 : }
4273 :
4274 : inline void
4275 : DestroyBoolean()
4276 : {
4277 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4278 : mValue.mBoolean.Destroy();
4279 : mType = eUninitialized;
4280 : }
4281 : };
4282 :
4283 : class NodeOrString
4284 : {
4285 : friend class NodeOrStringArgument;
4286 : enum Type
4287 : {
4288 : eUninitialized,
4289 : eNode,
4290 : eString
4291 : };
4292 :
4293 : union Value
4294 : {
4295 : UnionMember<NonNull<nsINode> > mNode;
4296 : UnionMember<binding_detail::FakeString > mString;
4297 :
4298 : };
4299 :
4300 : Type mType;
4301 : Value mValue;
4302 :
4303 : NodeOrString(const NodeOrString&) = delete;
4304 : NodeOrString& operator=(const NodeOrString&) = delete;
4305 : public:
4306 : explicit inline NodeOrString()
4307 : : mType(eUninitialized)
4308 : {
4309 : }
4310 :
4311 : inline ~NodeOrString()
4312 : {
4313 : Uninit();
4314 : }
4315 :
4316 : inline NonNull<nsINode>&
4317 : RawSetAsNode()
4318 : {
4319 : if (mType == eNode) {
4320 : return mValue.mNode.Value();
4321 : }
4322 : MOZ_ASSERT(mType == eUninitialized);
4323 : mType = eNode;
4324 : return mValue.mNode.SetValue();
4325 : }
4326 :
4327 : inline NonNull<nsINode>&
4328 : SetAsNode()
4329 : {
4330 : if (mType == eNode) {
4331 : return mValue.mNode.Value();
4332 : }
4333 : Uninit();
4334 : mType = eNode;
4335 : return mValue.mNode.SetValue();
4336 : }
4337 :
4338 : inline bool
4339 : IsNode() const
4340 : {
4341 : return mType == eNode;
4342 : }
4343 :
4344 : inline NonNull<nsINode>&
4345 : GetAsNode()
4346 : {
4347 : MOZ_ASSERT(IsNode(), "Wrong type!");
4348 : return mValue.mNode.Value();
4349 : }
4350 :
4351 : inline nsINode&
4352 : GetAsNode() const
4353 : {
4354 : MOZ_ASSERT(IsNode(), "Wrong type!");
4355 : return mValue.mNode.Value();
4356 : }
4357 :
4358 : inline binding_detail::FakeString&
4359 : RawSetAsString()
4360 : {
4361 : if (mType == eString) {
4362 : return mValue.mString.Value();
4363 : }
4364 : MOZ_ASSERT(mType == eUninitialized);
4365 : mType = eString;
4366 : return mValue.mString.SetValue();
4367 : }
4368 :
4369 : inline binding_detail::FakeString&
4370 : SetAsString()
4371 : {
4372 : if (mType == eString) {
4373 : return mValue.mString.Value();
4374 : }
4375 : Uninit();
4376 : mType = eString;
4377 : return mValue.mString.SetValue();
4378 : }
4379 :
4380 : inline bool
4381 : IsString() const
4382 : {
4383 : return mType == eString;
4384 : }
4385 :
4386 : inline binding_detail::FakeString&
4387 : GetAsString()
4388 : {
4389 : MOZ_ASSERT(IsString(), "Wrong type!");
4390 : return mValue.mString.Value();
4391 : }
4392 :
4393 : inline const nsAString&
4394 : GetAsString() const
4395 : {
4396 : MOZ_ASSERT(IsString(), "Wrong type!");
4397 : return mValue.mString.Value();
4398 : }
4399 :
4400 : inline void
4401 : Uninit()
4402 : {
4403 : switch (mType) {
4404 : case eUninitialized: {
4405 : break;
4406 : }
4407 : case eNode: {
4408 : DestroyNode();
4409 : break;
4410 : }
4411 : case eString: {
4412 : DestroyString();
4413 : break;
4414 : }
4415 : }
4416 : }
4417 :
4418 : bool
4419 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
4420 :
4421 : private:
4422 : inline void
4423 : DestroyNode()
4424 : {
4425 : MOZ_ASSERT(IsNode(), "Wrong type!");
4426 : mValue.mNode.Destroy();
4427 : mType = eUninitialized;
4428 : }
4429 :
4430 : inline void
4431 : DestroyString()
4432 : {
4433 : MOZ_ASSERT(IsString(), "Wrong type!");
4434 : mValue.mString.Destroy();
4435 : mType = eUninitialized;
4436 : }
4437 : };
4438 :
4439 : class ObjectOrBoolean
4440 : {
4441 : friend class ObjectOrBooleanArgument;
4442 : enum Type
4443 : {
4444 : eUninitialized,
4445 : eObject,
4446 : eBoolean
4447 : };
4448 :
4449 : union Value
4450 : {
4451 : UnionMember<JS::Rooted<JSObject*> > mObject;
4452 : UnionMember<bool > mBoolean;
4453 :
4454 : };
4455 :
4456 : Type mType;
4457 : Value mValue;
4458 :
4459 : ObjectOrBoolean(const ObjectOrBoolean&) = delete;
4460 : ObjectOrBoolean& operator=(const ObjectOrBoolean&) = delete;
4461 : public:
4462 : explicit inline ObjectOrBoolean()
4463 : : mType(eUninitialized)
4464 : {
4465 : }
4466 :
4467 : inline ~ObjectOrBoolean()
4468 : {
4469 : Uninit();
4470 : }
4471 :
4472 : inline bool
4473 : IsObject() const
4474 : {
4475 : return mType == eObject;
4476 : }
4477 :
4478 : inline JS::Rooted<JSObject*>&
4479 : GetAsObject()
4480 : {
4481 : MOZ_ASSERT(IsObject(), "Wrong type!");
4482 : return mValue.mObject.Value();
4483 : }
4484 :
4485 : inline JSObject*
4486 : GetAsObject() const
4487 : {
4488 : MOZ_ASSERT(IsObject(), "Wrong type!");
4489 : return mValue.mObject.Value();
4490 : }
4491 :
4492 : inline bool&
4493 : RawSetAsBoolean()
4494 : {
4495 : if (mType == eBoolean) {
4496 : return mValue.mBoolean.Value();
4497 : }
4498 : MOZ_ASSERT(mType == eUninitialized);
4499 : mType = eBoolean;
4500 : return mValue.mBoolean.SetValue();
4501 : }
4502 :
4503 : inline bool&
4504 : SetAsBoolean()
4505 : {
4506 : if (mType == eBoolean) {
4507 : return mValue.mBoolean.Value();
4508 : }
4509 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
4510 : Uninit();
4511 : mType = eBoolean;
4512 : return mValue.mBoolean.SetValue();
4513 : }
4514 :
4515 : inline bool
4516 : IsBoolean() const
4517 : {
4518 : return mType == eBoolean;
4519 : }
4520 :
4521 : inline bool&
4522 : GetAsBoolean()
4523 : {
4524 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4525 : return mValue.mBoolean.Value();
4526 : }
4527 :
4528 : inline bool
4529 : GetAsBoolean() const
4530 : {
4531 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4532 : return mValue.mBoolean.Value();
4533 : }
4534 :
4535 : inline void
4536 : Uninit()
4537 : {
4538 : switch (mType) {
4539 : case eUninitialized: {
4540 : break;
4541 : }
4542 : case eObject: {
4543 : DestroyObject();
4544 : break;
4545 : }
4546 : case eBoolean: {
4547 : DestroyBoolean();
4548 : break;
4549 : }
4550 : }
4551 : }
4552 :
4553 : bool
4554 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
4555 :
4556 : private:
4557 : inline void
4558 : DestroyObject()
4559 : {
4560 : MOZ_ASSERT(IsObject(), "Wrong type!");
4561 : mValue.mObject.Destroy();
4562 : mType = eUninitialized;
4563 : }
4564 :
4565 : inline void
4566 : DestroyBoolean()
4567 : {
4568 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4569 : mValue.mBoolean.Destroy();
4570 : mType = eUninitialized;
4571 : }
4572 : };
4573 :
4574 : class ObjectOrLong
4575 : {
4576 : friend class ObjectOrLongArgument;
4577 : enum Type
4578 : {
4579 : eUninitialized,
4580 : eObject,
4581 : eLong
4582 : };
4583 :
4584 : union Value
4585 : {
4586 : UnionMember<JS::Rooted<JSObject*> > mObject;
4587 : UnionMember<int32_t > mLong;
4588 :
4589 : };
4590 :
4591 : Type mType;
4592 : Value mValue;
4593 :
4594 : ObjectOrLong(const ObjectOrLong&) = delete;
4595 : ObjectOrLong& operator=(const ObjectOrLong&) = delete;
4596 : public:
4597 : explicit inline ObjectOrLong()
4598 : : mType(eUninitialized)
4599 : {
4600 : }
4601 :
4602 : inline ~ObjectOrLong()
4603 : {
4604 : Uninit();
4605 : }
4606 :
4607 : inline bool
4608 : IsObject() const
4609 : {
4610 : return mType == eObject;
4611 : }
4612 :
4613 : inline JS::Rooted<JSObject*>&
4614 : GetAsObject()
4615 : {
4616 : MOZ_ASSERT(IsObject(), "Wrong type!");
4617 : return mValue.mObject.Value();
4618 : }
4619 :
4620 : inline JSObject*
4621 : GetAsObject() const
4622 : {
4623 : MOZ_ASSERT(IsObject(), "Wrong type!");
4624 : return mValue.mObject.Value();
4625 : }
4626 :
4627 : inline int32_t&
4628 : RawSetAsLong()
4629 : {
4630 : if (mType == eLong) {
4631 : return mValue.mLong.Value();
4632 : }
4633 : MOZ_ASSERT(mType == eUninitialized);
4634 : mType = eLong;
4635 : return mValue.mLong.SetValue();
4636 : }
4637 :
4638 : inline int32_t&
4639 : SetAsLong()
4640 : {
4641 : if (mType == eLong) {
4642 : return mValue.mLong.Value();
4643 : }
4644 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
4645 : Uninit();
4646 : mType = eLong;
4647 : return mValue.mLong.SetValue();
4648 : }
4649 :
4650 : inline bool
4651 : IsLong() const
4652 : {
4653 : return mType == eLong;
4654 : }
4655 :
4656 : inline int32_t&
4657 : GetAsLong()
4658 : {
4659 : MOZ_ASSERT(IsLong(), "Wrong type!");
4660 : return mValue.mLong.Value();
4661 : }
4662 :
4663 : inline int32_t
4664 : GetAsLong() const
4665 : {
4666 : MOZ_ASSERT(IsLong(), "Wrong type!");
4667 : return mValue.mLong.Value();
4668 : }
4669 :
4670 : inline void
4671 : Uninit()
4672 : {
4673 : switch (mType) {
4674 : case eUninitialized: {
4675 : break;
4676 : }
4677 : case eObject: {
4678 : DestroyObject();
4679 : break;
4680 : }
4681 : case eLong: {
4682 : DestroyLong();
4683 : break;
4684 : }
4685 : }
4686 : }
4687 :
4688 : bool
4689 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
4690 :
4691 : private:
4692 : inline void
4693 : DestroyObject()
4694 : {
4695 : MOZ_ASSERT(IsObject(), "Wrong type!");
4696 : mValue.mObject.Destroy();
4697 : mType = eUninitialized;
4698 : }
4699 :
4700 : inline void
4701 : DestroyLong()
4702 : {
4703 : MOZ_ASSERT(IsLong(), "Wrong type!");
4704 : mValue.mLong.Destroy();
4705 : mType = eUninitialized;
4706 : }
4707 : };
4708 :
4709 : class ObjectOrLongOrBoolean
4710 : {
4711 : friend class ObjectOrLongOrBooleanArgument;
4712 : enum Type
4713 : {
4714 : eUninitialized,
4715 : eObject,
4716 : eLong,
4717 : eBoolean
4718 : };
4719 :
4720 : union Value
4721 : {
4722 : UnionMember<JS::Rooted<JSObject*> > mObject;
4723 : UnionMember<int32_t > mLong;
4724 : UnionMember<bool > mBoolean;
4725 :
4726 : };
4727 :
4728 : Type mType;
4729 : Value mValue;
4730 :
4731 : ObjectOrLongOrBoolean(const ObjectOrLongOrBoolean&) = delete;
4732 : ObjectOrLongOrBoolean& operator=(const ObjectOrLongOrBoolean&) = delete;
4733 : public:
4734 : explicit inline ObjectOrLongOrBoolean()
4735 : : mType(eUninitialized)
4736 : {
4737 : }
4738 :
4739 : inline ~ObjectOrLongOrBoolean()
4740 : {
4741 : Uninit();
4742 : }
4743 :
4744 : inline bool
4745 : IsObject() const
4746 : {
4747 : return mType == eObject;
4748 : }
4749 :
4750 : inline JS::Rooted<JSObject*>&
4751 : GetAsObject()
4752 : {
4753 : MOZ_ASSERT(IsObject(), "Wrong type!");
4754 : return mValue.mObject.Value();
4755 : }
4756 :
4757 : inline JSObject*
4758 : GetAsObject() const
4759 : {
4760 : MOZ_ASSERT(IsObject(), "Wrong type!");
4761 : return mValue.mObject.Value();
4762 : }
4763 :
4764 : inline int32_t&
4765 : RawSetAsLong()
4766 : {
4767 : if (mType == eLong) {
4768 : return mValue.mLong.Value();
4769 : }
4770 : MOZ_ASSERT(mType == eUninitialized);
4771 : mType = eLong;
4772 : return mValue.mLong.SetValue();
4773 : }
4774 :
4775 : inline int32_t&
4776 : SetAsLong()
4777 : {
4778 : if (mType == eLong) {
4779 : return mValue.mLong.Value();
4780 : }
4781 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
4782 : Uninit();
4783 : mType = eLong;
4784 : return mValue.mLong.SetValue();
4785 : }
4786 :
4787 : inline bool
4788 : IsLong() const
4789 : {
4790 : return mType == eLong;
4791 : }
4792 :
4793 : inline int32_t&
4794 : GetAsLong()
4795 : {
4796 : MOZ_ASSERT(IsLong(), "Wrong type!");
4797 : return mValue.mLong.Value();
4798 : }
4799 :
4800 : inline int32_t
4801 : GetAsLong() const
4802 : {
4803 : MOZ_ASSERT(IsLong(), "Wrong type!");
4804 : return mValue.mLong.Value();
4805 : }
4806 :
4807 : inline bool&
4808 : RawSetAsBoolean()
4809 : {
4810 : if (mType == eBoolean) {
4811 : return mValue.mBoolean.Value();
4812 : }
4813 : MOZ_ASSERT(mType == eUninitialized);
4814 : mType = eBoolean;
4815 : return mValue.mBoolean.SetValue();
4816 : }
4817 :
4818 : inline bool&
4819 : SetAsBoolean()
4820 : {
4821 : if (mType == eBoolean) {
4822 : return mValue.mBoolean.Value();
4823 : }
4824 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
4825 : Uninit();
4826 : mType = eBoolean;
4827 : return mValue.mBoolean.SetValue();
4828 : }
4829 :
4830 : inline bool
4831 : IsBoolean() const
4832 : {
4833 : return mType == eBoolean;
4834 : }
4835 :
4836 : inline bool&
4837 : GetAsBoolean()
4838 : {
4839 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4840 : return mValue.mBoolean.Value();
4841 : }
4842 :
4843 : inline bool
4844 : GetAsBoolean() const
4845 : {
4846 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4847 : return mValue.mBoolean.Value();
4848 : }
4849 :
4850 : inline void
4851 : Uninit()
4852 : {
4853 : switch (mType) {
4854 : case eUninitialized: {
4855 : break;
4856 : }
4857 : case eObject: {
4858 : DestroyObject();
4859 : break;
4860 : }
4861 : case eLong: {
4862 : DestroyLong();
4863 : break;
4864 : }
4865 : case eBoolean: {
4866 : DestroyBoolean();
4867 : break;
4868 : }
4869 : }
4870 : }
4871 :
4872 : bool
4873 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
4874 :
4875 : private:
4876 : inline void
4877 : DestroyObject()
4878 : {
4879 : MOZ_ASSERT(IsObject(), "Wrong type!");
4880 : mValue.mObject.Destroy();
4881 : mType = eUninitialized;
4882 : }
4883 :
4884 : inline void
4885 : DestroyLong()
4886 : {
4887 : MOZ_ASSERT(IsLong(), "Wrong type!");
4888 : mValue.mLong.Destroy();
4889 : mType = eUninitialized;
4890 : }
4891 :
4892 : inline void
4893 : DestroyBoolean()
4894 : {
4895 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
4896 : mValue.mBoolean.Destroy();
4897 : mType = eUninitialized;
4898 : }
4899 : };
4900 :
4901 : class ObjectOrLongOrNull
4902 : {
4903 : friend class ObjectOrLongOrNullArgument;
4904 : enum Type
4905 : {
4906 : eUninitialized,
4907 : eNull,
4908 : eObject,
4909 : eLong
4910 : };
4911 :
4912 : union Value
4913 : {
4914 : UnionMember<JS::Rooted<JSObject*> > mObject;
4915 : UnionMember<int32_t > mLong;
4916 :
4917 : };
4918 :
4919 : Type mType;
4920 : Value mValue;
4921 :
4922 : ObjectOrLongOrNull(const ObjectOrLongOrNull&) = delete;
4923 : ObjectOrLongOrNull& operator=(const ObjectOrLongOrNull&) = delete;
4924 : public:
4925 : explicit inline ObjectOrLongOrNull()
4926 : : mType(eUninitialized)
4927 : {
4928 : }
4929 :
4930 : inline ~ObjectOrLongOrNull()
4931 : {
4932 : Uninit();
4933 : }
4934 :
4935 : inline bool
4936 : IsNull() const
4937 : {
4938 : return mType == eNull;
4939 : }
4940 :
4941 : inline void
4942 : SetNull()
4943 : {
4944 : Uninit();
4945 : mType = eNull;
4946 : }
4947 :
4948 : inline bool
4949 : IsObject() const
4950 : {
4951 : return mType == eObject;
4952 : }
4953 :
4954 : inline JS::Rooted<JSObject*>&
4955 : GetAsObject()
4956 : {
4957 : MOZ_ASSERT(IsObject(), "Wrong type!");
4958 : return mValue.mObject.Value();
4959 : }
4960 :
4961 : inline JSObject*
4962 : GetAsObject() const
4963 : {
4964 : MOZ_ASSERT(IsObject(), "Wrong type!");
4965 : return mValue.mObject.Value();
4966 : }
4967 :
4968 : inline int32_t&
4969 : RawSetAsLong()
4970 : {
4971 : if (mType == eLong) {
4972 : return mValue.mLong.Value();
4973 : }
4974 : MOZ_ASSERT(mType == eUninitialized);
4975 : mType = eLong;
4976 : return mValue.mLong.SetValue();
4977 : }
4978 :
4979 : inline int32_t&
4980 : SetAsLong()
4981 : {
4982 : if (mType == eLong) {
4983 : return mValue.mLong.Value();
4984 : }
4985 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
4986 : Uninit();
4987 : mType = eLong;
4988 : return mValue.mLong.SetValue();
4989 : }
4990 :
4991 : inline bool
4992 : IsLong() const
4993 : {
4994 : return mType == eLong;
4995 : }
4996 :
4997 : inline int32_t&
4998 : GetAsLong()
4999 : {
5000 : MOZ_ASSERT(IsLong(), "Wrong type!");
5001 : return mValue.mLong.Value();
5002 : }
5003 :
5004 : inline int32_t
5005 : GetAsLong() const
5006 : {
5007 : MOZ_ASSERT(IsLong(), "Wrong type!");
5008 : return mValue.mLong.Value();
5009 : }
5010 :
5011 : inline void
5012 : Uninit()
5013 : {
5014 : switch (mType) {
5015 : case eUninitialized: {
5016 : break;
5017 : }
5018 : case eNull: {
5019 : break;
5020 : }
5021 : case eObject: {
5022 : DestroyObject();
5023 : break;
5024 : }
5025 : case eLong: {
5026 : DestroyLong();
5027 : break;
5028 : }
5029 : }
5030 : }
5031 :
5032 : bool
5033 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
5034 :
5035 : private:
5036 : inline void
5037 : DestroyObject()
5038 : {
5039 : MOZ_ASSERT(IsObject(), "Wrong type!");
5040 : mValue.mObject.Destroy();
5041 : mType = eUninitialized;
5042 : }
5043 :
5044 : inline void
5045 : DestroyLong()
5046 : {
5047 : MOZ_ASSERT(IsLong(), "Wrong type!");
5048 : mValue.mLong.Destroy();
5049 : mType = eUninitialized;
5050 : }
5051 : };
5052 :
5053 : class ObjectOrNullOrLong
5054 : {
5055 : friend class ObjectOrNullOrLongArgument;
5056 : enum Type
5057 : {
5058 : eUninitialized,
5059 : eNull,
5060 : eObject,
5061 : eLong
5062 : };
5063 :
5064 : union Value
5065 : {
5066 : UnionMember<JS::Rooted<JSObject*> > mObject;
5067 : UnionMember<int32_t > mLong;
5068 :
5069 : };
5070 :
5071 : Type mType;
5072 : Value mValue;
5073 :
5074 : ObjectOrNullOrLong(const ObjectOrNullOrLong&) = delete;
5075 : ObjectOrNullOrLong& operator=(const ObjectOrNullOrLong&) = delete;
5076 : public:
5077 : explicit inline ObjectOrNullOrLong()
5078 : : mType(eUninitialized)
5079 : {
5080 : }
5081 :
5082 : inline ~ObjectOrNullOrLong()
5083 : {
5084 : Uninit();
5085 : }
5086 :
5087 : inline bool
5088 : IsNull() const
5089 : {
5090 : return mType == eNull;
5091 : }
5092 :
5093 : inline void
5094 : SetNull()
5095 : {
5096 : Uninit();
5097 : mType = eNull;
5098 : }
5099 :
5100 : inline bool
5101 : IsObject() const
5102 : {
5103 : return mType == eObject;
5104 : }
5105 :
5106 : inline JS::Rooted<JSObject*>&
5107 : GetAsObject()
5108 : {
5109 : MOZ_ASSERT(IsObject(), "Wrong type!");
5110 : return mValue.mObject.Value();
5111 : }
5112 :
5113 : inline JSObject*
5114 : GetAsObject() const
5115 : {
5116 : MOZ_ASSERT(IsObject(), "Wrong type!");
5117 : return mValue.mObject.Value();
5118 : }
5119 :
5120 : inline int32_t&
5121 : RawSetAsLong()
5122 : {
5123 : if (mType == eLong) {
5124 : return mValue.mLong.Value();
5125 : }
5126 : MOZ_ASSERT(mType == eUninitialized);
5127 : mType = eLong;
5128 : return mValue.mLong.SetValue();
5129 : }
5130 :
5131 : inline int32_t&
5132 : SetAsLong()
5133 : {
5134 : if (mType == eLong) {
5135 : return mValue.mLong.Value();
5136 : }
5137 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5138 : Uninit();
5139 : mType = eLong;
5140 : return mValue.mLong.SetValue();
5141 : }
5142 :
5143 : inline bool
5144 : IsLong() const
5145 : {
5146 : return mType == eLong;
5147 : }
5148 :
5149 : inline int32_t&
5150 : GetAsLong()
5151 : {
5152 : MOZ_ASSERT(IsLong(), "Wrong type!");
5153 : return mValue.mLong.Value();
5154 : }
5155 :
5156 : inline int32_t
5157 : GetAsLong() const
5158 : {
5159 : MOZ_ASSERT(IsLong(), "Wrong type!");
5160 : return mValue.mLong.Value();
5161 : }
5162 :
5163 : inline void
5164 : Uninit()
5165 : {
5166 : switch (mType) {
5167 : case eUninitialized: {
5168 : break;
5169 : }
5170 : case eNull: {
5171 : break;
5172 : }
5173 : case eObject: {
5174 : DestroyObject();
5175 : break;
5176 : }
5177 : case eLong: {
5178 : DestroyLong();
5179 : break;
5180 : }
5181 : }
5182 : }
5183 :
5184 : bool
5185 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
5186 :
5187 : private:
5188 : inline void
5189 : DestroyObject()
5190 : {
5191 : MOZ_ASSERT(IsObject(), "Wrong type!");
5192 : mValue.mObject.Destroy();
5193 : mType = eUninitialized;
5194 : }
5195 :
5196 : inline void
5197 : DestroyLong()
5198 : {
5199 : MOZ_ASSERT(IsLong(), "Wrong type!");
5200 : mValue.mLong.Destroy();
5201 : mType = eUninitialized;
5202 : }
5203 : };
5204 :
5205 : class ObjectOrString
5206 : {
5207 : friend class ObjectOrStringArgument;
5208 : enum Type
5209 : {
5210 : eUninitialized,
5211 : eObject,
5212 : eString
5213 : };
5214 :
5215 0 : union Value
5216 : {
5217 : UnionMember<JS::Rooted<JSObject*> > mObject;
5218 : UnionMember<binding_detail::FakeString > mString;
5219 :
5220 : };
5221 :
5222 : Type mType;
5223 : Value mValue;
5224 :
5225 : ObjectOrString(const ObjectOrString&) = delete;
5226 : ObjectOrString& operator=(const ObjectOrString&) = delete;
5227 : public:
5228 0 : explicit inline ObjectOrString()
5229 0 : : mType(eUninitialized)
5230 : {
5231 0 : }
5232 :
5233 0 : inline ~ObjectOrString()
5234 0 : {
5235 0 : Uninit();
5236 0 : }
5237 :
5238 : inline bool
5239 0 : IsObject() const
5240 : {
5241 0 : return mType == eObject;
5242 : }
5243 :
5244 : inline JS::Rooted<JSObject*>&
5245 : GetAsObject()
5246 : {
5247 : MOZ_ASSERT(IsObject(), "Wrong type!");
5248 : return mValue.mObject.Value();
5249 : }
5250 :
5251 : inline JSObject*
5252 0 : GetAsObject() const
5253 : {
5254 0 : MOZ_ASSERT(IsObject(), "Wrong type!");
5255 0 : return mValue.mObject.Value();
5256 : }
5257 :
5258 : inline binding_detail::FakeString&
5259 : RawSetAsString()
5260 : {
5261 : if (mType == eString) {
5262 : return mValue.mString.Value();
5263 : }
5264 : MOZ_ASSERT(mType == eUninitialized);
5265 : mType = eString;
5266 : return mValue.mString.SetValue();
5267 : }
5268 :
5269 : inline binding_detail::FakeString&
5270 : SetAsString()
5271 : {
5272 : if (mType == eString) {
5273 : return mValue.mString.Value();
5274 : }
5275 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5276 : Uninit();
5277 : mType = eString;
5278 : return mValue.mString.SetValue();
5279 : }
5280 :
5281 : inline bool
5282 0 : IsString() const
5283 : {
5284 0 : return mType == eString;
5285 : }
5286 :
5287 : inline binding_detail::FakeString&
5288 : GetAsString()
5289 : {
5290 : MOZ_ASSERT(IsString(), "Wrong type!");
5291 : return mValue.mString.Value();
5292 : }
5293 :
5294 : inline const nsAString&
5295 0 : GetAsString() const
5296 : {
5297 0 : MOZ_ASSERT(IsString(), "Wrong type!");
5298 0 : return mValue.mString.Value();
5299 : }
5300 :
5301 : inline void
5302 0 : Uninit()
5303 : {
5304 0 : switch (mType) {
5305 : case eUninitialized: {
5306 0 : break;
5307 : }
5308 : case eObject: {
5309 0 : DestroyObject();
5310 0 : break;
5311 : }
5312 : case eString: {
5313 0 : DestroyString();
5314 0 : break;
5315 : }
5316 : }
5317 0 : }
5318 :
5319 : bool
5320 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
5321 :
5322 : private:
5323 : inline void
5324 0 : DestroyObject()
5325 : {
5326 0 : MOZ_ASSERT(IsObject(), "Wrong type!");
5327 0 : mValue.mObject.Destroy();
5328 0 : mType = eUninitialized;
5329 0 : }
5330 :
5331 : inline void
5332 0 : DestroyString()
5333 : {
5334 0 : MOZ_ASSERT(IsString(), "Wrong type!");
5335 0 : mValue.mString.Destroy();
5336 0 : mType = eUninitialized;
5337 0 : }
5338 : };
5339 :
5340 : class ObjectOrStringOrBoolean
5341 : {
5342 : friend class ObjectOrStringOrBooleanArgument;
5343 : enum Type
5344 : {
5345 : eUninitialized,
5346 : eObject,
5347 : eString,
5348 : eBoolean
5349 : };
5350 :
5351 : union Value
5352 : {
5353 : UnionMember<JS::Rooted<JSObject*> > mObject;
5354 : UnionMember<binding_detail::FakeString > mString;
5355 : UnionMember<bool > mBoolean;
5356 :
5357 : };
5358 :
5359 : Type mType;
5360 : Value mValue;
5361 :
5362 : ObjectOrStringOrBoolean(const ObjectOrStringOrBoolean&) = delete;
5363 : ObjectOrStringOrBoolean& operator=(const ObjectOrStringOrBoolean&) = delete;
5364 : public:
5365 : explicit inline ObjectOrStringOrBoolean()
5366 : : mType(eUninitialized)
5367 : {
5368 : }
5369 :
5370 : inline ~ObjectOrStringOrBoolean()
5371 : {
5372 : Uninit();
5373 : }
5374 :
5375 : inline bool
5376 : IsObject() const
5377 : {
5378 : return mType == eObject;
5379 : }
5380 :
5381 : inline JS::Rooted<JSObject*>&
5382 : GetAsObject()
5383 : {
5384 : MOZ_ASSERT(IsObject(), "Wrong type!");
5385 : return mValue.mObject.Value();
5386 : }
5387 :
5388 : inline JSObject*
5389 : GetAsObject() const
5390 : {
5391 : MOZ_ASSERT(IsObject(), "Wrong type!");
5392 : return mValue.mObject.Value();
5393 : }
5394 :
5395 : inline binding_detail::FakeString&
5396 : RawSetAsString()
5397 : {
5398 : if (mType == eString) {
5399 : return mValue.mString.Value();
5400 : }
5401 : MOZ_ASSERT(mType == eUninitialized);
5402 : mType = eString;
5403 : return mValue.mString.SetValue();
5404 : }
5405 :
5406 : inline binding_detail::FakeString&
5407 : SetAsString()
5408 : {
5409 : if (mType == eString) {
5410 : return mValue.mString.Value();
5411 : }
5412 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5413 : Uninit();
5414 : mType = eString;
5415 : return mValue.mString.SetValue();
5416 : }
5417 :
5418 : inline bool
5419 : IsString() const
5420 : {
5421 : return mType == eString;
5422 : }
5423 :
5424 : inline binding_detail::FakeString&
5425 : GetAsString()
5426 : {
5427 : MOZ_ASSERT(IsString(), "Wrong type!");
5428 : return mValue.mString.Value();
5429 : }
5430 :
5431 : inline const nsAString&
5432 : GetAsString() const
5433 : {
5434 : MOZ_ASSERT(IsString(), "Wrong type!");
5435 : return mValue.mString.Value();
5436 : }
5437 :
5438 : inline bool&
5439 : RawSetAsBoolean()
5440 : {
5441 : if (mType == eBoolean) {
5442 : return mValue.mBoolean.Value();
5443 : }
5444 : MOZ_ASSERT(mType == eUninitialized);
5445 : mType = eBoolean;
5446 : return mValue.mBoolean.SetValue();
5447 : }
5448 :
5449 : inline bool&
5450 : SetAsBoolean()
5451 : {
5452 : if (mType == eBoolean) {
5453 : return mValue.mBoolean.Value();
5454 : }
5455 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5456 : Uninit();
5457 : mType = eBoolean;
5458 : return mValue.mBoolean.SetValue();
5459 : }
5460 :
5461 : inline bool
5462 : IsBoolean() const
5463 : {
5464 : return mType == eBoolean;
5465 : }
5466 :
5467 : inline bool&
5468 : GetAsBoolean()
5469 : {
5470 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
5471 : return mValue.mBoolean.Value();
5472 : }
5473 :
5474 : inline bool
5475 : GetAsBoolean() const
5476 : {
5477 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
5478 : return mValue.mBoolean.Value();
5479 : }
5480 :
5481 : inline void
5482 : Uninit()
5483 : {
5484 : switch (mType) {
5485 : case eUninitialized: {
5486 : break;
5487 : }
5488 : case eObject: {
5489 : DestroyObject();
5490 : break;
5491 : }
5492 : case eString: {
5493 : DestroyString();
5494 : break;
5495 : }
5496 : case eBoolean: {
5497 : DestroyBoolean();
5498 : break;
5499 : }
5500 : }
5501 : }
5502 :
5503 : bool
5504 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
5505 :
5506 : private:
5507 : inline void
5508 : DestroyObject()
5509 : {
5510 : MOZ_ASSERT(IsObject(), "Wrong type!");
5511 : mValue.mObject.Destroy();
5512 : mType = eUninitialized;
5513 : }
5514 :
5515 : inline void
5516 : DestroyString()
5517 : {
5518 : MOZ_ASSERT(IsString(), "Wrong type!");
5519 : mValue.mString.Destroy();
5520 : mType = eUninitialized;
5521 : }
5522 :
5523 : inline void
5524 : DestroyBoolean()
5525 : {
5526 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
5527 : mValue.mBoolean.Destroy();
5528 : mType = eUninitialized;
5529 : }
5530 : };
5531 :
5532 : class ObjectOrStringOrLong
5533 : {
5534 : friend class ObjectOrStringOrLongArgument;
5535 : enum Type
5536 : {
5537 : eUninitialized,
5538 : eObject,
5539 : eString,
5540 : eLong
5541 : };
5542 :
5543 : union Value
5544 : {
5545 : UnionMember<JS::Rooted<JSObject*> > mObject;
5546 : UnionMember<binding_detail::FakeString > mString;
5547 : UnionMember<int32_t > mLong;
5548 :
5549 : };
5550 :
5551 : Type mType;
5552 : Value mValue;
5553 :
5554 : ObjectOrStringOrLong(const ObjectOrStringOrLong&) = delete;
5555 : ObjectOrStringOrLong& operator=(const ObjectOrStringOrLong&) = delete;
5556 : public:
5557 : explicit inline ObjectOrStringOrLong()
5558 : : mType(eUninitialized)
5559 : {
5560 : }
5561 :
5562 : inline ~ObjectOrStringOrLong()
5563 : {
5564 : Uninit();
5565 : }
5566 :
5567 : inline bool
5568 : IsObject() const
5569 : {
5570 : return mType == eObject;
5571 : }
5572 :
5573 : inline JS::Rooted<JSObject*>&
5574 : GetAsObject()
5575 : {
5576 : MOZ_ASSERT(IsObject(), "Wrong type!");
5577 : return mValue.mObject.Value();
5578 : }
5579 :
5580 : inline JSObject*
5581 : GetAsObject() const
5582 : {
5583 : MOZ_ASSERT(IsObject(), "Wrong type!");
5584 : return mValue.mObject.Value();
5585 : }
5586 :
5587 : inline binding_detail::FakeString&
5588 : RawSetAsString()
5589 : {
5590 : if (mType == eString) {
5591 : return mValue.mString.Value();
5592 : }
5593 : MOZ_ASSERT(mType == eUninitialized);
5594 : mType = eString;
5595 : return mValue.mString.SetValue();
5596 : }
5597 :
5598 : inline binding_detail::FakeString&
5599 : SetAsString()
5600 : {
5601 : if (mType == eString) {
5602 : return mValue.mString.Value();
5603 : }
5604 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5605 : Uninit();
5606 : mType = eString;
5607 : return mValue.mString.SetValue();
5608 : }
5609 :
5610 : inline bool
5611 : IsString() const
5612 : {
5613 : return mType == eString;
5614 : }
5615 :
5616 : inline binding_detail::FakeString&
5617 : GetAsString()
5618 : {
5619 : MOZ_ASSERT(IsString(), "Wrong type!");
5620 : return mValue.mString.Value();
5621 : }
5622 :
5623 : inline const nsAString&
5624 : GetAsString() const
5625 : {
5626 : MOZ_ASSERT(IsString(), "Wrong type!");
5627 : return mValue.mString.Value();
5628 : }
5629 :
5630 : inline int32_t&
5631 : RawSetAsLong()
5632 : {
5633 : if (mType == eLong) {
5634 : return mValue.mLong.Value();
5635 : }
5636 : MOZ_ASSERT(mType == eUninitialized);
5637 : mType = eLong;
5638 : return mValue.mLong.SetValue();
5639 : }
5640 :
5641 : inline int32_t&
5642 : SetAsLong()
5643 : {
5644 : if (mType == eLong) {
5645 : return mValue.mLong.Value();
5646 : }
5647 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5648 : Uninit();
5649 : mType = eLong;
5650 : return mValue.mLong.SetValue();
5651 : }
5652 :
5653 : inline bool
5654 : IsLong() const
5655 : {
5656 : return mType == eLong;
5657 : }
5658 :
5659 : inline int32_t&
5660 : GetAsLong()
5661 : {
5662 : MOZ_ASSERT(IsLong(), "Wrong type!");
5663 : return mValue.mLong.Value();
5664 : }
5665 :
5666 : inline int32_t
5667 : GetAsLong() const
5668 : {
5669 : MOZ_ASSERT(IsLong(), "Wrong type!");
5670 : return mValue.mLong.Value();
5671 : }
5672 :
5673 : inline void
5674 : Uninit()
5675 : {
5676 : switch (mType) {
5677 : case eUninitialized: {
5678 : break;
5679 : }
5680 : case eObject: {
5681 : DestroyObject();
5682 : break;
5683 : }
5684 : case eString: {
5685 : DestroyString();
5686 : break;
5687 : }
5688 : case eLong: {
5689 : DestroyLong();
5690 : break;
5691 : }
5692 : }
5693 : }
5694 :
5695 : bool
5696 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
5697 :
5698 : private:
5699 : inline void
5700 : DestroyObject()
5701 : {
5702 : MOZ_ASSERT(IsObject(), "Wrong type!");
5703 : mValue.mObject.Destroy();
5704 : mType = eUninitialized;
5705 : }
5706 :
5707 : inline void
5708 : DestroyString()
5709 : {
5710 : MOZ_ASSERT(IsString(), "Wrong type!");
5711 : mValue.mString.Destroy();
5712 : mType = eUninitialized;
5713 : }
5714 :
5715 : inline void
5716 : DestroyLong()
5717 : {
5718 : MOZ_ASSERT(IsLong(), "Wrong type!");
5719 : mValue.mLong.Destroy();
5720 : mType = eUninitialized;
5721 : }
5722 : };
5723 :
5724 : class ObjectOrStringOrLongOrBoolean
5725 : {
5726 : friend class ObjectOrStringOrLongOrBooleanArgument;
5727 : enum Type
5728 : {
5729 : eUninitialized,
5730 : eObject,
5731 : eString,
5732 : eLong,
5733 : eBoolean
5734 : };
5735 :
5736 : union Value
5737 : {
5738 : UnionMember<JS::Rooted<JSObject*> > mObject;
5739 : UnionMember<binding_detail::FakeString > mString;
5740 : UnionMember<int32_t > mLong;
5741 : UnionMember<bool > mBoolean;
5742 :
5743 : };
5744 :
5745 : Type mType;
5746 : Value mValue;
5747 :
5748 : ObjectOrStringOrLongOrBoolean(const ObjectOrStringOrLongOrBoolean&) = delete;
5749 : ObjectOrStringOrLongOrBoolean& operator=(const ObjectOrStringOrLongOrBoolean&) = delete;
5750 : public:
5751 : explicit inline ObjectOrStringOrLongOrBoolean()
5752 : : mType(eUninitialized)
5753 : {
5754 : }
5755 :
5756 : inline ~ObjectOrStringOrLongOrBoolean()
5757 : {
5758 : Uninit();
5759 : }
5760 :
5761 : inline bool
5762 : IsObject() const
5763 : {
5764 : return mType == eObject;
5765 : }
5766 :
5767 : inline JS::Rooted<JSObject*>&
5768 : GetAsObject()
5769 : {
5770 : MOZ_ASSERT(IsObject(), "Wrong type!");
5771 : return mValue.mObject.Value();
5772 : }
5773 :
5774 : inline JSObject*
5775 : GetAsObject() const
5776 : {
5777 : MOZ_ASSERT(IsObject(), "Wrong type!");
5778 : return mValue.mObject.Value();
5779 : }
5780 :
5781 : inline binding_detail::FakeString&
5782 : RawSetAsString()
5783 : {
5784 : if (mType == eString) {
5785 : return mValue.mString.Value();
5786 : }
5787 : MOZ_ASSERT(mType == eUninitialized);
5788 : mType = eString;
5789 : return mValue.mString.SetValue();
5790 : }
5791 :
5792 : inline binding_detail::FakeString&
5793 : SetAsString()
5794 : {
5795 : if (mType == eString) {
5796 : return mValue.mString.Value();
5797 : }
5798 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5799 : Uninit();
5800 : mType = eString;
5801 : return mValue.mString.SetValue();
5802 : }
5803 :
5804 : inline bool
5805 : IsString() const
5806 : {
5807 : return mType == eString;
5808 : }
5809 :
5810 : inline binding_detail::FakeString&
5811 : GetAsString()
5812 : {
5813 : MOZ_ASSERT(IsString(), "Wrong type!");
5814 : return mValue.mString.Value();
5815 : }
5816 :
5817 : inline const nsAString&
5818 : GetAsString() const
5819 : {
5820 : MOZ_ASSERT(IsString(), "Wrong type!");
5821 : return mValue.mString.Value();
5822 : }
5823 :
5824 : inline int32_t&
5825 : RawSetAsLong()
5826 : {
5827 : if (mType == eLong) {
5828 : return mValue.mLong.Value();
5829 : }
5830 : MOZ_ASSERT(mType == eUninitialized);
5831 : mType = eLong;
5832 : return mValue.mLong.SetValue();
5833 : }
5834 :
5835 : inline int32_t&
5836 : SetAsLong()
5837 : {
5838 : if (mType == eLong) {
5839 : return mValue.mLong.Value();
5840 : }
5841 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5842 : Uninit();
5843 : mType = eLong;
5844 : return mValue.mLong.SetValue();
5845 : }
5846 :
5847 : inline bool
5848 : IsLong() const
5849 : {
5850 : return mType == eLong;
5851 : }
5852 :
5853 : inline int32_t&
5854 : GetAsLong()
5855 : {
5856 : MOZ_ASSERT(IsLong(), "Wrong type!");
5857 : return mValue.mLong.Value();
5858 : }
5859 :
5860 : inline int32_t
5861 : GetAsLong() const
5862 : {
5863 : MOZ_ASSERT(IsLong(), "Wrong type!");
5864 : return mValue.mLong.Value();
5865 : }
5866 :
5867 : inline bool&
5868 : RawSetAsBoolean()
5869 : {
5870 : if (mType == eBoolean) {
5871 : return mValue.mBoolean.Value();
5872 : }
5873 : MOZ_ASSERT(mType == eUninitialized);
5874 : mType = eBoolean;
5875 : return mValue.mBoolean.SetValue();
5876 : }
5877 :
5878 : inline bool&
5879 : SetAsBoolean()
5880 : {
5881 : if (mType == eBoolean) {
5882 : return mValue.mBoolean.Value();
5883 : }
5884 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
5885 : Uninit();
5886 : mType = eBoolean;
5887 : return mValue.mBoolean.SetValue();
5888 : }
5889 :
5890 : inline bool
5891 : IsBoolean() const
5892 : {
5893 : return mType == eBoolean;
5894 : }
5895 :
5896 : inline bool&
5897 : GetAsBoolean()
5898 : {
5899 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
5900 : return mValue.mBoolean.Value();
5901 : }
5902 :
5903 : inline bool
5904 : GetAsBoolean() const
5905 : {
5906 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
5907 : return mValue.mBoolean.Value();
5908 : }
5909 :
5910 : inline void
5911 : Uninit()
5912 : {
5913 : switch (mType) {
5914 : case eUninitialized: {
5915 : break;
5916 : }
5917 : case eObject: {
5918 : DestroyObject();
5919 : break;
5920 : }
5921 : case eString: {
5922 : DestroyString();
5923 : break;
5924 : }
5925 : case eLong: {
5926 : DestroyLong();
5927 : break;
5928 : }
5929 : case eBoolean: {
5930 : DestroyBoolean();
5931 : break;
5932 : }
5933 : }
5934 : }
5935 :
5936 : bool
5937 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
5938 :
5939 : private:
5940 : inline void
5941 : DestroyObject()
5942 : {
5943 : MOZ_ASSERT(IsObject(), "Wrong type!");
5944 : mValue.mObject.Destroy();
5945 : mType = eUninitialized;
5946 : }
5947 :
5948 : inline void
5949 : DestroyString()
5950 : {
5951 : MOZ_ASSERT(IsString(), "Wrong type!");
5952 : mValue.mString.Destroy();
5953 : mType = eUninitialized;
5954 : }
5955 :
5956 : inline void
5957 : DestroyLong()
5958 : {
5959 : MOZ_ASSERT(IsLong(), "Wrong type!");
5960 : mValue.mLong.Destroy();
5961 : mType = eUninitialized;
5962 : }
5963 :
5964 : inline void
5965 : DestroyBoolean()
5966 : {
5967 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
5968 : mValue.mBoolean.Destroy();
5969 : mType = eUninitialized;
5970 : }
5971 : };
5972 :
5973 : class ObjectSequenceOrLong
5974 : {
5975 : friend class ObjectSequenceOrLongArgument;
5976 : enum Type
5977 : {
5978 : eUninitialized,
5979 : eObjectSequence,
5980 : eLong
5981 : };
5982 :
5983 : union Value
5984 : {
5985 : UnionMember<binding_detail::AutoSequence<JSObject*> > mObjectSequence;
5986 : UnionMember<int32_t > mLong;
5987 :
5988 : };
5989 :
5990 : Type mType;
5991 : Value mValue;
5992 :
5993 : ObjectSequenceOrLong(const ObjectSequenceOrLong&) = delete;
5994 : ObjectSequenceOrLong& operator=(const ObjectSequenceOrLong&) = delete;
5995 : public:
5996 : explicit inline ObjectSequenceOrLong()
5997 : : mType(eUninitialized)
5998 : {
5999 : }
6000 :
6001 : inline ~ObjectSequenceOrLong()
6002 : {
6003 : Uninit();
6004 : }
6005 :
6006 : inline binding_detail::AutoSequence<JSObject*>&
6007 : RawSetAsObjectSequence()
6008 : {
6009 : if (mType == eObjectSequence) {
6010 : return mValue.mObjectSequence.Value();
6011 : }
6012 : MOZ_ASSERT(mType == eUninitialized);
6013 : mType = eObjectSequence;
6014 : return mValue.mObjectSequence.SetValue();
6015 : }
6016 :
6017 : inline binding_detail::AutoSequence<JSObject*>&
6018 : SetAsObjectSequence()
6019 : {
6020 : if (mType == eObjectSequence) {
6021 : return mValue.mObjectSequence.Value();
6022 : }
6023 : Uninit();
6024 : mType = eObjectSequence;
6025 : return mValue.mObjectSequence.SetValue();
6026 : }
6027 :
6028 : inline bool
6029 : IsObjectSequence() const
6030 : {
6031 : return mType == eObjectSequence;
6032 : }
6033 :
6034 : inline binding_detail::AutoSequence<JSObject*>&
6035 : GetAsObjectSequence()
6036 : {
6037 : MOZ_ASSERT(IsObjectSequence(), "Wrong type!");
6038 : return mValue.mObjectSequence.Value();
6039 : }
6040 :
6041 : inline const Sequence<JSObject*>&
6042 : GetAsObjectSequence() const
6043 : {
6044 : MOZ_ASSERT(IsObjectSequence(), "Wrong type!");
6045 : return mValue.mObjectSequence.Value();
6046 : }
6047 :
6048 : inline int32_t&
6049 : RawSetAsLong()
6050 : {
6051 : if (mType == eLong) {
6052 : return mValue.mLong.Value();
6053 : }
6054 : MOZ_ASSERT(mType == eUninitialized);
6055 : mType = eLong;
6056 : return mValue.mLong.SetValue();
6057 : }
6058 :
6059 : inline int32_t&
6060 : SetAsLong()
6061 : {
6062 : if (mType == eLong) {
6063 : return mValue.mLong.Value();
6064 : }
6065 : Uninit();
6066 : mType = eLong;
6067 : return mValue.mLong.SetValue();
6068 : }
6069 :
6070 : inline bool
6071 : IsLong() const
6072 : {
6073 : return mType == eLong;
6074 : }
6075 :
6076 : inline int32_t&
6077 : GetAsLong()
6078 : {
6079 : MOZ_ASSERT(IsLong(), "Wrong type!");
6080 : return mValue.mLong.Value();
6081 : }
6082 :
6083 : inline int32_t
6084 : GetAsLong() const
6085 : {
6086 : MOZ_ASSERT(IsLong(), "Wrong type!");
6087 : return mValue.mLong.Value();
6088 : }
6089 :
6090 : inline void
6091 : Uninit()
6092 : {
6093 : switch (mType) {
6094 : case eUninitialized: {
6095 : break;
6096 : }
6097 : case eObjectSequence: {
6098 : DestroyObjectSequence();
6099 : break;
6100 : }
6101 : case eLong: {
6102 : DestroyLong();
6103 : break;
6104 : }
6105 : }
6106 : }
6107 :
6108 : bool
6109 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
6110 :
6111 : private:
6112 : inline void
6113 : DestroyObjectSequence()
6114 : {
6115 : MOZ_ASSERT(IsObjectSequence(), "Wrong type!");
6116 : mValue.mObjectSequence.Destroy();
6117 : mType = eUninitialized;
6118 : }
6119 :
6120 : inline void
6121 : DestroyLong()
6122 : {
6123 : MOZ_ASSERT(IsLong(), "Wrong type!");
6124 : mValue.mLong.Destroy();
6125 : mType = eUninitialized;
6126 : }
6127 : };
6128 :
6129 : class StringLongRecordOrLong
6130 : {
6131 : friend class StringLongRecordOrLongArgument;
6132 : enum Type
6133 : {
6134 : eUninitialized,
6135 : eStringLongRecord,
6136 : eLong
6137 : };
6138 :
6139 : union Value
6140 : {
6141 : UnionMember<Record<nsString, int32_t> > mStringLongRecord;
6142 : UnionMember<int32_t > mLong;
6143 :
6144 : };
6145 :
6146 : Type mType;
6147 : Value mValue;
6148 :
6149 : StringLongRecordOrLong(const StringLongRecordOrLong&) = delete;
6150 : StringLongRecordOrLong& operator=(const StringLongRecordOrLong&) = delete;
6151 : public:
6152 : explicit inline StringLongRecordOrLong()
6153 : : mType(eUninitialized)
6154 : {
6155 : }
6156 :
6157 : inline ~StringLongRecordOrLong()
6158 : {
6159 : Uninit();
6160 : }
6161 :
6162 : inline Record<nsString, int32_t>&
6163 : RawSetAsStringLongRecord()
6164 : {
6165 : if (mType == eStringLongRecord) {
6166 : return mValue.mStringLongRecord.Value();
6167 : }
6168 : MOZ_ASSERT(mType == eUninitialized);
6169 : mType = eStringLongRecord;
6170 : return mValue.mStringLongRecord.SetValue();
6171 : }
6172 :
6173 : inline Record<nsString, int32_t>&
6174 : SetAsStringLongRecord()
6175 : {
6176 : if (mType == eStringLongRecord) {
6177 : return mValue.mStringLongRecord.Value();
6178 : }
6179 : Uninit();
6180 : mType = eStringLongRecord;
6181 : return mValue.mStringLongRecord.SetValue();
6182 : }
6183 :
6184 : inline bool
6185 : IsStringLongRecord() const
6186 : {
6187 : return mType == eStringLongRecord;
6188 : }
6189 :
6190 : inline Record<nsString, int32_t>&
6191 : GetAsStringLongRecord()
6192 : {
6193 : MOZ_ASSERT(IsStringLongRecord(), "Wrong type!");
6194 : return mValue.mStringLongRecord.Value();
6195 : }
6196 :
6197 : inline const Record<nsString, int32_t>&
6198 : GetAsStringLongRecord() const
6199 : {
6200 : MOZ_ASSERT(IsStringLongRecord(), "Wrong type!");
6201 : return mValue.mStringLongRecord.Value();
6202 : }
6203 :
6204 : inline int32_t&
6205 : RawSetAsLong()
6206 : {
6207 : if (mType == eLong) {
6208 : return mValue.mLong.Value();
6209 : }
6210 : MOZ_ASSERT(mType == eUninitialized);
6211 : mType = eLong;
6212 : return mValue.mLong.SetValue();
6213 : }
6214 :
6215 : inline int32_t&
6216 : SetAsLong()
6217 : {
6218 : if (mType == eLong) {
6219 : return mValue.mLong.Value();
6220 : }
6221 : Uninit();
6222 : mType = eLong;
6223 : return mValue.mLong.SetValue();
6224 : }
6225 :
6226 : inline bool
6227 : IsLong() const
6228 : {
6229 : return mType == eLong;
6230 : }
6231 :
6232 : inline int32_t&
6233 : GetAsLong()
6234 : {
6235 : MOZ_ASSERT(IsLong(), "Wrong type!");
6236 : return mValue.mLong.Value();
6237 : }
6238 :
6239 : inline int32_t
6240 : GetAsLong() const
6241 : {
6242 : MOZ_ASSERT(IsLong(), "Wrong type!");
6243 : return mValue.mLong.Value();
6244 : }
6245 :
6246 : inline void
6247 : Uninit()
6248 : {
6249 : switch (mType) {
6250 : case eUninitialized: {
6251 : break;
6252 : }
6253 : case eStringLongRecord: {
6254 : DestroyStringLongRecord();
6255 : break;
6256 : }
6257 : case eLong: {
6258 : DestroyLong();
6259 : break;
6260 : }
6261 : }
6262 : }
6263 :
6264 : bool
6265 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
6266 :
6267 : private:
6268 : inline void
6269 : DestroyStringLongRecord()
6270 : {
6271 : MOZ_ASSERT(IsStringLongRecord(), "Wrong type!");
6272 : mValue.mStringLongRecord.Destroy();
6273 : mType = eUninitialized;
6274 : }
6275 :
6276 : inline void
6277 : DestroyLong()
6278 : {
6279 : MOZ_ASSERT(IsLong(), "Wrong type!");
6280 : mValue.mLong.Destroy();
6281 : mType = eUninitialized;
6282 : }
6283 : };
6284 :
6285 : class StringObjectRecordOrLong
6286 : {
6287 : friend class StringObjectRecordOrLongArgument;
6288 : enum Type
6289 : {
6290 : eUninitialized,
6291 : eStringObjectRecord,
6292 : eLong
6293 : };
6294 :
6295 : union Value
6296 : {
6297 : UnionMember<Record<nsString, JSObject*> > mStringObjectRecord;
6298 : UnionMember<int32_t > mLong;
6299 :
6300 : };
6301 :
6302 : Type mType;
6303 : Value mValue;
6304 :
6305 : StringObjectRecordOrLong(const StringObjectRecordOrLong&) = delete;
6306 : StringObjectRecordOrLong& operator=(const StringObjectRecordOrLong&) = delete;
6307 : public:
6308 : explicit inline StringObjectRecordOrLong()
6309 : : mType(eUninitialized)
6310 : {
6311 : }
6312 :
6313 : inline ~StringObjectRecordOrLong()
6314 : {
6315 : Uninit();
6316 : }
6317 :
6318 : inline Record<nsString, JSObject*>&
6319 : RawSetAsStringObjectRecord()
6320 : {
6321 : if (mType == eStringObjectRecord) {
6322 : return mValue.mStringObjectRecord.Value();
6323 : }
6324 : MOZ_ASSERT(mType == eUninitialized);
6325 : mType = eStringObjectRecord;
6326 : return mValue.mStringObjectRecord.SetValue();
6327 : }
6328 :
6329 : inline Record<nsString, JSObject*>&
6330 : SetAsStringObjectRecord()
6331 : {
6332 : if (mType == eStringObjectRecord) {
6333 : return mValue.mStringObjectRecord.Value();
6334 : }
6335 : Uninit();
6336 : mType = eStringObjectRecord;
6337 : return mValue.mStringObjectRecord.SetValue();
6338 : }
6339 :
6340 : inline bool
6341 : IsStringObjectRecord() const
6342 : {
6343 : return mType == eStringObjectRecord;
6344 : }
6345 :
6346 : inline Record<nsString, JSObject*>&
6347 : GetAsStringObjectRecord()
6348 : {
6349 : MOZ_ASSERT(IsStringObjectRecord(), "Wrong type!");
6350 : return mValue.mStringObjectRecord.Value();
6351 : }
6352 :
6353 : inline const Record<nsString, JSObject*>&
6354 : GetAsStringObjectRecord() const
6355 : {
6356 : MOZ_ASSERT(IsStringObjectRecord(), "Wrong type!");
6357 : return mValue.mStringObjectRecord.Value();
6358 : }
6359 :
6360 : inline int32_t&
6361 : RawSetAsLong()
6362 : {
6363 : if (mType == eLong) {
6364 : return mValue.mLong.Value();
6365 : }
6366 : MOZ_ASSERT(mType == eUninitialized);
6367 : mType = eLong;
6368 : return mValue.mLong.SetValue();
6369 : }
6370 :
6371 : inline int32_t&
6372 : SetAsLong()
6373 : {
6374 : if (mType == eLong) {
6375 : return mValue.mLong.Value();
6376 : }
6377 : Uninit();
6378 : mType = eLong;
6379 : return mValue.mLong.SetValue();
6380 : }
6381 :
6382 : inline bool
6383 : IsLong() const
6384 : {
6385 : return mType == eLong;
6386 : }
6387 :
6388 : inline int32_t&
6389 : GetAsLong()
6390 : {
6391 : MOZ_ASSERT(IsLong(), "Wrong type!");
6392 : return mValue.mLong.Value();
6393 : }
6394 :
6395 : inline int32_t
6396 : GetAsLong() const
6397 : {
6398 : MOZ_ASSERT(IsLong(), "Wrong type!");
6399 : return mValue.mLong.Value();
6400 : }
6401 :
6402 : inline void
6403 : Uninit()
6404 : {
6405 : switch (mType) {
6406 : case eUninitialized: {
6407 : break;
6408 : }
6409 : case eStringObjectRecord: {
6410 : DestroyStringObjectRecord();
6411 : break;
6412 : }
6413 : case eLong: {
6414 : DestroyLong();
6415 : break;
6416 : }
6417 : }
6418 : }
6419 :
6420 : bool
6421 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
6422 :
6423 : private:
6424 : inline void
6425 : DestroyStringObjectRecord()
6426 : {
6427 : MOZ_ASSERT(IsStringObjectRecord(), "Wrong type!");
6428 : mValue.mStringObjectRecord.Destroy();
6429 : mType = eUninitialized;
6430 : }
6431 :
6432 : inline void
6433 : DestroyLong()
6434 : {
6435 : MOZ_ASSERT(IsLong(), "Wrong type!");
6436 : mValue.mLong.Destroy();
6437 : mType = eUninitialized;
6438 : }
6439 : };
6440 :
6441 : class StringOrObject
6442 : {
6443 : friend class StringOrObjectArgument;
6444 : enum Type
6445 : {
6446 : eUninitialized,
6447 : eString,
6448 : eObject
6449 : };
6450 :
6451 : union Value
6452 : {
6453 : UnionMember<binding_detail::FakeString > mString;
6454 : UnionMember<JS::Rooted<JSObject*> > mObject;
6455 :
6456 : };
6457 :
6458 : Type mType;
6459 : Value mValue;
6460 :
6461 : StringOrObject(const StringOrObject&) = delete;
6462 : StringOrObject& operator=(const StringOrObject&) = delete;
6463 : public:
6464 : explicit inline StringOrObject()
6465 : : mType(eUninitialized)
6466 : {
6467 : }
6468 :
6469 : inline ~StringOrObject()
6470 : {
6471 : Uninit();
6472 : }
6473 :
6474 : inline binding_detail::FakeString&
6475 : RawSetAsString()
6476 : {
6477 : if (mType == eString) {
6478 : return mValue.mString.Value();
6479 : }
6480 : MOZ_ASSERT(mType == eUninitialized);
6481 : mType = eString;
6482 : return mValue.mString.SetValue();
6483 : }
6484 :
6485 : inline binding_detail::FakeString&
6486 : SetAsString()
6487 : {
6488 : if (mType == eString) {
6489 : return mValue.mString.Value();
6490 : }
6491 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
6492 : Uninit();
6493 : mType = eString;
6494 : return mValue.mString.SetValue();
6495 : }
6496 :
6497 : inline bool
6498 : IsString() const
6499 : {
6500 : return mType == eString;
6501 : }
6502 :
6503 : inline binding_detail::FakeString&
6504 : GetAsString()
6505 : {
6506 : MOZ_ASSERT(IsString(), "Wrong type!");
6507 : return mValue.mString.Value();
6508 : }
6509 :
6510 : inline const nsAString&
6511 : GetAsString() const
6512 : {
6513 : MOZ_ASSERT(IsString(), "Wrong type!");
6514 : return mValue.mString.Value();
6515 : }
6516 :
6517 : inline bool
6518 : IsObject() const
6519 : {
6520 : return mType == eObject;
6521 : }
6522 :
6523 : inline JS::Rooted<JSObject*>&
6524 : GetAsObject()
6525 : {
6526 : MOZ_ASSERT(IsObject(), "Wrong type!");
6527 : return mValue.mObject.Value();
6528 : }
6529 :
6530 : inline JSObject*
6531 : GetAsObject() const
6532 : {
6533 : MOZ_ASSERT(IsObject(), "Wrong type!");
6534 : return mValue.mObject.Value();
6535 : }
6536 :
6537 : inline void
6538 : Uninit()
6539 : {
6540 : switch (mType) {
6541 : case eUninitialized: {
6542 : break;
6543 : }
6544 : case eString: {
6545 : DestroyString();
6546 : break;
6547 : }
6548 : case eObject: {
6549 : DestroyObject();
6550 : break;
6551 : }
6552 : }
6553 : }
6554 :
6555 : bool
6556 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
6557 :
6558 : private:
6559 : inline void
6560 : DestroyString()
6561 : {
6562 : MOZ_ASSERT(IsString(), "Wrong type!");
6563 : mValue.mString.Destroy();
6564 : mType = eUninitialized;
6565 : }
6566 :
6567 : inline void
6568 : DestroyObject()
6569 : {
6570 : MOZ_ASSERT(IsObject(), "Wrong type!");
6571 : mValue.mObject.Destroy();
6572 : mType = eUninitialized;
6573 : }
6574 : };
6575 :
6576 : class StringOrStringSequence
6577 : {
6578 : friend class StringOrStringSequenceArgument;
6579 : enum Type
6580 : {
6581 : eUninitialized,
6582 : eString,
6583 : eStringSequence
6584 : };
6585 :
6586 0 : union Value
6587 : {
6588 : UnionMember<binding_detail::FakeString > mString;
6589 : UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence;
6590 :
6591 : };
6592 :
6593 : Type mType;
6594 : Value mValue;
6595 :
6596 : StringOrStringSequence(const StringOrStringSequence&) = delete;
6597 : StringOrStringSequence& operator=(const StringOrStringSequence&) = delete;
6598 : public:
6599 0 : explicit inline StringOrStringSequence()
6600 0 : : mType(eUninitialized)
6601 : {
6602 0 : }
6603 :
6604 0 : inline ~StringOrStringSequence()
6605 0 : {
6606 0 : Uninit();
6607 0 : }
6608 :
6609 : inline binding_detail::FakeString&
6610 : RawSetAsString()
6611 : {
6612 : if (mType == eString) {
6613 : return mValue.mString.Value();
6614 : }
6615 : MOZ_ASSERT(mType == eUninitialized);
6616 : mType = eString;
6617 : return mValue.mString.SetValue();
6618 : }
6619 :
6620 : inline binding_detail::FakeString&
6621 : SetAsString()
6622 : {
6623 : if (mType == eString) {
6624 : return mValue.mString.Value();
6625 : }
6626 : Uninit();
6627 : mType = eString;
6628 : return mValue.mString.SetValue();
6629 : }
6630 :
6631 : inline bool
6632 0 : IsString() const
6633 : {
6634 0 : return mType == eString;
6635 : }
6636 :
6637 : inline binding_detail::FakeString&
6638 : GetAsString()
6639 : {
6640 : MOZ_ASSERT(IsString(), "Wrong type!");
6641 : return mValue.mString.Value();
6642 : }
6643 :
6644 : inline const nsAString&
6645 0 : GetAsString() const
6646 : {
6647 0 : MOZ_ASSERT(IsString(), "Wrong type!");
6648 0 : return mValue.mString.Value();
6649 : }
6650 :
6651 : inline binding_detail::AutoSequence<nsString>&
6652 : RawSetAsStringSequence()
6653 : {
6654 : if (mType == eStringSequence) {
6655 : return mValue.mStringSequence.Value();
6656 : }
6657 : MOZ_ASSERT(mType == eUninitialized);
6658 : mType = eStringSequence;
6659 : return mValue.mStringSequence.SetValue();
6660 : }
6661 :
6662 : inline binding_detail::AutoSequence<nsString>&
6663 : SetAsStringSequence()
6664 : {
6665 : if (mType == eStringSequence) {
6666 : return mValue.mStringSequence.Value();
6667 : }
6668 : Uninit();
6669 : mType = eStringSequence;
6670 : return mValue.mStringSequence.SetValue();
6671 : }
6672 :
6673 : inline bool
6674 0 : IsStringSequence() const
6675 : {
6676 0 : return mType == eStringSequence;
6677 : }
6678 :
6679 : inline binding_detail::AutoSequence<nsString>&
6680 : GetAsStringSequence()
6681 : {
6682 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6683 : return mValue.mStringSequence.Value();
6684 : }
6685 :
6686 : inline const Sequence<nsString>&
6687 0 : GetAsStringSequence() const
6688 : {
6689 0 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6690 0 : return mValue.mStringSequence.Value();
6691 : }
6692 :
6693 : inline void
6694 0 : Uninit()
6695 : {
6696 0 : switch (mType) {
6697 : case eUninitialized: {
6698 0 : break;
6699 : }
6700 : case eString: {
6701 0 : DestroyString();
6702 0 : break;
6703 : }
6704 : case eStringSequence: {
6705 0 : DestroyStringSequence();
6706 0 : break;
6707 : }
6708 : }
6709 0 : }
6710 :
6711 : bool
6712 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
6713 :
6714 : private:
6715 : inline void
6716 0 : DestroyString()
6717 : {
6718 0 : MOZ_ASSERT(IsString(), "Wrong type!");
6719 0 : mValue.mString.Destroy();
6720 0 : mType = eUninitialized;
6721 0 : }
6722 :
6723 : inline void
6724 0 : DestroyStringSequence()
6725 : {
6726 0 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6727 0 : mValue.mStringSequence.Destroy();
6728 0 : mType = eUninitialized;
6729 0 : }
6730 : };
6731 :
6732 : class StringSequenceOrEventInit
6733 : {
6734 : friend class StringSequenceOrEventInitArgument;
6735 : enum Type
6736 : {
6737 : eUninitialized,
6738 : eStringSequence,
6739 : eEventInit
6740 : };
6741 :
6742 : union Value
6743 : {
6744 : UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence;
6745 : UnionMember<binding_detail::FastEventInit > mEventInit;
6746 :
6747 : };
6748 :
6749 : Type mType;
6750 : Value mValue;
6751 :
6752 : StringSequenceOrEventInit(const StringSequenceOrEventInit&) = delete;
6753 : StringSequenceOrEventInit& operator=(const StringSequenceOrEventInit&) = delete;
6754 : public:
6755 : explicit inline StringSequenceOrEventInit()
6756 : : mType(eUninitialized)
6757 : {
6758 : }
6759 :
6760 : inline ~StringSequenceOrEventInit()
6761 : {
6762 : Uninit();
6763 : }
6764 :
6765 : inline binding_detail::AutoSequence<nsString>&
6766 : RawSetAsStringSequence()
6767 : {
6768 : if (mType == eStringSequence) {
6769 : return mValue.mStringSequence.Value();
6770 : }
6771 : MOZ_ASSERT(mType == eUninitialized);
6772 : mType = eStringSequence;
6773 : return mValue.mStringSequence.SetValue();
6774 : }
6775 :
6776 : inline binding_detail::AutoSequence<nsString>&
6777 : SetAsStringSequence()
6778 : {
6779 : if (mType == eStringSequence) {
6780 : return mValue.mStringSequence.Value();
6781 : }
6782 : Uninit();
6783 : mType = eStringSequence;
6784 : return mValue.mStringSequence.SetValue();
6785 : }
6786 :
6787 : inline bool
6788 : IsStringSequence() const
6789 : {
6790 : return mType == eStringSequence;
6791 : }
6792 :
6793 : inline binding_detail::AutoSequence<nsString>&
6794 : GetAsStringSequence()
6795 : {
6796 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6797 : return mValue.mStringSequence.Value();
6798 : }
6799 :
6800 : inline const Sequence<nsString>&
6801 : GetAsStringSequence() const
6802 : {
6803 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6804 : return mValue.mStringSequence.Value();
6805 : }
6806 :
6807 : inline binding_detail::FastEventInit&
6808 : RawSetAsEventInit()
6809 : {
6810 : if (mType == eEventInit) {
6811 : return mValue.mEventInit.Value();
6812 : }
6813 : MOZ_ASSERT(mType == eUninitialized);
6814 : mType = eEventInit;
6815 : return mValue.mEventInit.SetValue();
6816 : }
6817 :
6818 : inline binding_detail::FastEventInit&
6819 : SetAsEventInit()
6820 : {
6821 : if (mType == eEventInit) {
6822 : return mValue.mEventInit.Value();
6823 : }
6824 : Uninit();
6825 : mType = eEventInit;
6826 : return mValue.mEventInit.SetValue();
6827 : }
6828 :
6829 : inline bool
6830 : IsEventInit() const
6831 : {
6832 : return mType == eEventInit;
6833 : }
6834 :
6835 : inline binding_detail::FastEventInit&
6836 : GetAsEventInit()
6837 : {
6838 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
6839 : return mValue.mEventInit.Value();
6840 : }
6841 :
6842 : inline const EventInit&
6843 : GetAsEventInit() const
6844 : {
6845 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
6846 : return mValue.mEventInit.Value();
6847 : }
6848 :
6849 : inline void
6850 : Uninit()
6851 : {
6852 : switch (mType) {
6853 : case eUninitialized: {
6854 : break;
6855 : }
6856 : case eStringSequence: {
6857 : DestroyStringSequence();
6858 : break;
6859 : }
6860 : case eEventInit: {
6861 : DestroyEventInit();
6862 : break;
6863 : }
6864 : }
6865 : }
6866 :
6867 : bool
6868 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
6869 :
6870 : private:
6871 : inline void
6872 : DestroyStringSequence()
6873 : {
6874 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6875 : mValue.mStringSequence.Destroy();
6876 : mType = eUninitialized;
6877 : }
6878 :
6879 : inline void
6880 : DestroyEventInit()
6881 : {
6882 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
6883 : mValue.mEventInit.Destroy();
6884 : mType = eUninitialized;
6885 : }
6886 : };
6887 :
6888 : class StringSequenceOrStringStringRecord
6889 : {
6890 : friend class StringSequenceOrStringStringRecordArgument;
6891 : enum Type
6892 : {
6893 : eUninitialized,
6894 : eStringSequence,
6895 : eStringStringRecord
6896 : };
6897 :
6898 : union Value
6899 : {
6900 : UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence;
6901 : UnionMember<Record<nsString, nsString> > mStringStringRecord;
6902 :
6903 : };
6904 :
6905 : Type mType;
6906 : Value mValue;
6907 :
6908 : StringSequenceOrStringStringRecord(const StringSequenceOrStringStringRecord&) = delete;
6909 : StringSequenceOrStringStringRecord& operator=(const StringSequenceOrStringStringRecord&) = delete;
6910 : public:
6911 : explicit inline StringSequenceOrStringStringRecord()
6912 : : mType(eUninitialized)
6913 : {
6914 : }
6915 :
6916 : inline ~StringSequenceOrStringStringRecord()
6917 : {
6918 : Uninit();
6919 : }
6920 :
6921 : inline binding_detail::AutoSequence<nsString>&
6922 : RawSetAsStringSequence()
6923 : {
6924 : if (mType == eStringSequence) {
6925 : return mValue.mStringSequence.Value();
6926 : }
6927 : MOZ_ASSERT(mType == eUninitialized);
6928 : mType = eStringSequence;
6929 : return mValue.mStringSequence.SetValue();
6930 : }
6931 :
6932 : inline binding_detail::AutoSequence<nsString>&
6933 : SetAsStringSequence()
6934 : {
6935 : if (mType == eStringSequence) {
6936 : return mValue.mStringSequence.Value();
6937 : }
6938 : Uninit();
6939 : mType = eStringSequence;
6940 : return mValue.mStringSequence.SetValue();
6941 : }
6942 :
6943 : inline bool
6944 : IsStringSequence() const
6945 : {
6946 : return mType == eStringSequence;
6947 : }
6948 :
6949 : inline binding_detail::AutoSequence<nsString>&
6950 : GetAsStringSequence()
6951 : {
6952 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6953 : return mValue.mStringSequence.Value();
6954 : }
6955 :
6956 : inline const Sequence<nsString>&
6957 : GetAsStringSequence() const
6958 : {
6959 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
6960 : return mValue.mStringSequence.Value();
6961 : }
6962 :
6963 : inline Record<nsString, nsString>&
6964 : RawSetAsStringStringRecord()
6965 : {
6966 : if (mType == eStringStringRecord) {
6967 : return mValue.mStringStringRecord.Value();
6968 : }
6969 : MOZ_ASSERT(mType == eUninitialized);
6970 : mType = eStringStringRecord;
6971 : return mValue.mStringStringRecord.SetValue();
6972 : }
6973 :
6974 : inline Record<nsString, nsString>&
6975 : SetAsStringStringRecord()
6976 : {
6977 : if (mType == eStringStringRecord) {
6978 : return mValue.mStringStringRecord.Value();
6979 : }
6980 : Uninit();
6981 : mType = eStringStringRecord;
6982 : return mValue.mStringStringRecord.SetValue();
6983 : }
6984 :
6985 : inline bool
6986 : IsStringStringRecord() const
6987 : {
6988 : return mType == eStringStringRecord;
6989 : }
6990 :
6991 : inline Record<nsString, nsString>&
6992 : GetAsStringStringRecord()
6993 : {
6994 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
6995 : return mValue.mStringStringRecord.Value();
6996 : }
6997 :
6998 : inline const Record<nsString, nsString>&
6999 : GetAsStringStringRecord() const
7000 : {
7001 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7002 : return mValue.mStringStringRecord.Value();
7003 : }
7004 :
7005 : inline void
7006 : Uninit()
7007 : {
7008 : switch (mType) {
7009 : case eUninitialized: {
7010 : break;
7011 : }
7012 : case eStringSequence: {
7013 : DestroyStringSequence();
7014 : break;
7015 : }
7016 : case eStringStringRecord: {
7017 : DestroyStringStringRecord();
7018 : break;
7019 : }
7020 : }
7021 : }
7022 :
7023 : bool
7024 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7025 :
7026 : private:
7027 : inline void
7028 : DestroyStringSequence()
7029 : {
7030 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
7031 : mValue.mStringSequence.Destroy();
7032 : mType = eUninitialized;
7033 : }
7034 :
7035 : inline void
7036 : DestroyStringStringRecord()
7037 : {
7038 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7039 : mValue.mStringStringRecord.Destroy();
7040 : mType = eUninitialized;
7041 : }
7042 : };
7043 :
7044 : class StringStringRecordOrString
7045 : {
7046 : friend class StringStringRecordOrStringArgument;
7047 : enum Type
7048 : {
7049 : eUninitialized,
7050 : eStringStringRecord,
7051 : eString
7052 : };
7053 :
7054 : union Value
7055 : {
7056 : UnionMember<Record<nsString, nsString> > mStringStringRecord;
7057 : UnionMember<binding_detail::FakeString > mString;
7058 :
7059 : };
7060 :
7061 : Type mType;
7062 : Value mValue;
7063 :
7064 : StringStringRecordOrString(const StringStringRecordOrString&) = delete;
7065 : StringStringRecordOrString& operator=(const StringStringRecordOrString&) = delete;
7066 : public:
7067 : explicit inline StringStringRecordOrString()
7068 : : mType(eUninitialized)
7069 : {
7070 : }
7071 :
7072 : inline ~StringStringRecordOrString()
7073 : {
7074 : Uninit();
7075 : }
7076 :
7077 : inline Record<nsString, nsString>&
7078 : RawSetAsStringStringRecord()
7079 : {
7080 : if (mType == eStringStringRecord) {
7081 : return mValue.mStringStringRecord.Value();
7082 : }
7083 : MOZ_ASSERT(mType == eUninitialized);
7084 : mType = eStringStringRecord;
7085 : return mValue.mStringStringRecord.SetValue();
7086 : }
7087 :
7088 : inline Record<nsString, nsString>&
7089 : SetAsStringStringRecord()
7090 : {
7091 : if (mType == eStringStringRecord) {
7092 : return mValue.mStringStringRecord.Value();
7093 : }
7094 : Uninit();
7095 : mType = eStringStringRecord;
7096 : return mValue.mStringStringRecord.SetValue();
7097 : }
7098 :
7099 : inline bool
7100 : IsStringStringRecord() const
7101 : {
7102 : return mType == eStringStringRecord;
7103 : }
7104 :
7105 : inline Record<nsString, nsString>&
7106 : GetAsStringStringRecord()
7107 : {
7108 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7109 : return mValue.mStringStringRecord.Value();
7110 : }
7111 :
7112 : inline const Record<nsString, nsString>&
7113 : GetAsStringStringRecord() const
7114 : {
7115 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7116 : return mValue.mStringStringRecord.Value();
7117 : }
7118 :
7119 : inline binding_detail::FakeString&
7120 : RawSetAsString()
7121 : {
7122 : if (mType == eString) {
7123 : return mValue.mString.Value();
7124 : }
7125 : MOZ_ASSERT(mType == eUninitialized);
7126 : mType = eString;
7127 : return mValue.mString.SetValue();
7128 : }
7129 :
7130 : inline binding_detail::FakeString&
7131 : SetAsString()
7132 : {
7133 : if (mType == eString) {
7134 : return mValue.mString.Value();
7135 : }
7136 : Uninit();
7137 : mType = eString;
7138 : return mValue.mString.SetValue();
7139 : }
7140 :
7141 : inline bool
7142 : IsString() const
7143 : {
7144 : return mType == eString;
7145 : }
7146 :
7147 : inline binding_detail::FakeString&
7148 : GetAsString()
7149 : {
7150 : MOZ_ASSERT(IsString(), "Wrong type!");
7151 : return mValue.mString.Value();
7152 : }
7153 :
7154 : inline const nsAString&
7155 : GetAsString() const
7156 : {
7157 : MOZ_ASSERT(IsString(), "Wrong type!");
7158 : return mValue.mString.Value();
7159 : }
7160 :
7161 : inline void
7162 : Uninit()
7163 : {
7164 : switch (mType) {
7165 : case eUninitialized: {
7166 : break;
7167 : }
7168 : case eStringStringRecord: {
7169 : DestroyStringStringRecord();
7170 : break;
7171 : }
7172 : case eString: {
7173 : DestroyString();
7174 : break;
7175 : }
7176 : }
7177 : }
7178 :
7179 : bool
7180 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7181 :
7182 : private:
7183 : inline void
7184 : DestroyStringStringRecord()
7185 : {
7186 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7187 : mValue.mStringStringRecord.Destroy();
7188 : mType = eUninitialized;
7189 : }
7190 :
7191 : inline void
7192 : DestroyString()
7193 : {
7194 : MOZ_ASSERT(IsString(), "Wrong type!");
7195 : mValue.mString.Destroy();
7196 : mType = eUninitialized;
7197 : }
7198 : };
7199 :
7200 : class StringStringRecordOrStringSequence
7201 : {
7202 : friend class StringStringRecordOrStringSequenceArgument;
7203 : enum Type
7204 : {
7205 : eUninitialized,
7206 : eStringStringRecord,
7207 : eStringSequence
7208 : };
7209 :
7210 : union Value
7211 : {
7212 : UnionMember<Record<nsString, nsString> > mStringStringRecord;
7213 : UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence;
7214 :
7215 : };
7216 :
7217 : Type mType;
7218 : Value mValue;
7219 :
7220 : StringStringRecordOrStringSequence(const StringStringRecordOrStringSequence&) = delete;
7221 : StringStringRecordOrStringSequence& operator=(const StringStringRecordOrStringSequence&) = delete;
7222 : public:
7223 : explicit inline StringStringRecordOrStringSequence()
7224 : : mType(eUninitialized)
7225 : {
7226 : }
7227 :
7228 : inline ~StringStringRecordOrStringSequence()
7229 : {
7230 : Uninit();
7231 : }
7232 :
7233 : inline Record<nsString, nsString>&
7234 : RawSetAsStringStringRecord()
7235 : {
7236 : if (mType == eStringStringRecord) {
7237 : return mValue.mStringStringRecord.Value();
7238 : }
7239 : MOZ_ASSERT(mType == eUninitialized);
7240 : mType = eStringStringRecord;
7241 : return mValue.mStringStringRecord.SetValue();
7242 : }
7243 :
7244 : inline Record<nsString, nsString>&
7245 : SetAsStringStringRecord()
7246 : {
7247 : if (mType == eStringStringRecord) {
7248 : return mValue.mStringStringRecord.Value();
7249 : }
7250 : Uninit();
7251 : mType = eStringStringRecord;
7252 : return mValue.mStringStringRecord.SetValue();
7253 : }
7254 :
7255 : inline bool
7256 : IsStringStringRecord() const
7257 : {
7258 : return mType == eStringStringRecord;
7259 : }
7260 :
7261 : inline Record<nsString, nsString>&
7262 : GetAsStringStringRecord()
7263 : {
7264 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7265 : return mValue.mStringStringRecord.Value();
7266 : }
7267 :
7268 : inline const Record<nsString, nsString>&
7269 : GetAsStringStringRecord() const
7270 : {
7271 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7272 : return mValue.mStringStringRecord.Value();
7273 : }
7274 :
7275 : inline binding_detail::AutoSequence<nsString>&
7276 : RawSetAsStringSequence()
7277 : {
7278 : if (mType == eStringSequence) {
7279 : return mValue.mStringSequence.Value();
7280 : }
7281 : MOZ_ASSERT(mType == eUninitialized);
7282 : mType = eStringSequence;
7283 : return mValue.mStringSequence.SetValue();
7284 : }
7285 :
7286 : inline binding_detail::AutoSequence<nsString>&
7287 : SetAsStringSequence()
7288 : {
7289 : if (mType == eStringSequence) {
7290 : return mValue.mStringSequence.Value();
7291 : }
7292 : Uninit();
7293 : mType = eStringSequence;
7294 : return mValue.mStringSequence.SetValue();
7295 : }
7296 :
7297 : inline bool
7298 : IsStringSequence() const
7299 : {
7300 : return mType == eStringSequence;
7301 : }
7302 :
7303 : inline binding_detail::AutoSequence<nsString>&
7304 : GetAsStringSequence()
7305 : {
7306 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
7307 : return mValue.mStringSequence.Value();
7308 : }
7309 :
7310 : inline const Sequence<nsString>&
7311 : GetAsStringSequence() const
7312 : {
7313 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
7314 : return mValue.mStringSequence.Value();
7315 : }
7316 :
7317 : inline void
7318 : Uninit()
7319 : {
7320 : switch (mType) {
7321 : case eUninitialized: {
7322 : break;
7323 : }
7324 : case eStringStringRecord: {
7325 : DestroyStringStringRecord();
7326 : break;
7327 : }
7328 : case eStringSequence: {
7329 : DestroyStringSequence();
7330 : break;
7331 : }
7332 : }
7333 : }
7334 :
7335 : bool
7336 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7337 :
7338 : private:
7339 : inline void
7340 : DestroyStringStringRecord()
7341 : {
7342 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
7343 : mValue.mStringStringRecord.Destroy();
7344 : mType = eUninitialized;
7345 : }
7346 :
7347 : inline void
7348 : DestroyStringSequence()
7349 : {
7350 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
7351 : mValue.mStringSequence.Destroy();
7352 : mType = eUninitialized;
7353 : }
7354 : };
7355 :
7356 : class SupportedTypeOrObject
7357 : {
7358 : friend class SupportedTypeOrObjectArgument;
7359 : enum Type
7360 : {
7361 : eUninitialized,
7362 : eSupportedType,
7363 : eObject
7364 : };
7365 :
7366 : union Value
7367 : {
7368 : UnionMember<SupportedType > mSupportedType;
7369 : UnionMember<JS::Rooted<JSObject*> > mObject;
7370 :
7371 : };
7372 :
7373 : Type mType;
7374 : Value mValue;
7375 :
7376 : SupportedTypeOrObject(const SupportedTypeOrObject&) = delete;
7377 : SupportedTypeOrObject& operator=(const SupportedTypeOrObject&) = delete;
7378 : public:
7379 : explicit inline SupportedTypeOrObject()
7380 : : mType(eUninitialized)
7381 : {
7382 : }
7383 :
7384 : inline ~SupportedTypeOrObject()
7385 : {
7386 : Uninit();
7387 : }
7388 :
7389 : inline SupportedType&
7390 : RawSetAsSupportedType()
7391 : {
7392 : if (mType == eSupportedType) {
7393 : return mValue.mSupportedType.Value();
7394 : }
7395 : MOZ_ASSERT(mType == eUninitialized);
7396 : mType = eSupportedType;
7397 : return mValue.mSupportedType.SetValue();
7398 : }
7399 :
7400 : inline SupportedType&
7401 : SetAsSupportedType()
7402 : {
7403 : if (mType == eSupportedType) {
7404 : return mValue.mSupportedType.Value();
7405 : }
7406 : MOZ_ASSERT(mType != eObject, "This will not play well with Rooted");
7407 : Uninit();
7408 : mType = eSupportedType;
7409 : return mValue.mSupportedType.SetValue();
7410 : }
7411 :
7412 : inline bool
7413 : IsSupportedType() const
7414 : {
7415 : return mType == eSupportedType;
7416 : }
7417 :
7418 : inline SupportedType&
7419 : GetAsSupportedType()
7420 : {
7421 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
7422 : return mValue.mSupportedType.Value();
7423 : }
7424 :
7425 : inline SupportedType
7426 : GetAsSupportedType() const
7427 : {
7428 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
7429 : return mValue.mSupportedType.Value();
7430 : }
7431 :
7432 : inline bool
7433 : IsObject() const
7434 : {
7435 : return mType == eObject;
7436 : }
7437 :
7438 : inline JS::Rooted<JSObject*>&
7439 : GetAsObject()
7440 : {
7441 : MOZ_ASSERT(IsObject(), "Wrong type!");
7442 : return mValue.mObject.Value();
7443 : }
7444 :
7445 : inline JSObject*
7446 : GetAsObject() const
7447 : {
7448 : MOZ_ASSERT(IsObject(), "Wrong type!");
7449 : return mValue.mObject.Value();
7450 : }
7451 :
7452 : inline void
7453 : Uninit()
7454 : {
7455 : switch (mType) {
7456 : case eUninitialized: {
7457 : break;
7458 : }
7459 : case eSupportedType: {
7460 : DestroySupportedType();
7461 : break;
7462 : }
7463 : case eObject: {
7464 : DestroyObject();
7465 : break;
7466 : }
7467 : }
7468 : }
7469 :
7470 : bool
7471 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7472 :
7473 : private:
7474 : inline void
7475 : DestroySupportedType()
7476 : {
7477 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
7478 : mValue.mSupportedType.Destroy();
7479 : mType = eUninitialized;
7480 : }
7481 :
7482 : inline void
7483 : DestroyObject()
7484 : {
7485 : MOZ_ASSERT(IsObject(), "Wrong type!");
7486 : mValue.mObject.Destroy();
7487 : mType = eUninitialized;
7488 : }
7489 : };
7490 :
7491 : class USVStringOrLong
7492 : {
7493 : friend class USVStringOrLongArgument;
7494 : enum Type
7495 : {
7496 : eUninitialized,
7497 : eUSVString,
7498 : eLong
7499 : };
7500 :
7501 : union Value
7502 : {
7503 : UnionMember<binding_detail::FakeString > mUSVString;
7504 : UnionMember<int32_t > mLong;
7505 :
7506 : };
7507 :
7508 : Type mType;
7509 : Value mValue;
7510 :
7511 : USVStringOrLong(const USVStringOrLong&) = delete;
7512 : USVStringOrLong& operator=(const USVStringOrLong&) = delete;
7513 : public:
7514 : explicit inline USVStringOrLong()
7515 : : mType(eUninitialized)
7516 : {
7517 : }
7518 :
7519 : inline ~USVStringOrLong()
7520 : {
7521 : Uninit();
7522 : }
7523 :
7524 : inline binding_detail::FakeString&
7525 : RawSetAsUSVString()
7526 : {
7527 : if (mType == eUSVString) {
7528 : return mValue.mUSVString.Value();
7529 : }
7530 : MOZ_ASSERT(mType == eUninitialized);
7531 : mType = eUSVString;
7532 : return mValue.mUSVString.SetValue();
7533 : }
7534 :
7535 : inline binding_detail::FakeString&
7536 : SetAsUSVString()
7537 : {
7538 : if (mType == eUSVString) {
7539 : return mValue.mUSVString.Value();
7540 : }
7541 : Uninit();
7542 : mType = eUSVString;
7543 : return mValue.mUSVString.SetValue();
7544 : }
7545 :
7546 : inline bool
7547 : IsUSVString() const
7548 : {
7549 : return mType == eUSVString;
7550 : }
7551 :
7552 : inline binding_detail::FakeString&
7553 : GetAsUSVString()
7554 : {
7555 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
7556 : return mValue.mUSVString.Value();
7557 : }
7558 :
7559 : inline const nsAString&
7560 : GetAsUSVString() const
7561 : {
7562 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
7563 : return mValue.mUSVString.Value();
7564 : }
7565 :
7566 : inline int32_t&
7567 : RawSetAsLong()
7568 : {
7569 : if (mType == eLong) {
7570 : return mValue.mLong.Value();
7571 : }
7572 : MOZ_ASSERT(mType == eUninitialized);
7573 : mType = eLong;
7574 : return mValue.mLong.SetValue();
7575 : }
7576 :
7577 : inline int32_t&
7578 : SetAsLong()
7579 : {
7580 : if (mType == eLong) {
7581 : return mValue.mLong.Value();
7582 : }
7583 : Uninit();
7584 : mType = eLong;
7585 : return mValue.mLong.SetValue();
7586 : }
7587 :
7588 : inline bool
7589 : IsLong() const
7590 : {
7591 : return mType == eLong;
7592 : }
7593 :
7594 : inline int32_t&
7595 : GetAsLong()
7596 : {
7597 : MOZ_ASSERT(IsLong(), "Wrong type!");
7598 : return mValue.mLong.Value();
7599 : }
7600 :
7601 : inline int32_t
7602 : GetAsLong() const
7603 : {
7604 : MOZ_ASSERT(IsLong(), "Wrong type!");
7605 : return mValue.mLong.Value();
7606 : }
7607 :
7608 : inline void
7609 : Uninit()
7610 : {
7611 : switch (mType) {
7612 : case eUninitialized: {
7613 : break;
7614 : }
7615 : case eUSVString: {
7616 : DestroyUSVString();
7617 : break;
7618 : }
7619 : case eLong: {
7620 : DestroyLong();
7621 : break;
7622 : }
7623 : }
7624 : }
7625 :
7626 : bool
7627 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7628 :
7629 : private:
7630 : inline void
7631 : DestroyUSVString()
7632 : {
7633 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
7634 : mValue.mUSVString.Destroy();
7635 : mType = eUninitialized;
7636 : }
7637 :
7638 : inline void
7639 : DestroyLong()
7640 : {
7641 : MOZ_ASSERT(IsLong(), "Wrong type!");
7642 : mValue.mLong.Destroy();
7643 : mType = eUninitialized;
7644 : }
7645 : };
7646 :
7647 : class UnrestrictedDoubleOrString
7648 : {
7649 : friend class UnrestrictedDoubleOrStringArgument;
7650 : enum Type
7651 : {
7652 : eUninitialized,
7653 : eUnrestrictedDouble,
7654 : eString
7655 : };
7656 :
7657 0 : union Value
7658 : {
7659 : UnionMember<double > mUnrestrictedDouble;
7660 : UnionMember<binding_detail::FakeString > mString;
7661 :
7662 : };
7663 :
7664 : Type mType;
7665 : Value mValue;
7666 :
7667 : UnrestrictedDoubleOrString(const UnrestrictedDoubleOrString&) = delete;
7668 : UnrestrictedDoubleOrString& operator=(const UnrestrictedDoubleOrString&) = delete;
7669 : public:
7670 0 : explicit inline UnrestrictedDoubleOrString()
7671 0 : : mType(eUninitialized)
7672 : {
7673 0 : }
7674 :
7675 0 : inline ~UnrestrictedDoubleOrString()
7676 0 : {
7677 0 : Uninit();
7678 0 : }
7679 :
7680 : inline double&
7681 : RawSetAsUnrestrictedDouble()
7682 : {
7683 : if (mType == eUnrestrictedDouble) {
7684 : return mValue.mUnrestrictedDouble.Value();
7685 : }
7686 : MOZ_ASSERT(mType == eUninitialized);
7687 : mType = eUnrestrictedDouble;
7688 : return mValue.mUnrestrictedDouble.SetValue();
7689 : }
7690 :
7691 : inline double&
7692 : SetAsUnrestrictedDouble()
7693 : {
7694 : if (mType == eUnrestrictedDouble) {
7695 : return mValue.mUnrestrictedDouble.Value();
7696 : }
7697 : Uninit();
7698 : mType = eUnrestrictedDouble;
7699 : return mValue.mUnrestrictedDouble.SetValue();
7700 : }
7701 :
7702 : inline bool
7703 0 : IsUnrestrictedDouble() const
7704 : {
7705 0 : return mType == eUnrestrictedDouble;
7706 : }
7707 :
7708 : inline double&
7709 : GetAsUnrestrictedDouble()
7710 : {
7711 : MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
7712 : return mValue.mUnrestrictedDouble.Value();
7713 : }
7714 :
7715 : inline double
7716 0 : GetAsUnrestrictedDouble() const
7717 : {
7718 0 : MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
7719 0 : return mValue.mUnrestrictedDouble.Value();
7720 : }
7721 :
7722 : inline binding_detail::FakeString&
7723 : RawSetAsString()
7724 : {
7725 : if (mType == eString) {
7726 : return mValue.mString.Value();
7727 : }
7728 : MOZ_ASSERT(mType == eUninitialized);
7729 : mType = eString;
7730 : return mValue.mString.SetValue();
7731 : }
7732 :
7733 : inline binding_detail::FakeString&
7734 : SetAsString()
7735 : {
7736 : if (mType == eString) {
7737 : return mValue.mString.Value();
7738 : }
7739 : Uninit();
7740 : mType = eString;
7741 : return mValue.mString.SetValue();
7742 : }
7743 :
7744 : inline bool
7745 0 : IsString() const
7746 : {
7747 0 : return mType == eString;
7748 : }
7749 :
7750 : inline binding_detail::FakeString&
7751 : GetAsString()
7752 : {
7753 : MOZ_ASSERT(IsString(), "Wrong type!");
7754 : return mValue.mString.Value();
7755 : }
7756 :
7757 : inline const nsAString&
7758 0 : GetAsString() const
7759 : {
7760 0 : MOZ_ASSERT(IsString(), "Wrong type!");
7761 0 : return mValue.mString.Value();
7762 : }
7763 :
7764 : inline void
7765 0 : Uninit()
7766 : {
7767 0 : switch (mType) {
7768 : case eUninitialized: {
7769 0 : break;
7770 : }
7771 : case eUnrestrictedDouble: {
7772 0 : DestroyUnrestrictedDouble();
7773 0 : break;
7774 : }
7775 : case eString: {
7776 0 : DestroyString();
7777 0 : break;
7778 : }
7779 : }
7780 0 : }
7781 :
7782 : bool
7783 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7784 :
7785 : private:
7786 : inline void
7787 0 : DestroyUnrestrictedDouble()
7788 : {
7789 0 : MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
7790 0 : mValue.mUnrestrictedDouble.Destroy();
7791 0 : mType = eUninitialized;
7792 0 : }
7793 :
7794 : inline void
7795 0 : DestroyString()
7796 : {
7797 0 : MOZ_ASSERT(IsString(), "Wrong type!");
7798 0 : mValue.mString.Destroy();
7799 0 : mType = eUninitialized;
7800 0 : }
7801 : };
7802 :
7803 : class UnrestrictedFloatOrString
7804 : {
7805 : friend class UnrestrictedFloatOrStringArgument;
7806 : enum Type
7807 : {
7808 : eUninitialized,
7809 : eUnrestrictedFloat,
7810 : eString
7811 : };
7812 :
7813 : union Value
7814 : {
7815 : UnionMember<float > mUnrestrictedFloat;
7816 : UnionMember<binding_detail::FakeString > mString;
7817 :
7818 : };
7819 :
7820 : Type mType;
7821 : Value mValue;
7822 :
7823 : UnrestrictedFloatOrString(const UnrestrictedFloatOrString&) = delete;
7824 : UnrestrictedFloatOrString& operator=(const UnrestrictedFloatOrString&) = delete;
7825 : public:
7826 : explicit inline UnrestrictedFloatOrString()
7827 : : mType(eUninitialized)
7828 : {
7829 : }
7830 :
7831 : inline ~UnrestrictedFloatOrString()
7832 : {
7833 : Uninit();
7834 : }
7835 :
7836 : inline float&
7837 : RawSetAsUnrestrictedFloat()
7838 : {
7839 : if (mType == eUnrestrictedFloat) {
7840 : return mValue.mUnrestrictedFloat.Value();
7841 : }
7842 : MOZ_ASSERT(mType == eUninitialized);
7843 : mType = eUnrestrictedFloat;
7844 : return mValue.mUnrestrictedFloat.SetValue();
7845 : }
7846 :
7847 : inline float&
7848 : SetAsUnrestrictedFloat()
7849 : {
7850 : if (mType == eUnrestrictedFloat) {
7851 : return mValue.mUnrestrictedFloat.Value();
7852 : }
7853 : Uninit();
7854 : mType = eUnrestrictedFloat;
7855 : return mValue.mUnrestrictedFloat.SetValue();
7856 : }
7857 :
7858 : inline bool
7859 : IsUnrestrictedFloat() const
7860 : {
7861 : return mType == eUnrestrictedFloat;
7862 : }
7863 :
7864 : inline float&
7865 : GetAsUnrestrictedFloat()
7866 : {
7867 : MOZ_ASSERT(IsUnrestrictedFloat(), "Wrong type!");
7868 : return mValue.mUnrestrictedFloat.Value();
7869 : }
7870 :
7871 : inline float
7872 : GetAsUnrestrictedFloat() const
7873 : {
7874 : MOZ_ASSERT(IsUnrestrictedFloat(), "Wrong type!");
7875 : return mValue.mUnrestrictedFloat.Value();
7876 : }
7877 :
7878 : inline binding_detail::FakeString&
7879 : RawSetAsString()
7880 : {
7881 : if (mType == eString) {
7882 : return mValue.mString.Value();
7883 : }
7884 : MOZ_ASSERT(mType == eUninitialized);
7885 : mType = eString;
7886 : return mValue.mString.SetValue();
7887 : }
7888 :
7889 : inline binding_detail::FakeString&
7890 : SetAsString()
7891 : {
7892 : if (mType == eString) {
7893 : return mValue.mString.Value();
7894 : }
7895 : Uninit();
7896 : mType = eString;
7897 : return mValue.mString.SetValue();
7898 : }
7899 :
7900 : inline bool
7901 : IsString() const
7902 : {
7903 : return mType == eString;
7904 : }
7905 :
7906 : inline binding_detail::FakeString&
7907 : GetAsString()
7908 : {
7909 : MOZ_ASSERT(IsString(), "Wrong type!");
7910 : return mValue.mString.Value();
7911 : }
7912 :
7913 : inline const nsAString&
7914 : GetAsString() const
7915 : {
7916 : MOZ_ASSERT(IsString(), "Wrong type!");
7917 : return mValue.mString.Value();
7918 : }
7919 :
7920 : inline void
7921 : Uninit()
7922 : {
7923 : switch (mType) {
7924 : case eUninitialized: {
7925 : break;
7926 : }
7927 : case eUnrestrictedFloat: {
7928 : DestroyUnrestrictedFloat();
7929 : break;
7930 : }
7931 : case eString: {
7932 : DestroyString();
7933 : break;
7934 : }
7935 : }
7936 : }
7937 :
7938 : bool
7939 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
7940 :
7941 : private:
7942 : inline void
7943 : DestroyUnrestrictedFloat()
7944 : {
7945 : MOZ_ASSERT(IsUnrestrictedFloat(), "Wrong type!");
7946 : mValue.mUnrestrictedFloat.Destroy();
7947 : mType = eUninitialized;
7948 : }
7949 :
7950 : inline void
7951 : DestroyString()
7952 : {
7953 : MOZ_ASSERT(IsString(), "Wrong type!");
7954 : mValue.mString.Destroy();
7955 : mType = eUninitialized;
7956 : }
7957 : };
7958 :
7959 : class OwningArrayBufferOrLong : public AllOwningUnionBase
7960 : {
7961 : friend void ImplCycleCollectionUnlink(OwningArrayBufferOrLong& aUnion);
7962 : enum Type
7963 : {
7964 : eUninitialized,
7965 : eArrayBuffer,
7966 : eLong
7967 : };
7968 :
7969 : union Value
7970 : {
7971 : UnionMember<ArrayBuffer > mArrayBuffer;
7972 : UnionMember<int32_t > mLong;
7973 :
7974 : };
7975 :
7976 : Type mType;
7977 : Value mValue;
7978 :
7979 : OwningArrayBufferOrLong(const OwningArrayBufferOrLong&) = delete;
7980 : OwningArrayBufferOrLong& operator=(const OwningArrayBufferOrLong&) = delete;
7981 : public:
7982 : explicit inline OwningArrayBufferOrLong()
7983 : : mType(eUninitialized)
7984 : {
7985 : }
7986 :
7987 : inline ~OwningArrayBufferOrLong()
7988 : {
7989 : Uninit();
7990 : }
7991 :
7992 : ArrayBuffer&
7993 : RawSetAsArrayBuffer();
7994 :
7995 : ArrayBuffer&
7996 : SetAsArrayBuffer();
7997 :
7998 : bool
7999 : TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8000 :
8001 : inline bool
8002 0 : IsArrayBuffer() const
8003 : {
8004 0 : return mType == eArrayBuffer;
8005 : }
8006 :
8007 : inline ArrayBuffer&
8008 : GetAsArrayBuffer()
8009 : {
8010 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
8011 : return mValue.mArrayBuffer.Value();
8012 : }
8013 :
8014 : inline ArrayBuffer const &
8015 : GetAsArrayBuffer() const
8016 : {
8017 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
8018 : return mValue.mArrayBuffer.Value();
8019 : }
8020 :
8021 : int32_t&
8022 : RawSetAsLong();
8023 :
8024 : int32_t&
8025 : SetAsLong();
8026 :
8027 : bool
8028 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8029 :
8030 : inline bool
8031 0 : IsLong() const
8032 : {
8033 0 : return mType == eLong;
8034 : }
8035 :
8036 : inline int32_t&
8037 : GetAsLong()
8038 : {
8039 : MOZ_ASSERT(IsLong(), "Wrong type!");
8040 : return mValue.mLong.Value();
8041 : }
8042 :
8043 : inline int32_t const &
8044 : GetAsLong() const
8045 : {
8046 : MOZ_ASSERT(IsLong(), "Wrong type!");
8047 : return mValue.mLong.Value();
8048 : }
8049 :
8050 : void
8051 : Uninit();
8052 :
8053 : bool
8054 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8055 :
8056 : void
8057 : TraceUnion(JSTracer* trc);
8058 :
8059 : private:
8060 : void
8061 : DestroyArrayBuffer();
8062 :
8063 : void
8064 : DestroyLong();
8065 : };
8066 :
8067 : class OwningArrayBufferViewOrArrayBuffer : public AllOwningUnionBase
8068 : {
8069 : friend void ImplCycleCollectionUnlink(OwningArrayBufferViewOrArrayBuffer& aUnion);
8070 : enum Type
8071 : {
8072 : eUninitialized,
8073 : eArrayBufferView,
8074 : eArrayBuffer
8075 : };
8076 :
8077 0 : union Value
8078 : {
8079 : UnionMember<ArrayBufferView > mArrayBufferView;
8080 : UnionMember<ArrayBuffer > mArrayBuffer;
8081 :
8082 : };
8083 :
8084 : Type mType;
8085 : Value mValue;
8086 :
8087 : OwningArrayBufferViewOrArrayBuffer(const OwningArrayBufferViewOrArrayBuffer&) = delete;
8088 : OwningArrayBufferViewOrArrayBuffer& operator=(const OwningArrayBufferViewOrArrayBuffer&) = delete;
8089 : public:
8090 0 : explicit inline OwningArrayBufferViewOrArrayBuffer()
8091 0 : : mType(eUninitialized)
8092 : {
8093 0 : }
8094 :
8095 0 : inline ~OwningArrayBufferViewOrArrayBuffer()
8096 0 : {
8097 0 : Uninit();
8098 0 : }
8099 :
8100 : ArrayBufferView&
8101 : RawSetAsArrayBufferView();
8102 :
8103 : ArrayBufferView&
8104 : SetAsArrayBufferView();
8105 :
8106 : bool
8107 : TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8108 :
8109 : inline bool
8110 0 : IsArrayBufferView() const
8111 : {
8112 0 : return mType == eArrayBufferView;
8113 : }
8114 :
8115 : inline ArrayBufferView&
8116 0 : GetAsArrayBufferView()
8117 : {
8118 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
8119 0 : return mValue.mArrayBufferView.Value();
8120 : }
8121 :
8122 : inline ArrayBufferView const &
8123 0 : GetAsArrayBufferView() const
8124 : {
8125 0 : MOZ_ASSERT(IsArrayBufferView(), "Wrong type!");
8126 0 : return mValue.mArrayBufferView.Value();
8127 : }
8128 :
8129 : ArrayBuffer&
8130 : RawSetAsArrayBuffer();
8131 :
8132 : ArrayBuffer&
8133 : SetAsArrayBuffer();
8134 :
8135 : bool
8136 : TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8137 :
8138 : inline bool
8139 0 : IsArrayBuffer() const
8140 : {
8141 0 : return mType == eArrayBuffer;
8142 : }
8143 :
8144 : inline ArrayBuffer&
8145 0 : GetAsArrayBuffer()
8146 : {
8147 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
8148 0 : return mValue.mArrayBuffer.Value();
8149 : }
8150 :
8151 : inline ArrayBuffer const &
8152 0 : GetAsArrayBuffer() const
8153 : {
8154 0 : MOZ_ASSERT(IsArrayBuffer(), "Wrong type!");
8155 0 : return mValue.mArrayBuffer.Value();
8156 : }
8157 :
8158 : void
8159 : Uninit();
8160 :
8161 : bool
8162 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8163 :
8164 : void
8165 : TraceUnion(JSTracer* trc);
8166 :
8167 : private:
8168 : void
8169 : DestroyArrayBufferView();
8170 :
8171 : void
8172 : DestroyArrayBuffer();
8173 : };
8174 :
8175 : class OwningByteStringOrLong : public AllOwningUnionBase
8176 : {
8177 : friend void ImplCycleCollectionUnlink(OwningByteStringOrLong& aUnion);
8178 : enum Type
8179 : {
8180 : eUninitialized,
8181 : eByteString,
8182 : eLong
8183 : };
8184 :
8185 : union Value
8186 : {
8187 : UnionMember<nsCString > mByteString;
8188 : UnionMember<int32_t > mLong;
8189 :
8190 : };
8191 :
8192 : Type mType;
8193 : Value mValue;
8194 :
8195 : public:
8196 : explicit inline OwningByteStringOrLong()
8197 : : mType(eUninitialized)
8198 : {
8199 : }
8200 :
8201 : explicit inline OwningByteStringOrLong(const OwningByteStringOrLong& aOther)
8202 : : mType(eUninitialized)
8203 : {
8204 : *this = aOther;
8205 : }
8206 :
8207 : inline ~OwningByteStringOrLong()
8208 : {
8209 : Uninit();
8210 : }
8211 :
8212 : nsCString&
8213 : RawSetAsByteString();
8214 :
8215 : nsCString&
8216 : SetAsByteString();
8217 :
8218 : bool
8219 : TrySetToByteString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8220 :
8221 : inline void
8222 : SetStringData(const nsCString::char_type* aData, nsCString::size_type aLength)
8223 : {
8224 : RawSetAsByteString().Assign(aData, aLength);
8225 : }
8226 :
8227 : inline bool
8228 0 : IsByteString() const
8229 : {
8230 0 : return mType == eByteString;
8231 : }
8232 :
8233 : inline nsCString&
8234 : GetAsByteString()
8235 : {
8236 : MOZ_ASSERT(IsByteString(), "Wrong type!");
8237 : return mValue.mByteString.Value();
8238 : }
8239 :
8240 : inline nsCString const &
8241 0 : GetAsByteString() const
8242 : {
8243 0 : MOZ_ASSERT(IsByteString(), "Wrong type!");
8244 0 : return mValue.mByteString.Value();
8245 : }
8246 :
8247 : int32_t&
8248 : RawSetAsLong();
8249 :
8250 : int32_t&
8251 : SetAsLong();
8252 :
8253 : bool
8254 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8255 :
8256 : inline bool
8257 0 : IsLong() const
8258 : {
8259 0 : return mType == eLong;
8260 : }
8261 :
8262 : inline int32_t&
8263 : GetAsLong()
8264 : {
8265 : MOZ_ASSERT(IsLong(), "Wrong type!");
8266 : return mValue.mLong.Value();
8267 : }
8268 :
8269 : inline int32_t const &
8270 0 : GetAsLong() const
8271 : {
8272 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
8273 0 : return mValue.mLong.Value();
8274 : }
8275 :
8276 : void
8277 : Uninit();
8278 :
8279 : bool
8280 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8281 :
8282 : void
8283 : TraceUnion(JSTracer* trc);
8284 :
8285 : OwningByteStringOrLong&
8286 : operator=(const OwningByteStringOrLong& aOther);
8287 :
8288 : private:
8289 : void
8290 : DestroyByteString();
8291 :
8292 : void
8293 : DestroyLong();
8294 : };
8295 :
8296 : class OwningCanvasPatternOrCanvasGradient : public AllOwningUnionBase
8297 : {
8298 : friend void ImplCycleCollectionUnlink(OwningCanvasPatternOrCanvasGradient& aUnion);
8299 : enum Type
8300 : {
8301 : eUninitialized,
8302 : eCanvasPattern,
8303 : eCanvasGradient
8304 : };
8305 :
8306 : union Value
8307 : {
8308 : UnionMember<OwningNonNull<mozilla::dom::CanvasPattern> > mCanvasPattern;
8309 : UnionMember<OwningNonNull<mozilla::dom::CanvasGradient> > mCanvasGradient;
8310 :
8311 : };
8312 :
8313 : Type mType;
8314 : Value mValue;
8315 :
8316 : public:
8317 : explicit inline OwningCanvasPatternOrCanvasGradient()
8318 : : mType(eUninitialized)
8319 : {
8320 : }
8321 :
8322 : explicit inline OwningCanvasPatternOrCanvasGradient(const OwningCanvasPatternOrCanvasGradient& aOther)
8323 : : mType(eUninitialized)
8324 : {
8325 : *this = aOther;
8326 : }
8327 :
8328 : inline ~OwningCanvasPatternOrCanvasGradient()
8329 : {
8330 : Uninit();
8331 : }
8332 :
8333 : OwningNonNull<mozilla::dom::CanvasPattern>&
8334 : RawSetAsCanvasPattern();
8335 :
8336 : OwningNonNull<mozilla::dom::CanvasPattern>&
8337 : SetAsCanvasPattern();
8338 :
8339 : bool
8340 : TrySetToCanvasPattern(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8341 :
8342 : inline bool
8343 0 : IsCanvasPattern() const
8344 : {
8345 0 : return mType == eCanvasPattern;
8346 : }
8347 :
8348 : inline OwningNonNull<mozilla::dom::CanvasPattern>&
8349 0 : GetAsCanvasPattern()
8350 : {
8351 0 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
8352 0 : return mValue.mCanvasPattern.Value();
8353 : }
8354 :
8355 : inline OwningNonNull<mozilla::dom::CanvasPattern> const &
8356 0 : GetAsCanvasPattern() const
8357 : {
8358 0 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
8359 0 : return mValue.mCanvasPattern.Value();
8360 : }
8361 :
8362 : OwningNonNull<mozilla::dom::CanvasGradient>&
8363 : RawSetAsCanvasGradient();
8364 :
8365 : OwningNonNull<mozilla::dom::CanvasGradient>&
8366 : SetAsCanvasGradient();
8367 :
8368 : bool
8369 : TrySetToCanvasGradient(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8370 :
8371 : inline bool
8372 0 : IsCanvasGradient() const
8373 : {
8374 0 : return mType == eCanvasGradient;
8375 : }
8376 :
8377 : inline OwningNonNull<mozilla::dom::CanvasGradient>&
8378 0 : GetAsCanvasGradient()
8379 : {
8380 0 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
8381 0 : return mValue.mCanvasGradient.Value();
8382 : }
8383 :
8384 : inline OwningNonNull<mozilla::dom::CanvasGradient> const &
8385 0 : GetAsCanvasGradient() const
8386 : {
8387 0 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
8388 0 : return mValue.mCanvasGradient.Value();
8389 : }
8390 :
8391 : void
8392 : Uninit();
8393 :
8394 : bool
8395 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8396 :
8397 : void
8398 : TraceUnion(JSTracer* trc);
8399 :
8400 : OwningCanvasPatternOrCanvasGradient&
8401 : operator=(const OwningCanvasPatternOrCanvasGradient& aOther);
8402 :
8403 : private:
8404 : void
8405 : DestroyCanvasPattern();
8406 :
8407 : void
8408 : DestroyCanvasGradient();
8409 : };
8410 :
8411 : class OwningCanvasPatternOrNullOrCanvasGradient : public AllOwningUnionBase
8412 : {
8413 : friend void ImplCycleCollectionUnlink(OwningCanvasPatternOrNullOrCanvasGradient& aUnion);
8414 : enum Type
8415 : {
8416 : eUninitialized,
8417 : eNull,
8418 : eCanvasPattern,
8419 : eCanvasGradient
8420 : };
8421 :
8422 : union Value
8423 : {
8424 : UnionMember<OwningNonNull<mozilla::dom::CanvasPattern> > mCanvasPattern;
8425 : UnionMember<OwningNonNull<mozilla::dom::CanvasGradient> > mCanvasGradient;
8426 :
8427 : };
8428 :
8429 : Type mType;
8430 : Value mValue;
8431 :
8432 : public:
8433 : explicit inline OwningCanvasPatternOrNullOrCanvasGradient()
8434 : : mType(eUninitialized)
8435 : {
8436 : }
8437 :
8438 : explicit inline OwningCanvasPatternOrNullOrCanvasGradient(const OwningCanvasPatternOrNullOrCanvasGradient& aOther)
8439 : : mType(eUninitialized)
8440 : {
8441 : *this = aOther;
8442 : }
8443 :
8444 : inline ~OwningCanvasPatternOrNullOrCanvasGradient()
8445 : {
8446 : Uninit();
8447 : }
8448 :
8449 : inline bool
8450 : IsNull() const
8451 : {
8452 : return mType == eNull;
8453 : }
8454 :
8455 : inline void
8456 : SetNull()
8457 : {
8458 : Uninit();
8459 : mType = eNull;
8460 : }
8461 :
8462 : OwningNonNull<mozilla::dom::CanvasPattern>&
8463 : RawSetAsCanvasPattern();
8464 :
8465 : OwningNonNull<mozilla::dom::CanvasPattern>&
8466 : SetAsCanvasPattern();
8467 :
8468 : bool
8469 : TrySetToCanvasPattern(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8470 :
8471 : inline bool
8472 0 : IsCanvasPattern() const
8473 : {
8474 0 : return mType == eCanvasPattern;
8475 : }
8476 :
8477 : inline OwningNonNull<mozilla::dom::CanvasPattern>&
8478 0 : GetAsCanvasPattern()
8479 : {
8480 0 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
8481 0 : return mValue.mCanvasPattern.Value();
8482 : }
8483 :
8484 : inline OwningNonNull<mozilla::dom::CanvasPattern> const &
8485 0 : GetAsCanvasPattern() const
8486 : {
8487 0 : MOZ_ASSERT(IsCanvasPattern(), "Wrong type!");
8488 0 : return mValue.mCanvasPattern.Value();
8489 : }
8490 :
8491 : OwningNonNull<mozilla::dom::CanvasGradient>&
8492 : RawSetAsCanvasGradient();
8493 :
8494 : OwningNonNull<mozilla::dom::CanvasGradient>&
8495 : SetAsCanvasGradient();
8496 :
8497 : bool
8498 : TrySetToCanvasGradient(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8499 :
8500 : inline bool
8501 0 : IsCanvasGradient() const
8502 : {
8503 0 : return mType == eCanvasGradient;
8504 : }
8505 :
8506 : inline OwningNonNull<mozilla::dom::CanvasGradient>&
8507 0 : GetAsCanvasGradient()
8508 : {
8509 0 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
8510 0 : return mValue.mCanvasGradient.Value();
8511 : }
8512 :
8513 : inline OwningNonNull<mozilla::dom::CanvasGradient> const &
8514 0 : GetAsCanvasGradient() const
8515 : {
8516 0 : MOZ_ASSERT(IsCanvasGradient(), "Wrong type!");
8517 0 : return mValue.mCanvasGradient.Value();
8518 : }
8519 :
8520 : void
8521 : Uninit();
8522 :
8523 : bool
8524 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8525 :
8526 : void
8527 : TraceUnion(JSTracer* trc);
8528 :
8529 : OwningCanvasPatternOrNullOrCanvasGradient&
8530 : operator=(const OwningCanvasPatternOrNullOrCanvasGradient& aOther);
8531 :
8532 : private:
8533 : void
8534 : DestroyCanvasPattern();
8535 :
8536 : void
8537 : DestroyCanvasGradient();
8538 : };
8539 :
8540 : class OwningCustomEventInitOrLong : public AllOwningUnionBase
8541 : {
8542 : friend void ImplCycleCollectionUnlink(OwningCustomEventInitOrLong& aUnion);
8543 : enum Type
8544 : {
8545 : eUninitialized,
8546 : eCustomEventInit,
8547 : eLong
8548 : };
8549 :
8550 : union Value
8551 : {
8552 : UnionMember<CustomEventInit > mCustomEventInit;
8553 : UnionMember<int32_t > mLong;
8554 :
8555 : };
8556 :
8557 : Type mType;
8558 : Value mValue;
8559 :
8560 : OwningCustomEventInitOrLong(const OwningCustomEventInitOrLong&) = delete;
8561 : OwningCustomEventInitOrLong& operator=(const OwningCustomEventInitOrLong&) = delete;
8562 : public:
8563 : explicit inline OwningCustomEventInitOrLong()
8564 : : mType(eUninitialized)
8565 : {
8566 : }
8567 :
8568 : inline ~OwningCustomEventInitOrLong()
8569 : {
8570 : Uninit();
8571 : }
8572 :
8573 : CustomEventInit&
8574 : RawSetAsCustomEventInit();
8575 :
8576 : CustomEventInit&
8577 : SetAsCustomEventInit();
8578 :
8579 : bool
8580 : TrySetToCustomEventInit(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8581 :
8582 : inline bool
8583 0 : IsCustomEventInit() const
8584 : {
8585 0 : return mType == eCustomEventInit;
8586 : }
8587 :
8588 : inline CustomEventInit&
8589 : GetAsCustomEventInit()
8590 : {
8591 : MOZ_ASSERT(IsCustomEventInit(), "Wrong type!");
8592 : return mValue.mCustomEventInit.Value();
8593 : }
8594 :
8595 : inline CustomEventInit const &
8596 : GetAsCustomEventInit() const
8597 : {
8598 : MOZ_ASSERT(IsCustomEventInit(), "Wrong type!");
8599 : return mValue.mCustomEventInit.Value();
8600 : }
8601 :
8602 : int32_t&
8603 : RawSetAsLong();
8604 :
8605 : int32_t&
8606 : SetAsLong();
8607 :
8608 : bool
8609 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8610 :
8611 : inline bool
8612 0 : IsLong() const
8613 : {
8614 0 : return mType == eLong;
8615 : }
8616 :
8617 : inline int32_t&
8618 : GetAsLong()
8619 : {
8620 : MOZ_ASSERT(IsLong(), "Wrong type!");
8621 : return mValue.mLong.Value();
8622 : }
8623 :
8624 : inline int32_t const &
8625 : GetAsLong() const
8626 : {
8627 : MOZ_ASSERT(IsLong(), "Wrong type!");
8628 : return mValue.mLong.Value();
8629 : }
8630 :
8631 : void
8632 : Uninit();
8633 :
8634 : bool
8635 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8636 :
8637 : void
8638 : TraceUnion(JSTracer* trc);
8639 :
8640 : private:
8641 : void
8642 : DestroyCustomEventInit();
8643 :
8644 : void
8645 : DestroyLong();
8646 : };
8647 :
8648 : class OwningDoubleOrByteString : public AllOwningUnionBase
8649 : {
8650 : friend void ImplCycleCollectionUnlink(OwningDoubleOrByteString& aUnion);
8651 : enum Type
8652 : {
8653 : eUninitialized,
8654 : eDouble,
8655 : eByteString
8656 : };
8657 :
8658 : union Value
8659 : {
8660 : UnionMember<double > mDouble;
8661 : UnionMember<nsCString > mByteString;
8662 :
8663 : };
8664 :
8665 : Type mType;
8666 : Value mValue;
8667 :
8668 : public:
8669 : explicit inline OwningDoubleOrByteString()
8670 : : mType(eUninitialized)
8671 : {
8672 : }
8673 :
8674 : explicit inline OwningDoubleOrByteString(const OwningDoubleOrByteString& aOther)
8675 : : mType(eUninitialized)
8676 : {
8677 : *this = aOther;
8678 : }
8679 :
8680 : inline ~OwningDoubleOrByteString()
8681 : {
8682 : Uninit();
8683 : }
8684 :
8685 : double&
8686 : RawSetAsDouble();
8687 :
8688 : double&
8689 : SetAsDouble();
8690 :
8691 : bool
8692 : TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8693 :
8694 : inline bool
8695 0 : IsDouble() const
8696 : {
8697 0 : return mType == eDouble;
8698 : }
8699 :
8700 : inline double&
8701 : GetAsDouble()
8702 : {
8703 : MOZ_ASSERT(IsDouble(), "Wrong type!");
8704 : return mValue.mDouble.Value();
8705 : }
8706 :
8707 : inline double const &
8708 0 : GetAsDouble() const
8709 : {
8710 0 : MOZ_ASSERT(IsDouble(), "Wrong type!");
8711 0 : return mValue.mDouble.Value();
8712 : }
8713 :
8714 : nsCString&
8715 : RawSetAsByteString();
8716 :
8717 : nsCString&
8718 : SetAsByteString();
8719 :
8720 : bool
8721 : TrySetToByteString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8722 :
8723 : inline void
8724 : SetStringData(const nsCString::char_type* aData, nsCString::size_type aLength)
8725 : {
8726 : RawSetAsByteString().Assign(aData, aLength);
8727 : }
8728 :
8729 : inline bool
8730 0 : IsByteString() const
8731 : {
8732 0 : return mType == eByteString;
8733 : }
8734 :
8735 : inline nsCString&
8736 : GetAsByteString()
8737 : {
8738 : MOZ_ASSERT(IsByteString(), "Wrong type!");
8739 : return mValue.mByteString.Value();
8740 : }
8741 :
8742 : inline nsCString const &
8743 0 : GetAsByteString() const
8744 : {
8745 0 : MOZ_ASSERT(IsByteString(), "Wrong type!");
8746 0 : return mValue.mByteString.Value();
8747 : }
8748 :
8749 : void
8750 : Uninit();
8751 :
8752 : bool
8753 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8754 :
8755 : void
8756 : TraceUnion(JSTracer* trc);
8757 :
8758 : OwningDoubleOrByteString&
8759 : operator=(const OwningDoubleOrByteString& aOther);
8760 :
8761 : private:
8762 : void
8763 : DestroyDouble();
8764 :
8765 : void
8766 : DestroyByteString();
8767 : };
8768 :
8769 : class OwningDoubleOrString : public AllOwningUnionBase
8770 : {
8771 : friend void ImplCycleCollectionUnlink(OwningDoubleOrString& aUnion);
8772 : enum Type
8773 : {
8774 : eUninitialized,
8775 : eDouble,
8776 : eString
8777 : };
8778 :
8779 : union Value
8780 : {
8781 : UnionMember<double > mDouble;
8782 : UnionMember<nsString > mString;
8783 :
8784 : };
8785 :
8786 : Type mType;
8787 : Value mValue;
8788 :
8789 : public:
8790 : explicit inline OwningDoubleOrString()
8791 : : mType(eUninitialized)
8792 : {
8793 : }
8794 :
8795 : explicit inline OwningDoubleOrString(const OwningDoubleOrString& aOther)
8796 : : mType(eUninitialized)
8797 : {
8798 : *this = aOther;
8799 : }
8800 :
8801 : inline ~OwningDoubleOrString()
8802 : {
8803 : Uninit();
8804 : }
8805 :
8806 : double&
8807 : RawSetAsDouble();
8808 :
8809 : double&
8810 : SetAsDouble();
8811 :
8812 : bool
8813 : TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8814 :
8815 : inline bool
8816 0 : IsDouble() const
8817 : {
8818 0 : return mType == eDouble;
8819 : }
8820 :
8821 : inline double&
8822 : GetAsDouble()
8823 : {
8824 : MOZ_ASSERT(IsDouble(), "Wrong type!");
8825 : return mValue.mDouble.Value();
8826 : }
8827 :
8828 : inline double const &
8829 0 : GetAsDouble() const
8830 : {
8831 0 : MOZ_ASSERT(IsDouble(), "Wrong type!");
8832 0 : return mValue.mDouble.Value();
8833 : }
8834 :
8835 : nsString&
8836 : RawSetAsString();
8837 :
8838 : nsString&
8839 : SetAsString();
8840 :
8841 : bool
8842 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8843 :
8844 : inline void
8845 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
8846 : {
8847 : RawSetAsString().Assign(aData, aLength);
8848 : }
8849 :
8850 : inline bool
8851 0 : IsString() const
8852 : {
8853 0 : return mType == eString;
8854 : }
8855 :
8856 : inline nsString&
8857 : GetAsString()
8858 : {
8859 : MOZ_ASSERT(IsString(), "Wrong type!");
8860 : return mValue.mString.Value();
8861 : }
8862 :
8863 : inline nsString const &
8864 0 : GetAsString() const
8865 : {
8866 0 : MOZ_ASSERT(IsString(), "Wrong type!");
8867 0 : return mValue.mString.Value();
8868 : }
8869 :
8870 : void
8871 : Uninit();
8872 :
8873 : bool
8874 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8875 :
8876 : void
8877 : TraceUnion(JSTracer* trc);
8878 :
8879 : OwningDoubleOrString&
8880 : operator=(const OwningDoubleOrString& aOther);
8881 :
8882 : private:
8883 : void
8884 : DestroyDouble();
8885 :
8886 : void
8887 : DestroyString();
8888 : };
8889 :
8890 : class OwningDoubleOrSupportedType : public AllOwningUnionBase
8891 : {
8892 : friend void ImplCycleCollectionUnlink(OwningDoubleOrSupportedType& aUnion);
8893 : enum Type
8894 : {
8895 : eUninitialized,
8896 : eDouble,
8897 : eSupportedType
8898 : };
8899 :
8900 : union Value
8901 : {
8902 : UnionMember<double > mDouble;
8903 : UnionMember<SupportedType > mSupportedType;
8904 :
8905 : };
8906 :
8907 : Type mType;
8908 : Value mValue;
8909 :
8910 : public:
8911 : explicit inline OwningDoubleOrSupportedType()
8912 : : mType(eUninitialized)
8913 : {
8914 : }
8915 :
8916 : explicit inline OwningDoubleOrSupportedType(const OwningDoubleOrSupportedType& aOther)
8917 : : mType(eUninitialized)
8918 : {
8919 : *this = aOther;
8920 : }
8921 :
8922 : inline ~OwningDoubleOrSupportedType()
8923 : {
8924 : Uninit();
8925 : }
8926 :
8927 : double&
8928 : RawSetAsDouble();
8929 :
8930 : double&
8931 : SetAsDouble();
8932 :
8933 : bool
8934 : TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8935 :
8936 : inline bool
8937 0 : IsDouble() const
8938 : {
8939 0 : return mType == eDouble;
8940 : }
8941 :
8942 : inline double&
8943 : GetAsDouble()
8944 : {
8945 : MOZ_ASSERT(IsDouble(), "Wrong type!");
8946 : return mValue.mDouble.Value();
8947 : }
8948 :
8949 : inline double const &
8950 0 : GetAsDouble() const
8951 : {
8952 0 : MOZ_ASSERT(IsDouble(), "Wrong type!");
8953 0 : return mValue.mDouble.Value();
8954 : }
8955 :
8956 : SupportedType&
8957 : RawSetAsSupportedType();
8958 :
8959 : SupportedType&
8960 : SetAsSupportedType();
8961 :
8962 : bool
8963 : TrySetToSupportedType(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
8964 :
8965 : inline bool
8966 0 : IsSupportedType() const
8967 : {
8968 0 : return mType == eSupportedType;
8969 : }
8970 :
8971 : inline SupportedType&
8972 : GetAsSupportedType()
8973 : {
8974 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
8975 : return mValue.mSupportedType.Value();
8976 : }
8977 :
8978 : inline SupportedType const &
8979 0 : GetAsSupportedType() const
8980 : {
8981 0 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
8982 0 : return mValue.mSupportedType.Value();
8983 : }
8984 :
8985 : void
8986 : Uninit();
8987 :
8988 : bool
8989 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
8990 :
8991 : void
8992 : TraceUnion(JSTracer* trc);
8993 :
8994 : OwningDoubleOrSupportedType&
8995 : operator=(const OwningDoubleOrSupportedType& aOther);
8996 :
8997 : private:
8998 : void
8999 : DestroyDouble();
9000 :
9001 : void
9002 : DestroySupportedType();
9003 : };
9004 :
9005 : class OwningDoubleOrUSVString : public AllOwningUnionBase
9006 : {
9007 : friend void ImplCycleCollectionUnlink(OwningDoubleOrUSVString& aUnion);
9008 : enum Type
9009 : {
9010 : eUninitialized,
9011 : eDouble,
9012 : eUSVString
9013 : };
9014 :
9015 : union Value
9016 : {
9017 : UnionMember<double > mDouble;
9018 : UnionMember<nsString > mUSVString;
9019 :
9020 : };
9021 :
9022 : Type mType;
9023 : Value mValue;
9024 :
9025 : public:
9026 : explicit inline OwningDoubleOrUSVString()
9027 : : mType(eUninitialized)
9028 : {
9029 : }
9030 :
9031 : explicit inline OwningDoubleOrUSVString(const OwningDoubleOrUSVString& aOther)
9032 : : mType(eUninitialized)
9033 : {
9034 : *this = aOther;
9035 : }
9036 :
9037 : inline ~OwningDoubleOrUSVString()
9038 : {
9039 : Uninit();
9040 : }
9041 :
9042 : double&
9043 : RawSetAsDouble();
9044 :
9045 : double&
9046 : SetAsDouble();
9047 :
9048 : bool
9049 : TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9050 :
9051 : inline bool
9052 0 : IsDouble() const
9053 : {
9054 0 : return mType == eDouble;
9055 : }
9056 :
9057 : inline double&
9058 : GetAsDouble()
9059 : {
9060 : MOZ_ASSERT(IsDouble(), "Wrong type!");
9061 : return mValue.mDouble.Value();
9062 : }
9063 :
9064 : inline double const &
9065 0 : GetAsDouble() const
9066 : {
9067 0 : MOZ_ASSERT(IsDouble(), "Wrong type!");
9068 0 : return mValue.mDouble.Value();
9069 : }
9070 :
9071 : nsString&
9072 : RawSetAsUSVString();
9073 :
9074 : nsString&
9075 : SetAsUSVString();
9076 :
9077 : bool
9078 : TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9079 :
9080 : inline void
9081 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
9082 : {
9083 : RawSetAsUSVString().Assign(aData, aLength);
9084 : }
9085 :
9086 : inline bool
9087 0 : IsUSVString() const
9088 : {
9089 0 : return mType == eUSVString;
9090 : }
9091 :
9092 : inline nsString&
9093 : GetAsUSVString()
9094 : {
9095 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
9096 : return mValue.mUSVString.Value();
9097 : }
9098 :
9099 : inline nsString const &
9100 0 : GetAsUSVString() const
9101 : {
9102 0 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
9103 0 : return mValue.mUSVString.Value();
9104 : }
9105 :
9106 : void
9107 : Uninit();
9108 :
9109 : bool
9110 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9111 :
9112 : void
9113 : TraceUnion(JSTracer* trc);
9114 :
9115 : OwningDoubleOrUSVString&
9116 : operator=(const OwningDoubleOrUSVString& aOther);
9117 :
9118 : private:
9119 : void
9120 : DestroyDouble();
9121 :
9122 : void
9123 : DestroyUSVString();
9124 : };
9125 :
9126 : class OwningEventHandlerNonNullOrNullOrLong : public AllOwningUnionBase
9127 : {
9128 : friend void ImplCycleCollectionUnlink(OwningEventHandlerNonNullOrNullOrLong& aUnion);
9129 : enum Type
9130 : {
9131 : eUninitialized,
9132 : eNull,
9133 : eEventHandlerNonNull,
9134 : eLong
9135 : };
9136 :
9137 : union Value
9138 : {
9139 : UnionMember<OwningNonNull<EventHandlerNonNull> > mEventHandlerNonNull;
9140 : UnionMember<int32_t > mLong;
9141 :
9142 : };
9143 :
9144 : Type mType;
9145 : Value mValue;
9146 :
9147 : OwningEventHandlerNonNullOrNullOrLong(const OwningEventHandlerNonNullOrNullOrLong&) = delete;
9148 : OwningEventHandlerNonNullOrNullOrLong& operator=(const OwningEventHandlerNonNullOrNullOrLong&) = delete;
9149 : public:
9150 : explicit inline OwningEventHandlerNonNullOrNullOrLong()
9151 : : mType(eUninitialized)
9152 : {
9153 : }
9154 :
9155 : inline ~OwningEventHandlerNonNullOrNullOrLong()
9156 : {
9157 : Uninit();
9158 : }
9159 :
9160 : inline bool
9161 : IsNull() const
9162 : {
9163 : return mType == eNull;
9164 : }
9165 :
9166 : inline void
9167 : SetNull()
9168 : {
9169 : Uninit();
9170 : mType = eNull;
9171 : }
9172 :
9173 : OwningNonNull<EventHandlerNonNull>&
9174 : RawSetAsEventHandlerNonNull();
9175 :
9176 : OwningNonNull<EventHandlerNonNull>&
9177 : SetAsEventHandlerNonNull();
9178 :
9179 : bool
9180 : TrySetToEventHandlerNonNull(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9181 :
9182 : inline bool
9183 0 : IsEventHandlerNonNull() const
9184 : {
9185 0 : return mType == eEventHandlerNonNull;
9186 : }
9187 :
9188 : inline OwningNonNull<EventHandlerNonNull>&
9189 0 : GetAsEventHandlerNonNull()
9190 : {
9191 0 : MOZ_ASSERT(IsEventHandlerNonNull(), "Wrong type!");
9192 0 : return mValue.mEventHandlerNonNull.Value();
9193 : }
9194 :
9195 : inline OwningNonNull<EventHandlerNonNull> const &
9196 : GetAsEventHandlerNonNull() const
9197 : {
9198 : MOZ_ASSERT(IsEventHandlerNonNull(), "Wrong type!");
9199 : return mValue.mEventHandlerNonNull.Value();
9200 : }
9201 :
9202 : int32_t&
9203 : RawSetAsLong();
9204 :
9205 : int32_t&
9206 : SetAsLong();
9207 :
9208 : bool
9209 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9210 :
9211 : inline bool
9212 0 : IsLong() const
9213 : {
9214 0 : return mType == eLong;
9215 : }
9216 :
9217 : inline int32_t&
9218 : GetAsLong()
9219 : {
9220 : MOZ_ASSERT(IsLong(), "Wrong type!");
9221 : return mValue.mLong.Value();
9222 : }
9223 :
9224 : inline int32_t const &
9225 : GetAsLong() const
9226 : {
9227 : MOZ_ASSERT(IsLong(), "Wrong type!");
9228 : return mValue.mLong.Value();
9229 : }
9230 :
9231 : void
9232 : Uninit();
9233 :
9234 : bool
9235 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9236 :
9237 : void
9238 : TraceUnion(JSTracer* trc);
9239 :
9240 : private:
9241 : void
9242 : DestroyEventHandlerNonNull();
9243 :
9244 : void
9245 : DestroyLong();
9246 : };
9247 :
9248 : class OwningEventInitOrLong : public AllOwningUnionBase
9249 : {
9250 : friend void ImplCycleCollectionUnlink(OwningEventInitOrLong& aUnion);
9251 : enum Type
9252 : {
9253 : eUninitialized,
9254 : eEventInit,
9255 : eLong
9256 : };
9257 :
9258 : union Value
9259 : {
9260 : UnionMember<EventInit > mEventInit;
9261 : UnionMember<int32_t > mLong;
9262 :
9263 : };
9264 :
9265 : Type mType;
9266 : Value mValue;
9267 :
9268 : public:
9269 : explicit inline OwningEventInitOrLong()
9270 : : mType(eUninitialized)
9271 : {
9272 : }
9273 :
9274 : explicit inline OwningEventInitOrLong(const OwningEventInitOrLong& aOther)
9275 : : mType(eUninitialized)
9276 : {
9277 : *this = aOther;
9278 : }
9279 :
9280 : inline ~OwningEventInitOrLong()
9281 : {
9282 : Uninit();
9283 : }
9284 :
9285 : EventInit&
9286 : RawSetAsEventInit();
9287 :
9288 : EventInit&
9289 : SetAsEventInit();
9290 :
9291 : bool
9292 : TrySetToEventInit(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9293 :
9294 : inline bool
9295 0 : IsEventInit() const
9296 : {
9297 0 : return mType == eEventInit;
9298 : }
9299 :
9300 : inline EventInit&
9301 : GetAsEventInit()
9302 : {
9303 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
9304 : return mValue.mEventInit.Value();
9305 : }
9306 :
9307 : inline EventInit const &
9308 0 : GetAsEventInit() const
9309 : {
9310 0 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
9311 0 : return mValue.mEventInit.Value();
9312 : }
9313 :
9314 : int32_t&
9315 : RawSetAsLong();
9316 :
9317 : int32_t&
9318 : SetAsLong();
9319 :
9320 : bool
9321 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9322 :
9323 : inline bool
9324 0 : IsLong() const
9325 : {
9326 0 : return mType == eLong;
9327 : }
9328 :
9329 : inline int32_t&
9330 : GetAsLong()
9331 : {
9332 : MOZ_ASSERT(IsLong(), "Wrong type!");
9333 : return mValue.mLong.Value();
9334 : }
9335 :
9336 : inline int32_t const &
9337 0 : GetAsLong() const
9338 : {
9339 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
9340 0 : return mValue.mLong.Value();
9341 : }
9342 :
9343 : void
9344 : Uninit();
9345 :
9346 : bool
9347 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9348 :
9349 : void
9350 : TraceUnion(JSTracer* trc);
9351 :
9352 : OwningEventInitOrLong&
9353 : operator=(const OwningEventInitOrLong& aOther);
9354 :
9355 : private:
9356 : void
9357 : DestroyEventInit();
9358 :
9359 : void
9360 : DestroyLong();
9361 : };
9362 :
9363 : class OwningEventInitOrStringSequence : public AllOwningUnionBase
9364 : {
9365 : friend void ImplCycleCollectionUnlink(OwningEventInitOrStringSequence& aUnion);
9366 : enum Type
9367 : {
9368 : eUninitialized,
9369 : eEventInit,
9370 : eStringSequence
9371 : };
9372 :
9373 : union Value
9374 : {
9375 : UnionMember<EventInit > mEventInit;
9376 : UnionMember<Sequence<nsString> > mStringSequence;
9377 :
9378 : };
9379 :
9380 : Type mType;
9381 : Value mValue;
9382 :
9383 : public:
9384 : explicit inline OwningEventInitOrStringSequence()
9385 : : mType(eUninitialized)
9386 : {
9387 : }
9388 :
9389 : explicit inline OwningEventInitOrStringSequence(const OwningEventInitOrStringSequence& aOther)
9390 : : mType(eUninitialized)
9391 : {
9392 : *this = aOther;
9393 : }
9394 :
9395 : inline ~OwningEventInitOrStringSequence()
9396 : {
9397 : Uninit();
9398 : }
9399 :
9400 : EventInit&
9401 : RawSetAsEventInit();
9402 :
9403 : EventInit&
9404 : SetAsEventInit();
9405 :
9406 : bool
9407 : TrySetToEventInit(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9408 :
9409 : inline bool
9410 0 : IsEventInit() const
9411 : {
9412 0 : return mType == eEventInit;
9413 : }
9414 :
9415 : inline EventInit&
9416 : GetAsEventInit()
9417 : {
9418 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
9419 : return mValue.mEventInit.Value();
9420 : }
9421 :
9422 : inline EventInit const &
9423 0 : GetAsEventInit() const
9424 : {
9425 0 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
9426 0 : return mValue.mEventInit.Value();
9427 : }
9428 :
9429 : Sequence<nsString>&
9430 : RawSetAsStringSequence();
9431 :
9432 : Sequence<nsString>&
9433 : SetAsStringSequence();
9434 :
9435 : bool
9436 : TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9437 :
9438 : inline bool
9439 0 : IsStringSequence() const
9440 : {
9441 0 : return mType == eStringSequence;
9442 : }
9443 :
9444 : inline Sequence<nsString>&
9445 : GetAsStringSequence()
9446 : {
9447 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
9448 : return mValue.mStringSequence.Value();
9449 : }
9450 :
9451 : inline Sequence<nsString> const &
9452 0 : GetAsStringSequence() const
9453 : {
9454 0 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
9455 0 : return mValue.mStringSequence.Value();
9456 : }
9457 :
9458 : void
9459 : Uninit();
9460 :
9461 : bool
9462 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9463 :
9464 : void
9465 : TraceUnion(JSTracer* trc);
9466 :
9467 : OwningEventInitOrStringSequence&
9468 : operator=(const OwningEventInitOrStringSequence& aOther);
9469 :
9470 : private:
9471 : void
9472 : DestroyEventInit();
9473 :
9474 : void
9475 : DestroyStringSequence();
9476 : };
9477 :
9478 : class OwningFileOrDirectory : public AllOwningUnionBase
9479 : {
9480 : friend void ImplCycleCollectionUnlink(OwningFileOrDirectory& aUnion);
9481 : enum Type
9482 : {
9483 : eUninitialized,
9484 : eFile,
9485 : eDirectory
9486 : };
9487 :
9488 0 : union Value
9489 : {
9490 : UnionMember<OwningNonNull<mozilla::dom::File> > mFile;
9491 : UnionMember<OwningNonNull<mozilla::dom::Directory> > mDirectory;
9492 :
9493 : };
9494 :
9495 : Type mType;
9496 : Value mValue;
9497 :
9498 : public:
9499 0 : explicit inline OwningFileOrDirectory()
9500 0 : : mType(eUninitialized)
9501 : {
9502 0 : }
9503 :
9504 0 : explicit inline OwningFileOrDirectory(const OwningFileOrDirectory& aOther)
9505 0 : : mType(eUninitialized)
9506 : {
9507 0 : *this = aOther;
9508 0 : }
9509 :
9510 0 : inline ~OwningFileOrDirectory()
9511 0 : {
9512 0 : Uninit();
9513 0 : }
9514 :
9515 : OwningNonNull<mozilla::dom::File>&
9516 : RawSetAsFile();
9517 :
9518 : OwningNonNull<mozilla::dom::File>&
9519 : SetAsFile();
9520 :
9521 : bool
9522 : TrySetToFile(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9523 :
9524 : inline bool
9525 0 : IsFile() const
9526 : {
9527 0 : return mType == eFile;
9528 : }
9529 :
9530 : inline OwningNonNull<mozilla::dom::File>&
9531 0 : GetAsFile()
9532 : {
9533 0 : MOZ_ASSERT(IsFile(), "Wrong type!");
9534 0 : return mValue.mFile.Value();
9535 : }
9536 :
9537 : inline OwningNonNull<mozilla::dom::File> const &
9538 0 : GetAsFile() const
9539 : {
9540 0 : MOZ_ASSERT(IsFile(), "Wrong type!");
9541 0 : return mValue.mFile.Value();
9542 : }
9543 :
9544 : OwningNonNull<mozilla::dom::Directory>&
9545 : RawSetAsDirectory();
9546 :
9547 : OwningNonNull<mozilla::dom::Directory>&
9548 : SetAsDirectory();
9549 :
9550 : bool
9551 : TrySetToDirectory(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9552 :
9553 : inline bool
9554 0 : IsDirectory() const
9555 : {
9556 0 : return mType == eDirectory;
9557 : }
9558 :
9559 : inline OwningNonNull<mozilla::dom::Directory>&
9560 0 : GetAsDirectory()
9561 : {
9562 0 : MOZ_ASSERT(IsDirectory(), "Wrong type!");
9563 0 : return mValue.mDirectory.Value();
9564 : }
9565 :
9566 : inline OwningNonNull<mozilla::dom::Directory> const &
9567 0 : GetAsDirectory() const
9568 : {
9569 0 : MOZ_ASSERT(IsDirectory(), "Wrong type!");
9570 0 : return mValue.mDirectory.Value();
9571 : }
9572 :
9573 : void
9574 : Uninit();
9575 :
9576 : bool
9577 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9578 :
9579 : void
9580 : TraceUnion(JSTracer* trc);
9581 :
9582 : OwningFileOrDirectory&
9583 : operator=(const OwningFileOrDirectory& aOther);
9584 :
9585 : private:
9586 : void
9587 : DestroyFile();
9588 :
9589 : void
9590 : DestroyDirectory();
9591 : };
9592 :
9593 : class OwningFloatOrString : public AllOwningUnionBase
9594 : {
9595 : friend void ImplCycleCollectionUnlink(OwningFloatOrString& aUnion);
9596 : enum Type
9597 : {
9598 : eUninitialized,
9599 : eFloat,
9600 : eString
9601 : };
9602 :
9603 : union Value
9604 : {
9605 : UnionMember<float > mFloat;
9606 : UnionMember<nsString > mString;
9607 :
9608 : };
9609 :
9610 : Type mType;
9611 : Value mValue;
9612 :
9613 : public:
9614 : explicit inline OwningFloatOrString()
9615 : : mType(eUninitialized)
9616 : {
9617 : }
9618 :
9619 : explicit inline OwningFloatOrString(const OwningFloatOrString& aOther)
9620 : : mType(eUninitialized)
9621 : {
9622 : *this = aOther;
9623 : }
9624 :
9625 : inline ~OwningFloatOrString()
9626 : {
9627 : Uninit();
9628 : }
9629 :
9630 : float&
9631 : RawSetAsFloat();
9632 :
9633 : float&
9634 : SetAsFloat();
9635 :
9636 : bool
9637 : TrySetToFloat(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9638 :
9639 : inline bool
9640 0 : IsFloat() const
9641 : {
9642 0 : return mType == eFloat;
9643 : }
9644 :
9645 : inline float&
9646 : GetAsFloat()
9647 : {
9648 : MOZ_ASSERT(IsFloat(), "Wrong type!");
9649 : return mValue.mFloat.Value();
9650 : }
9651 :
9652 : inline float const &
9653 0 : GetAsFloat() const
9654 : {
9655 0 : MOZ_ASSERT(IsFloat(), "Wrong type!");
9656 0 : return mValue.mFloat.Value();
9657 : }
9658 :
9659 : nsString&
9660 : RawSetAsString();
9661 :
9662 : nsString&
9663 : SetAsString();
9664 :
9665 : bool
9666 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9667 :
9668 : inline void
9669 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
9670 : {
9671 : RawSetAsString().Assign(aData, aLength);
9672 : }
9673 :
9674 : inline bool
9675 0 : IsString() const
9676 : {
9677 0 : return mType == eString;
9678 : }
9679 :
9680 : inline nsString&
9681 : GetAsString()
9682 : {
9683 : MOZ_ASSERT(IsString(), "Wrong type!");
9684 : return mValue.mString.Value();
9685 : }
9686 :
9687 : inline nsString const &
9688 0 : GetAsString() const
9689 : {
9690 0 : MOZ_ASSERT(IsString(), "Wrong type!");
9691 0 : return mValue.mString.Value();
9692 : }
9693 :
9694 : void
9695 : Uninit();
9696 :
9697 : bool
9698 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9699 :
9700 : void
9701 : TraceUnion(JSTracer* trc);
9702 :
9703 : OwningFloatOrString&
9704 : operator=(const OwningFloatOrString& aOther);
9705 :
9706 : private:
9707 : void
9708 : DestroyFloat();
9709 :
9710 : void
9711 : DestroyString();
9712 : };
9713 :
9714 : class OwningHTMLElementOrLong : public AllOwningUnionBase
9715 : {
9716 : friend void ImplCycleCollectionUnlink(OwningHTMLElementOrLong& aUnion);
9717 : enum Type
9718 : {
9719 : eUninitialized,
9720 : eHTMLElement,
9721 : eLong
9722 : };
9723 :
9724 : union Value
9725 : {
9726 : UnionMember<OwningNonNull<nsGenericHTMLElement> > mHTMLElement;
9727 : UnionMember<int32_t > mLong;
9728 :
9729 : };
9730 :
9731 : Type mType;
9732 : Value mValue;
9733 :
9734 : public:
9735 : explicit inline OwningHTMLElementOrLong()
9736 : : mType(eUninitialized)
9737 : {
9738 : }
9739 :
9740 : explicit inline OwningHTMLElementOrLong(const OwningHTMLElementOrLong& aOther)
9741 : : mType(eUninitialized)
9742 : {
9743 : *this = aOther;
9744 : }
9745 :
9746 : inline ~OwningHTMLElementOrLong()
9747 : {
9748 : Uninit();
9749 : }
9750 :
9751 : OwningNonNull<nsGenericHTMLElement>&
9752 : RawSetAsHTMLElement();
9753 :
9754 : OwningNonNull<nsGenericHTMLElement>&
9755 : SetAsHTMLElement();
9756 :
9757 : bool
9758 : TrySetToHTMLElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9759 :
9760 : inline bool
9761 0 : IsHTMLElement() const
9762 : {
9763 0 : return mType == eHTMLElement;
9764 : }
9765 :
9766 : inline OwningNonNull<nsGenericHTMLElement>&
9767 0 : GetAsHTMLElement()
9768 : {
9769 0 : MOZ_ASSERT(IsHTMLElement(), "Wrong type!");
9770 0 : return mValue.mHTMLElement.Value();
9771 : }
9772 :
9773 : inline OwningNonNull<nsGenericHTMLElement> const &
9774 0 : GetAsHTMLElement() const
9775 : {
9776 0 : MOZ_ASSERT(IsHTMLElement(), "Wrong type!");
9777 0 : return mValue.mHTMLElement.Value();
9778 : }
9779 :
9780 : int32_t&
9781 : RawSetAsLong();
9782 :
9783 : int32_t&
9784 : SetAsLong();
9785 :
9786 : bool
9787 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9788 :
9789 : inline bool
9790 0 : IsLong() const
9791 : {
9792 0 : return mType == eLong;
9793 : }
9794 :
9795 : inline int32_t&
9796 : GetAsLong()
9797 : {
9798 : MOZ_ASSERT(IsLong(), "Wrong type!");
9799 : return mValue.mLong.Value();
9800 : }
9801 :
9802 : inline int32_t const &
9803 0 : GetAsLong() const
9804 : {
9805 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
9806 0 : return mValue.mLong.Value();
9807 : }
9808 :
9809 : void
9810 : Uninit();
9811 :
9812 : bool
9813 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9814 :
9815 : void
9816 : TraceUnion(JSTracer* trc);
9817 :
9818 : OwningHTMLElementOrLong&
9819 : operator=(const OwningHTMLElementOrLong& aOther);
9820 :
9821 : private:
9822 : void
9823 : DestroyHTMLElement();
9824 :
9825 : void
9826 : DestroyLong();
9827 : };
9828 :
9829 : class OwningHTMLOptionElementOrHTMLOptGroupElement : public AllOwningUnionBase
9830 : {
9831 : friend void ImplCycleCollectionUnlink(OwningHTMLOptionElementOrHTMLOptGroupElement& aUnion);
9832 : enum Type
9833 : {
9834 : eUninitialized,
9835 : eHTMLOptionElement,
9836 : eHTMLOptGroupElement
9837 : };
9838 :
9839 : union Value
9840 : {
9841 : UnionMember<OwningNonNull<mozilla::dom::HTMLOptionElement> > mHTMLOptionElement;
9842 : UnionMember<OwningNonNull<mozilla::dom::HTMLOptGroupElement> > mHTMLOptGroupElement;
9843 :
9844 : };
9845 :
9846 : Type mType;
9847 : Value mValue;
9848 :
9849 : public:
9850 : explicit inline OwningHTMLOptionElementOrHTMLOptGroupElement()
9851 : : mType(eUninitialized)
9852 : {
9853 : }
9854 :
9855 : explicit inline OwningHTMLOptionElementOrHTMLOptGroupElement(const OwningHTMLOptionElementOrHTMLOptGroupElement& aOther)
9856 : : mType(eUninitialized)
9857 : {
9858 : *this = aOther;
9859 : }
9860 :
9861 : inline ~OwningHTMLOptionElementOrHTMLOptGroupElement()
9862 : {
9863 : Uninit();
9864 : }
9865 :
9866 : OwningNonNull<mozilla::dom::HTMLOptionElement>&
9867 : RawSetAsHTMLOptionElement();
9868 :
9869 : OwningNonNull<mozilla::dom::HTMLOptionElement>&
9870 : SetAsHTMLOptionElement();
9871 :
9872 : bool
9873 : TrySetToHTMLOptionElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9874 :
9875 : inline bool
9876 0 : IsHTMLOptionElement() const
9877 : {
9878 0 : return mType == eHTMLOptionElement;
9879 : }
9880 :
9881 : inline OwningNonNull<mozilla::dom::HTMLOptionElement>&
9882 0 : GetAsHTMLOptionElement()
9883 : {
9884 0 : MOZ_ASSERT(IsHTMLOptionElement(), "Wrong type!");
9885 0 : return mValue.mHTMLOptionElement.Value();
9886 : }
9887 :
9888 : inline OwningNonNull<mozilla::dom::HTMLOptionElement> const &
9889 0 : GetAsHTMLOptionElement() const
9890 : {
9891 0 : MOZ_ASSERT(IsHTMLOptionElement(), "Wrong type!");
9892 0 : return mValue.mHTMLOptionElement.Value();
9893 : }
9894 :
9895 : OwningNonNull<mozilla::dom::HTMLOptGroupElement>&
9896 : RawSetAsHTMLOptGroupElement();
9897 :
9898 : OwningNonNull<mozilla::dom::HTMLOptGroupElement>&
9899 : SetAsHTMLOptGroupElement();
9900 :
9901 : bool
9902 : TrySetToHTMLOptGroupElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9903 :
9904 : inline bool
9905 0 : IsHTMLOptGroupElement() const
9906 : {
9907 0 : return mType == eHTMLOptGroupElement;
9908 : }
9909 :
9910 : inline OwningNonNull<mozilla::dom::HTMLOptGroupElement>&
9911 0 : GetAsHTMLOptGroupElement()
9912 : {
9913 0 : MOZ_ASSERT(IsHTMLOptGroupElement(), "Wrong type!");
9914 0 : return mValue.mHTMLOptGroupElement.Value();
9915 : }
9916 :
9917 : inline OwningNonNull<mozilla::dom::HTMLOptGroupElement> const &
9918 0 : GetAsHTMLOptGroupElement() const
9919 : {
9920 0 : MOZ_ASSERT(IsHTMLOptGroupElement(), "Wrong type!");
9921 0 : return mValue.mHTMLOptGroupElement.Value();
9922 : }
9923 :
9924 : void
9925 : Uninit();
9926 :
9927 : bool
9928 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
9929 :
9930 : void
9931 : TraceUnion(JSTracer* trc);
9932 :
9933 : OwningHTMLOptionElementOrHTMLOptGroupElement&
9934 : operator=(const OwningHTMLOptionElementOrHTMLOptGroupElement& aOther);
9935 :
9936 : private:
9937 : void
9938 : DestroyHTMLOptionElement();
9939 :
9940 : void
9941 : DestroyHTMLOptGroupElement();
9942 : };
9943 :
9944 : class OwningImageDataOrNullSequenceOrLong : public AllOwningUnionBase
9945 : {
9946 : friend void ImplCycleCollectionUnlink(OwningImageDataOrNullSequenceOrLong& aUnion);
9947 : enum Type
9948 : {
9949 : eUninitialized,
9950 : eImageDataOrNullSequence,
9951 : eLong
9952 : };
9953 :
9954 : union Value
9955 : {
9956 : UnionMember<Sequence<RefPtr<mozilla::dom::ImageData>> > mImageDataOrNullSequence;
9957 : UnionMember<int32_t > mLong;
9958 :
9959 : };
9960 :
9961 : Type mType;
9962 : Value mValue;
9963 :
9964 : public:
9965 : explicit inline OwningImageDataOrNullSequenceOrLong()
9966 : : mType(eUninitialized)
9967 : {
9968 : }
9969 :
9970 : explicit inline OwningImageDataOrNullSequenceOrLong(const OwningImageDataOrNullSequenceOrLong& aOther)
9971 : : mType(eUninitialized)
9972 : {
9973 : *this = aOther;
9974 : }
9975 :
9976 : inline ~OwningImageDataOrNullSequenceOrLong()
9977 : {
9978 : Uninit();
9979 : }
9980 :
9981 : Sequence<RefPtr<mozilla::dom::ImageData>>&
9982 : RawSetAsImageDataOrNullSequence();
9983 :
9984 : Sequence<RefPtr<mozilla::dom::ImageData>>&
9985 : SetAsImageDataOrNullSequence();
9986 :
9987 : bool
9988 : TrySetToImageDataOrNullSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
9989 :
9990 : inline bool
9991 0 : IsImageDataOrNullSequence() const
9992 : {
9993 0 : return mType == eImageDataOrNullSequence;
9994 : }
9995 :
9996 : inline Sequence<RefPtr<mozilla::dom::ImageData>>&
9997 0 : GetAsImageDataOrNullSequence()
9998 : {
9999 0 : MOZ_ASSERT(IsImageDataOrNullSequence(), "Wrong type!");
10000 0 : return mValue.mImageDataOrNullSequence.Value();
10001 : }
10002 :
10003 : inline Sequence<RefPtr<mozilla::dom::ImageData>> const &
10004 0 : GetAsImageDataOrNullSequence() const
10005 : {
10006 0 : MOZ_ASSERT(IsImageDataOrNullSequence(), "Wrong type!");
10007 0 : return mValue.mImageDataOrNullSequence.Value();
10008 : }
10009 :
10010 : int32_t&
10011 : RawSetAsLong();
10012 :
10013 : int32_t&
10014 : SetAsLong();
10015 :
10016 : bool
10017 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10018 :
10019 : inline bool
10020 0 : IsLong() const
10021 : {
10022 0 : return mType == eLong;
10023 : }
10024 :
10025 : inline int32_t&
10026 : GetAsLong()
10027 : {
10028 : MOZ_ASSERT(IsLong(), "Wrong type!");
10029 : return mValue.mLong.Value();
10030 : }
10031 :
10032 : inline int32_t const &
10033 0 : GetAsLong() const
10034 : {
10035 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10036 0 : return mValue.mLong.Value();
10037 : }
10038 :
10039 : void
10040 : Uninit();
10041 :
10042 : bool
10043 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10044 :
10045 : void
10046 : TraceUnion(JSTracer* trc);
10047 :
10048 : OwningImageDataOrNullSequenceOrLong&
10049 : operator=(const OwningImageDataOrNullSequenceOrLong& aOther);
10050 :
10051 : private:
10052 : void
10053 : DestroyImageDataOrNullSequence();
10054 :
10055 : void
10056 : DestroyLong();
10057 : };
10058 :
10059 : class OwningImageDataOrNullSequenceSequenceOrLong : public AllOwningUnionBase
10060 : {
10061 : friend void ImplCycleCollectionUnlink(OwningImageDataOrNullSequenceSequenceOrLong& aUnion);
10062 : enum Type
10063 : {
10064 : eUninitialized,
10065 : eImageDataOrNullSequenceSequence,
10066 : eLong
10067 : };
10068 :
10069 : union Value
10070 : {
10071 : UnionMember<Sequence<Sequence<RefPtr<mozilla::dom::ImageData>>> > mImageDataOrNullSequenceSequence;
10072 : UnionMember<int32_t > mLong;
10073 :
10074 : };
10075 :
10076 : Type mType;
10077 : Value mValue;
10078 :
10079 : public:
10080 : explicit inline OwningImageDataOrNullSequenceSequenceOrLong()
10081 : : mType(eUninitialized)
10082 : {
10083 : }
10084 :
10085 : explicit inline OwningImageDataOrNullSequenceSequenceOrLong(const OwningImageDataOrNullSequenceSequenceOrLong& aOther)
10086 : : mType(eUninitialized)
10087 : {
10088 : *this = aOther;
10089 : }
10090 :
10091 : inline ~OwningImageDataOrNullSequenceSequenceOrLong()
10092 : {
10093 : Uninit();
10094 : }
10095 :
10096 : Sequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
10097 : RawSetAsImageDataOrNullSequenceSequence();
10098 :
10099 : Sequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
10100 : SetAsImageDataOrNullSequenceSequence();
10101 :
10102 : bool
10103 : TrySetToImageDataOrNullSequenceSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10104 :
10105 : inline bool
10106 0 : IsImageDataOrNullSequenceSequence() const
10107 : {
10108 0 : return mType == eImageDataOrNullSequenceSequence;
10109 : }
10110 :
10111 : inline Sequence<Sequence<RefPtr<mozilla::dom::ImageData>>>&
10112 0 : GetAsImageDataOrNullSequenceSequence()
10113 : {
10114 0 : MOZ_ASSERT(IsImageDataOrNullSequenceSequence(), "Wrong type!");
10115 0 : return mValue.mImageDataOrNullSequenceSequence.Value();
10116 : }
10117 :
10118 : inline Sequence<Sequence<RefPtr<mozilla::dom::ImageData>>> const &
10119 0 : GetAsImageDataOrNullSequenceSequence() const
10120 : {
10121 0 : MOZ_ASSERT(IsImageDataOrNullSequenceSequence(), "Wrong type!");
10122 0 : return mValue.mImageDataOrNullSequenceSequence.Value();
10123 : }
10124 :
10125 : int32_t&
10126 : RawSetAsLong();
10127 :
10128 : int32_t&
10129 : SetAsLong();
10130 :
10131 : bool
10132 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10133 :
10134 : inline bool
10135 0 : IsLong() const
10136 : {
10137 0 : return mType == eLong;
10138 : }
10139 :
10140 : inline int32_t&
10141 : GetAsLong()
10142 : {
10143 : MOZ_ASSERT(IsLong(), "Wrong type!");
10144 : return mValue.mLong.Value();
10145 : }
10146 :
10147 : inline int32_t const &
10148 0 : GetAsLong() const
10149 : {
10150 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10151 0 : return mValue.mLong.Value();
10152 : }
10153 :
10154 : void
10155 : Uninit();
10156 :
10157 : bool
10158 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10159 :
10160 : void
10161 : TraceUnion(JSTracer* trc);
10162 :
10163 : OwningImageDataOrNullSequenceSequenceOrLong&
10164 : operator=(const OwningImageDataOrNullSequenceSequenceOrLong& aOther);
10165 :
10166 : private:
10167 : void
10168 : DestroyImageDataOrNullSequenceSequence();
10169 :
10170 : void
10171 : DestroyLong();
10172 : };
10173 :
10174 : class OwningImageDataSequenceOrLong : public AllOwningUnionBase
10175 : {
10176 : friend void ImplCycleCollectionUnlink(OwningImageDataSequenceOrLong& aUnion);
10177 : enum Type
10178 : {
10179 : eUninitialized,
10180 : eImageDataSequence,
10181 : eLong
10182 : };
10183 :
10184 : union Value
10185 : {
10186 : UnionMember<Sequence<OwningNonNull<mozilla::dom::ImageData>> > mImageDataSequence;
10187 : UnionMember<int32_t > mLong;
10188 :
10189 : };
10190 :
10191 : Type mType;
10192 : Value mValue;
10193 :
10194 : public:
10195 : explicit inline OwningImageDataSequenceOrLong()
10196 : : mType(eUninitialized)
10197 : {
10198 : }
10199 :
10200 : explicit inline OwningImageDataSequenceOrLong(const OwningImageDataSequenceOrLong& aOther)
10201 : : mType(eUninitialized)
10202 : {
10203 : *this = aOther;
10204 : }
10205 :
10206 : inline ~OwningImageDataSequenceOrLong()
10207 : {
10208 : Uninit();
10209 : }
10210 :
10211 : Sequence<OwningNonNull<mozilla::dom::ImageData>>&
10212 : RawSetAsImageDataSequence();
10213 :
10214 : Sequence<OwningNonNull<mozilla::dom::ImageData>>&
10215 : SetAsImageDataSequence();
10216 :
10217 : bool
10218 : TrySetToImageDataSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10219 :
10220 : inline bool
10221 0 : IsImageDataSequence() const
10222 : {
10223 0 : return mType == eImageDataSequence;
10224 : }
10225 :
10226 : inline Sequence<OwningNonNull<mozilla::dom::ImageData>>&
10227 0 : GetAsImageDataSequence()
10228 : {
10229 0 : MOZ_ASSERT(IsImageDataSequence(), "Wrong type!");
10230 0 : return mValue.mImageDataSequence.Value();
10231 : }
10232 :
10233 : inline Sequence<OwningNonNull<mozilla::dom::ImageData>> const &
10234 0 : GetAsImageDataSequence() const
10235 : {
10236 0 : MOZ_ASSERT(IsImageDataSequence(), "Wrong type!");
10237 0 : return mValue.mImageDataSequence.Value();
10238 : }
10239 :
10240 : int32_t&
10241 : RawSetAsLong();
10242 :
10243 : int32_t&
10244 : SetAsLong();
10245 :
10246 : bool
10247 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10248 :
10249 : inline bool
10250 0 : IsLong() const
10251 : {
10252 0 : return mType == eLong;
10253 : }
10254 :
10255 : inline int32_t&
10256 : GetAsLong()
10257 : {
10258 : MOZ_ASSERT(IsLong(), "Wrong type!");
10259 : return mValue.mLong.Value();
10260 : }
10261 :
10262 : inline int32_t const &
10263 0 : GetAsLong() const
10264 : {
10265 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10266 0 : return mValue.mLong.Value();
10267 : }
10268 :
10269 : void
10270 : Uninit();
10271 :
10272 : bool
10273 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10274 :
10275 : void
10276 : TraceUnion(JSTracer* trc);
10277 :
10278 : OwningImageDataSequenceOrLong&
10279 : operator=(const OwningImageDataSequenceOrLong& aOther);
10280 :
10281 : private:
10282 : void
10283 : DestroyImageDataSequence();
10284 :
10285 : void
10286 : DestroyLong();
10287 : };
10288 :
10289 : class OwningImageDataSequenceSequenceOrLong : public AllOwningUnionBase
10290 : {
10291 : friend void ImplCycleCollectionUnlink(OwningImageDataSequenceSequenceOrLong& aUnion);
10292 : enum Type
10293 : {
10294 : eUninitialized,
10295 : eImageDataSequenceSequence,
10296 : eLong
10297 : };
10298 :
10299 : union Value
10300 : {
10301 : UnionMember<Sequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>> > mImageDataSequenceSequence;
10302 : UnionMember<int32_t > mLong;
10303 :
10304 : };
10305 :
10306 : Type mType;
10307 : Value mValue;
10308 :
10309 : public:
10310 : explicit inline OwningImageDataSequenceSequenceOrLong()
10311 : : mType(eUninitialized)
10312 : {
10313 : }
10314 :
10315 : explicit inline OwningImageDataSequenceSequenceOrLong(const OwningImageDataSequenceSequenceOrLong& aOther)
10316 : : mType(eUninitialized)
10317 : {
10318 : *this = aOther;
10319 : }
10320 :
10321 : inline ~OwningImageDataSequenceSequenceOrLong()
10322 : {
10323 : Uninit();
10324 : }
10325 :
10326 : Sequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
10327 : RawSetAsImageDataSequenceSequence();
10328 :
10329 : Sequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
10330 : SetAsImageDataSequenceSequence();
10331 :
10332 : bool
10333 : TrySetToImageDataSequenceSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10334 :
10335 : inline bool
10336 0 : IsImageDataSequenceSequence() const
10337 : {
10338 0 : return mType == eImageDataSequenceSequence;
10339 : }
10340 :
10341 : inline Sequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>>&
10342 0 : GetAsImageDataSequenceSequence()
10343 : {
10344 0 : MOZ_ASSERT(IsImageDataSequenceSequence(), "Wrong type!");
10345 0 : return mValue.mImageDataSequenceSequence.Value();
10346 : }
10347 :
10348 : inline Sequence<Sequence<OwningNonNull<mozilla::dom::ImageData>>> const &
10349 0 : GetAsImageDataSequenceSequence() const
10350 : {
10351 0 : MOZ_ASSERT(IsImageDataSequenceSequence(), "Wrong type!");
10352 0 : return mValue.mImageDataSequenceSequence.Value();
10353 : }
10354 :
10355 : int32_t&
10356 : RawSetAsLong();
10357 :
10358 : int32_t&
10359 : SetAsLong();
10360 :
10361 : bool
10362 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10363 :
10364 : inline bool
10365 0 : IsLong() const
10366 : {
10367 0 : return mType == eLong;
10368 : }
10369 :
10370 : inline int32_t&
10371 : GetAsLong()
10372 : {
10373 : MOZ_ASSERT(IsLong(), "Wrong type!");
10374 : return mValue.mLong.Value();
10375 : }
10376 :
10377 : inline int32_t const &
10378 0 : GetAsLong() const
10379 : {
10380 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10381 0 : return mValue.mLong.Value();
10382 : }
10383 :
10384 : void
10385 : Uninit();
10386 :
10387 : bool
10388 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10389 :
10390 : void
10391 : TraceUnion(JSTracer* trc);
10392 :
10393 : OwningImageDataSequenceSequenceOrLong&
10394 : operator=(const OwningImageDataSequenceSequenceOrLong& aOther);
10395 :
10396 : private:
10397 : void
10398 : DestroyImageDataSequenceSequence();
10399 :
10400 : void
10401 : DestroyLong();
10402 : };
10403 :
10404 : class OwningLongOrBoolean : public AllOwningUnionBase
10405 : {
10406 : friend void ImplCycleCollectionUnlink(OwningLongOrBoolean& aUnion);
10407 : enum Type
10408 : {
10409 : eUninitialized,
10410 : eLong,
10411 : eBoolean
10412 : };
10413 :
10414 : union Value
10415 : {
10416 : UnionMember<int32_t > mLong;
10417 : UnionMember<bool > mBoolean;
10418 :
10419 : };
10420 :
10421 : Type mType;
10422 : Value mValue;
10423 :
10424 : public:
10425 : explicit inline OwningLongOrBoolean()
10426 : : mType(eUninitialized)
10427 : {
10428 : }
10429 :
10430 : explicit inline OwningLongOrBoolean(const OwningLongOrBoolean& aOther)
10431 : : mType(eUninitialized)
10432 : {
10433 : *this = aOther;
10434 : }
10435 :
10436 : inline ~OwningLongOrBoolean()
10437 : {
10438 : Uninit();
10439 : }
10440 :
10441 : int32_t&
10442 : RawSetAsLong();
10443 :
10444 : int32_t&
10445 : SetAsLong();
10446 :
10447 : bool
10448 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10449 :
10450 : inline bool
10451 0 : IsLong() const
10452 : {
10453 0 : return mType == eLong;
10454 : }
10455 :
10456 : inline int32_t&
10457 : GetAsLong()
10458 : {
10459 : MOZ_ASSERT(IsLong(), "Wrong type!");
10460 : return mValue.mLong.Value();
10461 : }
10462 :
10463 : inline int32_t const &
10464 0 : GetAsLong() const
10465 : {
10466 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10467 0 : return mValue.mLong.Value();
10468 : }
10469 :
10470 : bool&
10471 : RawSetAsBoolean();
10472 :
10473 : bool&
10474 : SetAsBoolean();
10475 :
10476 : bool
10477 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10478 :
10479 : inline bool
10480 0 : IsBoolean() const
10481 : {
10482 0 : return mType == eBoolean;
10483 : }
10484 :
10485 : inline bool&
10486 : GetAsBoolean()
10487 : {
10488 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
10489 : return mValue.mBoolean.Value();
10490 : }
10491 :
10492 : inline bool const &
10493 0 : GetAsBoolean() const
10494 : {
10495 0 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
10496 0 : return mValue.mBoolean.Value();
10497 : }
10498 :
10499 : void
10500 : Uninit();
10501 :
10502 : bool
10503 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10504 :
10505 : void
10506 : TraceUnion(JSTracer* trc);
10507 :
10508 : OwningLongOrBoolean&
10509 : operator=(const OwningLongOrBoolean& aOther);
10510 :
10511 : private:
10512 : void
10513 : DestroyLong();
10514 :
10515 : void
10516 : DestroyBoolean();
10517 : };
10518 :
10519 : class OwningLongOrStringAnyRecord : public AllOwningUnionBase
10520 : {
10521 : friend void ImplCycleCollectionUnlink(OwningLongOrStringAnyRecord& aUnion);
10522 : enum Type
10523 : {
10524 : eUninitialized,
10525 : eLong,
10526 : eStringAnyRecord
10527 : };
10528 :
10529 : union Value
10530 : {
10531 : UnionMember<int32_t > mLong;
10532 : UnionMember<Record<nsString, JS::Value> > mStringAnyRecord;
10533 :
10534 : };
10535 :
10536 : Type mType;
10537 : Value mValue;
10538 :
10539 : OwningLongOrStringAnyRecord(const OwningLongOrStringAnyRecord&) = delete;
10540 : OwningLongOrStringAnyRecord& operator=(const OwningLongOrStringAnyRecord&) = delete;
10541 : public:
10542 : explicit inline OwningLongOrStringAnyRecord()
10543 : : mType(eUninitialized)
10544 : {
10545 : }
10546 :
10547 : inline ~OwningLongOrStringAnyRecord()
10548 : {
10549 : Uninit();
10550 : }
10551 :
10552 : int32_t&
10553 : RawSetAsLong();
10554 :
10555 : int32_t&
10556 : SetAsLong();
10557 :
10558 : bool
10559 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10560 :
10561 : inline bool
10562 0 : IsLong() const
10563 : {
10564 0 : return mType == eLong;
10565 : }
10566 :
10567 : inline int32_t&
10568 : GetAsLong()
10569 : {
10570 : MOZ_ASSERT(IsLong(), "Wrong type!");
10571 : return mValue.mLong.Value();
10572 : }
10573 :
10574 : inline int32_t const &
10575 : GetAsLong() const
10576 : {
10577 : MOZ_ASSERT(IsLong(), "Wrong type!");
10578 : return mValue.mLong.Value();
10579 : }
10580 :
10581 : Record<nsString, JS::Value>&
10582 : RawSetAsStringAnyRecord();
10583 :
10584 : Record<nsString, JS::Value>&
10585 : SetAsStringAnyRecord();
10586 :
10587 : bool
10588 : TrySetToStringAnyRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10589 :
10590 : inline bool
10591 0 : IsStringAnyRecord() const
10592 : {
10593 0 : return mType == eStringAnyRecord;
10594 : }
10595 :
10596 : inline Record<nsString, JS::Value>&
10597 : GetAsStringAnyRecord()
10598 : {
10599 : MOZ_ASSERT(IsStringAnyRecord(), "Wrong type!");
10600 : return mValue.mStringAnyRecord.Value();
10601 : }
10602 :
10603 : inline Record<nsString, JS::Value> const &
10604 : GetAsStringAnyRecord() const
10605 : {
10606 : MOZ_ASSERT(IsStringAnyRecord(), "Wrong type!");
10607 : return mValue.mStringAnyRecord.Value();
10608 : }
10609 :
10610 : void
10611 : Uninit();
10612 :
10613 : bool
10614 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10615 :
10616 : void
10617 : TraceUnion(JSTracer* trc);
10618 :
10619 : private:
10620 : void
10621 : DestroyLong();
10622 :
10623 : void
10624 : DestroyStringAnyRecord();
10625 : };
10626 :
10627 : class OwningLongSequenceOrLong : public AllOwningUnionBase
10628 : {
10629 : friend void ImplCycleCollectionUnlink(OwningLongSequenceOrLong& aUnion);
10630 : enum Type
10631 : {
10632 : eUninitialized,
10633 : eLongSequence,
10634 : eLong
10635 : };
10636 :
10637 : union Value
10638 : {
10639 : UnionMember<Sequence<int32_t> > mLongSequence;
10640 : UnionMember<int32_t > mLong;
10641 :
10642 : };
10643 :
10644 : Type mType;
10645 : Value mValue;
10646 :
10647 : public:
10648 : explicit inline OwningLongSequenceOrLong()
10649 : : mType(eUninitialized)
10650 : {
10651 : }
10652 :
10653 : explicit inline OwningLongSequenceOrLong(const OwningLongSequenceOrLong& aOther)
10654 : : mType(eUninitialized)
10655 : {
10656 : *this = aOther;
10657 : }
10658 :
10659 : inline ~OwningLongSequenceOrLong()
10660 : {
10661 : Uninit();
10662 : }
10663 :
10664 : Sequence<int32_t>&
10665 : RawSetAsLongSequence();
10666 :
10667 : Sequence<int32_t>&
10668 : SetAsLongSequence();
10669 :
10670 : bool
10671 : TrySetToLongSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10672 :
10673 : inline bool
10674 0 : IsLongSequence() const
10675 : {
10676 0 : return mType == eLongSequence;
10677 : }
10678 :
10679 : inline Sequence<int32_t>&
10680 : GetAsLongSequence()
10681 : {
10682 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
10683 : return mValue.mLongSequence.Value();
10684 : }
10685 :
10686 : inline Sequence<int32_t> const &
10687 0 : GetAsLongSequence() const
10688 : {
10689 0 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
10690 0 : return mValue.mLongSequence.Value();
10691 : }
10692 :
10693 : int32_t&
10694 : RawSetAsLong();
10695 :
10696 : int32_t&
10697 : SetAsLong();
10698 :
10699 : bool
10700 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10701 :
10702 : inline bool
10703 0 : IsLong() const
10704 : {
10705 0 : return mType == eLong;
10706 : }
10707 :
10708 : inline int32_t&
10709 : GetAsLong()
10710 : {
10711 : MOZ_ASSERT(IsLong(), "Wrong type!");
10712 : return mValue.mLong.Value();
10713 : }
10714 :
10715 : inline int32_t const &
10716 0 : GetAsLong() const
10717 : {
10718 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10719 0 : return mValue.mLong.Value();
10720 : }
10721 :
10722 : void
10723 : Uninit();
10724 :
10725 : bool
10726 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10727 :
10728 : void
10729 : TraceUnion(JSTracer* trc);
10730 :
10731 : OwningLongSequenceOrLong&
10732 : operator=(const OwningLongSequenceOrLong& aOther);
10733 :
10734 : private:
10735 : void
10736 : DestroyLongSequence();
10737 :
10738 : void
10739 : DestroyLong();
10740 : };
10741 :
10742 : class OwningLongSequenceOrNullOrLong : public AllOwningUnionBase
10743 : {
10744 : friend void ImplCycleCollectionUnlink(OwningLongSequenceOrNullOrLong& aUnion);
10745 : enum Type
10746 : {
10747 : eUninitialized,
10748 : eNull,
10749 : eLongSequence,
10750 : eLong
10751 : };
10752 :
10753 : union Value
10754 : {
10755 : UnionMember<Sequence<int32_t> > mLongSequence;
10756 : UnionMember<int32_t > mLong;
10757 :
10758 : };
10759 :
10760 : Type mType;
10761 : Value mValue;
10762 :
10763 : public:
10764 : explicit inline OwningLongSequenceOrNullOrLong()
10765 : : mType(eUninitialized)
10766 : {
10767 : }
10768 :
10769 : explicit inline OwningLongSequenceOrNullOrLong(const OwningLongSequenceOrNullOrLong& aOther)
10770 : : mType(eUninitialized)
10771 : {
10772 : *this = aOther;
10773 : }
10774 :
10775 : inline ~OwningLongSequenceOrNullOrLong()
10776 : {
10777 : Uninit();
10778 : }
10779 :
10780 : inline bool
10781 : IsNull() const
10782 : {
10783 : return mType == eNull;
10784 : }
10785 :
10786 : inline void
10787 : SetNull()
10788 : {
10789 : Uninit();
10790 : mType = eNull;
10791 : }
10792 :
10793 : Sequence<int32_t>&
10794 : RawSetAsLongSequence();
10795 :
10796 : Sequence<int32_t>&
10797 : SetAsLongSequence();
10798 :
10799 : bool
10800 : TrySetToLongSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10801 :
10802 : inline bool
10803 0 : IsLongSequence() const
10804 : {
10805 0 : return mType == eLongSequence;
10806 : }
10807 :
10808 : inline Sequence<int32_t>&
10809 : GetAsLongSequence()
10810 : {
10811 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
10812 : return mValue.mLongSequence.Value();
10813 : }
10814 :
10815 : inline Sequence<int32_t> const &
10816 0 : GetAsLongSequence() const
10817 : {
10818 0 : MOZ_ASSERT(IsLongSequence(), "Wrong type!");
10819 0 : return mValue.mLongSequence.Value();
10820 : }
10821 :
10822 : int32_t&
10823 : RawSetAsLong();
10824 :
10825 : int32_t&
10826 : SetAsLong();
10827 :
10828 : bool
10829 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10830 :
10831 : inline bool
10832 0 : IsLong() const
10833 : {
10834 0 : return mType == eLong;
10835 : }
10836 :
10837 : inline int32_t&
10838 : GetAsLong()
10839 : {
10840 : MOZ_ASSERT(IsLong(), "Wrong type!");
10841 : return mValue.mLong.Value();
10842 : }
10843 :
10844 : inline int32_t const &
10845 0 : GetAsLong() const
10846 : {
10847 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10848 0 : return mValue.mLong.Value();
10849 : }
10850 :
10851 : void
10852 : Uninit();
10853 :
10854 : bool
10855 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
10856 :
10857 : void
10858 : TraceUnion(JSTracer* trc);
10859 :
10860 : OwningLongSequenceOrNullOrLong&
10861 : operator=(const OwningLongSequenceOrNullOrLong& aOther);
10862 :
10863 : private:
10864 : void
10865 : DestroyLongSequence();
10866 :
10867 : void
10868 : DestroyLong();
10869 : };
10870 :
10871 : class OwningNodeOrLongOrBoolean : public AllOwningUnionBase
10872 : {
10873 : friend void ImplCycleCollectionUnlink(OwningNodeOrLongOrBoolean& aUnion);
10874 : enum Type
10875 : {
10876 : eUninitialized,
10877 : eNode,
10878 : eLong,
10879 : eBoolean
10880 : };
10881 :
10882 : union Value
10883 : {
10884 : UnionMember<OwningNonNull<nsINode> > mNode;
10885 : UnionMember<int32_t > mLong;
10886 : UnionMember<bool > mBoolean;
10887 :
10888 : };
10889 :
10890 : Type mType;
10891 : Value mValue;
10892 :
10893 : public:
10894 : explicit inline OwningNodeOrLongOrBoolean()
10895 : : mType(eUninitialized)
10896 : {
10897 : }
10898 :
10899 : explicit inline OwningNodeOrLongOrBoolean(const OwningNodeOrLongOrBoolean& aOther)
10900 : : mType(eUninitialized)
10901 : {
10902 : *this = aOther;
10903 : }
10904 :
10905 : inline ~OwningNodeOrLongOrBoolean()
10906 : {
10907 : Uninit();
10908 : }
10909 :
10910 : OwningNonNull<nsINode>&
10911 : RawSetAsNode();
10912 :
10913 : OwningNonNull<nsINode>&
10914 : SetAsNode();
10915 :
10916 : bool
10917 : TrySetToNode(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10918 :
10919 : inline bool
10920 0 : IsNode() const
10921 : {
10922 0 : return mType == eNode;
10923 : }
10924 :
10925 : inline OwningNonNull<nsINode>&
10926 0 : GetAsNode()
10927 : {
10928 0 : MOZ_ASSERT(IsNode(), "Wrong type!");
10929 0 : return mValue.mNode.Value();
10930 : }
10931 :
10932 : inline OwningNonNull<nsINode> const &
10933 0 : GetAsNode() const
10934 : {
10935 0 : MOZ_ASSERT(IsNode(), "Wrong type!");
10936 0 : return mValue.mNode.Value();
10937 : }
10938 :
10939 : int32_t&
10940 : RawSetAsLong();
10941 :
10942 : int32_t&
10943 : SetAsLong();
10944 :
10945 : bool
10946 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10947 :
10948 : inline bool
10949 0 : IsLong() const
10950 : {
10951 0 : return mType == eLong;
10952 : }
10953 :
10954 : inline int32_t&
10955 : GetAsLong()
10956 : {
10957 : MOZ_ASSERT(IsLong(), "Wrong type!");
10958 : return mValue.mLong.Value();
10959 : }
10960 :
10961 : inline int32_t const &
10962 0 : GetAsLong() const
10963 : {
10964 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
10965 0 : return mValue.mLong.Value();
10966 : }
10967 :
10968 : bool&
10969 : RawSetAsBoolean();
10970 :
10971 : bool&
10972 : SetAsBoolean();
10973 :
10974 : bool
10975 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
10976 :
10977 : inline bool
10978 0 : IsBoolean() const
10979 : {
10980 0 : return mType == eBoolean;
10981 : }
10982 :
10983 : inline bool&
10984 : GetAsBoolean()
10985 : {
10986 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
10987 : return mValue.mBoolean.Value();
10988 : }
10989 :
10990 : inline bool const &
10991 0 : GetAsBoolean() const
10992 : {
10993 0 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
10994 0 : return mValue.mBoolean.Value();
10995 : }
10996 :
10997 : void
10998 : Uninit();
10999 :
11000 : bool
11001 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11002 :
11003 : void
11004 : TraceUnion(JSTracer* trc);
11005 :
11006 : OwningNodeOrLongOrBoolean&
11007 : operator=(const OwningNodeOrLongOrBoolean& aOther);
11008 :
11009 : private:
11010 : void
11011 : DestroyNode();
11012 :
11013 : void
11014 : DestroyLong();
11015 :
11016 : void
11017 : DestroyBoolean();
11018 : };
11019 :
11020 : class OwningNodeOrString : public AllOwningUnionBase
11021 : {
11022 : friend void ImplCycleCollectionUnlink(OwningNodeOrString& aUnion);
11023 : enum Type
11024 : {
11025 : eUninitialized,
11026 : eNode,
11027 : eString
11028 : };
11029 :
11030 0 : union Value
11031 : {
11032 : UnionMember<OwningNonNull<nsINode> > mNode;
11033 : UnionMember<nsString > mString;
11034 :
11035 : };
11036 :
11037 : Type mType;
11038 : Value mValue;
11039 :
11040 : public:
11041 0 : explicit inline OwningNodeOrString()
11042 0 : : mType(eUninitialized)
11043 : {
11044 0 : }
11045 :
11046 : explicit inline OwningNodeOrString(const OwningNodeOrString& aOther)
11047 : : mType(eUninitialized)
11048 : {
11049 : *this = aOther;
11050 : }
11051 :
11052 0 : inline ~OwningNodeOrString()
11053 0 : {
11054 0 : Uninit();
11055 0 : }
11056 :
11057 : OwningNonNull<nsINode>&
11058 : RawSetAsNode();
11059 :
11060 : OwningNonNull<nsINode>&
11061 : SetAsNode();
11062 :
11063 : bool
11064 : TrySetToNode(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11065 :
11066 : inline bool
11067 0 : IsNode() const
11068 : {
11069 0 : return mType == eNode;
11070 : }
11071 :
11072 : inline OwningNonNull<nsINode>&
11073 0 : GetAsNode()
11074 : {
11075 0 : MOZ_ASSERT(IsNode(), "Wrong type!");
11076 0 : return mValue.mNode.Value();
11077 : }
11078 :
11079 : inline OwningNonNull<nsINode> const &
11080 0 : GetAsNode() const
11081 : {
11082 0 : MOZ_ASSERT(IsNode(), "Wrong type!");
11083 0 : return mValue.mNode.Value();
11084 : }
11085 :
11086 : nsString&
11087 : RawSetAsString();
11088 :
11089 : nsString&
11090 : SetAsString();
11091 :
11092 : bool
11093 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11094 :
11095 : inline void
11096 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
11097 : {
11098 : RawSetAsString().Assign(aData, aLength);
11099 : }
11100 :
11101 : inline bool
11102 0 : IsString() const
11103 : {
11104 0 : return mType == eString;
11105 : }
11106 :
11107 : inline nsString&
11108 : GetAsString()
11109 : {
11110 : MOZ_ASSERT(IsString(), "Wrong type!");
11111 : return mValue.mString.Value();
11112 : }
11113 :
11114 : inline nsString const &
11115 0 : GetAsString() const
11116 : {
11117 0 : MOZ_ASSERT(IsString(), "Wrong type!");
11118 0 : return mValue.mString.Value();
11119 : }
11120 :
11121 : void
11122 : Uninit();
11123 :
11124 : bool
11125 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11126 :
11127 : void
11128 : TraceUnion(JSTracer* trc);
11129 :
11130 : OwningNodeOrString&
11131 : operator=(const OwningNodeOrString& aOther);
11132 :
11133 : private:
11134 : void
11135 : DestroyNode();
11136 :
11137 : void
11138 : DestroyString();
11139 : };
11140 :
11141 : class OwningObjectOrBoolean : public AllOwningUnionBase
11142 : {
11143 : friend void ImplCycleCollectionUnlink(OwningObjectOrBoolean& aUnion);
11144 : enum Type
11145 : {
11146 : eUninitialized,
11147 : eObject,
11148 : eBoolean
11149 : };
11150 :
11151 : union Value
11152 : {
11153 : UnionMember<JSObject* > mObject;
11154 : UnionMember<bool > mBoolean;
11155 :
11156 : };
11157 :
11158 : Type mType;
11159 : Value mValue;
11160 :
11161 : OwningObjectOrBoolean(const OwningObjectOrBoolean&) = delete;
11162 : OwningObjectOrBoolean& operator=(const OwningObjectOrBoolean&) = delete;
11163 : public:
11164 : explicit inline OwningObjectOrBoolean()
11165 : : mType(eUninitialized)
11166 : {
11167 : }
11168 :
11169 : inline ~OwningObjectOrBoolean()
11170 : {
11171 : Uninit();
11172 : }
11173 :
11174 : JSObject*&
11175 : RawSetAsObject();
11176 :
11177 : JSObject*&
11178 : SetAsObject();
11179 :
11180 : inline bool
11181 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11182 : {
11183 : MOZ_ASSERT(mType == eUninitialized);
11184 : mValue.mObject.SetValue(obj);
11185 : mType = eObject;
11186 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11187 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11188 : return false;
11189 : }
11190 : return true;
11191 : }
11192 :
11193 : inline bool
11194 0 : IsObject() const
11195 : {
11196 0 : return mType == eObject;
11197 : }
11198 :
11199 : inline JSObject*&
11200 : GetAsObject()
11201 : {
11202 : MOZ_ASSERT(IsObject(), "Wrong type!");
11203 : return mValue.mObject.Value();
11204 : }
11205 :
11206 : inline JSObject* const &
11207 : GetAsObject() const
11208 : {
11209 : MOZ_ASSERT(IsObject(), "Wrong type!");
11210 : return mValue.mObject.Value();
11211 : }
11212 :
11213 : bool&
11214 : RawSetAsBoolean();
11215 :
11216 : bool&
11217 : SetAsBoolean();
11218 :
11219 : bool
11220 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11221 :
11222 : inline bool
11223 0 : IsBoolean() const
11224 : {
11225 0 : return mType == eBoolean;
11226 : }
11227 :
11228 : inline bool&
11229 : GetAsBoolean()
11230 : {
11231 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
11232 : return mValue.mBoolean.Value();
11233 : }
11234 :
11235 : inline bool const &
11236 : GetAsBoolean() const
11237 : {
11238 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
11239 : return mValue.mBoolean.Value();
11240 : }
11241 :
11242 : void
11243 : Uninit();
11244 :
11245 : bool
11246 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11247 :
11248 : void
11249 : TraceUnion(JSTracer* trc);
11250 :
11251 : private:
11252 : void
11253 : DestroyObject();
11254 :
11255 : void
11256 : DestroyBoolean();
11257 : };
11258 :
11259 : class OwningObjectOrLong : public AllOwningUnionBase
11260 : {
11261 : friend void ImplCycleCollectionUnlink(OwningObjectOrLong& aUnion);
11262 : enum Type
11263 : {
11264 : eUninitialized,
11265 : eObject,
11266 : eLong
11267 : };
11268 :
11269 : union Value
11270 : {
11271 : UnionMember<JSObject* > mObject;
11272 : UnionMember<int32_t > mLong;
11273 :
11274 : };
11275 :
11276 : Type mType;
11277 : Value mValue;
11278 :
11279 : OwningObjectOrLong(const OwningObjectOrLong&) = delete;
11280 : OwningObjectOrLong& operator=(const OwningObjectOrLong&) = delete;
11281 : public:
11282 : explicit inline OwningObjectOrLong()
11283 : : mType(eUninitialized)
11284 : {
11285 : }
11286 :
11287 : inline ~OwningObjectOrLong()
11288 : {
11289 : Uninit();
11290 : }
11291 :
11292 : JSObject*&
11293 : RawSetAsObject();
11294 :
11295 : JSObject*&
11296 : SetAsObject();
11297 :
11298 : inline bool
11299 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11300 : {
11301 : MOZ_ASSERT(mType == eUninitialized);
11302 : mValue.mObject.SetValue(obj);
11303 : mType = eObject;
11304 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11305 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11306 : return false;
11307 : }
11308 : return true;
11309 : }
11310 :
11311 : inline bool
11312 0 : IsObject() const
11313 : {
11314 0 : return mType == eObject;
11315 : }
11316 :
11317 : inline JSObject*&
11318 : GetAsObject()
11319 : {
11320 : MOZ_ASSERT(IsObject(), "Wrong type!");
11321 : return mValue.mObject.Value();
11322 : }
11323 :
11324 : inline JSObject* const &
11325 : GetAsObject() const
11326 : {
11327 : MOZ_ASSERT(IsObject(), "Wrong type!");
11328 : return mValue.mObject.Value();
11329 : }
11330 :
11331 : int32_t&
11332 : RawSetAsLong();
11333 :
11334 : int32_t&
11335 : SetAsLong();
11336 :
11337 : bool
11338 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11339 :
11340 : inline bool
11341 0 : IsLong() const
11342 : {
11343 0 : return mType == eLong;
11344 : }
11345 :
11346 : inline int32_t&
11347 : GetAsLong()
11348 : {
11349 : MOZ_ASSERT(IsLong(), "Wrong type!");
11350 : return mValue.mLong.Value();
11351 : }
11352 :
11353 : inline int32_t const &
11354 : GetAsLong() const
11355 : {
11356 : MOZ_ASSERT(IsLong(), "Wrong type!");
11357 : return mValue.mLong.Value();
11358 : }
11359 :
11360 : void
11361 : Uninit();
11362 :
11363 : bool
11364 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11365 :
11366 : void
11367 : TraceUnion(JSTracer* trc);
11368 :
11369 : private:
11370 : void
11371 : DestroyObject();
11372 :
11373 : void
11374 : DestroyLong();
11375 : };
11376 :
11377 : class OwningObjectOrLongOrBoolean : public AllOwningUnionBase
11378 : {
11379 : friend void ImplCycleCollectionUnlink(OwningObjectOrLongOrBoolean& aUnion);
11380 : enum Type
11381 : {
11382 : eUninitialized,
11383 : eObject,
11384 : eLong,
11385 : eBoolean
11386 : };
11387 :
11388 : union Value
11389 : {
11390 : UnionMember<JSObject* > mObject;
11391 : UnionMember<int32_t > mLong;
11392 : UnionMember<bool > mBoolean;
11393 :
11394 : };
11395 :
11396 : Type mType;
11397 : Value mValue;
11398 :
11399 : OwningObjectOrLongOrBoolean(const OwningObjectOrLongOrBoolean&) = delete;
11400 : OwningObjectOrLongOrBoolean& operator=(const OwningObjectOrLongOrBoolean&) = delete;
11401 : public:
11402 : explicit inline OwningObjectOrLongOrBoolean()
11403 : : mType(eUninitialized)
11404 : {
11405 : }
11406 :
11407 : inline ~OwningObjectOrLongOrBoolean()
11408 : {
11409 : Uninit();
11410 : }
11411 :
11412 : JSObject*&
11413 : RawSetAsObject();
11414 :
11415 : JSObject*&
11416 : SetAsObject();
11417 :
11418 : inline bool
11419 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11420 : {
11421 : MOZ_ASSERT(mType == eUninitialized);
11422 : mValue.mObject.SetValue(obj);
11423 : mType = eObject;
11424 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11425 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11426 : return false;
11427 : }
11428 : return true;
11429 : }
11430 :
11431 : inline bool
11432 0 : IsObject() const
11433 : {
11434 0 : return mType == eObject;
11435 : }
11436 :
11437 : inline JSObject*&
11438 : GetAsObject()
11439 : {
11440 : MOZ_ASSERT(IsObject(), "Wrong type!");
11441 : return mValue.mObject.Value();
11442 : }
11443 :
11444 : inline JSObject* const &
11445 : GetAsObject() const
11446 : {
11447 : MOZ_ASSERT(IsObject(), "Wrong type!");
11448 : return mValue.mObject.Value();
11449 : }
11450 :
11451 : int32_t&
11452 : RawSetAsLong();
11453 :
11454 : int32_t&
11455 : SetAsLong();
11456 :
11457 : bool
11458 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11459 :
11460 : inline bool
11461 0 : IsLong() const
11462 : {
11463 0 : return mType == eLong;
11464 : }
11465 :
11466 : inline int32_t&
11467 : GetAsLong()
11468 : {
11469 : MOZ_ASSERT(IsLong(), "Wrong type!");
11470 : return mValue.mLong.Value();
11471 : }
11472 :
11473 : inline int32_t const &
11474 : GetAsLong() const
11475 : {
11476 : MOZ_ASSERT(IsLong(), "Wrong type!");
11477 : return mValue.mLong.Value();
11478 : }
11479 :
11480 : bool&
11481 : RawSetAsBoolean();
11482 :
11483 : bool&
11484 : SetAsBoolean();
11485 :
11486 : bool
11487 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11488 :
11489 : inline bool
11490 0 : IsBoolean() const
11491 : {
11492 0 : return mType == eBoolean;
11493 : }
11494 :
11495 : inline bool&
11496 : GetAsBoolean()
11497 : {
11498 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
11499 : return mValue.mBoolean.Value();
11500 : }
11501 :
11502 : inline bool const &
11503 : GetAsBoolean() const
11504 : {
11505 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
11506 : return mValue.mBoolean.Value();
11507 : }
11508 :
11509 : void
11510 : Uninit();
11511 :
11512 : bool
11513 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11514 :
11515 : void
11516 : TraceUnion(JSTracer* trc);
11517 :
11518 : private:
11519 : void
11520 : DestroyObject();
11521 :
11522 : void
11523 : DestroyLong();
11524 :
11525 : void
11526 : DestroyBoolean();
11527 : };
11528 :
11529 : class OwningObjectOrLongOrNull : public AllOwningUnionBase
11530 : {
11531 : friend void ImplCycleCollectionUnlink(OwningObjectOrLongOrNull& aUnion);
11532 : enum Type
11533 : {
11534 : eUninitialized,
11535 : eNull,
11536 : eObject,
11537 : eLong
11538 : };
11539 :
11540 : union Value
11541 : {
11542 : UnionMember<JSObject* > mObject;
11543 : UnionMember<int32_t > mLong;
11544 :
11545 : };
11546 :
11547 : Type mType;
11548 : Value mValue;
11549 :
11550 : OwningObjectOrLongOrNull(const OwningObjectOrLongOrNull&) = delete;
11551 : OwningObjectOrLongOrNull& operator=(const OwningObjectOrLongOrNull&) = delete;
11552 : public:
11553 : explicit inline OwningObjectOrLongOrNull()
11554 : : mType(eUninitialized)
11555 : {
11556 : }
11557 :
11558 : inline ~OwningObjectOrLongOrNull()
11559 : {
11560 : Uninit();
11561 : }
11562 :
11563 : inline bool
11564 : IsNull() const
11565 : {
11566 : return mType == eNull;
11567 : }
11568 :
11569 : inline void
11570 : SetNull()
11571 : {
11572 : Uninit();
11573 : mType = eNull;
11574 : }
11575 :
11576 : JSObject*&
11577 : RawSetAsObject();
11578 :
11579 : JSObject*&
11580 : SetAsObject();
11581 :
11582 : inline bool
11583 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11584 : {
11585 : MOZ_ASSERT(mType == eUninitialized);
11586 : mValue.mObject.SetValue(obj);
11587 : mType = eObject;
11588 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11589 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11590 : return false;
11591 : }
11592 : return true;
11593 : }
11594 :
11595 : inline bool
11596 0 : IsObject() const
11597 : {
11598 0 : return mType == eObject;
11599 : }
11600 :
11601 : inline JSObject*&
11602 : GetAsObject()
11603 : {
11604 : MOZ_ASSERT(IsObject(), "Wrong type!");
11605 : return mValue.mObject.Value();
11606 : }
11607 :
11608 : inline JSObject* const &
11609 : GetAsObject() const
11610 : {
11611 : MOZ_ASSERT(IsObject(), "Wrong type!");
11612 : return mValue.mObject.Value();
11613 : }
11614 :
11615 : int32_t&
11616 : RawSetAsLong();
11617 :
11618 : int32_t&
11619 : SetAsLong();
11620 :
11621 : bool
11622 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11623 :
11624 : inline bool
11625 0 : IsLong() const
11626 : {
11627 0 : return mType == eLong;
11628 : }
11629 :
11630 : inline int32_t&
11631 : GetAsLong()
11632 : {
11633 : MOZ_ASSERT(IsLong(), "Wrong type!");
11634 : return mValue.mLong.Value();
11635 : }
11636 :
11637 : inline int32_t const &
11638 : GetAsLong() const
11639 : {
11640 : MOZ_ASSERT(IsLong(), "Wrong type!");
11641 : return mValue.mLong.Value();
11642 : }
11643 :
11644 : void
11645 : Uninit();
11646 :
11647 : bool
11648 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11649 :
11650 : void
11651 : TraceUnion(JSTracer* trc);
11652 :
11653 : private:
11654 : void
11655 : DestroyObject();
11656 :
11657 : void
11658 : DestroyLong();
11659 : };
11660 :
11661 : class OwningObjectOrNullOrLong : public AllOwningUnionBase
11662 : {
11663 : friend void ImplCycleCollectionUnlink(OwningObjectOrNullOrLong& aUnion);
11664 : enum Type
11665 : {
11666 : eUninitialized,
11667 : eNull,
11668 : eObject,
11669 : eLong
11670 : };
11671 :
11672 : union Value
11673 : {
11674 : UnionMember<JSObject* > mObject;
11675 : UnionMember<int32_t > mLong;
11676 :
11677 : };
11678 :
11679 : Type mType;
11680 : Value mValue;
11681 :
11682 : OwningObjectOrNullOrLong(const OwningObjectOrNullOrLong&) = delete;
11683 : OwningObjectOrNullOrLong& operator=(const OwningObjectOrNullOrLong&) = delete;
11684 : public:
11685 : explicit inline OwningObjectOrNullOrLong()
11686 : : mType(eUninitialized)
11687 : {
11688 : }
11689 :
11690 : inline ~OwningObjectOrNullOrLong()
11691 : {
11692 : Uninit();
11693 : }
11694 :
11695 : inline bool
11696 : IsNull() const
11697 : {
11698 : return mType == eNull;
11699 : }
11700 :
11701 : inline void
11702 : SetNull()
11703 : {
11704 : Uninit();
11705 : mType = eNull;
11706 : }
11707 :
11708 : JSObject*&
11709 : RawSetAsObject();
11710 :
11711 : JSObject*&
11712 : SetAsObject();
11713 :
11714 : inline bool
11715 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11716 : {
11717 : MOZ_ASSERT(mType == eUninitialized);
11718 : mValue.mObject.SetValue(obj);
11719 : mType = eObject;
11720 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11721 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11722 : return false;
11723 : }
11724 : return true;
11725 : }
11726 :
11727 : inline bool
11728 0 : IsObject() const
11729 : {
11730 0 : return mType == eObject;
11731 : }
11732 :
11733 : inline JSObject*&
11734 : GetAsObject()
11735 : {
11736 : MOZ_ASSERT(IsObject(), "Wrong type!");
11737 : return mValue.mObject.Value();
11738 : }
11739 :
11740 : inline JSObject* const &
11741 : GetAsObject() const
11742 : {
11743 : MOZ_ASSERT(IsObject(), "Wrong type!");
11744 : return mValue.mObject.Value();
11745 : }
11746 :
11747 : int32_t&
11748 : RawSetAsLong();
11749 :
11750 : int32_t&
11751 : SetAsLong();
11752 :
11753 : bool
11754 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11755 :
11756 : inline bool
11757 0 : IsLong() const
11758 : {
11759 0 : return mType == eLong;
11760 : }
11761 :
11762 : inline int32_t&
11763 : GetAsLong()
11764 : {
11765 : MOZ_ASSERT(IsLong(), "Wrong type!");
11766 : return mValue.mLong.Value();
11767 : }
11768 :
11769 : inline int32_t const &
11770 : GetAsLong() const
11771 : {
11772 : MOZ_ASSERT(IsLong(), "Wrong type!");
11773 : return mValue.mLong.Value();
11774 : }
11775 :
11776 : void
11777 : Uninit();
11778 :
11779 : bool
11780 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11781 :
11782 : void
11783 : TraceUnion(JSTracer* trc);
11784 :
11785 : private:
11786 : void
11787 : DestroyObject();
11788 :
11789 : void
11790 : DestroyLong();
11791 : };
11792 :
11793 : class OwningObjectOrString : public AllOwningUnionBase
11794 : {
11795 : friend void ImplCycleCollectionUnlink(OwningObjectOrString& aUnion);
11796 : enum Type
11797 : {
11798 : eUninitialized,
11799 : eObject,
11800 : eString
11801 : };
11802 :
11803 0 : union Value
11804 : {
11805 : UnionMember<JSObject* > mObject;
11806 : UnionMember<nsString > mString;
11807 :
11808 : };
11809 :
11810 : Type mType;
11811 : Value mValue;
11812 :
11813 : OwningObjectOrString(const OwningObjectOrString&) = delete;
11814 : OwningObjectOrString& operator=(const OwningObjectOrString&) = delete;
11815 : public:
11816 0 : explicit inline OwningObjectOrString()
11817 0 : : mType(eUninitialized)
11818 : {
11819 0 : }
11820 :
11821 0 : inline ~OwningObjectOrString()
11822 0 : {
11823 0 : Uninit();
11824 0 : }
11825 :
11826 : JSObject*&
11827 : RawSetAsObject();
11828 :
11829 : JSObject*&
11830 : SetAsObject();
11831 :
11832 : inline bool
11833 0 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11834 : {
11835 0 : MOZ_ASSERT(mType == eUninitialized);
11836 0 : mValue.mObject.SetValue(obj);
11837 0 : mType = eObject;
11838 0 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11839 0 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11840 0 : return false;
11841 : }
11842 0 : return true;
11843 : }
11844 :
11845 : inline bool
11846 0 : IsObject() const
11847 : {
11848 0 : return mType == eObject;
11849 : }
11850 :
11851 : inline JSObject*&
11852 0 : GetAsObject()
11853 : {
11854 0 : MOZ_ASSERT(IsObject(), "Wrong type!");
11855 0 : return mValue.mObject.Value();
11856 : }
11857 :
11858 : inline JSObject* const &
11859 0 : GetAsObject() const
11860 : {
11861 0 : MOZ_ASSERT(IsObject(), "Wrong type!");
11862 0 : return mValue.mObject.Value();
11863 : }
11864 :
11865 : nsString&
11866 : RawSetAsString();
11867 :
11868 : nsString&
11869 : SetAsString();
11870 :
11871 : bool
11872 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11873 :
11874 : inline void
11875 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
11876 : {
11877 : RawSetAsString().Assign(aData, aLength);
11878 : }
11879 :
11880 : inline bool
11881 0 : IsString() const
11882 : {
11883 0 : return mType == eString;
11884 : }
11885 :
11886 : inline nsString&
11887 : GetAsString()
11888 : {
11889 : MOZ_ASSERT(IsString(), "Wrong type!");
11890 : return mValue.mString.Value();
11891 : }
11892 :
11893 : inline nsString const &
11894 0 : GetAsString() const
11895 : {
11896 0 : MOZ_ASSERT(IsString(), "Wrong type!");
11897 0 : return mValue.mString.Value();
11898 : }
11899 :
11900 : void
11901 : Uninit();
11902 :
11903 : bool
11904 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
11905 :
11906 : void
11907 : TraceUnion(JSTracer* trc);
11908 :
11909 : private:
11910 : void
11911 : DestroyObject();
11912 :
11913 : void
11914 : DestroyString();
11915 : };
11916 :
11917 : class OwningObjectOrStringOrBoolean : public AllOwningUnionBase
11918 : {
11919 : friend void ImplCycleCollectionUnlink(OwningObjectOrStringOrBoolean& aUnion);
11920 : enum Type
11921 : {
11922 : eUninitialized,
11923 : eObject,
11924 : eString,
11925 : eBoolean
11926 : };
11927 :
11928 : union Value
11929 : {
11930 : UnionMember<JSObject* > mObject;
11931 : UnionMember<nsString > mString;
11932 : UnionMember<bool > mBoolean;
11933 :
11934 : };
11935 :
11936 : Type mType;
11937 : Value mValue;
11938 :
11939 : OwningObjectOrStringOrBoolean(const OwningObjectOrStringOrBoolean&) = delete;
11940 : OwningObjectOrStringOrBoolean& operator=(const OwningObjectOrStringOrBoolean&) = delete;
11941 : public:
11942 : explicit inline OwningObjectOrStringOrBoolean()
11943 : : mType(eUninitialized)
11944 : {
11945 : }
11946 :
11947 : inline ~OwningObjectOrStringOrBoolean()
11948 : {
11949 : Uninit();
11950 : }
11951 :
11952 : JSObject*&
11953 : RawSetAsObject();
11954 :
11955 : JSObject*&
11956 : SetAsObject();
11957 :
11958 : inline bool
11959 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
11960 : {
11961 : MOZ_ASSERT(mType == eUninitialized);
11962 : mValue.mObject.SetValue(obj);
11963 : mType = eObject;
11964 : if (passedToJSImpl && !CallerSubsumes(obj)) {
11965 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
11966 : return false;
11967 : }
11968 : return true;
11969 : }
11970 :
11971 : inline bool
11972 0 : IsObject() const
11973 : {
11974 0 : return mType == eObject;
11975 : }
11976 :
11977 : inline JSObject*&
11978 : GetAsObject()
11979 : {
11980 : MOZ_ASSERT(IsObject(), "Wrong type!");
11981 : return mValue.mObject.Value();
11982 : }
11983 :
11984 : inline JSObject* const &
11985 : GetAsObject() const
11986 : {
11987 : MOZ_ASSERT(IsObject(), "Wrong type!");
11988 : return mValue.mObject.Value();
11989 : }
11990 :
11991 : nsString&
11992 : RawSetAsString();
11993 :
11994 : nsString&
11995 : SetAsString();
11996 :
11997 : bool
11998 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
11999 :
12000 : inline void
12001 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
12002 : {
12003 : RawSetAsString().Assign(aData, aLength);
12004 : }
12005 :
12006 : inline bool
12007 0 : IsString() const
12008 : {
12009 0 : return mType == eString;
12010 : }
12011 :
12012 : inline nsString&
12013 : GetAsString()
12014 : {
12015 : MOZ_ASSERT(IsString(), "Wrong type!");
12016 : return mValue.mString.Value();
12017 : }
12018 :
12019 : inline nsString const &
12020 : GetAsString() const
12021 : {
12022 : MOZ_ASSERT(IsString(), "Wrong type!");
12023 : return mValue.mString.Value();
12024 : }
12025 :
12026 : bool&
12027 : RawSetAsBoolean();
12028 :
12029 : bool&
12030 : SetAsBoolean();
12031 :
12032 : bool
12033 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12034 :
12035 : inline bool
12036 0 : IsBoolean() const
12037 : {
12038 0 : return mType == eBoolean;
12039 : }
12040 :
12041 : inline bool&
12042 : GetAsBoolean()
12043 : {
12044 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
12045 : return mValue.mBoolean.Value();
12046 : }
12047 :
12048 : inline bool const &
12049 : GetAsBoolean() const
12050 : {
12051 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
12052 : return mValue.mBoolean.Value();
12053 : }
12054 :
12055 : void
12056 : Uninit();
12057 :
12058 : bool
12059 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12060 :
12061 : void
12062 : TraceUnion(JSTracer* trc);
12063 :
12064 : private:
12065 : void
12066 : DestroyObject();
12067 :
12068 : void
12069 : DestroyString();
12070 :
12071 : void
12072 : DestroyBoolean();
12073 : };
12074 :
12075 : class OwningObjectOrStringOrLong : public AllOwningUnionBase
12076 : {
12077 : friend void ImplCycleCollectionUnlink(OwningObjectOrStringOrLong& aUnion);
12078 : enum Type
12079 : {
12080 : eUninitialized,
12081 : eObject,
12082 : eString,
12083 : eLong
12084 : };
12085 :
12086 : union Value
12087 : {
12088 : UnionMember<JSObject* > mObject;
12089 : UnionMember<nsString > mString;
12090 : UnionMember<int32_t > mLong;
12091 :
12092 : };
12093 :
12094 : Type mType;
12095 : Value mValue;
12096 :
12097 : OwningObjectOrStringOrLong(const OwningObjectOrStringOrLong&) = delete;
12098 : OwningObjectOrStringOrLong& operator=(const OwningObjectOrStringOrLong&) = delete;
12099 : public:
12100 : explicit inline OwningObjectOrStringOrLong()
12101 : : mType(eUninitialized)
12102 : {
12103 : }
12104 :
12105 : inline ~OwningObjectOrStringOrLong()
12106 : {
12107 : Uninit();
12108 : }
12109 :
12110 : JSObject*&
12111 : RawSetAsObject();
12112 :
12113 : JSObject*&
12114 : SetAsObject();
12115 :
12116 : inline bool
12117 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
12118 : {
12119 : MOZ_ASSERT(mType == eUninitialized);
12120 : mValue.mObject.SetValue(obj);
12121 : mType = eObject;
12122 : if (passedToJSImpl && !CallerSubsumes(obj)) {
12123 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
12124 : return false;
12125 : }
12126 : return true;
12127 : }
12128 :
12129 : inline bool
12130 0 : IsObject() const
12131 : {
12132 0 : return mType == eObject;
12133 : }
12134 :
12135 : inline JSObject*&
12136 : GetAsObject()
12137 : {
12138 : MOZ_ASSERT(IsObject(), "Wrong type!");
12139 : return mValue.mObject.Value();
12140 : }
12141 :
12142 : inline JSObject* const &
12143 : GetAsObject() const
12144 : {
12145 : MOZ_ASSERT(IsObject(), "Wrong type!");
12146 : return mValue.mObject.Value();
12147 : }
12148 :
12149 : nsString&
12150 : RawSetAsString();
12151 :
12152 : nsString&
12153 : SetAsString();
12154 :
12155 : bool
12156 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12157 :
12158 : inline void
12159 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
12160 : {
12161 : RawSetAsString().Assign(aData, aLength);
12162 : }
12163 :
12164 : inline bool
12165 0 : IsString() const
12166 : {
12167 0 : return mType == eString;
12168 : }
12169 :
12170 : inline nsString&
12171 : GetAsString()
12172 : {
12173 : MOZ_ASSERT(IsString(), "Wrong type!");
12174 : return mValue.mString.Value();
12175 : }
12176 :
12177 : inline nsString const &
12178 : GetAsString() const
12179 : {
12180 : MOZ_ASSERT(IsString(), "Wrong type!");
12181 : return mValue.mString.Value();
12182 : }
12183 :
12184 : int32_t&
12185 : RawSetAsLong();
12186 :
12187 : int32_t&
12188 : SetAsLong();
12189 :
12190 : bool
12191 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12192 :
12193 : inline bool
12194 0 : IsLong() const
12195 : {
12196 0 : return mType == eLong;
12197 : }
12198 :
12199 : inline int32_t&
12200 : GetAsLong()
12201 : {
12202 : MOZ_ASSERT(IsLong(), "Wrong type!");
12203 : return mValue.mLong.Value();
12204 : }
12205 :
12206 : inline int32_t const &
12207 : GetAsLong() const
12208 : {
12209 : MOZ_ASSERT(IsLong(), "Wrong type!");
12210 : return mValue.mLong.Value();
12211 : }
12212 :
12213 : void
12214 : Uninit();
12215 :
12216 : bool
12217 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12218 :
12219 : void
12220 : TraceUnion(JSTracer* trc);
12221 :
12222 : private:
12223 : void
12224 : DestroyObject();
12225 :
12226 : void
12227 : DestroyString();
12228 :
12229 : void
12230 : DestroyLong();
12231 : };
12232 :
12233 : class OwningObjectOrStringOrLongOrBoolean : public AllOwningUnionBase
12234 : {
12235 : friend void ImplCycleCollectionUnlink(OwningObjectOrStringOrLongOrBoolean& aUnion);
12236 : enum Type
12237 : {
12238 : eUninitialized,
12239 : eObject,
12240 : eString,
12241 : eLong,
12242 : eBoolean
12243 : };
12244 :
12245 : union Value
12246 : {
12247 : UnionMember<JSObject* > mObject;
12248 : UnionMember<nsString > mString;
12249 : UnionMember<int32_t > mLong;
12250 : UnionMember<bool > mBoolean;
12251 :
12252 : };
12253 :
12254 : Type mType;
12255 : Value mValue;
12256 :
12257 : OwningObjectOrStringOrLongOrBoolean(const OwningObjectOrStringOrLongOrBoolean&) = delete;
12258 : OwningObjectOrStringOrLongOrBoolean& operator=(const OwningObjectOrStringOrLongOrBoolean&) = delete;
12259 : public:
12260 : explicit inline OwningObjectOrStringOrLongOrBoolean()
12261 : : mType(eUninitialized)
12262 : {
12263 : }
12264 :
12265 : inline ~OwningObjectOrStringOrLongOrBoolean()
12266 : {
12267 : Uninit();
12268 : }
12269 :
12270 : JSObject*&
12271 : RawSetAsObject();
12272 :
12273 : JSObject*&
12274 : SetAsObject();
12275 :
12276 : inline bool
12277 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
12278 : {
12279 : MOZ_ASSERT(mType == eUninitialized);
12280 : mValue.mObject.SetValue(obj);
12281 : mType = eObject;
12282 : if (passedToJSImpl && !CallerSubsumes(obj)) {
12283 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
12284 : return false;
12285 : }
12286 : return true;
12287 : }
12288 :
12289 : inline bool
12290 0 : IsObject() const
12291 : {
12292 0 : return mType == eObject;
12293 : }
12294 :
12295 : inline JSObject*&
12296 : GetAsObject()
12297 : {
12298 : MOZ_ASSERT(IsObject(), "Wrong type!");
12299 : return mValue.mObject.Value();
12300 : }
12301 :
12302 : inline JSObject* const &
12303 : GetAsObject() const
12304 : {
12305 : MOZ_ASSERT(IsObject(), "Wrong type!");
12306 : return mValue.mObject.Value();
12307 : }
12308 :
12309 : nsString&
12310 : RawSetAsString();
12311 :
12312 : nsString&
12313 : SetAsString();
12314 :
12315 : bool
12316 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12317 :
12318 : inline void
12319 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
12320 : {
12321 : RawSetAsString().Assign(aData, aLength);
12322 : }
12323 :
12324 : inline bool
12325 0 : IsString() const
12326 : {
12327 0 : return mType == eString;
12328 : }
12329 :
12330 : inline nsString&
12331 : GetAsString()
12332 : {
12333 : MOZ_ASSERT(IsString(), "Wrong type!");
12334 : return mValue.mString.Value();
12335 : }
12336 :
12337 : inline nsString const &
12338 : GetAsString() const
12339 : {
12340 : MOZ_ASSERT(IsString(), "Wrong type!");
12341 : return mValue.mString.Value();
12342 : }
12343 :
12344 : int32_t&
12345 : RawSetAsLong();
12346 :
12347 : int32_t&
12348 : SetAsLong();
12349 :
12350 : bool
12351 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12352 :
12353 : inline bool
12354 0 : IsLong() const
12355 : {
12356 0 : return mType == eLong;
12357 : }
12358 :
12359 : inline int32_t&
12360 : GetAsLong()
12361 : {
12362 : MOZ_ASSERT(IsLong(), "Wrong type!");
12363 : return mValue.mLong.Value();
12364 : }
12365 :
12366 : inline int32_t const &
12367 : GetAsLong() const
12368 : {
12369 : MOZ_ASSERT(IsLong(), "Wrong type!");
12370 : return mValue.mLong.Value();
12371 : }
12372 :
12373 : bool&
12374 : RawSetAsBoolean();
12375 :
12376 : bool&
12377 : SetAsBoolean();
12378 :
12379 : bool
12380 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12381 :
12382 : inline bool
12383 0 : IsBoolean() const
12384 : {
12385 0 : return mType == eBoolean;
12386 : }
12387 :
12388 : inline bool&
12389 : GetAsBoolean()
12390 : {
12391 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
12392 : return mValue.mBoolean.Value();
12393 : }
12394 :
12395 : inline bool const &
12396 : GetAsBoolean() const
12397 : {
12398 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
12399 : return mValue.mBoolean.Value();
12400 : }
12401 :
12402 : void
12403 : Uninit();
12404 :
12405 : bool
12406 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12407 :
12408 : void
12409 : TraceUnion(JSTracer* trc);
12410 :
12411 : private:
12412 : void
12413 : DestroyObject();
12414 :
12415 : void
12416 : DestroyString();
12417 :
12418 : void
12419 : DestroyLong();
12420 :
12421 : void
12422 : DestroyBoolean();
12423 : };
12424 :
12425 : class OwningObjectSequenceOrLong : public AllOwningUnionBase
12426 : {
12427 : friend void ImplCycleCollectionUnlink(OwningObjectSequenceOrLong& aUnion);
12428 : enum Type
12429 : {
12430 : eUninitialized,
12431 : eObjectSequence,
12432 : eLong
12433 : };
12434 :
12435 : union Value
12436 : {
12437 : UnionMember<Sequence<JSObject*> > mObjectSequence;
12438 : UnionMember<int32_t > mLong;
12439 :
12440 : };
12441 :
12442 : Type mType;
12443 : Value mValue;
12444 :
12445 : OwningObjectSequenceOrLong(const OwningObjectSequenceOrLong&) = delete;
12446 : OwningObjectSequenceOrLong& operator=(const OwningObjectSequenceOrLong&) = delete;
12447 : public:
12448 : explicit inline OwningObjectSequenceOrLong()
12449 : : mType(eUninitialized)
12450 : {
12451 : }
12452 :
12453 : inline ~OwningObjectSequenceOrLong()
12454 : {
12455 : Uninit();
12456 : }
12457 :
12458 : Sequence<JSObject*>&
12459 : RawSetAsObjectSequence();
12460 :
12461 : Sequence<JSObject*>&
12462 : SetAsObjectSequence();
12463 :
12464 : bool
12465 : TrySetToObjectSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12466 :
12467 : inline bool
12468 0 : IsObjectSequence() const
12469 : {
12470 0 : return mType == eObjectSequence;
12471 : }
12472 :
12473 : inline Sequence<JSObject*>&
12474 : GetAsObjectSequence()
12475 : {
12476 : MOZ_ASSERT(IsObjectSequence(), "Wrong type!");
12477 : return mValue.mObjectSequence.Value();
12478 : }
12479 :
12480 : inline Sequence<JSObject*> const &
12481 : GetAsObjectSequence() const
12482 : {
12483 : MOZ_ASSERT(IsObjectSequence(), "Wrong type!");
12484 : return mValue.mObjectSequence.Value();
12485 : }
12486 :
12487 : int32_t&
12488 : RawSetAsLong();
12489 :
12490 : int32_t&
12491 : SetAsLong();
12492 :
12493 : bool
12494 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12495 :
12496 : inline bool
12497 0 : IsLong() const
12498 : {
12499 0 : return mType == eLong;
12500 : }
12501 :
12502 : inline int32_t&
12503 : GetAsLong()
12504 : {
12505 : MOZ_ASSERT(IsLong(), "Wrong type!");
12506 : return mValue.mLong.Value();
12507 : }
12508 :
12509 : inline int32_t const &
12510 : GetAsLong() const
12511 : {
12512 : MOZ_ASSERT(IsLong(), "Wrong type!");
12513 : return mValue.mLong.Value();
12514 : }
12515 :
12516 : void
12517 : Uninit();
12518 :
12519 : bool
12520 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12521 :
12522 : void
12523 : TraceUnion(JSTracer* trc);
12524 :
12525 : private:
12526 : void
12527 : DestroyObjectSequence();
12528 :
12529 : void
12530 : DestroyLong();
12531 : };
12532 :
12533 : class OwningStringLongRecordOrLong : public AllOwningUnionBase
12534 : {
12535 : friend void ImplCycleCollectionUnlink(OwningStringLongRecordOrLong& aUnion);
12536 : enum Type
12537 : {
12538 : eUninitialized,
12539 : eStringLongRecord,
12540 : eLong
12541 : };
12542 :
12543 : union Value
12544 : {
12545 : UnionMember<Record<nsString, int32_t> > mStringLongRecord;
12546 : UnionMember<int32_t > mLong;
12547 :
12548 : };
12549 :
12550 : Type mType;
12551 : Value mValue;
12552 :
12553 : OwningStringLongRecordOrLong(const OwningStringLongRecordOrLong&) = delete;
12554 : OwningStringLongRecordOrLong& operator=(const OwningStringLongRecordOrLong&) = delete;
12555 : public:
12556 : explicit inline OwningStringLongRecordOrLong()
12557 : : mType(eUninitialized)
12558 : {
12559 : }
12560 :
12561 : inline ~OwningStringLongRecordOrLong()
12562 : {
12563 : Uninit();
12564 : }
12565 :
12566 : Record<nsString, int32_t>&
12567 : RawSetAsStringLongRecord();
12568 :
12569 : Record<nsString, int32_t>&
12570 : SetAsStringLongRecord();
12571 :
12572 : bool
12573 : TrySetToStringLongRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12574 :
12575 : inline bool
12576 0 : IsStringLongRecord() const
12577 : {
12578 0 : return mType == eStringLongRecord;
12579 : }
12580 :
12581 : inline Record<nsString, int32_t>&
12582 : GetAsStringLongRecord()
12583 : {
12584 : MOZ_ASSERT(IsStringLongRecord(), "Wrong type!");
12585 : return mValue.mStringLongRecord.Value();
12586 : }
12587 :
12588 : inline Record<nsString, int32_t> const &
12589 : GetAsStringLongRecord() const
12590 : {
12591 : MOZ_ASSERT(IsStringLongRecord(), "Wrong type!");
12592 : return mValue.mStringLongRecord.Value();
12593 : }
12594 :
12595 : int32_t&
12596 : RawSetAsLong();
12597 :
12598 : int32_t&
12599 : SetAsLong();
12600 :
12601 : bool
12602 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12603 :
12604 : inline bool
12605 0 : IsLong() const
12606 : {
12607 0 : return mType == eLong;
12608 : }
12609 :
12610 : inline int32_t&
12611 : GetAsLong()
12612 : {
12613 : MOZ_ASSERT(IsLong(), "Wrong type!");
12614 : return mValue.mLong.Value();
12615 : }
12616 :
12617 : inline int32_t const &
12618 : GetAsLong() const
12619 : {
12620 : MOZ_ASSERT(IsLong(), "Wrong type!");
12621 : return mValue.mLong.Value();
12622 : }
12623 :
12624 : void
12625 : Uninit();
12626 :
12627 : bool
12628 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12629 :
12630 : void
12631 : TraceUnion(JSTracer* trc);
12632 :
12633 : private:
12634 : void
12635 : DestroyStringLongRecord();
12636 :
12637 : void
12638 : DestroyLong();
12639 : };
12640 :
12641 : class OwningStringObjectRecordOrLong : public AllOwningUnionBase
12642 : {
12643 : friend void ImplCycleCollectionUnlink(OwningStringObjectRecordOrLong& aUnion);
12644 : enum Type
12645 : {
12646 : eUninitialized,
12647 : eStringObjectRecord,
12648 : eLong
12649 : };
12650 :
12651 : union Value
12652 : {
12653 : UnionMember<Record<nsString, JSObject*> > mStringObjectRecord;
12654 : UnionMember<int32_t > mLong;
12655 :
12656 : };
12657 :
12658 : Type mType;
12659 : Value mValue;
12660 :
12661 : OwningStringObjectRecordOrLong(const OwningStringObjectRecordOrLong&) = delete;
12662 : OwningStringObjectRecordOrLong& operator=(const OwningStringObjectRecordOrLong&) = delete;
12663 : public:
12664 : explicit inline OwningStringObjectRecordOrLong()
12665 : : mType(eUninitialized)
12666 : {
12667 : }
12668 :
12669 : inline ~OwningStringObjectRecordOrLong()
12670 : {
12671 : Uninit();
12672 : }
12673 :
12674 : Record<nsString, JSObject*>&
12675 : RawSetAsStringObjectRecord();
12676 :
12677 : Record<nsString, JSObject*>&
12678 : SetAsStringObjectRecord();
12679 :
12680 : bool
12681 : TrySetToStringObjectRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12682 :
12683 : inline bool
12684 0 : IsStringObjectRecord() const
12685 : {
12686 0 : return mType == eStringObjectRecord;
12687 : }
12688 :
12689 : inline Record<nsString, JSObject*>&
12690 : GetAsStringObjectRecord()
12691 : {
12692 : MOZ_ASSERT(IsStringObjectRecord(), "Wrong type!");
12693 : return mValue.mStringObjectRecord.Value();
12694 : }
12695 :
12696 : inline Record<nsString, JSObject*> const &
12697 : GetAsStringObjectRecord() const
12698 : {
12699 : MOZ_ASSERT(IsStringObjectRecord(), "Wrong type!");
12700 : return mValue.mStringObjectRecord.Value();
12701 : }
12702 :
12703 : int32_t&
12704 : RawSetAsLong();
12705 :
12706 : int32_t&
12707 : SetAsLong();
12708 :
12709 : bool
12710 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12711 :
12712 : inline bool
12713 0 : IsLong() const
12714 : {
12715 0 : return mType == eLong;
12716 : }
12717 :
12718 : inline int32_t&
12719 : GetAsLong()
12720 : {
12721 : MOZ_ASSERT(IsLong(), "Wrong type!");
12722 : return mValue.mLong.Value();
12723 : }
12724 :
12725 : inline int32_t const &
12726 : GetAsLong() const
12727 : {
12728 : MOZ_ASSERT(IsLong(), "Wrong type!");
12729 : return mValue.mLong.Value();
12730 : }
12731 :
12732 : void
12733 : Uninit();
12734 :
12735 : bool
12736 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12737 :
12738 : void
12739 : TraceUnion(JSTracer* trc);
12740 :
12741 : private:
12742 : void
12743 : DestroyStringObjectRecord();
12744 :
12745 : void
12746 : DestroyLong();
12747 : };
12748 :
12749 : class OwningStringOrObject : public AllOwningUnionBase
12750 : {
12751 : friend void ImplCycleCollectionUnlink(OwningStringOrObject& aUnion);
12752 : enum Type
12753 : {
12754 : eUninitialized,
12755 : eString,
12756 : eObject
12757 : };
12758 :
12759 : union Value
12760 : {
12761 : UnionMember<nsString > mString;
12762 : UnionMember<JSObject* > mObject;
12763 :
12764 : };
12765 :
12766 : Type mType;
12767 : Value mValue;
12768 :
12769 : OwningStringOrObject(const OwningStringOrObject&) = delete;
12770 : OwningStringOrObject& operator=(const OwningStringOrObject&) = delete;
12771 : public:
12772 : explicit inline OwningStringOrObject()
12773 : : mType(eUninitialized)
12774 : {
12775 : }
12776 :
12777 : inline ~OwningStringOrObject()
12778 : {
12779 : Uninit();
12780 : }
12781 :
12782 : nsString&
12783 : RawSetAsString();
12784 :
12785 : nsString&
12786 : SetAsString();
12787 :
12788 : bool
12789 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12790 :
12791 : inline void
12792 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
12793 : {
12794 : RawSetAsString().Assign(aData, aLength);
12795 : }
12796 :
12797 : inline bool
12798 0 : IsString() const
12799 : {
12800 0 : return mType == eString;
12801 : }
12802 :
12803 : inline nsString&
12804 : GetAsString()
12805 : {
12806 : MOZ_ASSERT(IsString(), "Wrong type!");
12807 : return mValue.mString.Value();
12808 : }
12809 :
12810 : inline nsString const &
12811 : GetAsString() const
12812 : {
12813 : MOZ_ASSERT(IsString(), "Wrong type!");
12814 : return mValue.mString.Value();
12815 : }
12816 :
12817 : JSObject*&
12818 : RawSetAsObject();
12819 :
12820 : JSObject*&
12821 : SetAsObject();
12822 :
12823 : inline bool
12824 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
12825 : {
12826 : MOZ_ASSERT(mType == eUninitialized);
12827 : mValue.mObject.SetValue(obj);
12828 : mType = eObject;
12829 : if (passedToJSImpl && !CallerSubsumes(obj)) {
12830 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
12831 : return false;
12832 : }
12833 : return true;
12834 : }
12835 :
12836 : inline bool
12837 0 : IsObject() const
12838 : {
12839 0 : return mType == eObject;
12840 : }
12841 :
12842 : inline JSObject*&
12843 : GetAsObject()
12844 : {
12845 : MOZ_ASSERT(IsObject(), "Wrong type!");
12846 : return mValue.mObject.Value();
12847 : }
12848 :
12849 : inline JSObject* const &
12850 : GetAsObject() const
12851 : {
12852 : MOZ_ASSERT(IsObject(), "Wrong type!");
12853 : return mValue.mObject.Value();
12854 : }
12855 :
12856 : void
12857 : Uninit();
12858 :
12859 : bool
12860 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12861 :
12862 : void
12863 : TraceUnion(JSTracer* trc);
12864 :
12865 : private:
12866 : void
12867 : DestroyString();
12868 :
12869 : void
12870 : DestroyObject();
12871 : };
12872 :
12873 : class OwningStringOrStringSequence : public AllOwningUnionBase
12874 : {
12875 : friend void ImplCycleCollectionUnlink(OwningStringOrStringSequence& aUnion);
12876 : enum Type
12877 : {
12878 : eUninitialized,
12879 : eString,
12880 : eStringSequence
12881 : };
12882 :
12883 0 : union Value
12884 : {
12885 : UnionMember<nsString > mString;
12886 : UnionMember<Sequence<nsString> > mStringSequence;
12887 :
12888 : };
12889 :
12890 : Type mType;
12891 : Value mValue;
12892 :
12893 : public:
12894 0 : explicit inline OwningStringOrStringSequence()
12895 0 : : mType(eUninitialized)
12896 : {
12897 0 : }
12898 :
12899 0 : explicit inline OwningStringOrStringSequence(const OwningStringOrStringSequence& aOther)
12900 0 : : mType(eUninitialized)
12901 : {
12902 0 : *this = aOther;
12903 0 : }
12904 :
12905 0 : inline ~OwningStringOrStringSequence()
12906 0 : {
12907 0 : Uninit();
12908 0 : }
12909 :
12910 : nsString&
12911 : RawSetAsString();
12912 :
12913 : nsString&
12914 : SetAsString();
12915 :
12916 : bool
12917 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12918 :
12919 : inline void
12920 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
12921 : {
12922 : RawSetAsString().Assign(aData, aLength);
12923 : }
12924 :
12925 : inline bool
12926 0 : IsString() const
12927 : {
12928 0 : return mType == eString;
12929 : }
12930 :
12931 : inline nsString&
12932 : GetAsString()
12933 : {
12934 : MOZ_ASSERT(IsString(), "Wrong type!");
12935 : return mValue.mString.Value();
12936 : }
12937 :
12938 : inline nsString const &
12939 0 : GetAsString() const
12940 : {
12941 0 : MOZ_ASSERT(IsString(), "Wrong type!");
12942 0 : return mValue.mString.Value();
12943 : }
12944 :
12945 : Sequence<nsString>&
12946 : RawSetAsStringSequence();
12947 :
12948 : Sequence<nsString>&
12949 : SetAsStringSequence();
12950 :
12951 : bool
12952 : TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
12953 :
12954 : inline bool
12955 0 : IsStringSequence() const
12956 : {
12957 0 : return mType == eStringSequence;
12958 : }
12959 :
12960 : inline Sequence<nsString>&
12961 : GetAsStringSequence()
12962 : {
12963 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
12964 : return mValue.mStringSequence.Value();
12965 : }
12966 :
12967 : inline Sequence<nsString> const &
12968 0 : GetAsStringSequence() const
12969 : {
12970 0 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
12971 0 : return mValue.mStringSequence.Value();
12972 : }
12973 :
12974 : void
12975 : Uninit();
12976 :
12977 : bool
12978 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
12979 :
12980 : void
12981 : TraceUnion(JSTracer* trc);
12982 :
12983 : OwningStringOrStringSequence&
12984 : operator=(const OwningStringOrStringSequence& aOther);
12985 :
12986 : private:
12987 : void
12988 : DestroyString();
12989 :
12990 : void
12991 : DestroyStringSequence();
12992 : };
12993 :
12994 : class OwningStringSequenceOrEventInit : public AllOwningUnionBase
12995 : {
12996 : friend void ImplCycleCollectionUnlink(OwningStringSequenceOrEventInit& aUnion);
12997 : enum Type
12998 : {
12999 : eUninitialized,
13000 : eStringSequence,
13001 : eEventInit
13002 : };
13003 :
13004 : union Value
13005 : {
13006 : UnionMember<Sequence<nsString> > mStringSequence;
13007 : UnionMember<EventInit > mEventInit;
13008 :
13009 : };
13010 :
13011 : Type mType;
13012 : Value mValue;
13013 :
13014 : public:
13015 : explicit inline OwningStringSequenceOrEventInit()
13016 : : mType(eUninitialized)
13017 : {
13018 : }
13019 :
13020 : explicit inline OwningStringSequenceOrEventInit(const OwningStringSequenceOrEventInit& aOther)
13021 : : mType(eUninitialized)
13022 : {
13023 : *this = aOther;
13024 : }
13025 :
13026 : inline ~OwningStringSequenceOrEventInit()
13027 : {
13028 : Uninit();
13029 : }
13030 :
13031 : Sequence<nsString>&
13032 : RawSetAsStringSequence();
13033 :
13034 : Sequence<nsString>&
13035 : SetAsStringSequence();
13036 :
13037 : bool
13038 : TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13039 :
13040 : inline bool
13041 0 : IsStringSequence() const
13042 : {
13043 0 : return mType == eStringSequence;
13044 : }
13045 :
13046 : inline Sequence<nsString>&
13047 : GetAsStringSequence()
13048 : {
13049 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
13050 : return mValue.mStringSequence.Value();
13051 : }
13052 :
13053 : inline Sequence<nsString> const &
13054 0 : GetAsStringSequence() const
13055 : {
13056 0 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
13057 0 : return mValue.mStringSequence.Value();
13058 : }
13059 :
13060 : EventInit&
13061 : RawSetAsEventInit();
13062 :
13063 : EventInit&
13064 : SetAsEventInit();
13065 :
13066 : bool
13067 : TrySetToEventInit(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13068 :
13069 : inline bool
13070 0 : IsEventInit() const
13071 : {
13072 0 : return mType == eEventInit;
13073 : }
13074 :
13075 : inline EventInit&
13076 : GetAsEventInit()
13077 : {
13078 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
13079 : return mValue.mEventInit.Value();
13080 : }
13081 :
13082 : inline EventInit const &
13083 0 : GetAsEventInit() const
13084 : {
13085 0 : MOZ_ASSERT(IsEventInit(), "Wrong type!");
13086 0 : return mValue.mEventInit.Value();
13087 : }
13088 :
13089 : void
13090 : Uninit();
13091 :
13092 : bool
13093 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13094 :
13095 : void
13096 : TraceUnion(JSTracer* trc);
13097 :
13098 : OwningStringSequenceOrEventInit&
13099 : operator=(const OwningStringSequenceOrEventInit& aOther);
13100 :
13101 : private:
13102 : void
13103 : DestroyStringSequence();
13104 :
13105 : void
13106 : DestroyEventInit();
13107 : };
13108 :
13109 : class OwningStringSequenceOrStringStringRecord : public AllOwningUnionBase
13110 : {
13111 : friend void ImplCycleCollectionUnlink(OwningStringSequenceOrStringStringRecord& aUnion);
13112 : enum Type
13113 : {
13114 : eUninitialized,
13115 : eStringSequence,
13116 : eStringStringRecord
13117 : };
13118 :
13119 : union Value
13120 : {
13121 : UnionMember<Sequence<nsString> > mStringSequence;
13122 : UnionMember<Record<nsString, nsString> > mStringStringRecord;
13123 :
13124 : };
13125 :
13126 : Type mType;
13127 : Value mValue;
13128 :
13129 : OwningStringSequenceOrStringStringRecord(const OwningStringSequenceOrStringStringRecord&) = delete;
13130 : OwningStringSequenceOrStringStringRecord& operator=(const OwningStringSequenceOrStringStringRecord&) = delete;
13131 : public:
13132 : explicit inline OwningStringSequenceOrStringStringRecord()
13133 : : mType(eUninitialized)
13134 : {
13135 : }
13136 :
13137 : inline ~OwningStringSequenceOrStringStringRecord()
13138 : {
13139 : Uninit();
13140 : }
13141 :
13142 : Sequence<nsString>&
13143 : RawSetAsStringSequence();
13144 :
13145 : Sequence<nsString>&
13146 : SetAsStringSequence();
13147 :
13148 : bool
13149 : TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13150 :
13151 : inline bool
13152 0 : IsStringSequence() const
13153 : {
13154 0 : return mType == eStringSequence;
13155 : }
13156 :
13157 : inline Sequence<nsString>&
13158 : GetAsStringSequence()
13159 : {
13160 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
13161 : return mValue.mStringSequence.Value();
13162 : }
13163 :
13164 : inline Sequence<nsString> const &
13165 : GetAsStringSequence() const
13166 : {
13167 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
13168 : return mValue.mStringSequence.Value();
13169 : }
13170 :
13171 : Record<nsString, nsString>&
13172 : RawSetAsStringStringRecord();
13173 :
13174 : Record<nsString, nsString>&
13175 : SetAsStringStringRecord();
13176 :
13177 : bool
13178 : TrySetToStringStringRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13179 :
13180 : inline bool
13181 0 : IsStringStringRecord() const
13182 : {
13183 0 : return mType == eStringStringRecord;
13184 : }
13185 :
13186 : inline Record<nsString, nsString>&
13187 : GetAsStringStringRecord()
13188 : {
13189 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
13190 : return mValue.mStringStringRecord.Value();
13191 : }
13192 :
13193 : inline Record<nsString, nsString> const &
13194 : GetAsStringStringRecord() const
13195 : {
13196 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
13197 : return mValue.mStringStringRecord.Value();
13198 : }
13199 :
13200 : void
13201 : Uninit();
13202 :
13203 : bool
13204 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13205 :
13206 : void
13207 : TraceUnion(JSTracer* trc);
13208 :
13209 : private:
13210 : void
13211 : DestroyStringSequence();
13212 :
13213 : void
13214 : DestroyStringStringRecord();
13215 : };
13216 :
13217 : class OwningStringStringRecordOrString : public AllOwningUnionBase
13218 : {
13219 : friend void ImplCycleCollectionUnlink(OwningStringStringRecordOrString& aUnion);
13220 : enum Type
13221 : {
13222 : eUninitialized,
13223 : eStringStringRecord,
13224 : eString
13225 : };
13226 :
13227 : union Value
13228 : {
13229 : UnionMember<Record<nsString, nsString> > mStringStringRecord;
13230 : UnionMember<nsString > mString;
13231 :
13232 : };
13233 :
13234 : Type mType;
13235 : Value mValue;
13236 :
13237 : OwningStringStringRecordOrString(const OwningStringStringRecordOrString&) = delete;
13238 : OwningStringStringRecordOrString& operator=(const OwningStringStringRecordOrString&) = delete;
13239 : public:
13240 : explicit inline OwningStringStringRecordOrString()
13241 : : mType(eUninitialized)
13242 : {
13243 : }
13244 :
13245 : inline ~OwningStringStringRecordOrString()
13246 : {
13247 : Uninit();
13248 : }
13249 :
13250 : Record<nsString, nsString>&
13251 : RawSetAsStringStringRecord();
13252 :
13253 : Record<nsString, nsString>&
13254 : SetAsStringStringRecord();
13255 :
13256 : bool
13257 : TrySetToStringStringRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13258 :
13259 : inline bool
13260 0 : IsStringStringRecord() const
13261 : {
13262 0 : return mType == eStringStringRecord;
13263 : }
13264 :
13265 : inline Record<nsString, nsString>&
13266 : GetAsStringStringRecord()
13267 : {
13268 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
13269 : return mValue.mStringStringRecord.Value();
13270 : }
13271 :
13272 : inline Record<nsString, nsString> const &
13273 : GetAsStringStringRecord() const
13274 : {
13275 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
13276 : return mValue.mStringStringRecord.Value();
13277 : }
13278 :
13279 : nsString&
13280 : RawSetAsString();
13281 :
13282 : nsString&
13283 : SetAsString();
13284 :
13285 : bool
13286 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13287 :
13288 : inline void
13289 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
13290 : {
13291 : RawSetAsString().Assign(aData, aLength);
13292 : }
13293 :
13294 : inline bool
13295 0 : IsString() const
13296 : {
13297 0 : return mType == eString;
13298 : }
13299 :
13300 : inline nsString&
13301 : GetAsString()
13302 : {
13303 : MOZ_ASSERT(IsString(), "Wrong type!");
13304 : return mValue.mString.Value();
13305 : }
13306 :
13307 : inline nsString const &
13308 : GetAsString() const
13309 : {
13310 : MOZ_ASSERT(IsString(), "Wrong type!");
13311 : return mValue.mString.Value();
13312 : }
13313 :
13314 : void
13315 : Uninit();
13316 :
13317 : bool
13318 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13319 :
13320 : void
13321 : TraceUnion(JSTracer* trc);
13322 :
13323 : private:
13324 : void
13325 : DestroyStringStringRecord();
13326 :
13327 : void
13328 : DestroyString();
13329 : };
13330 :
13331 : class OwningStringStringRecordOrStringSequence : public AllOwningUnionBase
13332 : {
13333 : friend void ImplCycleCollectionUnlink(OwningStringStringRecordOrStringSequence& aUnion);
13334 : enum Type
13335 : {
13336 : eUninitialized,
13337 : eStringStringRecord,
13338 : eStringSequence
13339 : };
13340 :
13341 : union Value
13342 : {
13343 : UnionMember<Record<nsString, nsString> > mStringStringRecord;
13344 : UnionMember<Sequence<nsString> > mStringSequence;
13345 :
13346 : };
13347 :
13348 : Type mType;
13349 : Value mValue;
13350 :
13351 : OwningStringStringRecordOrStringSequence(const OwningStringStringRecordOrStringSequence&) = delete;
13352 : OwningStringStringRecordOrStringSequence& operator=(const OwningStringStringRecordOrStringSequence&) = delete;
13353 : public:
13354 : explicit inline OwningStringStringRecordOrStringSequence()
13355 : : mType(eUninitialized)
13356 : {
13357 : }
13358 :
13359 : inline ~OwningStringStringRecordOrStringSequence()
13360 : {
13361 : Uninit();
13362 : }
13363 :
13364 : Record<nsString, nsString>&
13365 : RawSetAsStringStringRecord();
13366 :
13367 : Record<nsString, nsString>&
13368 : SetAsStringStringRecord();
13369 :
13370 : bool
13371 : TrySetToStringStringRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13372 :
13373 : inline bool
13374 0 : IsStringStringRecord() const
13375 : {
13376 0 : return mType == eStringStringRecord;
13377 : }
13378 :
13379 : inline Record<nsString, nsString>&
13380 : GetAsStringStringRecord()
13381 : {
13382 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
13383 : return mValue.mStringStringRecord.Value();
13384 : }
13385 :
13386 : inline Record<nsString, nsString> const &
13387 : GetAsStringStringRecord() const
13388 : {
13389 : MOZ_ASSERT(IsStringStringRecord(), "Wrong type!");
13390 : return mValue.mStringStringRecord.Value();
13391 : }
13392 :
13393 : Sequence<nsString>&
13394 : RawSetAsStringSequence();
13395 :
13396 : Sequence<nsString>&
13397 : SetAsStringSequence();
13398 :
13399 : bool
13400 : TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13401 :
13402 : inline bool
13403 0 : IsStringSequence() const
13404 : {
13405 0 : return mType == eStringSequence;
13406 : }
13407 :
13408 : inline Sequence<nsString>&
13409 : GetAsStringSequence()
13410 : {
13411 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
13412 : return mValue.mStringSequence.Value();
13413 : }
13414 :
13415 : inline Sequence<nsString> const &
13416 : GetAsStringSequence() const
13417 : {
13418 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
13419 : return mValue.mStringSequence.Value();
13420 : }
13421 :
13422 : void
13423 : Uninit();
13424 :
13425 : bool
13426 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13427 :
13428 : void
13429 : TraceUnion(JSTracer* trc);
13430 :
13431 : private:
13432 : void
13433 : DestroyStringStringRecord();
13434 :
13435 : void
13436 : DestroyStringSequence();
13437 : };
13438 :
13439 : class OwningSupportedTypeOrObject : public AllOwningUnionBase
13440 : {
13441 : friend void ImplCycleCollectionUnlink(OwningSupportedTypeOrObject& aUnion);
13442 : enum Type
13443 : {
13444 : eUninitialized,
13445 : eSupportedType,
13446 : eObject
13447 : };
13448 :
13449 : union Value
13450 : {
13451 : UnionMember<SupportedType > mSupportedType;
13452 : UnionMember<JSObject* > mObject;
13453 :
13454 : };
13455 :
13456 : Type mType;
13457 : Value mValue;
13458 :
13459 : OwningSupportedTypeOrObject(const OwningSupportedTypeOrObject&) = delete;
13460 : OwningSupportedTypeOrObject& operator=(const OwningSupportedTypeOrObject&) = delete;
13461 : public:
13462 : explicit inline OwningSupportedTypeOrObject()
13463 : : mType(eUninitialized)
13464 : {
13465 : }
13466 :
13467 : inline ~OwningSupportedTypeOrObject()
13468 : {
13469 : Uninit();
13470 : }
13471 :
13472 : SupportedType&
13473 : RawSetAsSupportedType();
13474 :
13475 : SupportedType&
13476 : SetAsSupportedType();
13477 :
13478 : bool
13479 : TrySetToSupportedType(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13480 :
13481 : inline bool
13482 0 : IsSupportedType() const
13483 : {
13484 0 : return mType == eSupportedType;
13485 : }
13486 :
13487 : inline SupportedType&
13488 : GetAsSupportedType()
13489 : {
13490 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
13491 : return mValue.mSupportedType.Value();
13492 : }
13493 :
13494 : inline SupportedType const &
13495 : GetAsSupportedType() const
13496 : {
13497 : MOZ_ASSERT(IsSupportedType(), "Wrong type!");
13498 : return mValue.mSupportedType.Value();
13499 : }
13500 :
13501 : JSObject*&
13502 : RawSetAsObject();
13503 :
13504 : JSObject*&
13505 : SetAsObject();
13506 :
13507 : inline bool
13508 : SetToObject(JSContext* cx, JSObject* obj, bool passedToJSImpl = false)
13509 : {
13510 : MOZ_ASSERT(mType == eUninitialized);
13511 : mValue.mObject.SetValue(obj);
13512 : mType = eObject;
13513 : if (passedToJSImpl && !CallerSubsumes(obj)) {
13514 : ThrowErrorMessage(cx, MSG_PERMISSION_DENIED_TO_PASS_ARG, "%s");
13515 : return false;
13516 : }
13517 : return true;
13518 : }
13519 :
13520 : inline bool
13521 0 : IsObject() const
13522 : {
13523 0 : return mType == eObject;
13524 : }
13525 :
13526 : inline JSObject*&
13527 : GetAsObject()
13528 : {
13529 : MOZ_ASSERT(IsObject(), "Wrong type!");
13530 : return mValue.mObject.Value();
13531 : }
13532 :
13533 : inline JSObject* const &
13534 : GetAsObject() const
13535 : {
13536 : MOZ_ASSERT(IsObject(), "Wrong type!");
13537 : return mValue.mObject.Value();
13538 : }
13539 :
13540 : void
13541 : Uninit();
13542 :
13543 : bool
13544 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13545 :
13546 : void
13547 : TraceUnion(JSTracer* trc);
13548 :
13549 : private:
13550 : void
13551 : DestroySupportedType();
13552 :
13553 : void
13554 : DestroyObject();
13555 : };
13556 :
13557 : class OwningUSVStringOrLong : public AllOwningUnionBase
13558 : {
13559 : friend void ImplCycleCollectionUnlink(OwningUSVStringOrLong& aUnion);
13560 : enum Type
13561 : {
13562 : eUninitialized,
13563 : eUSVString,
13564 : eLong
13565 : };
13566 :
13567 : union Value
13568 : {
13569 : UnionMember<nsString > mUSVString;
13570 : UnionMember<int32_t > mLong;
13571 :
13572 : };
13573 :
13574 : Type mType;
13575 : Value mValue;
13576 :
13577 : public:
13578 : explicit inline OwningUSVStringOrLong()
13579 : : mType(eUninitialized)
13580 : {
13581 : }
13582 :
13583 : explicit inline OwningUSVStringOrLong(const OwningUSVStringOrLong& aOther)
13584 : : mType(eUninitialized)
13585 : {
13586 : *this = aOther;
13587 : }
13588 :
13589 : inline ~OwningUSVStringOrLong()
13590 : {
13591 : Uninit();
13592 : }
13593 :
13594 : nsString&
13595 : RawSetAsUSVString();
13596 :
13597 : nsString&
13598 : SetAsUSVString();
13599 :
13600 : bool
13601 : TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13602 :
13603 : inline void
13604 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
13605 : {
13606 : RawSetAsUSVString().Assign(aData, aLength);
13607 : }
13608 :
13609 : inline bool
13610 0 : IsUSVString() const
13611 : {
13612 0 : return mType == eUSVString;
13613 : }
13614 :
13615 : inline nsString&
13616 : GetAsUSVString()
13617 : {
13618 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
13619 : return mValue.mUSVString.Value();
13620 : }
13621 :
13622 : inline nsString const &
13623 0 : GetAsUSVString() const
13624 : {
13625 0 : MOZ_ASSERT(IsUSVString(), "Wrong type!");
13626 0 : return mValue.mUSVString.Value();
13627 : }
13628 :
13629 : int32_t&
13630 : RawSetAsLong();
13631 :
13632 : int32_t&
13633 : SetAsLong();
13634 :
13635 : bool
13636 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13637 :
13638 : inline bool
13639 0 : IsLong() const
13640 : {
13641 0 : return mType == eLong;
13642 : }
13643 :
13644 : inline int32_t&
13645 : GetAsLong()
13646 : {
13647 : MOZ_ASSERT(IsLong(), "Wrong type!");
13648 : return mValue.mLong.Value();
13649 : }
13650 :
13651 : inline int32_t const &
13652 0 : GetAsLong() const
13653 : {
13654 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
13655 0 : return mValue.mLong.Value();
13656 : }
13657 :
13658 : void
13659 : Uninit();
13660 :
13661 : bool
13662 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13663 :
13664 : void
13665 : TraceUnion(JSTracer* trc);
13666 :
13667 : OwningUSVStringOrLong&
13668 : operator=(const OwningUSVStringOrLong& aOther);
13669 :
13670 : private:
13671 : void
13672 : DestroyUSVString();
13673 :
13674 : void
13675 : DestroyLong();
13676 : };
13677 :
13678 : class OwningUnrestrictedDoubleOrString : public AllOwningUnionBase
13679 : {
13680 : friend void ImplCycleCollectionUnlink(OwningUnrestrictedDoubleOrString& aUnion);
13681 : enum Type
13682 : {
13683 : eUninitialized,
13684 : eUnrestrictedDouble,
13685 : eString
13686 : };
13687 :
13688 0 : union Value
13689 : {
13690 : UnionMember<double > mUnrestrictedDouble;
13691 : UnionMember<nsString > mString;
13692 :
13693 : };
13694 :
13695 : Type mType;
13696 : Value mValue;
13697 :
13698 : public:
13699 0 : explicit inline OwningUnrestrictedDoubleOrString()
13700 0 : : mType(eUninitialized)
13701 : {
13702 0 : }
13703 :
13704 : explicit inline OwningUnrestrictedDoubleOrString(const OwningUnrestrictedDoubleOrString& aOther)
13705 : : mType(eUninitialized)
13706 : {
13707 : *this = aOther;
13708 : }
13709 :
13710 0 : inline ~OwningUnrestrictedDoubleOrString()
13711 0 : {
13712 0 : Uninit();
13713 0 : }
13714 :
13715 : double&
13716 : RawSetAsUnrestrictedDouble();
13717 :
13718 : double&
13719 : SetAsUnrestrictedDouble();
13720 :
13721 : bool
13722 : TrySetToUnrestrictedDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13723 :
13724 : inline bool
13725 0 : IsUnrestrictedDouble() const
13726 : {
13727 0 : return mType == eUnrestrictedDouble;
13728 : }
13729 :
13730 : inline double&
13731 : GetAsUnrestrictedDouble()
13732 : {
13733 : MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
13734 : return mValue.mUnrestrictedDouble.Value();
13735 : }
13736 :
13737 : inline double const &
13738 0 : GetAsUnrestrictedDouble() const
13739 : {
13740 0 : MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
13741 0 : return mValue.mUnrestrictedDouble.Value();
13742 : }
13743 :
13744 : nsString&
13745 : RawSetAsString();
13746 :
13747 : nsString&
13748 : SetAsString();
13749 :
13750 : bool
13751 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13752 :
13753 : inline void
13754 0 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
13755 : {
13756 0 : RawSetAsString().Assign(aData, aLength);
13757 0 : }
13758 :
13759 : inline bool
13760 0 : IsString() const
13761 : {
13762 0 : return mType == eString;
13763 : }
13764 :
13765 : inline nsString&
13766 : GetAsString()
13767 : {
13768 : MOZ_ASSERT(IsString(), "Wrong type!");
13769 : return mValue.mString.Value();
13770 : }
13771 :
13772 : inline nsString const &
13773 0 : GetAsString() const
13774 : {
13775 0 : MOZ_ASSERT(IsString(), "Wrong type!");
13776 0 : return mValue.mString.Value();
13777 : }
13778 :
13779 : void
13780 : Uninit();
13781 :
13782 : bool
13783 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13784 :
13785 : void
13786 : TraceUnion(JSTracer* trc);
13787 :
13788 : OwningUnrestrictedDoubleOrString&
13789 : operator=(const OwningUnrestrictedDoubleOrString& aOther);
13790 :
13791 : private:
13792 : void
13793 : DestroyUnrestrictedDouble();
13794 :
13795 : void
13796 : DestroyString();
13797 : };
13798 :
13799 : class OwningUnrestrictedFloatOrString : public AllOwningUnionBase
13800 : {
13801 : friend void ImplCycleCollectionUnlink(OwningUnrestrictedFloatOrString& aUnion);
13802 : enum Type
13803 : {
13804 : eUninitialized,
13805 : eUnrestrictedFloat,
13806 : eString
13807 : };
13808 :
13809 : union Value
13810 : {
13811 : UnionMember<float > mUnrestrictedFloat;
13812 : UnionMember<nsString > mString;
13813 :
13814 : };
13815 :
13816 : Type mType;
13817 : Value mValue;
13818 :
13819 : public:
13820 : explicit inline OwningUnrestrictedFloatOrString()
13821 : : mType(eUninitialized)
13822 : {
13823 : }
13824 :
13825 : explicit inline OwningUnrestrictedFloatOrString(const OwningUnrestrictedFloatOrString& aOther)
13826 : : mType(eUninitialized)
13827 : {
13828 : *this = aOther;
13829 : }
13830 :
13831 : inline ~OwningUnrestrictedFloatOrString()
13832 : {
13833 : Uninit();
13834 : }
13835 :
13836 : float&
13837 : RawSetAsUnrestrictedFloat();
13838 :
13839 : float&
13840 : SetAsUnrestrictedFloat();
13841 :
13842 : bool
13843 : TrySetToUnrestrictedFloat(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13844 :
13845 : inline bool
13846 0 : IsUnrestrictedFloat() const
13847 : {
13848 0 : return mType == eUnrestrictedFloat;
13849 : }
13850 :
13851 : inline float&
13852 : GetAsUnrestrictedFloat()
13853 : {
13854 : MOZ_ASSERT(IsUnrestrictedFloat(), "Wrong type!");
13855 : return mValue.mUnrestrictedFloat.Value();
13856 : }
13857 :
13858 : inline float const &
13859 0 : GetAsUnrestrictedFloat() const
13860 : {
13861 0 : MOZ_ASSERT(IsUnrestrictedFloat(), "Wrong type!");
13862 0 : return mValue.mUnrestrictedFloat.Value();
13863 : }
13864 :
13865 : nsString&
13866 : RawSetAsString();
13867 :
13868 : nsString&
13869 : SetAsString();
13870 :
13871 : bool
13872 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
13873 :
13874 : inline void
13875 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
13876 : {
13877 : RawSetAsString().Assign(aData, aLength);
13878 : }
13879 :
13880 : inline bool
13881 0 : IsString() const
13882 : {
13883 0 : return mType == eString;
13884 : }
13885 :
13886 : inline nsString&
13887 : GetAsString()
13888 : {
13889 : MOZ_ASSERT(IsString(), "Wrong type!");
13890 : return mValue.mString.Value();
13891 : }
13892 :
13893 : inline nsString const &
13894 0 : GetAsString() const
13895 : {
13896 0 : MOZ_ASSERT(IsString(), "Wrong type!");
13897 0 : return mValue.mString.Value();
13898 : }
13899 :
13900 : void
13901 : Uninit();
13902 :
13903 : bool
13904 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
13905 :
13906 : void
13907 : TraceUnion(JSTracer* trc);
13908 :
13909 : OwningUnrestrictedFloatOrString&
13910 : operator=(const OwningUnrestrictedFloatOrString& aOther);
13911 :
13912 : private:
13913 : void
13914 : DestroyUnrestrictedFloat();
13915 :
13916 : void
13917 : DestroyString();
13918 : };
13919 : } // namespace dom
13920 : } // namespace mozilla
13921 :
13922 :
13923 : #endif // mozilla_dom_UnionTypes_h
|