Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/mozilla/RefPtr.h
Warning:line 79, column 9
Branch condition evaluates to a garbage value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name TestCodeGenBinding.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings/test -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings/test -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D IMPL_LIBXUL -D MOZILLA_INTERNAL_API -I /var/lib/jenkins/workspace/firefox-scan-build/dom/bindings/test -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings/test -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings -I /var/lib/jenkins/workspace/firefox-scan-build/dom/bindings -I /var/lib/jenkins/workspace/firefox-scan-build/js/xpconnect/src -I /var/lib/jenkins/workspace/firefox-scan-build/js/xpconnect/wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-05-16-034744-15991-1 -x c++ ../TestCodeGenBinding.cpp

../TestCodeGenBinding.cpp

1/* THIS FILE IS AUTOGENERATED FROM TestCodeGen.webidl BY Codegen.py - DO NOT EDIT */
2
3#include <type_traits>
4#include "AtomList.h"
5#include "CustomEventBinding.h"
6#include "EventBinding.h"
7#include "EventHandlerBinding.h"
8#include "MainThreadUtils.h"
9#include "TestBindingHeader.h"
10#include "TestCallbackBinding.h"
11#include "TestCodeGenBinding.h"
12#include "TestDictionaryBinding.h"
13#include "WrapperFactory.h"
14#include "XrayWrapper.h"
15#include "js/Array.h"
16#include "js/CallAndConstruct.h"
17#include "js/Exception.h"
18#include "js/ForOfIterator.h"
19#include "js/MapAndSet.h"
20#include "js/Object.h"
21#include "js/PropertyAndElement.h"
22#include "js/PropertyDescriptor.h"
23#include "js/experimental/JitInfo.h"
24#include "js/shadow/Object.h"
25#include "jsapi.h"
26#include "jsfriendapi.h"
27#include "mozilla/Atomics.h"
28#include "mozilla/BasePrincipal.h"
29#include "mozilla/FloatingPoint.h"
30#include "mozilla/OriginTrials.h"
31#include "mozilla/OwningNonNull.h"
32#include "mozilla/ProfilerLabels.h"
33#include "mozilla/StaticPrefs_dom.h"
34#include "mozilla/dom/BindingCallContext.h"
35#include "mozilla/dom/BindingUtils.h"
36#include "mozilla/dom/CanvasGradient.h"
37#include "mozilla/dom/CanvasPattern.h"
38#include "mozilla/dom/CustomElementRegistry.h"
39#include "mozilla/dom/DOMJSClass.h"
40#include "mozilla/dom/DOMJSProxyHandler.h"
41#include "mozilla/dom/DocGroup.h"
42#include "mozilla/dom/Document.h"
43#include "mozilla/dom/ImageData.h"
44#include "mozilla/dom/NonRefcountedDOMObject.h"
45#include "mozilla/dom/Nullable.h"
46#include "mozilla/dom/ObservableArrayProxyHandler.h"
47#include "mozilla/dom/PrimitiveConversions.h"
48#include "mozilla/dom/Promise.h"
49#include "mozilla/dom/ProxyHandlerUtils.h"
50#include "mozilla/dom/Record.h"
51#include "mozilla/dom/RootedDictionary.h"
52#include "mozilla/dom/ScriptSettings.h"
53#include "mozilla/dom/SimpleGlobalObject.h"
54#include "mozilla/dom/ToJSValue.h"
55#include "mozilla/dom/TypedArray.h"
56#include "mozilla/dom/UnionTypes.h"
57#include "mozilla/dom/WebIDLPrefs.h"
58#include "mozilla/dom/XrayExpandoClass.h"
59#include "nsContentUtils.h"
60#include "nsGenericHTMLElement.h"
61#include "nsIContent.h"
62#include "nsJSPrincipals.h"
63#include "nsJSUtils.h"
64
65namespace mozilla {
66
67namespace dom {
68
69namespace binding_detail {}; // Just to make sure it's known as a namespace
70using namespace mozilla::dom::binding_detail;
71
72
73namespace binding_detail {
74const nsLiteralCString EnumStrings<TestEnum>::Values[5] = {
75 "1"_ns,
76 "a"_ns,
77 "b"_ns,
78 "1-2"_ns,
79 "2d-array"_ns,
80};
81} // namespace binding_detail
82
83bool
84ToJSValue(JSContext* aCx, TestEnum aArgument, JS::MutableHandle<JS::Value> aValue)
85{
86 MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<TestEnum>::Values))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(uint32_t(aArgument) < ArrayLength(binding_detail::
EnumStrings<TestEnum>::Values))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(uint32_t(aArgument) < ArrayLength
(binding_detail::EnumStrings<TestEnum>::Values)))), 0))
) { do { } while (false); MOZ_ReportAssertionFailure("uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<TestEnum>::Values)"
, "../TestCodeGenBinding.cpp", 86); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<TestEnum>::Values)"
")"); do { *((volatile int*)__null) = 86; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
87 JSString* resultStr =
88 JS_NewStringCopyN(aCx, binding_detail::EnumStrings<TestEnum>::Values[uint32_t(aArgument)].BeginReading(),
89 binding_detail::EnumStrings<TestEnum>::Values[uint32_t(aArgument)].Length());
90 if (!resultStr) {
91 return false;
92 }
93 aValue.setString(resultStr);
94 return true;
95}
96
97
98namespace binding_detail {
99const nsLiteralCString EnumStrings<OnlyForUseInInnerUnion>::Values[1] = {
100 "1"_ns,
101};
102} // namespace binding_detail
103
104bool
105ToJSValue(JSContext* aCx, OnlyForUseInInnerUnion aArgument, JS::MutableHandle<JS::Value> aValue)
106{
107 MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(uint32_t(aArgument) < ArrayLength(binding_detail::
EnumStrings<OnlyForUseInInnerUnion>::Values))>::isValid
, "invalid assertion condition"); if ((__builtin_expect(!!(!(
!!(uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings
<OnlyForUseInInnerUnion>::Values)))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values)"
, "../TestCodeGenBinding.cpp", 107); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "uint32_t(aArgument) < ArrayLength(binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values)"
")"); do { *((volatile int*)__null) = 107; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
108 JSString* resultStr =
109 JS_NewStringCopyN(aCx, binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values[uint32_t(aArgument)].BeginReading(),
110 binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values[uint32_t(aArgument)].Length());
111 if (!resultStr) {
112 return false;
113 }
114 aValue.setString(resultStr);
115 return true;
116}
117
118
119void
120ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningOnlyForUseInInnerUnionOrCanvasPattern& aUnion, const char* aName, uint32_t aFlags)
121{
122 if (aUnion.IsCanvasPattern()) {
123 ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCanvasPattern(), "mCanvasPattern", aFlags);
124 }
125}
126
127
128void
129ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningStringOrOnlyForUseInInnerUnionOrCanvasPatternSequence& aUnion, const char* aName, uint32_t aFlags)
130{
131 if (aUnion.IsOnlyForUseInInnerUnionOrCanvasPatternSequence()) {
132 ImplCycleCollectionTraverse(aCallback, aUnion.GetAsOnlyForUseInInnerUnionOrCanvasPatternSequence(), "mOnlyForUseInInnerUnionOrCanvasPatternSequence", aFlags);
133 }
134}
135
136
137void
138ImplCycleCollectionUnlink(OwningOnlyForUseInInnerUnionOrCanvasPattern& aUnion)
139{
140 aUnion.Uninit();
141}
142
143
144void
145ImplCycleCollectionUnlink(OwningStringOrOnlyForUseInInnerUnionOrCanvasPatternSequence& aUnion)
146{
147 aUnion.Uninit();
148}
149
150
151
152DictContainingSequence::DictContainingSequence()
153{
154 // Safe to pass a null context if we pass a null value
155 Init(nullptr, JS::NullHandleValue);
156}
157
158
159
160bool
161DictContainingSequence::InitIds(JSContext* cx, DictContainingSequenceAtoms* atomsCache)
162{
163 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 163); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 163; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
164
165 // Initialize these in reverse order so that any failure leaves the first one
166 // uninitialized.
167 if (!atomsCache->ourSequence9_id.init(cx, "ourSequence9") ||
168 !atomsCache->ourSequence8_id.init(cx, "ourSequence8") ||
169 !atomsCache->ourSequence7_id.init(cx, "ourSequence7") ||
170 !atomsCache->ourSequence6_id.init(cx, "ourSequence6") ||
171 !atomsCache->ourSequence5_id.init(cx, "ourSequence5") ||
172 !atomsCache->ourSequence4_id.init(cx, "ourSequence4") ||
173 !atomsCache->ourSequence3_id.init(cx, "ourSequence3") ||
174 !atomsCache->ourSequence2_id.init(cx, "ourSequence2") ||
175 !atomsCache->ourSequence10_id.init(cx, "ourSequence10") ||
176 !atomsCache->ourSequence_id.init(cx, "ourSequence")) {
177 return false;
178 }
179 return true;
180}
181
182bool
183DictContainingSequence::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
184{
185 // Passing a null JSContext is OK only if we're initing from null,
186 // Since in that case we will not have to do any property gets
187 // Also evaluate isNullOrUndefined in order to avoid false-positive
188 // checkers by static analysis tools
189 MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined())do { if (!cx) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(val.isNull() && val.isNullOrUndefined())
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(val.isNull() && val.isNullOrUndefined()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("val.isNull() && val.isNullOrUndefined()"
, "../TestCodeGenBinding.cpp", 189); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "val.isNull() && val.isNullOrUndefined()" ")"); do
{ *((volatile int*)__null) = 189; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false); } } while (false
)
;
190 DictContainingSequenceAtoms* atomsCache = nullptr;
191 if (cx) {
192 atomsCache = GetAtomCache<DictContainingSequenceAtoms>(cx);
193 if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
194 !InitIds(cx, atomsCache)) {
195 return false;
196 }
197 }
198
199 if (!IsConvertibleToDictionary(val)) {
200 return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
201 }
202
203 bool isNull = val.isNullOrUndefined();
204 // We only need these if !isNull, in which case we have |cx|.
205 Maybe<JS::Rooted<JSObject *> > object;
206 Maybe<JS::Rooted<JS::Value> > temp;
207 if (!isNull) {
208 MOZ_ASSERT(cx)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(cx)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(cx))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("cx", "../TestCodeGenBinding.cpp"
, 208); AnnotateMozCrashReason("MOZ_ASSERT" "(" "cx" ")"); do
{ *((volatile int*)__null) = 208; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
209 object.emplace(cx, &val.toObject());
210 temp.emplace(cx);
211 }
212 if (!isNull) {
213 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence_id, temp.ptr())) {
214 return false;
215 }
216 }
217 if (!isNull && !temp->isUndefined()) {
218 mOurSequence.Construct();
219 if (temp.ref().isObject()) {
220 JS::ForOfIterator iter(cx);
221 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
222 return false;
223 }
224 if (!iter.valueIsIterable()) {
225 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence' member of DictContainingSequence", "sequence");
226 return false;
227 }
228 Sequence<int32_t> &arr = (mOurSequence.Value());
229 JS::Rooted<JS::Value> temp(cx);
230 while (true) {
231 bool done;
232 if (!iter.next(&temp, &done)) {
233 return false;
234 }
235 if (done) {
236 break;
237 }
238 int32_t* slotPtr = arr.AppendElement(mozilla::fallible);
239 if (!slotPtr) {
240 JS_ReportOutOfMemory(cx);
241 return false;
242 }
243 int32_t& slot = *slotPtr;
244 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Element of 'ourSequence' member of DictContainingSequence", &slot)) {
245 return false;
246 }
247 }
248 } else {
249 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence' member of DictContainingSequence", "sequence");
250 return false;
251 }
252 mIsAnyMemberPresent = true;
253 }
254
255 if (!isNull) {
256 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence10_id, temp.ptr())) {
257 return false;
258 }
259 }
260 if (!isNull && !temp->isUndefined()) {
261 mOurSequence10.Construct();
262 if (temp.ref().isObject()) {
263 JS::ForOfIterator iter(cx);
264 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
265 return false;
266 }
267 if (!iter.valueIsIterable()) {
268 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence10' member of DictContainingSequence", "sequence");
269 return false;
270 }
271 Sequence<OwningFloatOrString> &arr = (mOurSequence10.Value());
272 JS::Rooted<JS::Value> temp(cx);
273 while (true) {
274 bool done;
275 if (!iter.next(&temp, &done)) {
276 return false;
277 }
278 if (done) {
279 break;
280 }
281 OwningFloatOrString* slotPtr = arr.AppendElement(mozilla::fallible);
282 if (!slotPtr) {
283 JS_ReportOutOfMemory(cx);
284 return false;
285 }
286 OwningFloatOrString& slot = *slotPtr;
287 if (!slot.Init(cx, temp, "Element of 'ourSequence10' member of DictContainingSequence", passedToJSImpl)) {
288 return false;
289 }
290 }
291 } else {
292 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence10' member of DictContainingSequence", "sequence");
293 return false;
294 }
295 mIsAnyMemberPresent = true;
296 }
297
298 if (!isNull) {
299 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence2_id, temp.ptr())) {
300 return false;
301 }
302 }
303 if (!isNull && !temp->isUndefined()) {
304 mOurSequence2.Construct();
305 if (temp.ref().isObject()) {
306 JS::ForOfIterator iter(cx);
307 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
308 return false;
309 }
310 if (!iter.valueIsIterable()) {
311 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence2' member of DictContainingSequence", "sequence");
312 return false;
313 }
314 Sequence<OwningNonNull<mozilla::dom::TestInterface>> &arr = (mOurSequence2.Value());
315 JS::Rooted<JS::Value> temp(cx);
316 while (true) {
317 bool done;
318 if (!iter.next(&temp, &done)) {
319 return false;
320 }
321 if (done) {
322 break;
323 }
324 OwningNonNull<mozilla::dom::TestInterface>* slotPtr = arr.AppendElement(mozilla::fallible);
325 if (!slotPtr) {
326 JS_ReportOutOfMemory(cx);
327 return false;
328 }
329 OwningNonNull<mozilla::dom::TestInterface>& slot = *slotPtr;
330 if (temp.isObject()) {
331 static_assert(IsRefcounted<mozilla::dom::TestInterface>::value, "We can only store refcounted classes.");
332 {
333 // Our JSContext should be in the right global to do unwrapping in.
334 nsresult rv = UnwrapObject<prototypes::id::TestInterface, mozilla::dom::TestInterface>(&temp, slot, cx);
335 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
336 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Element of 'ourSequence2' member of DictContainingSequence", "TestInterface");
337 return false;
338 }
339 }
340 } else {
341 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence2' member of DictContainingSequence");
342 return false;
343 }
344 }
345 } else {
346 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence2' member of DictContainingSequence", "sequence");
347 return false;
348 }
349 mIsAnyMemberPresent = true;
350 }
351
352 if (!isNull) {
353 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence3_id, temp.ptr())) {
354 return false;
355 }
356 }
357 if (!isNull && !temp->isUndefined()) {
358 mOurSequence3.Construct();
359 if (temp.ref().isObject()) {
360 JS::ForOfIterator iter(cx);
361 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
362 return false;
363 }
364 if (!iter.valueIsIterable()) {
365 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence3' member of DictContainingSequence", "sequence");
366 return false;
367 }
368 Sequence<JS::Value> &arr = (mOurSequence3.Value());
369 JS::Rooted<JS::Value> temp(cx);
370 while (true) {
371 bool done;
372 if (!iter.next(&temp, &done)) {
373 return false;
374 }
375 if (done) {
376 break;
377 }
378 JS::Value* slotPtr = arr.AppendElement(mozilla::fallible);
379 if (!slotPtr) {
380 JS_ReportOutOfMemory(cx);
381 return false;
382 }
383 JS::Value& slot = *slotPtr;
384#ifdef __clang__1
385#pragma clang diagnostic push
386#pragma clang diagnostic ignored "-Wunreachable-code"
387#pragma clang diagnostic ignored "-Wunreachable-code-return"
388#endif // __clang__
389 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
390 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence3' member of DictContainingSequence");
391 return false;
392 }
393#ifdef __clang__1
394#pragma clang diagnostic pop
395#endif // __clang__
396 slot = temp;
397 }
398 } else {
399 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence3' member of DictContainingSequence", "sequence");
400 return false;
401 }
402 mIsAnyMemberPresent = true;
403 }
404
405 if (!isNull) {
406 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence4_id, temp.ptr())) {
407 return false;
408 }
409 }
410 if (!isNull && !temp->isUndefined()) {
411 mOurSequence4.Construct();
412 if (temp.ref().isObject()) {
413 JS::ForOfIterator iter(cx);
414 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
415 return false;
416 }
417 if (!iter.valueIsIterable()) {
418 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence4' member of DictContainingSequence", "sequence");
419 return false;
420 }
421 Sequence<JSObject*> &arr = (mOurSequence4.Value());
422 JS::Rooted<JS::Value> temp(cx);
423 while (true) {
424 bool done;
425 if (!iter.next(&temp, &done)) {
426 return false;
427 }
428 if (done) {
429 break;
430 }
431 JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
432 if (!slotPtr) {
433 JS_ReportOutOfMemory(cx);
434 return false;
435 }
436 JSObject*& slot = *slotPtr;
437 if (temp.isObject()) {
438#ifdef __clang__1
439#pragma clang diagnostic push
440#pragma clang diagnostic ignored "-Wunreachable-code"
441#pragma clang diagnostic ignored "-Wunreachable-code-return"
442#endif // __clang__
443 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
444 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence4' member of DictContainingSequence");
445 return false;
446 }
447#ifdef __clang__1
448#pragma clang diagnostic pop
449#endif // __clang__
450 slot = &temp.toObject();
451 } else {
452 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence4' member of DictContainingSequence");
453 return false;
454 }
455 }
456 } else {
457 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence4' member of DictContainingSequence", "sequence");
458 return false;
459 }
460 mIsAnyMemberPresent = true;
461 }
462
463 if (!isNull) {
464 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence5_id, temp.ptr())) {
465 return false;
466 }
467 }
468 if (!isNull && !temp->isUndefined()) {
469 mOurSequence5.Construct();
470 if (temp.ref().isObject()) {
471 JS::ForOfIterator iter(cx);
472 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
473 return false;
474 }
475 if (!iter.valueIsIterable()) {
476 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence5' member of DictContainingSequence", "sequence");
477 return false;
478 }
479 Sequence<JSObject*> &arr = (mOurSequence5.Value());
480 JS::Rooted<JS::Value> temp(cx);
481 while (true) {
482 bool done;
483 if (!iter.next(&temp, &done)) {
484 return false;
485 }
486 if (done) {
487 break;
488 }
489 JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
490 if (!slotPtr) {
491 JS_ReportOutOfMemory(cx);
492 return false;
493 }
494 JSObject*& slot = *slotPtr;
495 if (temp.isObject()) {
496#ifdef __clang__1
497#pragma clang diagnostic push
498#pragma clang diagnostic ignored "-Wunreachable-code"
499#pragma clang diagnostic ignored "-Wunreachable-code-return"
500#endif // __clang__
501 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
502 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence5' member of DictContainingSequence");
503 return false;
504 }
505#ifdef __clang__1
506#pragma clang diagnostic pop
507#endif // __clang__
508 slot = &temp.toObject();
509 } else if (temp.isNullOrUndefined()) {
510 slot = nullptr;
511 } else {
512 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence5' member of DictContainingSequence");
513 return false;
514 }
515 }
516 } else {
517 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence5' member of DictContainingSequence", "sequence");
518 return false;
519 }
520 mIsAnyMemberPresent = true;
521 }
522
523 if (!isNull) {
524 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence6_id, temp.ptr())) {
525 return false;
526 }
527 }
528 if (!isNull && !temp->isUndefined()) {
529 mOurSequence6.Construct();
530 if (temp.ref().isObject()) {
531 JS::ForOfIterator iter(cx);
532 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
533 return false;
534 }
535 if (!iter.valueIsIterable()) {
536 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence6' member of DictContainingSequence", "sequence");
537 return false;
538 }
539 Sequence<JSObject*> &arr = (mOurSequence6.Value()).SetValue();
540 JS::Rooted<JS::Value> temp(cx);
541 while (true) {
542 bool done;
543 if (!iter.next(&temp, &done)) {
544 return false;
545 }
546 if (done) {
547 break;
548 }
549 JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
550 if (!slotPtr) {
551 JS_ReportOutOfMemory(cx);
552 return false;
553 }
554 JSObject*& slot = *slotPtr;
555 if (temp.isObject()) {
556#ifdef __clang__1
557#pragma clang diagnostic push
558#pragma clang diagnostic ignored "-Wunreachable-code"
559#pragma clang diagnostic ignored "-Wunreachable-code-return"
560#endif // __clang__
561 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
562 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence6' member of DictContainingSequence");
563 return false;
564 }
565#ifdef __clang__1
566#pragma clang diagnostic pop
567#endif // __clang__
568 slot = &temp.toObject();
569 } else {
570 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence6' member of DictContainingSequence");
571 return false;
572 }
573 }
574 } else if (temp.ref().isNullOrUndefined()) {
575 (mOurSequence6.Value()).SetNull();
576 } else {
577 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence6' member of DictContainingSequence", "sequence");
578 return false;
579 }
580 mIsAnyMemberPresent = true;
581 }
582
583 if (!isNull) {
584 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence7_id, temp.ptr())) {
585 return false;
586 }
587 }
588 if (!isNull && !temp->isUndefined()) {
589 mOurSequence7.Construct();
590 if (temp.ref().isObject()) {
591 JS::ForOfIterator iter(cx);
592 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
593 return false;
594 }
595 if (!iter.valueIsIterable()) {
596 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence7' member of DictContainingSequence", "sequence");
597 return false;
598 }
599 Sequence<JSObject*> &arr = (mOurSequence7.Value()).SetValue();
600 JS::Rooted<JS::Value> temp(cx);
601 while (true) {
602 bool done;
603 if (!iter.next(&temp, &done)) {
604 return false;
605 }
606 if (done) {
607 break;
608 }
609 JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
610 if (!slotPtr) {
611 JS_ReportOutOfMemory(cx);
612 return false;
613 }
614 JSObject*& slot = *slotPtr;
615 if (temp.isObject()) {
616#ifdef __clang__1
617#pragma clang diagnostic push
618#pragma clang diagnostic ignored "-Wunreachable-code"
619#pragma clang diagnostic ignored "-Wunreachable-code-return"
620#endif // __clang__
621 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
622 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence7' member of DictContainingSequence");
623 return false;
624 }
625#ifdef __clang__1
626#pragma clang diagnostic pop
627#endif // __clang__
628 slot = &temp.toObject();
629 } else if (temp.isNullOrUndefined()) {
630 slot = nullptr;
631 } else {
632 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence7' member of DictContainingSequence");
633 return false;
634 }
635 }
636 } else if (temp.ref().isNullOrUndefined()) {
637 (mOurSequence7.Value()).SetNull();
638 } else {
639 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence7' member of DictContainingSequence", "sequence");
640 return false;
641 }
642 mIsAnyMemberPresent = true;
643 }
644
645 if (!isNull) {
646 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence8_id, temp.ptr())) {
647 return false;
648 }
649 }
650 if (!isNull && !temp->isUndefined()) {
651 if (temp.ref().isObject()) {
652 JS::ForOfIterator iter(cx);
653 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
654 return false;
655 }
656 if (!iter.valueIsIterable()) {
657 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence8' member of DictContainingSequence", "sequence");
658 return false;
659 }
660 Sequence<JSObject*> &arr = mOurSequence8.SetValue();
661 JS::Rooted<JS::Value> temp(cx);
662 while (true) {
663 bool done;
664 if (!iter.next(&temp, &done)) {
665 return false;
666 }
667 if (done) {
668 break;
669 }
670 JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
671 if (!slotPtr) {
672 JS_ReportOutOfMemory(cx);
673 return false;
674 }
675 JSObject*& slot = *slotPtr;
676 if (temp.isObject()) {
677#ifdef __clang__1
678#pragma clang diagnostic push
679#pragma clang diagnostic ignored "-Wunreachable-code"
680#pragma clang diagnostic ignored "-Wunreachable-code-return"
681#endif // __clang__
682 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
683 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence8' member of DictContainingSequence");
684 return false;
685 }
686#ifdef __clang__1
687#pragma clang diagnostic pop
688#endif // __clang__
689 slot = &temp.toObject();
690 } else {
691 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence8' member of DictContainingSequence");
692 return false;
693 }
694 }
695 } else if (temp.ref().isNullOrUndefined()) {
696 mOurSequence8.SetNull();
697 } else {
698 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence8' member of DictContainingSequence", "sequence");
699 return false;
700 }
701 } else {
702 mOurSequence8.SetNull();
703 }
704 mIsAnyMemberPresent = true;
705
706 if (!isNull) {
707 if (!JS_GetPropertyById(cx, *object, atomsCache->ourSequence9_id, temp.ptr())) {
708 return false;
709 }
710 }
711 if (!isNull && !temp->isUndefined()) {
712 if (temp.ref().isObject()) {
713 JS::ForOfIterator iter(cx);
714 if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
715 return false;
716 }
717 if (!iter.valueIsIterable()) {
718 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence9' member of DictContainingSequence", "sequence");
719 return false;
720 }
721 Sequence<JSObject*> &arr = mOurSequence9.SetValue();
722 JS::Rooted<JS::Value> temp(cx);
723 while (true) {
724 bool done;
725 if (!iter.next(&temp, &done)) {
726 return false;
727 }
728 if (done) {
729 break;
730 }
731 JSObject** slotPtr = arr.AppendElement(nullptr, mozilla::fallible);
732 if (!slotPtr) {
733 JS_ReportOutOfMemory(cx);
734 return false;
735 }
736 JSObject*& slot = *slotPtr;
737 if (temp.isObject()) {
738#ifdef __clang__1
739#pragma clang diagnostic push
740#pragma clang diagnostic ignored "-Wunreachable-code"
741#pragma clang diagnostic ignored "-Wunreachable-code-return"
742#endif // __clang__
743 if ((passedToJSImpl) && !CallerSubsumes(temp)) {
744 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("element of 'ourSequence9' member of DictContainingSequence");
745 return false;
746 }
747#ifdef __clang__1
748#pragma clang diagnostic pop
749#endif // __clang__
750 slot = &temp.toObject();
751 } else if (temp.isNullOrUndefined()) {
752 slot = nullptr;
753 } else {
754 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Element of 'ourSequence9' member of DictContainingSequence");
755 return false;
756 }
757 }
758 } else if (temp.ref().isNullOrUndefined()) {
759 mOurSequence9.SetNull();
760 } else {
761 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("'ourSequence9' member of DictContainingSequence", "sequence");
762 return false;
763 }
764 } else {
765 mOurSequence9.SetNull();
766 }
767 mIsAnyMemberPresent = true;
768 return true;
769}
770
771bool
772DictContainingSequence::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
773{
774 // We don't want to use sourceDescription for our context here;
775 // that's not really what it's formatted for.
776 BindingCallContext cx(cx_, nullptr);
777 return Init(cx, val, sourceDescription, passedToJSImpl);
778}
779
780bool
781DictContainingSequence::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
782{
783 DictContainingSequenceAtoms* atomsCache = GetAtomCache<DictContainingSequenceAtoms>(cx);
784 if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
785 !InitIds(cx, atomsCache)) {
786 return false;
787 }
788
789 JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
790 if (!obj) {
791 return false;
792 }
793 rval.set(JS::ObjectValue(*obj));
794
795 if (mOurSequence.WasPassed()) {
796 do {
797 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
798 JS::Rooted<JS::Value> temp(cx);
799 Sequence<int32_t> const & currentValue = mOurSequence.InternalValue();
800
801 uint32_t length = currentValue.Length();
802 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
803 if (!returnArray) {
804 return false;
805 }
806 // Scope for 'tmp'
807 {
808 JS::Rooted<JS::Value> tmp(cx);
809 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
810 // Control block to let us common up the JS_DefineElement calls when there
811 // are different ways to succeed at wrapping the object.
812 do {
813 tmp.setInt32(int32_t(currentValue[sequenceIdx0]));
814 break;
815 } while (false);
816 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
817 JSPROP_ENUMERATE)) {
818 return false;
819 }
820 }
821 }
822 temp.setObject(*returnArray);
823 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence_id, temp, JSPROP_ENUMERATE)) {
824 return false;
825 }
826 break;
827 } while(false);
828 }
829
830 if (mOurSequence10.WasPassed()) {
831 do {
832 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
833 JS::Rooted<JS::Value> temp(cx);
834 Sequence<OwningFloatOrString> const & currentValue = mOurSequence10.InternalValue();
835
836 uint32_t length = currentValue.Length();
837 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
838 if (!returnArray) {
839 return false;
840 }
841 // Scope for 'tmp'
842 {
843 JS::Rooted<JS::Value> tmp(cx);
844 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
845 // Control block to let us common up the JS_DefineElement calls when there
846 // are different ways to succeed at wrapping the object.
847 do {
848 if (!currentValue[sequenceIdx0].ToJSVal(cx, returnArray, &tmp)) {
849 return false;
850 }
851 break;
852 } while (false);
853 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
854 JSPROP_ENUMERATE)) {
855 return false;
856 }
857 }
858 }
859 temp.setObject(*returnArray);
860 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence10_id, temp, JSPROP_ENUMERATE)) {
861 return false;
862 }
863 break;
864 } while(false);
865 }
866
867 if (mOurSequence2.WasPassed()) {
868 do {
869 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
870 JS::Rooted<JS::Value> temp(cx);
871 Sequence<OwningNonNull<mozilla::dom::TestInterface>> const & currentValue = mOurSequence2.InternalValue();
872
873 uint32_t length = currentValue.Length();
874 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
875 if (!returnArray) {
876 return false;
877 }
878 // Scope for 'tmp'
879 {
880 JS::Rooted<JS::Value> tmp(cx);
881 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
882 // Control block to let us common up the JS_DefineElement calls when there
883 // are different ways to succeed at wrapping the object.
884 do {
885 if (!GetOrCreateDOMReflector(cx, currentValue[sequenceIdx0], &tmp)) {
886 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 886); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile int*)
__null) = 886; __attribute__((nomerge)) ::abort(); } while (false
); } } while (false)
;
887 return false;
888 }
889 break;
890 } while (false);
891 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
892 JSPROP_ENUMERATE)) {
893 return false;
894 }
895 }
896 }
897 temp.setObject(*returnArray);
898 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence2_id, temp, JSPROP_ENUMERATE)) {
899 return false;
900 }
901 break;
902 } while(false);
903 }
904
905 if (mOurSequence3.WasPassed()) {
906 do {
907 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
908 JS::Rooted<JS::Value> temp(cx);
909 Sequence<JS::Value> const & currentValue = mOurSequence3.InternalValue();
910
911 uint32_t length = currentValue.Length();
912 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
913 if (!returnArray) {
914 return false;
915 }
916 // Scope for 'tmp'
917 {
918 JS::Rooted<JS::Value> tmp(cx);
919 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
920 // Control block to let us common up the JS_DefineElement calls when there
921 // are different ways to succeed at wrapping the object.
922 do {
923 JS::ExposeValueToActiveJS(currentValue[sequenceIdx0]);
924 tmp.set(currentValue[sequenceIdx0]);
925 if (!MaybeWrapValue(cx, &tmp)) {
926 return false;
927 }
928 break;
929 } while (false);
930 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
931 JSPROP_ENUMERATE)) {
932 return false;
933 }
934 }
935 }
936 temp.setObject(*returnArray);
937 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence3_id, temp, JSPROP_ENUMERATE)) {
938 return false;
939 }
940 break;
941 } while(false);
942 }
943
944 if (mOurSequence4.WasPassed()) {
945 do {
946 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
947 JS::Rooted<JS::Value> temp(cx);
948 Sequence<JSObject*> const & currentValue = mOurSequence4.InternalValue();
949
950 uint32_t length = currentValue.Length();
951 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
952 if (!returnArray) {
953 return false;
954 }
955 // Scope for 'tmp'
956 {
957 JS::Rooted<JS::Value> tmp(cx);
958 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
959 // Control block to let us common up the JS_DefineElement calls when there
960 // are different ways to succeed at wrapping the object.
961 do {
962 JS::ExposeObjectToActiveJS(currentValue[sequenceIdx0]);
963 tmp.setObject(*currentValue[sequenceIdx0]);
964 if (!MaybeWrapObjectValue(cx, &tmp)) {
965 return false;
966 }
967 break;
968 } while (false);
969 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
970 JSPROP_ENUMERATE)) {
971 return false;
972 }
973 }
974 }
975 temp.setObject(*returnArray);
976 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence4_id, temp, JSPROP_ENUMERATE)) {
977 return false;
978 }
979 break;
980 } while(false);
981 }
982
983 if (mOurSequence5.WasPassed()) {
984 do {
985 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
986 JS::Rooted<JS::Value> temp(cx);
987 Sequence<JSObject*> const & currentValue = mOurSequence5.InternalValue();
988
989 uint32_t length = currentValue.Length();
990 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
991 if (!returnArray) {
992 return false;
993 }
994 // Scope for 'tmp'
995 {
996 JS::Rooted<JS::Value> tmp(cx);
997 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
998 // Control block to let us common up the JS_DefineElement calls when there
999 // are different ways to succeed at wrapping the object.
1000 do {
1001 if (currentValue[sequenceIdx0]) {
1002 JS::ExposeObjectToActiveJS(currentValue[sequenceIdx0]);
1003 }
1004 tmp.setObjectOrNull(currentValue[sequenceIdx0]);
1005 if (!MaybeWrapObjectOrNullValue(cx, &tmp)) {
1006 return false;
1007 }
1008 break;
1009 } while (false);
1010 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1011 JSPROP_ENUMERATE)) {
1012 return false;
1013 }
1014 }
1015 }
1016 temp.setObject(*returnArray);
1017 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence5_id, temp, JSPROP_ENUMERATE)) {
1018 return false;
1019 }
1020 break;
1021 } while(false);
1022 }
1023
1024 if (mOurSequence6.WasPassed()) {
1025 do {
1026 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1027 JS::Rooted<JS::Value> temp(cx);
1028 Nullable<Sequence<JSObject*>> const & currentValue = mOurSequence6.InternalValue();
1029
1030 if (currentValue.IsNull()) {
1031 temp.setNull();
1032 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence6_id, temp, JSPROP_ENUMERATE)) {
1033 return false;
1034 }
1035 break;
1036 }
1037
1038 uint32_t length = currentValue.Value().Length();
1039 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
1040 if (!returnArray) {
1041 return false;
1042 }
1043 // Scope for 'tmp'
1044 {
1045 JS::Rooted<JS::Value> tmp(cx);
1046 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1047 // Control block to let us common up the JS_DefineElement calls when there
1048 // are different ways to succeed at wrapping the object.
1049 do {
1050 JS::ExposeObjectToActiveJS(currentValue.Value()[sequenceIdx0]);
1051 tmp.setObject(*currentValue.Value()[sequenceIdx0]);
1052 if (!MaybeWrapObjectValue(cx, &tmp)) {
1053 return false;
1054 }
1055 break;
1056 } while (false);
1057 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1058 JSPROP_ENUMERATE)) {
1059 return false;
1060 }
1061 }
1062 }
1063 temp.setObject(*returnArray);
1064 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence6_id, temp, JSPROP_ENUMERATE)) {
1065 return false;
1066 }
1067 break;
1068 } while(false);
1069 }
1070
1071 if (mOurSequence7.WasPassed()) {
1072 do {
1073 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1074 JS::Rooted<JS::Value> temp(cx);
1075 Nullable<Sequence<JSObject*>> const & currentValue = mOurSequence7.InternalValue();
1076
1077 if (currentValue.IsNull()) {
1078 temp.setNull();
1079 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence7_id, temp, JSPROP_ENUMERATE)) {
1080 return false;
1081 }
1082 break;
1083 }
1084
1085 uint32_t length = currentValue.Value().Length();
1086 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
1087 if (!returnArray) {
1088 return false;
1089 }
1090 // Scope for 'tmp'
1091 {
1092 JS::Rooted<JS::Value> tmp(cx);
1093 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1094 // Control block to let us common up the JS_DefineElement calls when there
1095 // are different ways to succeed at wrapping the object.
1096 do {
1097 if (currentValue.Value()[sequenceIdx0]) {
1098 JS::ExposeObjectToActiveJS(currentValue.Value()[sequenceIdx0]);
1099 }
1100 tmp.setObjectOrNull(currentValue.Value()[sequenceIdx0]);
1101 if (!MaybeWrapObjectOrNullValue(cx, &tmp)) {
1102 return false;
1103 }
1104 break;
1105 } while (false);
1106 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1107 JSPROP_ENUMERATE)) {
1108 return false;
1109 }
1110 }
1111 }
1112 temp.setObject(*returnArray);
1113 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence7_id, temp, JSPROP_ENUMERATE)) {
1114 return false;
1115 }
1116 break;
1117 } while(false);
1118 }
1119
1120 do {
1121 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1122 JS::Rooted<JS::Value> temp(cx);
1123 Nullable<Sequence<JSObject*>> const & currentValue = mOurSequence8;
1124
1125 if (currentValue.IsNull()) {
1126 temp.setNull();
1127 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence8_id, temp, JSPROP_ENUMERATE)) {
1128 return false;
1129 }
1130 break;
1131 }
1132
1133 uint32_t length = currentValue.Value().Length();
1134 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
1135 if (!returnArray) {
1136 return false;
1137 }
1138 // Scope for 'tmp'
1139 {
1140 JS::Rooted<JS::Value> tmp(cx);
1141 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1142 // Control block to let us common up the JS_DefineElement calls when there
1143 // are different ways to succeed at wrapping the object.
1144 do {
1145 JS::ExposeObjectToActiveJS(currentValue.Value()[sequenceIdx0]);
1146 tmp.setObject(*currentValue.Value()[sequenceIdx0]);
1147 if (!MaybeWrapObjectValue(cx, &tmp)) {
1148 return false;
1149 }
1150 break;
1151 } while (false);
1152 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1153 JSPROP_ENUMERATE)) {
1154 return false;
1155 }
1156 }
1157 }
1158 temp.setObject(*returnArray);
1159 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence8_id, temp, JSPROP_ENUMERATE)) {
1160 return false;
1161 }
1162 break;
1163 } while(false);
1164
1165 do {
1166 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1167 JS::Rooted<JS::Value> temp(cx);
1168 Nullable<Sequence<JSObject*>> const & currentValue = mOurSequence9;
1169
1170 if (currentValue.IsNull()) {
1171 temp.setNull();
1172 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence9_id, temp, JSPROP_ENUMERATE)) {
1173 return false;
1174 }
1175 break;
1176 }
1177
1178 uint32_t length = currentValue.Value().Length();
1179 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
1180 if (!returnArray) {
1181 return false;
1182 }
1183 // Scope for 'tmp'
1184 {
1185 JS::Rooted<JS::Value> tmp(cx);
1186 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1187 // Control block to let us common up the JS_DefineElement calls when there
1188 // are different ways to succeed at wrapping the object.
1189 do {
1190 if (currentValue.Value()[sequenceIdx0]) {
1191 JS::ExposeObjectToActiveJS(currentValue.Value()[sequenceIdx0]);
1192 }
1193 tmp.setObjectOrNull(currentValue.Value()[sequenceIdx0]);
1194 if (!MaybeWrapObjectOrNullValue(cx, &tmp)) {
1195 return false;
1196 }
1197 break;
1198 } while (false);
1199 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1200 JSPROP_ENUMERATE)) {
1201 return false;
1202 }
1203 }
1204 }
1205 temp.setObject(*returnArray);
1206 if (!JS_DefinePropertyById(cx, obj, atomsCache->ourSequence9_id, temp, JSPROP_ENUMERATE)) {
1207 return false;
1208 }
1209 break;
1210 } while(false);
1211
1212 return true;
1213}
1214
1215void
1216DictContainingSequence::TraceDictionary(JSTracer* trc)
1217{
1218 if (mOurSequence3.WasPassed()) {
1219 DoTraceSequence(trc, mOurSequence3.Value());
1220 }
1221
1222 if (mOurSequence4.WasPassed()) {
1223 DoTraceSequence(trc, mOurSequence4.Value());
1224 }
1225
1226 if (mOurSequence5.WasPassed()) {
1227 DoTraceSequence(trc, mOurSequence5.Value());
1228 }
1229
1230 if (mOurSequence6.WasPassed()) {
1231 if (!mOurSequence6.Value().IsNull()) {
1232 DoTraceSequence(trc, mOurSequence6.Value().Value());
1233 }
1234 }
1235
1236 if (mOurSequence7.WasPassed()) {
1237 if (!mOurSequence7.Value().IsNull()) {
1238 DoTraceSequence(trc, mOurSequence7.Value().Value());
1239 }
1240 }
1241
1242 if (!mOurSequence8.IsNull()) {
1243 DoTraceSequence(trc, mOurSequence8.Value());
1244 }
1245
1246 if (!mOurSequence9.IsNull()) {
1247 DoTraceSequence(trc, mOurSequence9.Value());
1248 }
1249}
1250
1251
1252
1253
1254
1255DictWithAllowSharedMembers::DictWithAllowSharedMembers()
1256{
1257 // Safe to pass a null context if we pass a null value
1258 Init();
1259}
1260
1261
1262
1263bool
1264DictWithAllowSharedMembers::InitIds(JSContext* cx, DictWithAllowSharedMembersAtoms* atomsCache)
1265{
1266 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 1266); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 1266; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1267
1268 // Initialize these in reverse order so that any failure leaves the first one
1269 // uninitialized.
1270 if (!atomsCache->f_id.init(cx, "f") ||
1271 !atomsCache->e_id.init(cx, "e") ||
1272 !atomsCache->d_id.init(cx, "d") ||
1273 !atomsCache->c_id.init(cx, "c") ||
1274 !atomsCache->b_id.init(cx, "b") ||
1275 !atomsCache->a_id.init(cx, "a")) {
1276 return false;
1277 }
1278 return true;
1279}
1280
1281bool
1282DictWithAllowSharedMembers::Init(const char* sourceDescription, bool passedToJSImpl)
1283{
1284 return true;
1285}
1286
1287void
1288DictWithAllowSharedMembers::TraceDictionary(JSTracer* trc)
1289{
1290 if (mA.WasPassed()) {
1291 mA.Value().TraceSelf(trc);
1292 }
1293
1294 if (mB.WasPassed()) {
1295 if (!mB.Value().IsNull()) {
1296 mB.Value().Value().TraceSelf(trc);
1297 }
1298 }
1299
1300 if (mC.WasPassed()) {
1301 mC.Value().TraceSelf(trc);
1302 }
1303
1304 if (mD.WasPassed()) {
1305 if (!mD.Value().IsNull()) {
1306 mD.Value().Value().TraceSelf(trc);
1307 }
1308 }
1309
1310 if (mE.WasPassed()) {
1311 mE.Value().TraceSelf(trc);
1312 }
1313
1314 if (mF.WasPassed()) {
1315 mF.Value().TraceSelf(trc);
1316 }
1317}
1318
1319
1320
1321DictWithBinaryType::DictWithBinaryType()
1322{
1323 // Safe to pass a null context if we pass a null value
1324 Init();
1325}
1326
1327
1328
1329
1330bool
1331DictWithBinaryType::InitIds(JSContext* cx, DictWithBinaryTypeAtoms* atomsCache)
1332{
1333 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 1333); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 1333; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1334
1335 // Initialize these in reverse order so that any failure leaves the first one
1336 // uninitialized.
1337 if (!atomsCache->otherTypeOfStorageStr_id.init(cx, "otherTypeOfStorageStr")) {
1338 return false;
1339 }
1340 return true;
1341}
1342
1343bool
1344DictWithBinaryType::Init(const char* sourceDescription, bool passedToJSImpl)
1345{
1346 {
1347 // scope for any temporaries our default value setting needs.
1348 mOtherTypeOfStorageStr.AssignLiteral(u"");
1349 }
1350 mIsAnyMemberPresent = true;
1351 return true;
1352}
1353
1354void
1355DictWithBinaryType::TraceDictionary(JSTracer* trc)
1356{
1357}
1358
1359DictWithBinaryType&
1360DictWithBinaryType::operator=(const DictWithBinaryType& aOther)
1361{
1362 DictionaryBase::operator=(aOther);
1363 mOtherTypeOfStorageStr = aOther.mOtherTypeOfStorageStr;
1364 return *this;
1365}
1366
1367bool
1368DictWithBinaryType::operator==(const DictWithBinaryType& aOther) const
1369{
1370 if (mOtherTypeOfStorageStr != aOther.mOtherTypeOfStorageStr) {
1371 return false;
1372 }
1373 return true;
1374}
1375
1376
1377
1378DictWithConditionalMembers::DictWithConditionalMembers()
1379{
1380 // Safe to pass a null context if we pass a null value
1381 Init();
1382}
1383
1384
1385
1386
1387bool
1388DictWithConditionalMembers::InitIds(JSContext* cx, DictWithConditionalMembersAtoms* atomsCache)
1389{
1390 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 1390); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 1390; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1391
1392 // Initialize these in reverse order so that any failure leaves the first one
1393 // uninitialized.
1394 if (!atomsCache->prefControlledMember_id.init(cx, "prefControlledMember") ||
1395 !atomsCache->funcControlledMember_id.init(cx, "funcControlledMember") ||
1396 !atomsCache->chromeOnlyMember_id.init(cx, "chromeOnlyMember") ||
1397 !atomsCache->chromeOnlyFuncControlledMember_id.init(cx, "chromeOnlyFuncControlledMember") ||
1398 !atomsCache->chromeOnlyFuncAndPrefControlledMember_id.init(cx, "chromeOnlyFuncAndPrefControlledMember")) {
1399 return false;
1400 }
1401 return true;
1402}
1403
1404bool
1405DictWithConditionalMembers::Init(const char* sourceDescription, bool passedToJSImpl)
1406{
1407 return true;
1408}
1409
1410void
1411DictWithConditionalMembers::TraceDictionary(JSTracer* trc)
1412{
1413}
1414
1415DictWithConditionalMembers&
1416DictWithConditionalMembers::operator=(const DictWithConditionalMembers& aOther)
1417{
1418 DictionaryBase::operator=(aOther);
1419 mChromeOnlyFuncAndPrefControlledMember.Reset();
1420 if (aOther.mChromeOnlyFuncAndPrefControlledMember.WasPassed()) {
1421 mChromeOnlyFuncAndPrefControlledMember.Construct(aOther.mChromeOnlyFuncAndPrefControlledMember.Value());
1422 }
1423 mChromeOnlyFuncControlledMember.Reset();
1424 if (aOther.mChromeOnlyFuncControlledMember.WasPassed()) {
1425 mChromeOnlyFuncControlledMember.Construct(aOther.mChromeOnlyFuncControlledMember.Value());
1426 }
1427 mChromeOnlyMember.Reset();
1428 if (aOther.mChromeOnlyMember.WasPassed()) {
1429 mChromeOnlyMember.Construct(aOther.mChromeOnlyMember.Value());
1430 }
1431 mFuncControlledMember.Reset();
1432 if (aOther.mFuncControlledMember.WasPassed()) {
1433 mFuncControlledMember.Construct(aOther.mFuncControlledMember.Value());
1434 }
1435 mPrefControlledMember.Reset();
1436 if (aOther.mPrefControlledMember.WasPassed()) {
1437 mPrefControlledMember.Construct(aOther.mPrefControlledMember.Value());
1438 }
1439 return *this;
1440}
1441
1442bool
1443DictWithConditionalMembers::operator==(const DictWithConditionalMembers& aOther) const
1444{
1445 if (mChromeOnlyFuncAndPrefControlledMember != aOther.mChromeOnlyFuncAndPrefControlledMember) {
1446 return false;
1447 }
1448 if (mChromeOnlyFuncControlledMember != aOther.mChromeOnlyFuncControlledMember) {
1449 return false;
1450 }
1451 if (mChromeOnlyMember != aOther.mChromeOnlyMember) {
1452 return false;
1453 }
1454 if (mFuncControlledMember != aOther.mFuncControlledMember) {
1455 return false;
1456 }
1457 if (mPrefControlledMember != aOther.mPrefControlledMember) {
1458 return false;
1459 }
1460 return true;
1461}
1462
1463
1464bool
1465OnlyForUseInInnerUnionOrCanvasPattern::TrySetToOnlyForUseInInnerUnion(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1466{
1467 tryNext = false;
1468 { // scope for memberSlot
1469 OnlyForUseInInnerUnion& memberSlot = RawSetAsOnlyForUseInInnerUnion();
1470 {
1471 int index;
1472 if (!binding_detail::FindEnumStringIndex<true>(cx, value,
1473 binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values,
1474 "OnlyForUseInInnerUnion", "OnlyForUseInInnerUnion branch of (OnlyForUseInInnerUnion or CanvasPattern)",
1475 &index)) {
1476 return false;
1477 }
1478 MOZ_ASSERT(index >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index >= 0",
"../TestCodeGenBinding.cpp", 1478); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "index >= 0" ")"); do { *((volatile int*)__null) = 1478
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
1479 memberSlot = static_cast<OnlyForUseInInnerUnion>(index);
1480 }
1481 }
1482 return true;
1483}
1484
1485bool
1486OnlyForUseInInnerUnionOrCanvasPattern::TrySetToOnlyForUseInInnerUnion(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1487{
1488 BindingCallContext cx(cx_, nullptr);
1489 return TrySetToOnlyForUseInInnerUnion(cx, value, tryNext, passedToJSImpl);
1490}
1491
1492
1493
1494
1495
1496
1497
1498bool
1499OnlyForUseInInnerUnionOrCanvasPattern::TrySetToCanvasPattern(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1500{
1501 tryNext = false;
1502 { // scope for memberSlot
1503 NonNull<mozilla::dom::CanvasPattern>& memberSlot = RawSetAsCanvasPattern();
1504 {
1505 // Our JSContext should be in the right global to do unwrapping in.
1506 nsresult rv = UnwrapObject<prototypes::id::CanvasPattern, mozilla::dom::CanvasPattern>(value, memberSlot, cx);
1507 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1508 DestroyCanvasPattern();
1509 tryNext = true;
1510 return true;
1511 }
1512 }
1513 }
1514 return true;
1515}
1516
1517bool
1518OnlyForUseInInnerUnionOrCanvasPattern::TrySetToCanvasPattern(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1519{
1520 BindingCallContext cx(cx_, nullptr);
1521 return TrySetToCanvasPattern(cx, value, tryNext, passedToJSImpl);
1522}
1523
1524
1525
1526
1527
1528
1529
1530bool
1531OnlyForUseInInnerUnionOrCanvasPattern::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
1532{
1533 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 1533); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 1533; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1534
1535 bool done = false, failed = false, tryNext;
1536 if (value.isObject()) {
1537 done = (failed = !TrySetToCanvasPattern(cx, value, tryNext, passedToJSImpl)) || !tryNext;
1538 }
1539 if (!done) {
1540 do {
1541 done = (failed = !TrySetToOnlyForUseInInnerUnion(cx, value, tryNext)) || !tryNext;
1542 break;
1543 } while (false);
1544 }
1545 if (failed) {
1546 return false;
1547 }
1548 if (!done) {
1549 cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "CanvasPattern");
1550 return false;
1551 }
1552 return true;
1553}
1554
1555bool
1556OnlyForUseInInnerUnionOrCanvasPattern::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
1557{
1558 BindingCallContext cx(cx_, nullptr);
1559 return Init(cx, value, sourceDescription, passedToJSImpl);
1560}
1561
1562
1563bool
1564OnlyForUseInInnerUnionOrCanvasPattern::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
1565{
1566 switch (mType) {
1567 case eUninitialized: {
1568 return false;
1569 }
1570 case eOnlyForUseInInnerUnion: {
1571 if (!ToJSValue(cx, mValue.mOnlyForUseInInnerUnion.Value(), rval)) {
1572 return false;
1573 }
1574 return true;
1575 }
1576 case eCanvasPattern: {
1577 if (!GetOrCreateDOMReflector(cx, mValue.mCanvasPattern.Value(), rval)) {
1578 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 1578); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 1578; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1579 return false;
1580 }
1581 return true;
1582 }
1583 default: {
1584 return false;
1585 }
1586 }
1587}
1588
1589
1590
1591OwningOnlyForUseInInnerUnionOrCanvasPattern::OwningOnlyForUseInInnerUnionOrCanvasPattern(OwningOnlyForUseInInnerUnionOrCanvasPattern&& aOther)
1592 : mType(eUninitialized)
1593{
1594 switch (aOther.mType) {
1595 case eUninitialized: {
1596 MOZ_ASSERT(mType == eUninitialized,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 1597); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 1597; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
1597 "We need to destroy ourselves?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 1597); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 1597; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1598 break;
1599 }
1600 case eOnlyForUseInInnerUnion: {
1601 mType = eOnlyForUseInInnerUnion;
1602 mValue.mOnlyForUseInInnerUnion.SetValue(std::move(aOther.mValue.mOnlyForUseInInnerUnion.Value()));
1603 break;
1604 }
1605 case eCanvasPattern: {
1606 mType = eCanvasPattern;
1607 mValue.mCanvasPattern.SetValue(std::move(aOther.mValue.mCanvasPattern.Value()));
1608 break;
1609 }
1610 }
1611}
1612
1613
1614
1615bool
1616OwningOnlyForUseInInnerUnionOrCanvasPattern::TrySetToOnlyForUseInInnerUnion(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1617{
1618 tryNext = false;
1619 { // scope for memberSlot
1620 OnlyForUseInInnerUnion& memberSlot = RawSetAsOnlyForUseInInnerUnion();
1621 {
1622 int index;
1623 if (!binding_detail::FindEnumStringIndex<true>(cx, value,
1624 binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values,
1625 "OnlyForUseInInnerUnion", "OnlyForUseInInnerUnion branch of (OnlyForUseInInnerUnion or CanvasPattern)",
1626 &index)) {
1627 return false;
1628 }
1629 MOZ_ASSERT(index >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index >= 0",
"../TestCodeGenBinding.cpp", 1629); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "index >= 0" ")"); do { *((volatile int*)__null) = 1629
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
1630 memberSlot = static_cast<OnlyForUseInInnerUnion>(index);
1631 }
1632 }
1633 return true;
1634}
1635
1636bool
1637OwningOnlyForUseInInnerUnionOrCanvasPattern::TrySetToOnlyForUseInInnerUnion(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1638{
1639 BindingCallContext cx(cx_, nullptr);
1640 return TrySetToOnlyForUseInInnerUnion(cx, value, tryNext, passedToJSImpl);
1641}
1642
1643[[nodiscard]] OnlyForUseInInnerUnion&
1644OwningOnlyForUseInInnerUnionOrCanvasPattern::RawSetAsOnlyForUseInInnerUnion()
1645{
1646 if (mType == eOnlyForUseInInnerUnion) {
1647 return mValue.mOnlyForUseInInnerUnion.Value();
1648 }
1649 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 1649); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 1649; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1650 mType = eOnlyForUseInInnerUnion;
1651 return mValue.mOnlyForUseInInnerUnion.SetValue();
1652}
1653
1654[[nodiscard]] OnlyForUseInInnerUnion&
1655OwningOnlyForUseInInnerUnionOrCanvasPattern::SetAsOnlyForUseInInnerUnion()
1656{
1657 if (mType == eOnlyForUseInInnerUnion) {
1658 return mValue.mOnlyForUseInInnerUnion.Value();
1659 }
1660 Uninit();
1661 mType = eOnlyForUseInInnerUnion;
1662 return mValue.mOnlyForUseInInnerUnion.SetValue();
1663}
1664
1665
1666void
1667OwningOnlyForUseInInnerUnionOrCanvasPattern::DestroyOnlyForUseInInnerUnion()
1668{
1669 MOZ_RELEASE_ASSERT(IsOnlyForUseInInnerUnion(), "Wrong type!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsOnlyForUseInInnerUnion())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsOnlyForUseInInnerUnion()))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsOnlyForUseInInnerUnion()"
" (" "Wrong type!" ")", "../TestCodeGenBinding.cpp", 1669); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "IsOnlyForUseInInnerUnion()" ") (" "Wrong type!"
")"); do { *((volatile int*)__null) = 1669; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1670 mValue.mOnlyForUseInInnerUnion.Destroy();
1671 mType = eUninitialized;
1672}
1673
1674
1675
1676bool
1677OwningOnlyForUseInInnerUnionOrCanvasPattern::TrySetToCanvasPattern(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1678{
1679 tryNext = false;
1680 { // scope for memberSlot
1681 OwningNonNull<mozilla::dom::CanvasPattern>& memberSlot = RawSetAsCanvasPattern();
1682 static_assert(IsRefcounted<mozilla::dom::CanvasPattern>::value, "We can only store refcounted classes.");
1683 {
1684 // Our JSContext should be in the right global to do unwrapping in.
1685 nsresult rv = UnwrapObject<prototypes::id::CanvasPattern, mozilla::dom::CanvasPattern>(value, memberSlot, cx);
1686 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
1687 DestroyCanvasPattern();
1688 tryNext = true;
1689 return true;
1690 }
1691 }
1692 }
1693 return true;
1694}
1695
1696bool
1697OwningOnlyForUseInInnerUnionOrCanvasPattern::TrySetToCanvasPattern(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1698{
1699 BindingCallContext cx(cx_, nullptr);
1700 return TrySetToCanvasPattern(cx, value, tryNext, passedToJSImpl);
1701}
1702
1703[[nodiscard]] OwningNonNull<mozilla::dom::CanvasPattern>&
1704OwningOnlyForUseInInnerUnionOrCanvasPattern::RawSetAsCanvasPattern()
1705{
1706 if (mType == eCanvasPattern) {
1707 return mValue.mCanvasPattern.Value();
1708 }
1709 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 1709); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 1709; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1710 mType = eCanvasPattern;
1711 return mValue.mCanvasPattern.SetValue();
1712}
1713
1714[[nodiscard]] OwningNonNull<mozilla::dom::CanvasPattern>&
1715OwningOnlyForUseInInnerUnionOrCanvasPattern::SetAsCanvasPattern()
1716{
1717 if (mType == eCanvasPattern) {
1718 return mValue.mCanvasPattern.Value();
1719 }
1720 Uninit();
1721 mType = eCanvasPattern;
1722 return mValue.mCanvasPattern.SetValue();
1723}
1724
1725
1726void
1727OwningOnlyForUseInInnerUnionOrCanvasPattern::DestroyCanvasPattern()
1728{
1729 MOZ_RELEASE_ASSERT(IsCanvasPattern(), "Wrong type!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsCanvasPattern())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsCanvasPattern()))), 0))) {
do { } while (false); MOZ_ReportAssertionFailure("IsCanvasPattern()"
" (" "Wrong type!" ")", "../TestCodeGenBinding.cpp", 1729); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "IsCanvasPattern()" ") (" "Wrong type!"
")"); do { *((volatile int*)__null) = 1729; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
1730 mValue.mCanvasPattern.Destroy();
1731 mType = eUninitialized;
1732}
1733
1734
1735
1736bool
1737OwningOnlyForUseInInnerUnionOrCanvasPattern::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
1738{
1739 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 1739); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 1739; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1740
1741 bool done = false, failed = false, tryNext;
1742 if (value.isObject()) {
1743 done = (failed = !TrySetToCanvasPattern(cx, value, tryNext, passedToJSImpl)) || !tryNext;
1744 }
1745 if (!done) {
1746 do {
1747 done = (failed = !TrySetToOnlyForUseInInnerUnion(cx, value, tryNext)) || !tryNext;
1748 break;
1749 } while (false);
1750 }
1751 if (failed) {
1752 return false;
1753 }
1754 if (!done) {
1755 cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "CanvasPattern");
1756 return false;
1757 }
1758 return true;
1759}
1760
1761bool
1762OwningOnlyForUseInInnerUnionOrCanvasPattern::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
1763{
1764 BindingCallContext cx(cx_, nullptr);
1765 return Init(cx, value, sourceDescription, passedToJSImpl);
1766}
1767
1768void
1769OwningOnlyForUseInInnerUnionOrCanvasPattern::Uninit()
1770{
1771 switch (mType) {
1772 case eUninitialized: {
1773 break;
1774 }
1775 case eOnlyForUseInInnerUnion: {
1776 DestroyOnlyForUseInInnerUnion();
1777 break;
1778 }
1779 case eCanvasPattern: {
1780 DestroyCanvasPattern();
1781 break;
1782 }
1783 }
1784}
1785
1786bool
1787OwningOnlyForUseInInnerUnionOrCanvasPattern::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
1788{
1789 switch (mType) {
1790 case eUninitialized: {
1791 return false;
1792 }
1793 case eOnlyForUseInInnerUnion: {
1794 if (!ToJSValue(cx, mValue.mOnlyForUseInInnerUnion.Value(), rval)) {
1795 return false;
1796 }
1797 return true;
1798 }
1799 case eCanvasPattern: {
1800 if (!GetOrCreateDOMReflector(cx, mValue.mCanvasPattern.Value(), rval)) {
1801 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 1801); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 1801; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1802 return false;
1803 }
1804 return true;
1805 }
1806 default: {
1807 return false;
1808 }
1809 }
1810}
1811
1812OwningOnlyForUseInInnerUnionOrCanvasPattern&
1813OwningOnlyForUseInInnerUnionOrCanvasPattern::operator=(OwningOnlyForUseInInnerUnionOrCanvasPattern&& aOther)
1814{
1815 this->~OwningOnlyForUseInInnerUnionOrCanvasPattern();
1816 new (this) OwningOnlyForUseInInnerUnionOrCanvasPattern (std::move(aOther));
1817 return *this;
1818}
1819
1820
1821OwningOnlyForUseInInnerUnionOrCanvasPattern&
1822OwningOnlyForUseInInnerUnionOrCanvasPattern::operator=(const OwningOnlyForUseInInnerUnionOrCanvasPattern& aOther)
1823{
1824 switch (aOther.mType) {
1825 case eUninitialized: {
1826 MOZ_ASSERT(mType == eUninitialized,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 1827); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 1827; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
1827 "We need to destroy ourselves?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 1827); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 1827; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1828 break;
1829 }
1830 case eOnlyForUseInInnerUnion: {
1831 SetAsOnlyForUseInInnerUnion() = aOther.GetAsOnlyForUseInInnerUnion();
1832 break;
1833 }
1834 case eCanvasPattern: {
1835 SetAsCanvasPattern() = aOther.GetAsCanvasPattern();
1836 break;
1837 }
1838 }
1839 return *this;
1840}
1841
1842
1843bool
1844OnlyForUseInInnerUnionOrLongSequence::TrySetToOnlyForUseInInnerUnion(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1845{
1846 tryNext = false;
1847 { // scope for memberSlot
1848 OnlyForUseInInnerUnion& memberSlot = RawSetAsOnlyForUseInInnerUnion();
1849 {
1850 int index;
1851 if (!binding_detail::FindEnumStringIndex<true>(cx, value,
1852 binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values,
1853 "OnlyForUseInInnerUnion", "OnlyForUseInInnerUnion branch of (OnlyForUseInInnerUnion or sequence<long>)",
1854 &index)) {
1855 return false;
1856 }
1857 MOZ_ASSERT(index >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index >= 0",
"../TestCodeGenBinding.cpp", 1857); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "index >= 0" ")"); do { *((volatile int*)__null) = 1857
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
1858 memberSlot = static_cast<OnlyForUseInInnerUnion>(index);
1859 }
1860 }
1861 return true;
1862}
1863
1864bool
1865OnlyForUseInInnerUnionOrLongSequence::TrySetToOnlyForUseInInnerUnion(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1866{
1867 BindingCallContext cx(cx_, nullptr);
1868 return TrySetToOnlyForUseInInnerUnion(cx, value, tryNext, passedToJSImpl);
1869}
1870
1871
1872
1873
1874
1875
1876
1877bool
1878OnlyForUseInInnerUnionOrLongSequence::TrySetToLongSequence(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1879{
1880 tryNext = false;
1881 { // scope for memberSlot
1882 binding_detail::AutoSequence<int32_t>& memberSlot = RawSetAsLongSequence();
1883 JS::ForOfIterator iter(cx);
1884 if (!iter.init(value, JS::ForOfIterator::AllowNonIterable)) {
1885 return false;
1886 }
1887 if (!iter.valueIsIterable()) {
1888 DestroyLongSequence();
1889 tryNext = true;
1890 return true;
1891 }
1892 binding_detail::AutoSequence<int32_t> &arr = memberSlot;
1893 JS::Rooted<JS::Value> temp(cx);
1894 while (true) {
1895 bool done;
1896 if (!iter.next(&temp, &done)) {
1897 return false;
1898 }
1899 if (done) {
1900 break;
1901 }
1902 int32_t* slotPtr = arr.AppendElement(mozilla::fallible);
1903 if (!slotPtr) {
1904 JS_ReportOutOfMemory(cx);
1905 return false;
1906 }
1907 int32_t& slot = *slotPtr;
1908 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Element of sequence<long> branch of (OnlyForUseInInnerUnion or sequence<long>)", &slot)) {
1909 return false;
1910 }
1911 }
1912 }
1913 return true;
1914}
1915
1916bool
1917OnlyForUseInInnerUnionOrLongSequence::TrySetToLongSequence(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
1918{
1919 BindingCallContext cx(cx_, nullptr);
1920 return TrySetToLongSequence(cx, value, tryNext, passedToJSImpl);
1921}
1922
1923
1924
1925
1926
1927
1928
1929bool
1930OnlyForUseInInnerUnionOrLongSequence::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
1931{
1932 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 1932); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 1932; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
1933
1934 bool done = false, failed = false, tryNext;
1935 if (value.isObject()) {
1936 done = (failed = !TrySetToLongSequence(cx, value, tryNext, passedToJSImpl)) || !tryNext;
1937 }
1938 if (!done) {
1939 do {
1940 done = (failed = !TrySetToOnlyForUseInInnerUnion(cx, value, tryNext)) || !tryNext;
1941 break;
1942 } while (false);
1943 }
1944 if (failed) {
1945 return false;
1946 }
1947 if (!done) {
1948 cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "sequence<long>");
1949 return false;
1950 }
1951 return true;
1952}
1953
1954bool
1955OnlyForUseInInnerUnionOrLongSequence::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
1956{
1957 BindingCallContext cx(cx_, nullptr);
1958 return Init(cx, value, sourceDescription, passedToJSImpl);
1959}
1960
1961
1962bool
1963OnlyForUseInInnerUnionOrLongSequence::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
1964{
1965 switch (mType) {
1966 case eUninitialized: {
1967 return false;
1968 }
1969 case eOnlyForUseInInnerUnion: {
1970 if (!ToJSValue(cx, mValue.mOnlyForUseInInnerUnion.Value(), rval)) {
1971 return false;
1972 }
1973 return true;
1974 }
1975 case eLongSequence: {
1976
1977 uint32_t length = mValue.mLongSequence.Value().Length();
1978 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
1979 if (!returnArray) {
1980 return false;
1981 }
1982 // Scope for 'tmp'
1983 {
1984 JS::Rooted<JS::Value> tmp(cx);
1985 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
1986 // Control block to let us common up the JS_DefineElement calls when there
1987 // are different ways to succeed at wrapping the object.
1988 do {
1989 tmp.setInt32(int32_t(mValue.mLongSequence.Value()[sequenceIdx0]));
1990 break;
1991 } while (false);
1992 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
1993 JSPROP_ENUMERATE)) {
1994 return false;
1995 }
1996 }
1997 }
1998 rval.setObject(*returnArray);
1999 return true;
2000 }
2001 default: {
2002 return false;
2003 }
2004 }
2005}
2006
2007
2008
2009OwningOnlyForUseInInnerUnionOrLongSequence::OwningOnlyForUseInInnerUnionOrLongSequence(OwningOnlyForUseInInnerUnionOrLongSequence&& aOther)
2010 : mType(eUninitialized)
2011{
2012 switch (aOther.mType) {
2013 case eUninitialized: {
2014 MOZ_ASSERT(mType == eUninitialized,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 2015); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 2015; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
2015 "We need to destroy ourselves?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 2015); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 2015; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2016 break;
2017 }
2018 case eOnlyForUseInInnerUnion: {
2019 mType = eOnlyForUseInInnerUnion;
2020 mValue.mOnlyForUseInInnerUnion.SetValue(std::move(aOther.mValue.mOnlyForUseInInnerUnion.Value()));
2021 break;
2022 }
2023 case eLongSequence: {
2024 mType = eLongSequence;
2025 mValue.mLongSequence.SetValue(std::move(aOther.mValue.mLongSequence.Value()));
2026 break;
2027 }
2028 }
2029}
2030
2031
2032
2033bool
2034OwningOnlyForUseInInnerUnionOrLongSequence::TrySetToOnlyForUseInInnerUnion(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
2035{
2036 tryNext = false;
2037 { // scope for memberSlot
2038 OnlyForUseInInnerUnion& memberSlot = RawSetAsOnlyForUseInInnerUnion();
2039 {
2040 int index;
2041 if (!binding_detail::FindEnumStringIndex<true>(cx, value,
2042 binding_detail::EnumStrings<OnlyForUseInInnerUnion>::Values,
2043 "OnlyForUseInInnerUnion", "OnlyForUseInInnerUnion branch of (OnlyForUseInInnerUnion or sequence<long>)",
2044 &index)) {
2045 return false;
2046 }
2047 MOZ_ASSERT(index >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index >= 0",
"../TestCodeGenBinding.cpp", 2047); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "index >= 0" ")"); do { *((volatile int*)__null) = 2047
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
2048 memberSlot = static_cast<OnlyForUseInInnerUnion>(index);
2049 }
2050 }
2051 return true;
2052}
2053
2054bool
2055OwningOnlyForUseInInnerUnionOrLongSequence::TrySetToOnlyForUseInInnerUnion(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
2056{
2057 BindingCallContext cx(cx_, nullptr);
2058 return TrySetToOnlyForUseInInnerUnion(cx, value, tryNext, passedToJSImpl);
2059}
2060
2061[[nodiscard]] OnlyForUseInInnerUnion&
2062OwningOnlyForUseInInnerUnionOrLongSequence::RawSetAsOnlyForUseInInnerUnion()
2063{
2064 if (mType == eOnlyForUseInInnerUnion) {
2065 return mValue.mOnlyForUseInInnerUnion.Value();
2066 }
2067 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 2067); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 2067; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2068 mType = eOnlyForUseInInnerUnion;
2069 return mValue.mOnlyForUseInInnerUnion.SetValue();
2070}
2071
2072[[nodiscard]] OnlyForUseInInnerUnion&
2073OwningOnlyForUseInInnerUnionOrLongSequence::SetAsOnlyForUseInInnerUnion()
2074{
2075 if (mType == eOnlyForUseInInnerUnion) {
2076 return mValue.mOnlyForUseInInnerUnion.Value();
2077 }
2078 Uninit();
2079 mType = eOnlyForUseInInnerUnion;
2080 return mValue.mOnlyForUseInInnerUnion.SetValue();
2081}
2082
2083
2084void
2085OwningOnlyForUseInInnerUnionOrLongSequence::DestroyOnlyForUseInInnerUnion()
2086{
2087 MOZ_RELEASE_ASSERT(IsOnlyForUseInInnerUnion(), "Wrong type!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsOnlyForUseInInnerUnion())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsOnlyForUseInInnerUnion()))
), 0))) { do { } while (false); MOZ_ReportAssertionFailure("IsOnlyForUseInInnerUnion()"
" (" "Wrong type!" ")", "../TestCodeGenBinding.cpp", 2087); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "IsOnlyForUseInInnerUnion()" ") (" "Wrong type!"
")"); do { *((volatile int*)__null) = 2087; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2088 mValue.mOnlyForUseInInnerUnion.Destroy();
2089 mType = eUninitialized;
2090}
2091
2092
2093
2094bool
2095OwningOnlyForUseInInnerUnionOrLongSequence::TrySetToLongSequence(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
2096{
2097 tryNext = false;
2098 { // scope for memberSlot
2099 Sequence<int32_t>& memberSlot = RawSetAsLongSequence();
2100 JS::ForOfIterator iter(cx);
2101 if (!iter.init(value, JS::ForOfIterator::AllowNonIterable)) {
2102 return false;
2103 }
2104 if (!iter.valueIsIterable()) {
2105 DestroyLongSequence();
2106 tryNext = true;
2107 return true;
2108 }
2109 Sequence<int32_t> &arr = memberSlot;
2110 JS::Rooted<JS::Value> temp(cx);
2111 while (true) {
2112 bool done;
2113 if (!iter.next(&temp, &done)) {
2114 return false;
2115 }
2116 if (done) {
2117 break;
2118 }
2119 int32_t* slotPtr = arr.AppendElement(mozilla::fallible);
2120 if (!slotPtr) {
2121 JS_ReportOutOfMemory(cx);
2122 return false;
2123 }
2124 int32_t& slot = *slotPtr;
2125 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Element of sequence<long> branch of (OnlyForUseInInnerUnion or sequence<long>)", &slot)) {
2126 return false;
2127 }
2128 }
2129 }
2130 return true;
2131}
2132
2133bool
2134OwningOnlyForUseInInnerUnionOrLongSequence::TrySetToLongSequence(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
2135{
2136 BindingCallContext cx(cx_, nullptr);
2137 return TrySetToLongSequence(cx, value, tryNext, passedToJSImpl);
2138}
2139
2140[[nodiscard]] Sequence<int32_t>&
2141OwningOnlyForUseInInnerUnionOrLongSequence::RawSetAsLongSequence()
2142{
2143 if (mType == eLongSequence) {
2144 return mValue.mLongSequence.Value();
2145 }
2146 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 2146); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 2146; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2147 mType = eLongSequence;
2148 return mValue.mLongSequence.SetValue();
2149}
2150
2151[[nodiscard]] Sequence<int32_t>&
2152OwningOnlyForUseInInnerUnionOrLongSequence::SetAsLongSequence()
2153{
2154 if (mType == eLongSequence) {
2155 return mValue.mLongSequence.Value();
2156 }
2157 Uninit();
2158 mType = eLongSequence;
2159 return mValue.mLongSequence.SetValue();
2160}
2161
2162
2163void
2164OwningOnlyForUseInInnerUnionOrLongSequence::DestroyLongSequence()
2165{
2166 MOZ_RELEASE_ASSERT(IsLongSequence(), "Wrong type!")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(IsLongSequence())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(IsLongSequence()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("IsLongSequence()"
" (" "Wrong type!" ")", "../TestCodeGenBinding.cpp", 2166); AnnotateMozCrashReason
("MOZ_RELEASE_ASSERT" "(" "IsLongSequence()" ") (" "Wrong type!"
")"); do { *((volatile int*)__null) = 2166; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2167 mValue.mLongSequence.Destroy();
2168 mType = eUninitialized;
2169}
2170
2171
2172
2173bool
2174OwningOnlyForUseInInnerUnionOrLongSequence::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
2175{
2176 MOZ_ASSERT(mType == eUninitialized)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
, "../TestCodeGenBinding.cpp", 2176); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "mType == eUninitialized" ")"); do { *((volatile
int*)__null) = 2176; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2177
2178 bool done = false, failed = false, tryNext;
2179 if (value.isObject()) {
2180 done = (failed = !TrySetToLongSequence(cx, value, tryNext, passedToJSImpl)) || !tryNext;
2181 }
2182 if (!done) {
2183 do {
2184 done = (failed = !TrySetToOnlyForUseInInnerUnion(cx, value, tryNext)) || !tryNext;
2185 break;
2186 } while (false);
2187 }
2188 if (failed) {
2189 return false;
2190 }
2191 if (!done) {
2192 cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "sequence<long>");
2193 return false;
2194 }
2195 return true;
2196}
2197
2198bool
2199OwningOnlyForUseInInnerUnionOrLongSequence::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
2200{
2201 BindingCallContext cx(cx_, nullptr);
2202 return Init(cx, value, sourceDescription, passedToJSImpl);
2203}
2204
2205void
2206OwningOnlyForUseInInnerUnionOrLongSequence::Uninit()
2207{
2208 switch (mType) {
2209 case eUninitialized: {
2210 break;
2211 }
2212 case eOnlyForUseInInnerUnion: {
2213 DestroyOnlyForUseInInnerUnion();
2214 break;
2215 }
2216 case eLongSequence: {
2217 DestroyLongSequence();
2218 break;
2219 }
2220 }
2221}
2222
2223bool
2224OwningOnlyForUseInInnerUnionOrLongSequence::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
2225{
2226 switch (mType) {
2227 case eUninitialized: {
2228 return false;
2229 }
2230 case eOnlyForUseInInnerUnion: {
2231 if (!ToJSValue(cx, mValue.mOnlyForUseInInnerUnion.Value(), rval)) {
2232 return false;
2233 }
2234 return true;
2235 }
2236 case eLongSequence: {
2237
2238 uint32_t length = mValue.mLongSequence.Value().Length();
2239 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
2240 if (!returnArray) {
2241 return false;
2242 }
2243 // Scope for 'tmp'
2244 {
2245 JS::Rooted<JS::Value> tmp(cx);
2246 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
2247 // Control block to let us common up the JS_DefineElement calls when there
2248 // are different ways to succeed at wrapping the object.
2249 do {
2250 tmp.setInt32(int32_t(mValue.mLongSequence.Value()[sequenceIdx0]));
2251 break;
2252 } while (false);
2253 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
2254 JSPROP_ENUMERATE)) {
2255 return false;
2256 }
2257 }
2258 }
2259 rval.setObject(*returnArray);
2260 return true;
2261 }
2262 default: {
2263 return false;
2264 }
2265 }
2266}
2267
2268OwningOnlyForUseInInnerUnionOrLongSequence&
2269OwningOnlyForUseInInnerUnionOrLongSequence::operator=(OwningOnlyForUseInInnerUnionOrLongSequence&& aOther)
2270{
2271 this->~OwningOnlyForUseInInnerUnionOrLongSequence();
2272 new (this) OwningOnlyForUseInInnerUnionOrLongSequence (std::move(aOther));
2273 return *this;
2274}
2275
2276
2277OwningOnlyForUseInInnerUnionOrLongSequence&
2278OwningOnlyForUseInInnerUnionOrLongSequence::operator=(const OwningOnlyForUseInInnerUnionOrLongSequence& aOther)
2279{
2280 switch (aOther.mType) {
2281 case eUninitialized: {
2282 MOZ_ASSERT(mType == eUninitialized,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 2283); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 2283; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
2283 "We need to destroy ourselves?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(mType == eUninitialized)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(mType == eUninitialized))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("mType == eUninitialized"
" (" "We need to destroy ourselves?" ")", "../TestCodeGenBinding.cpp"
, 2283); AnnotateMozCrashReason("MOZ_ASSERT" "(" "mType == eUninitialized"
") (" "We need to destroy ourselves?" ")"); do { *((volatile
int*)__null) = 2283; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2284 break;
2285 }
2286 case eOnlyForUseInInnerUnion: {
2287 SetAsOnlyForUseInInnerUnion() = aOther.GetAsOnlyForUseInInnerUnion();
2288 break;
2289 }
2290 case eLongSequence: {
2291 SetAsLongSequence() = aOther.GetAsLongSequence();
2292 break;
2293 }
2294 }
2295 return *this;
2296}
2297
2298
2299
2300ParentDict::ParentDict()
2301 : GrandparentDict(FastDictionaryInitializer())
2302{
2303 // Safe to pass a null context if we pass a null value
2304 Init(nullptr, JS::NullHandleValue);
2305}
2306
2307
2308
2309bool
2310ParentDict::InitIds(JSContext* cx, ParentDictAtoms* atomsCache)
2311{
2312 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 2312); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 2312; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2313
2314 // Initialize these in reverse order so that any failure leaves the first one
2315 // uninitialized.
2316 if (!atomsCache->someNullableInterface_id.init(cx, "someNullableInterface") ||
2317 !atomsCache->someInterface_id.init(cx, "someInterface") ||
2318 !atomsCache->someExternalInterface_id.init(cx, "someExternalInterface") ||
2319 !atomsCache->parentAny_id.init(cx, "parentAny") ||
2320 !atomsCache->c_id.init(cx, "c")) {
2321 return false;
2322 }
2323 return true;
2324}
2325
2326bool
2327ParentDict::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
2328{
2329 // Passing a null JSContext is OK only if we're initing from null,
2330 // Since in that case we will not have to do any property gets
2331 // Also evaluate isNullOrUndefined in order to avoid false-positive
2332 // checkers by static analysis tools
2333 MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined())do { if (!cx) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(val.isNull() && val.isNullOrUndefined())
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(val.isNull() && val.isNullOrUndefined()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("val.isNull() && val.isNullOrUndefined()"
, "../TestCodeGenBinding.cpp", 2333); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "val.isNull() && val.isNullOrUndefined()"
")"); do { *((volatile int*)__null) = 2333; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
2334 ParentDictAtoms* atomsCache = nullptr;
2335 if (cx) {
2336 atomsCache = GetAtomCache<ParentDictAtoms>(cx);
2337 if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
2338 !InitIds(cx, atomsCache)) {
2339 return false;
2340 }
2341 }
2342
2343 // Per spec, we init the parent's members first
2344 if (!GrandparentDict::Init(cx, val)) {
2345 return false;
2346 }
2347
2348 bool isNull = val.isNullOrUndefined();
2349 // We only need these if !isNull, in which case we have |cx|.
2350 Maybe<JS::Rooted<JSObject *> > object;
2351 Maybe<JS::Rooted<JS::Value> > temp;
2352 if (!isNull) {
2353 MOZ_ASSERT(cx)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(cx)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(cx))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("cx", "../TestCodeGenBinding.cpp"
, 2353); AnnotateMozCrashReason("MOZ_ASSERT" "(" "cx" ")"); do
{ *((volatile int*)__null) = 2353; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
2354 object.emplace(cx, &val.toObject());
2355 temp.emplace(cx);
2356 }
2357 if (!isNull) {
2358 if (!JS_GetPropertyById(cx, *object, atomsCache->c_id, temp.ptr())) {
2359 return false;
2360 }
2361 }
2362 if (!isNull && !temp->isUndefined()) {
2363 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'c' member of ParentDict", &mC)) {
2364 return false;
2365 }
2366 } else {
2367 mC = 5;
2368 }
2369 mIsAnyMemberPresent = true;
2370
2371 if (!isNull) {
2372 if (!JS_GetPropertyById(cx, *object, atomsCache->parentAny_id, temp.ptr())) {
2373 return false;
2374 }
2375 }
2376 if (!isNull && !temp->isUndefined()) {
2377#ifdef __clang__1
2378#pragma clang diagnostic push
2379#pragma clang diagnostic ignored "-Wunreachable-code"
2380#pragma clang diagnostic ignored "-Wunreachable-code-return"
2381#endif // __clang__
2382 if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
2383 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("'parentAny' member of ParentDict");
2384 return false;
2385 }
2386#ifdef __clang__1
2387#pragma clang diagnostic pop
2388#endif // __clang__
2389 mParentAny = temp.ref();
2390 } else {
2391 mParentAny = JS::UndefinedValue();
2392 }
2393 mIsAnyMemberPresent = true;
2394
2395 if (!isNull) {
2396 if (!JS_GetPropertyById(cx, *object, atomsCache->someExternalInterface_id, temp.ptr())) {
2397 return false;
2398 }
2399 }
2400 if (!isNull && !temp->isUndefined()) {
2401 mSomeExternalInterface.Construct();
2402 if (temp.ref().isObject()) {
2403 static_assert(IsRefcounted<mozilla::dom::TestExternalInterface>::value, "We can only store refcounted classes.");
2404 RefPtr<mozilla::dom::TestExternalInterface> holder;
2405 JS::Rooted<JSObject*> source(cx, &temp.ref().toObject());
2406 if (NS_FAILED(UnwrapArg<mozilla::dom::TestExternalInterface>(cx, source, getter_AddRefs(holder)))((bool)(__builtin_expect(!!(NS_FAILED_impl(UnwrapArg<mozilla
::dom::TestExternalInterface>(cx, source, getter_AddRefs(holder
)))), 0)))
) {
2407 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'someExternalInterface' member of ParentDict", "TestExternalInterface");
2408 return false;
2409 }
2410 MOZ_ASSERT(holder)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(holder)>::isValid, "invalid assertion condition")
; if ((__builtin_expect(!!(!(!!(holder))), 0))) { do { } while
(false); MOZ_ReportAssertionFailure("holder", "../TestCodeGenBinding.cpp"
, 2410); AnnotateMozCrashReason("MOZ_ASSERT" "(" "holder" ")"
); do { *((volatile int*)__null) = 2410; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2411 (mSomeExternalInterface.Value()) = holder;
2412 } else {
2413 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'someExternalInterface' member of ParentDict");
2414 return false;
2415 }
2416 mIsAnyMemberPresent = true;
2417 }
2418
2419 if (!isNull) {
2420 if (!JS_GetPropertyById(cx, *object, atomsCache->someInterface_id, temp.ptr())) {
2421 return false;
2422 }
2423 }
2424 if (!isNull && !temp->isUndefined()) {
2425 mSomeInterface.Construct();
2426 if (temp.ref().isObject()) {
2427 static_assert(IsRefcounted<mozilla::dom::TestInterface>::value, "We can only store refcounted classes.");
2428 {
2429 // Our JSContext should be in the right global to do unwrapping in.
2430 nsresult rv = UnwrapObject<prototypes::id::TestInterface, mozilla::dom::TestInterface>(temp.ptr(), (mSomeInterface.Value()), cx);
2431 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2432 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'someInterface' member of ParentDict", "TestInterface");
2433 return false;
2434 }
2435 }
2436 } else {
2437 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'someInterface' member of ParentDict");
2438 return false;
2439 }
2440 mIsAnyMemberPresent = true;
2441 }
2442
2443 if (!isNull) {
2444 if (!JS_GetPropertyById(cx, *object, atomsCache->someNullableInterface_id, temp.ptr())) {
2445 return false;
2446 }
2447 }
2448 if (!isNull && !temp->isUndefined()) {
2449 if (temp.ref().isObject()) {
2450 static_assert(IsRefcounted<mozilla::dom::TestInterface>::value, "We can only store refcounted classes.");
2451 {
2452 // Our JSContext should be in the right global to do unwrapping in.
2453 nsresult rv = UnwrapObject<prototypes::id::TestInterface, mozilla::dom::TestInterface>(temp.ptr(), mSomeNullableInterface, cx);
2454 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
2455 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'someNullableInterface' member of ParentDict", "TestInterface");
2456 return false;
2457 }
2458 }
2459 } else if (temp.ref().isNullOrUndefined()) {
2460 mSomeNullableInterface = nullptr;
2461 } else {
2462 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'someNullableInterface' member of ParentDict");
2463 return false;
2464 }
2465 } else {
2466 mSomeNullableInterface = nullptr;
2467 }
2468 mIsAnyMemberPresent = true;
2469 return true;
2470}
2471
2472bool
2473ParentDict::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
2474{
2475 // We don't want to use sourceDescription for our context here;
2476 // that's not really what it's formatted for.
2477 BindingCallContext cx(cx_, nullptr);
2478 return Init(cx, val, sourceDescription, passedToJSImpl);
2479}
2480
2481bool
2482ParentDict::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
2483{
2484 ParentDictAtoms* atomsCache = GetAtomCache<ParentDictAtoms>(cx);
2485 if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
2486 !InitIds(cx, atomsCache)) {
2487 return false;
2488 }
2489
2490 // Per spec, we define the parent's members first
2491 if (!GrandparentDict::ToObjectInternal(cx, rval)) {
2492 return false;
2493 }
2494 JS::Rooted<JSObject*> obj(cx, &rval.toObject());
2495
2496 do {
2497 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2498 JS::Rooted<JS::Value> temp(cx);
2499 int32_t const & currentValue = mC;
2500 temp.setInt32(int32_t(currentValue));
2501 if (!JS_DefinePropertyById(cx, obj, atomsCache->c_id, temp, JSPROP_ENUMERATE)) {
2502 return false;
2503 }
2504 break;
2505 } while(false);
2506
2507 do {
2508 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2509 JS::Rooted<JS::Value> temp(cx);
2510 JS::Value const & currentValue = mParentAny;
2511 JS::ExposeValueToActiveJS(currentValue);
2512 temp.set(currentValue);
2513 if (!MaybeWrapValue(cx, &temp)) {
2514 return false;
2515 }
2516 if (!JS_DefinePropertyById(cx, obj, atomsCache->parentAny_id, temp, JSPROP_ENUMERATE)) {
2517 return false;
2518 }
2519 break;
2520 } while(false);
2521
2522 if (mSomeExternalInterface.WasPassed()) {
2523 do {
2524 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2525 JS::Rooted<JS::Value> temp(cx);
2526 RefPtr<mozilla::dom::TestExternalInterface> const & currentValue = mSomeExternalInterface.InternalValue();
2527 if (!WrapObject(cx, currentValue, &temp)) {
2528 return false;
2529 }
2530 if (!JS_DefinePropertyById(cx, obj, atomsCache->someExternalInterface_id, temp, JSPROP_ENUMERATE)) {
2531 return false;
2532 }
2533 break;
2534 } while(false);
2535 }
2536
2537 if (mSomeInterface.WasPassed()) {
2538 do {
2539 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2540 JS::Rooted<JS::Value> temp(cx);
2541 OwningNonNull<mozilla::dom::TestInterface> const & currentValue = mSomeInterface.InternalValue();
2542 if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
2543 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 2543); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 2543; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2544 return false;
2545 }
2546 if (!JS_DefinePropertyById(cx, obj, atomsCache->someInterface_id, temp, JSPROP_ENUMERATE)) {
2547 return false;
2548 }
2549 break;
2550 } while(false);
2551 }
2552
2553 do {
2554 // block for our 'break' successCode and scope for 'temp' and 'currentValue'
2555 JS::Rooted<JS::Value> temp(cx);
2556 RefPtr<mozilla::dom::TestInterface> const & currentValue = mSomeNullableInterface;
2557 if (!currentValue) {
2558 temp.setNull();
2559 if (!JS_DefinePropertyById(cx, obj, atomsCache->someNullableInterface_id, temp, JSPROP_ENUMERATE)) {
2560 return false;
2561 }
2562 break;
2563 }
2564 if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
2565 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 2565); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 2565; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
2566 return false;
2567 }
2568 if (!JS_DefinePropertyById(cx, obj, atomsCache->someNullableInterface_id, temp, JSPROP_ENUMERATE)) {
2569 return false;
2570 }
2571 break;
2572 } while(false);
2573
2574 return true;
2575}
2576
2577void
2578ParentDict::TraceDictionary(JSTracer* trc)
2579{
2580 GrandparentDict::TraceDictionary(trc);
2581 JS::TraceRoot(trc, &mParentAny, "ParentDict.mParentAny");
2582}
2583
2584
2585
2586
2587
2588TestAttributesOnDictionaryMembers::TestAttributesOnDictionaryMembers()
2589{
2590 // Safe to pass a null context if we pass a null value
2591 Init();
2592}
2593
2594
2595
2596
2597bool
2598TestAttributesOnDictionaryMembers::InitIds(JSContext* cx, TestAttributesOnDictionaryMembersAtoms* atomsCache)
2599{
2600 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 2600); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 2600; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
2601
2602 // Initialize these in reverse order so that any failure leaves the first one
2603 // uninitialized.
2604 if (!atomsCache->d_id.init(cx, "d") ||
2605 !atomsCache->c_id.init(cx, "c") ||
2606 !atomsCache->b_id.init(cx, "b") ||
2607 !atomsCache->a_id.init(cx, "a")) {
2608 return false;
2609 }
2610 return true;
2611}
2612
2613bool
2614TestAttributesOnDictionaryMembers::Init(const char* sourceDescription, bool passedToJSImpl)
2615{
2616 return true;
2617}
2618
2619void
2620TestAttributesOnDictionaryMembers::TraceDictionary(JSTracer* trc)
2621{
2622}
2623
2624TestAttributesOnDictionaryMembers&
2625TestAttributesOnDictionaryMembers::operator=(const TestAttributesOnDictionaryMembers& aOther)
2626{
2627 DictionaryBase::operator=(aOther);
2628 mA.Reset();
2629 if (aOther.mA.WasPassed()) {
2630 mA.Construct(aOther.mA.Value());
2631 }
2632 mB.Reset();
2633 if (aOther.mB.WasPassed()) {
2634 mB.Construct(aOther.mB.Value());
2635 }
2636 mC = aOther.mC;
2637 mD.Reset();
2638 if (aOther.mD.WasPassed()) {
2639 mD.Construct(aOther.mD.Value());
2640 }
2641 return *this;
2642}
2643
2644bool
2645TestAttributesOnDictionaryMembers::operator==(const TestAttributesOnDictionaryMembers& aOther) const
2646{
2647 if (mA != aOther.mA) {
2648 return false;
2649 }
2650 if (mB != aOther.mB) {
2651 return false;
2652 }
2653 if (mC != aOther.mC) {
2654 return false;
2655 }
2656 if (mD != aOther.mD) {
2657 return false;
2658 }
2659 return true;
2660}
2661
2662
2663MOZ_CAN_RUN_SCRIPT bool
2664TestBooleanConstruction::Construct(JS::Handle<JS::Value> arg1, const Optional<JS::Handle<JS::Value>>& arg2, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
2665{
2666 CallSetup s(this, aRv, "TestBooleanConstruction", aExceptionHandling, aRealm);
2667 if (aRv.Failed()) {
2668 return bool(0);
2669 }
2670 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 2670); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 2670; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2671 BindingCallContext& cx = s.GetCallContext();
2672
2673 JS::Rooted<JS::Value> rval(cx);
2674 JS::RootedVector<JS::Value> argv(cx);
2675 if (!argv.resize(2)) {
2676 // That threw an exception on the JSContext, and our CallSetup will do
2677 // the right thing with that.
2678 return bool(0);
2679 }
2680 unsigned argc = 2;
2681
2682 do {
2683 if (arg2.WasPassed()) {
2684 JS::ExposeValueToActiveJS(arg2.Value());
2685 argv[1].set(arg2.Value());
2686 if (!MaybeWrapValue(cx, argv[1])) {
2687 aRv.Throw(NS_ERROR_UNEXPECTED);
2688 return bool(0);
2689 }
2690 break;
2691 } else if (argc == 2) {
2692 // This is our current trailing argument; reduce argc
2693 --argc;
2694 } else {
2695 argv[1].setUndefined();
2696 }
2697 } while (false);
2698
2699 do {
2700 JS::ExposeValueToActiveJS(arg1);
2701 argv[0].set(arg1);
2702 if (!MaybeWrapValue(cx, argv[0])) {
2703 aRv.Throw(NS_ERROR_UNEXPECTED);
2704 return bool(0);
2705 }
2706 break;
2707 } while (false);
2708
2709 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
2710 JS::Rooted<JSObject*> constructedObj(cx);
2711 if (!JS::Construct(cx, constructor,
2712 JS::HandleValueArray::subarray(argv, 0, argc), &constructedObj)) {
2713 aRv.NoteJSContextException(cx);
2714 return bool(0);
2715 }
2716 rval.setObject(*constructedObj);
2717 bool rvalDecl;
2718 if (!ValueToPrimitive<bool, eDefault>(cx, rval, "Return value of TestBooleanConstruction", &rvalDecl)) {
2719 aRv.Throw(NS_ERROR_UNEXPECTED);
2720 return bool(0);
2721 }
2722 return rvalDecl;
2723}
2724
2725
2726
2727MOZ_CAN_RUN_SCRIPT bool
2728TestBooleanReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
2729{
2730 JS::Rooted<JS::Value> rval(cx);
2731
2732 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
2733 if (!JS::Call(cx, aThisVal, callable,
2734 JS::HandleValueArray::empty(), &rval)) {
2735 aRv.NoteJSContextException(cx);
2736 return bool(0);
2737 }
2738 bool rvalDecl;
2739 if (!ValueToPrimitive<bool, eDefault>(cx, rval, "Return value of TestBooleanReturn", &rvalDecl)) {
2740 aRv.Throw(NS_ERROR_UNEXPECTED);
2741 return bool(0);
2742 }
2743 return rvalDecl;
2744}
2745
2746
2747
2748MOZ_CAN_RUN_SCRIPT void
2749TestCallback::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
2750{
2751 JS::Rooted<JS::Value> rval(cx);
2752
2753 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
2754 if (!JS::Call(cx, aThisVal, callable,
2755 JS::HandleValueArray::empty(), &rval)) {
2756 aRv.NoteJSContextException(cx);
2757 return;
2758 }
2759}
2760
2761
2762
2763MOZ_CAN_RUN_SCRIPT already_AddRefed<TestCallback>
2764TestCallbackConstruction::Construct(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
2765{
2766 CallSetup s(this, aRv, "TestCallbackConstruction", aExceptionHandling, aRealm);
2767 if (aRv.Failed()) {
2768 return nullptr;
2769 }
2770 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 2770); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 2770; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2771 BindingCallContext& cx = s.GetCallContext();
2772
2773 JS::Rooted<JS::Value> rval(cx);
2774
2775 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
2776 JS::Rooted<JSObject*> constructedObj(cx);
2777 if (!JS::Construct(cx, constructor,
2778 JS::HandleValueArray::empty(), &constructedObj)) {
2779 aRv.NoteJSContextException(cx);
2780 return nullptr;
2781 }
2782 rval.setObject(*constructedObj);
2783 RefPtr<TestCallback> rvalDecl;
2784 if (JS::IsCallable(&rval.toObject())) {
2785 { // scope for tempRoot and tempGlobalRoot if needed
2786 JS::Rooted<JSObject*> tempRoot(cx, &rval.toObject());
2787 JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
2788 rvalDecl = new TestCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
2789 }
2790 } else {
2791 cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("Return value of TestCallbackConstruction");
2792 aRv.Throw(NS_ERROR_UNEXPECTED);
2793 return nullptr;
2794 }
2795 return rvalDecl.forget();
2796}
2797
2798
2799
2800MOZ_CAN_RUN_SCRIPT already_AddRefed<TestCallbackInterface>
2801TestCallbackInterfaceConstruction::Construct(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
2802{
2803 CallSetup s(this, aRv, "TestCallbackInterfaceConstruction", aExceptionHandling, aRealm);
2804 if (aRv.Failed()) {
2805 return nullptr;
2806 }
2807 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 2807); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 2807; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2808 BindingCallContext& cx = s.GetCallContext();
2809
2810 JS::Rooted<JS::Value> rval(cx);
2811
2812 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
2813 JS::Rooted<JSObject*> constructedObj(cx);
2814 if (!JS::Construct(cx, constructor,
2815 JS::HandleValueArray::empty(), &constructedObj)) {
2816 aRv.NoteJSContextException(cx);
2817 return nullptr;
2818 }
2819 rval.setObject(*constructedObj);
2820 RefPtr<TestCallbackInterface> rvalDecl;
2821 { // scope for tempRoot and tempGlobalRoot if needed
2822 JS::Rooted<JSObject*> tempRoot(cx, &rval.toObject());
2823 JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
2824 rvalDecl = new TestCallbackInterface(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
2825 }
2826 return rvalDecl.forget();
2827}
2828
2829
2830
2831MOZ_CAN_RUN_SCRIPT already_AddRefed<TestCallbackInterface>
2832TestCallbackInterfaceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
2833{
2834 JS::Rooted<JS::Value> rval(cx);
2835
2836 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
2837 if (!JS::Call(cx, aThisVal, callable,
2838 JS::HandleValueArray::empty(), &rval)) {
2839 aRv.NoteJSContextException(cx);
2840 return nullptr;
2841 }
2842 RefPtr<TestCallbackInterface> rvalDecl;
2843 if (rval.isObject()) {
2844 { // scope for tempRoot and tempGlobalRoot if needed
2845 JS::Rooted<JSObject*> tempRoot(cx, &rval.toObject());
2846 JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
2847 rvalDecl = new TestCallbackInterface(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
2848 }
2849 } else {
2850 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestCallbackInterfaceReturn");
2851 aRv.Throw(NS_ERROR_UNEXPECTED);
2852 return nullptr;
2853 }
2854 return rvalDecl.forget();
2855}
2856
2857
2858
2859MOZ_CAN_RUN_SCRIPT already_AddRefed<TestCallback>
2860TestCallbackReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
2861{
2862 JS::Rooted<JS::Value> rval(cx);
2863
2864 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
2865 if (!JS::Call(cx, aThisVal, callable,
2866 JS::HandleValueArray::empty(), &rval)) {
2867 aRv.NoteJSContextException(cx);
2868 return nullptr;
2869 }
2870 RefPtr<TestCallback> rvalDecl;
2871 if (rval.isObject()) {
2872 if (JS::IsCallable(&rval.toObject())) {
2873 { // scope for tempRoot and tempGlobalRoot if needed
2874 JS::Rooted<JSObject*> tempRoot(cx, &rval.toObject());
2875 JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
2876 rvalDecl = new TestCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
2877 }
2878 } else {
2879 cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("Return value of TestCallbackReturn");
2880 aRv.Throw(NS_ERROR_UNEXPECTED);
2881 return nullptr;
2882 }
2883 } else {
2884 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestCallbackReturn");
2885 aRv.Throw(NS_ERROR_UNEXPECTED);
2886 return nullptr;
2887 }
2888 return rvalDecl.forget();
2889}
2890
2891
2892
2893MOZ_CAN_RUN_SCRIPT TestEnum
2894TestEnumConstruction::Construct(const nsTArray<JS::Value>& arg, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
2895{
2896 CallSetup s(this, aRv, "TestEnumConstruction", aExceptionHandling, aRealm);
2897 if (aRv.Failed()) {
2898 return TestEnum(0);
2899 }
2900 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 2900); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 2900; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2901 BindingCallContext& cx = s.GetCallContext();
2902
2903 JS::Rooted<JS::Value> rval(cx);
2904 JS::RootedVector<JS::Value> argv(cx);
2905 if (!argv.resize((1 - 1) + arg.Length())) {
2906 // That threw an exception on the JSContext, and our CallSetup will do
2907 // the right thing with that.
2908 return TestEnum(0);
2909 }
2910 unsigned argc = (1 - 1) + arg.Length();
2911
2912 do {
2913 for (uint32_t idx = 0; idx < arg.Length(); ++idx) {
2914 JS::ExposeValueToActiveJS(arg[idx]);
2915 argv[0 + idx].set(arg[idx]);
2916 if (!MaybeWrapValue(cx, argv[0 + idx])) {
2917 aRv.Throw(NS_ERROR_UNEXPECTED);
2918 return TestEnum(0);
2919 }
2920 continue;
2921 }
2922 break;
2923 } while (false);
2924
2925 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
2926 JS::Rooted<JSObject*> constructedObj(cx);
2927 if (!JS::Construct(cx, constructor,
2928 JS::HandleValueArray::subarray(argv, 0, argc), &constructedObj)) {
2929 aRv.NoteJSContextException(cx);
2930 return TestEnum(0);
2931 }
2932 rval.setObject(*constructedObj);
2933 TestEnum rvalDecl;
2934 {
2935 int index;
2936 if (!binding_detail::FindEnumStringIndex<true>(cx, rval,
2937 binding_detail::EnumStrings<TestEnum>::Values,
2938 "TestEnum", "return value of TestEnumConstruction",
2939 &index)) {
2940 aRv.Throw(NS_ERROR_UNEXPECTED);
2941 return TestEnum(0);
2942 }
2943 MOZ_ASSERT(index >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index >= 0",
"../TestCodeGenBinding.cpp", 2943); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "index >= 0" ")"); do { *((volatile int*)__null) = 2943
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
2944 rvalDecl = static_cast<TestEnum>(index);
2945 }
2946 return rvalDecl;
2947}
2948
2949
2950
2951MOZ_CAN_RUN_SCRIPT TestEnum
2952TestEnumReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
2953{
2954 JS::Rooted<JS::Value> rval(cx);
2955
2956 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
2957 if (!JS::Call(cx, aThisVal, callable,
2958 JS::HandleValueArray::empty(), &rval)) {
2959 aRv.NoteJSContextException(cx);
2960 return TestEnum(0);
2961 }
2962 TestEnum rvalDecl;
2963 {
2964 int index;
2965 if (!binding_detail::FindEnumStringIndex<true>(cx, rval,
2966 binding_detail::EnumStrings<TestEnum>::Values,
2967 "TestEnum", "return value of TestEnumReturn",
2968 &index)) {
2969 aRv.Throw(NS_ERROR_UNEXPECTED);
2970 return TestEnum(0);
2971 }
2972 MOZ_ASSERT(index >= 0)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(index >= 0)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(index >= 0))), 0))) { do {
} while (false); MOZ_ReportAssertionFailure("index >= 0",
"../TestCodeGenBinding.cpp", 2972); AnnotateMozCrashReason("MOZ_ASSERT"
"(" "index >= 0" ")"); do { *((volatile int*)__null) = 2972
; __attribute__((nomerge)) ::abort(); } while (false); } } while
(false)
;
2973 rvalDecl = static_cast<TestEnum>(index);
2974 }
2975 return rvalDecl;
2976}
2977
2978
2979
2980MOZ_CAN_RUN_SCRIPT already_AddRefed<TestExternalInterface>
2981TestExternalInterfaceConstruction::Construct(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
2982{
2983 CallSetup s(this, aRv, "TestExternalInterfaceConstruction", aExceptionHandling, aRealm);
2984 if (aRv.Failed()) {
2985 return nullptr;
2986 }
2987 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 2987); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 2987; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
2988 BindingCallContext& cx = s.GetCallContext();
2989
2990 JS::Rooted<JS::Value> rval(cx);
2991
2992 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
2993 JS::Rooted<JSObject*> constructedObj(cx);
2994 if (!JS::Construct(cx, constructor,
2995 JS::HandleValueArray::empty(), &constructedObj)) {
2996 aRv.NoteJSContextException(cx);
2997 return nullptr;
2998 }
2999 rval.setObject(*constructedObj);
3000 RefPtr<mozilla::dom::TestExternalInterface> rvalDecl;
3001 static_assert(IsRefcounted<mozilla::dom::TestExternalInterface>::value, "We can only store refcounted classes.");
3002 RefPtr<mozilla::dom::TestExternalInterface> rvalHolder;
3003 JS::Rooted<JSObject*> source(cx, &rval.toObject());
3004 if (NS_FAILED(UnwrapArg<mozilla::dom::TestExternalInterface>(cx, source, getter_AddRefs(rvalHolder)))((bool)(__builtin_expect(!!(NS_FAILED_impl(UnwrapArg<mozilla
::dom::TestExternalInterface>(cx, source, getter_AddRefs(rvalHolder
)))), 0)))
) {
3005 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestExternalInterfaceConstruction", "TestExternalInterface");
3006 aRv.Throw(NS_ERROR_UNEXPECTED);
3007 return nullptr;
3008 }
3009 MOZ_ASSERT(rvalHolder)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(rvalHolder)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(rvalHolder))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("rvalHolder", "../TestCodeGenBinding.cpp"
, 3009); AnnotateMozCrashReason("MOZ_ASSERT" "(" "rvalHolder"
")"); do { *((volatile int*)__null) = 3009; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3010 rvalDecl = rvalHolder;
3011 return rvalDecl.forget();
3012}
3013
3014
3015
3016MOZ_CAN_RUN_SCRIPT already_AddRefed<TestExternalInterface>
3017TestExternalInterfaceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3018{
3019 JS::Rooted<JS::Value> rval(cx);
3020
3021 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3022 if (!JS::Call(cx, aThisVal, callable,
3023 JS::HandleValueArray::empty(), &rval)) {
3024 aRv.NoteJSContextException(cx);
3025 return nullptr;
3026 }
3027 RefPtr<mozilla::dom::TestExternalInterface> rvalDecl;
3028 if (rval.isObject()) {
3029 static_assert(IsRefcounted<mozilla::dom::TestExternalInterface>::value, "We can only store refcounted classes.");
3030 RefPtr<mozilla::dom::TestExternalInterface> rvalHolder;
3031 JS::Rooted<JSObject*> source(cx, &rval.toObject());
3032 if (NS_FAILED(UnwrapArg<mozilla::dom::TestExternalInterface>(cx, source, getter_AddRefs(rvalHolder)))((bool)(__builtin_expect(!!(NS_FAILED_impl(UnwrapArg<mozilla
::dom::TestExternalInterface>(cx, source, getter_AddRefs(rvalHolder
)))), 0)))
) {
3033 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestExternalInterfaceReturn", "TestExternalInterface");
3034 aRv.Throw(NS_ERROR_UNEXPECTED);
3035 return nullptr;
3036 }
3037 MOZ_ASSERT(rvalHolder)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(rvalHolder)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(rvalHolder))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("rvalHolder", "../TestCodeGenBinding.cpp"
, 3037); AnnotateMozCrashReason("MOZ_ASSERT" "(" "rvalHolder"
")"); do { *((volatile int*)__null) = 3037; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3038 rvalDecl = rvalHolder;
3039 } else {
3040 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestExternalInterfaceReturn");
3041 aRv.Throw(NS_ERROR_UNEXPECTED);
3042 return nullptr;
3043 }
3044 return rvalDecl.forget();
3045}
3046
3047
3048
3049MOZ_CAN_RUN_SCRIPT float
3050TestFloatConstruction::Construct(const Optional<JS::Handle<JSObject*>>& arg1, const Optional<CustomEventInit>& arg2, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
3051{
3052 CallSetup s(this, aRv, "TestFloatConstruction", aExceptionHandling, aRealm);
3053 if (aRv.Failed()) {
3054 return float(0);
3055 }
3056 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 3056); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 3056; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
3057 BindingCallContext& cx = s.GetCallContext();
3058
3059 JS::Rooted<JS::Value> rval(cx);
3060 JS::RootedVector<JS::Value> argv(cx);
3061 if (!argv.resize(2)) {
3062 // That threw an exception on the JSContext, and our CallSetup will do
3063 // the right thing with that.
3064 return float(0);
3065 }
3066 unsigned argc = 2;
3067
3068 do {
3069 if (arg2.WasPassed()) {
3070 if (!arg2.Value().ToObjectInternal(cx, argv[1])) {
3071 aRv.Throw(NS_ERROR_UNEXPECTED);
3072 return float(0);
3073 }
3074 break;
3075 } else if (argc == 2) {
3076 // This is our current trailing argument; reduce argc
3077 --argc;
3078 } else {
3079 argv[1].setUndefined();
3080 }
3081 } while (false);
3082
3083 do {
3084 if (arg1.WasPassed()) {
3085 JS::ExposeObjectToActiveJS(arg1.Value());
3086 argv[0].setObject(*arg1.Value());
3087 if (!MaybeWrapObjectValue(cx, argv[0])) {
3088 aRv.Throw(NS_ERROR_UNEXPECTED);
3089 return float(0);
3090 }
3091 break;
3092 } else if (argc == 1) {
3093 // This is our current trailing argument; reduce argc
3094 --argc;
3095 } else {
3096 argv[0].setUndefined();
3097 }
3098 } while (false);
3099
3100 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
3101 JS::Rooted<JSObject*> constructedObj(cx);
3102 if (!JS::Construct(cx, constructor,
3103 JS::HandleValueArray::subarray(argv, 0, argc), &constructedObj)) {
3104 aRv.NoteJSContextException(cx);
3105 return float(0);
3106 }
3107 rval.setObject(*constructedObj);
3108 float rvalDecl;
3109 if (!ValueToPrimitive<float, eDefault>(cx, rval, "Return value of TestFloatConstruction", &rvalDecl)) {
3110 aRv.Throw(NS_ERROR_UNEXPECTED);
3111 return float(0);
3112 }
3113 return rvalDecl;
3114}
3115
3116
3117
3118MOZ_CAN_RUN_SCRIPT float
3119TestFloatReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3120{
3121 JS::Rooted<JS::Value> rval(cx);
3122
3123 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3124 if (!JS::Call(cx, aThisVal, callable,
3125 JS::HandleValueArray::empty(), &rval)) {
3126 aRv.NoteJSContextException(cx);
3127 return float(0);
3128 }
3129 float rvalDecl;
3130 if (!ValueToPrimitive<float, eDefault>(cx, rval, "Return value of TestFloatReturn", &rvalDecl)) {
3131 aRv.Throw(NS_ERROR_UNEXPECTED);
3132 return float(0);
3133 } else if (!std::isfinite(rvalDecl)) {
3134 cx.ThrowErrorMessage<MSG_NOT_FINITE>("Return value of TestFloatReturn");
3135 aRv.Throw(NS_ERROR_UNEXPECTED);
3136 return float(0);
3137 }
3138 return rvalDecl;
3139}
3140
3141
3142
3143MOZ_CAN_RUN_SCRIPT void
3144TestIntegerArguments::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, int32_t arg1, const Nullable<int32_t>& arg2, const Sequence<int32_t>& arg3, const Nullable<Sequence<Nullable<int32_t>>>& arg4, nsTArray<int32_t>& aRetVal, ErrorResult& aRv)
3145{
3146 JS::Rooted<JS::Value> rval(cx);
3147 JS::RootedVector<JS::Value> argv(cx);
3148 if (!argv.resize(4)) {
3149 // That threw an exception on the JSContext, and our CallSetup will do
3150 // the right thing with that.
3151 return;
3152 }
3153 unsigned argc = 4;
3154
3155 do {
3156
3157 if (arg4.IsNull()) {
3158 argv[3].setNull();
3159 break;
3160 }
3161
3162 uint32_t length = arg4.Value().Length();
3163 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3164 if (!returnArray) {
3165 aRv.Throw(NS_ERROR_UNEXPECTED);
3166 return;
3167 }
3168 // Scope for 'tmp'
3169 {
3170 JS::Rooted<JS::Value> tmp(cx);
3171 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3172 // Control block to let us common up the JS_DefineElement calls when there
3173 // are different ways to succeed at wrapping the object.
3174 do {
3175 if (arg4.Value()[sequenceIdx0].IsNull()) {
3176 tmp.setNull();
3177 break;
3178 }
3179 tmp.setInt32(int32_t(arg4.Value()[sequenceIdx0].Value()));
3180 break;
3181 } while (false);
3182 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3183 JSPROP_ENUMERATE)) {
3184 aRv.Throw(NS_ERROR_UNEXPECTED);
3185 return;
3186 }
3187 }
3188 }
3189 argv[3].setObject(*returnArray);
3190 break;
3191 } while (false);
3192
3193 do {
3194
3195 uint32_t length = arg3.Length();
3196 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3197 if (!returnArray) {
3198 aRv.Throw(NS_ERROR_UNEXPECTED);
3199 return;
3200 }
3201 // Scope for 'tmp'
3202 {
3203 JS::Rooted<JS::Value> tmp(cx);
3204 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3205 // Control block to let us common up the JS_DefineElement calls when there
3206 // are different ways to succeed at wrapping the object.
3207 do {
3208 tmp.setInt32(int32_t(arg3[sequenceIdx0]));
3209 break;
3210 } while (false);
3211 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3212 JSPROP_ENUMERATE)) {
3213 aRv.Throw(NS_ERROR_UNEXPECTED);
3214 return;
3215 }
3216 }
3217 }
3218 argv[2].setObject(*returnArray);
3219 break;
3220 } while (false);
3221
3222 do {
3223 if (arg2.IsNull()) {
3224 argv[1].setNull();
3225 break;
3226 }
3227 argv[1].setInt32(int32_t(arg2.Value()));
3228 break;
3229 } while (false);
3230
3231 do {
3232 argv[0].setInt32(int32_t(arg1));
3233 break;
3234 } while (false);
3235
3236 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3237 if (!JS::Call(cx, aThisVal, callable,
3238 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
3239 aRv.NoteJSContextException(cx);
3240 return;
3241 }
3242 Sequence<int32_t> rvalDecl;
3243 if (rval.isObject()) {
3244 JS::ForOfIterator iter(cx);
3245 if (!iter.init(rval, JS::ForOfIterator::AllowNonIterable)) {
3246 aRv.Throw(NS_ERROR_UNEXPECTED);
3247 return;
3248 }
3249 if (!iter.valueIsIterable()) {
3250 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestIntegerArguments", "sequence");
3251 aRv.Throw(NS_ERROR_UNEXPECTED);
3252 return;
3253 }
3254 Sequence<int32_t> &arr = rvalDecl;
3255 JS::Rooted<JS::Value> temp(cx);
3256 while (true) {
3257 bool done;
3258 if (!iter.next(&temp, &done)) {
3259 aRv.Throw(NS_ERROR_UNEXPECTED);
3260 return;
3261 }
3262 if (done) {
3263 break;
3264 }
3265 int32_t* slotPtr = arr.AppendElement(mozilla::fallible);
3266 if (!slotPtr) {
3267 JS_ReportOutOfMemory(cx);
3268 aRv.Throw(NS_ERROR_UNEXPECTED);
3269 return;
3270 }
3271 int32_t& slot = *slotPtr;
3272 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Element of return value of TestIntegerArguments", &slot)) {
3273 aRv.Throw(NS_ERROR_UNEXPECTED);
3274 return;
3275 }
3276 }
3277 } else {
3278 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestIntegerArguments", "sequence");
3279 aRv.Throw(NS_ERROR_UNEXPECTED);
3280 return;
3281 }
3282 aRetVal = std::move(rvalDecl);
3283}
3284
3285
3286
3287MOZ_CAN_RUN_SCRIPT uint32_t
3288TestIntegerConstruction::Construct(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
3289{
3290 CallSetup s(this, aRv, "TestIntegerConstruction", aExceptionHandling, aRealm);
3291 if (aRv.Failed()) {
3292 return uint32_t(0);
3293 }
3294 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 3294); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 3294; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
3295 BindingCallContext& cx = s.GetCallContext();
3296
3297 JS::Rooted<JS::Value> rval(cx);
3298
3299 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
3300 JS::Rooted<JSObject*> constructedObj(cx);
3301 if (!JS::Construct(cx, constructor,
3302 JS::HandleValueArray::empty(), &constructedObj)) {
3303 aRv.NoteJSContextException(cx);
3304 return uint32_t(0);
3305 }
3306 rval.setObject(*constructedObj);
3307 uint32_t rvalDecl;
3308 if (!ValueToPrimitive<uint32_t, eDefault>(cx, rval, "Return value of TestIntegerConstruction", &rvalDecl)) {
3309 aRv.Throw(NS_ERROR_UNEXPECTED);
3310 return uint32_t(0);
3311 }
3312 return rvalDecl;
3313}
3314
3315
3316
3317MOZ_CAN_RUN_SCRIPT int32_t
3318TestIntegerReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3319{
3320 JS::Rooted<JS::Value> rval(cx);
3321
3322 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3323 if (!JS::Call(cx, aThisVal, callable,
3324 JS::HandleValueArray::empty(), &rval)) {
3325 aRv.NoteJSContextException(cx);
3326 return int32_t(0);
3327 }
3328 int32_t rvalDecl;
3329 if (!ValueToPrimitive<int32_t, eDefault>(cx, rval, "Return value of TestIntegerReturn", &rvalDecl)) {
3330 aRv.Throw(NS_ERROR_UNEXPECTED);
3331 return int32_t(0);
3332 }
3333 return rvalDecl;
3334}
3335
3336
3337
3338MOZ_CAN_RUN_SCRIPT void
3339TestInterfaceArguments::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, TestInterface& arg1, TestInterface* arg2, TestExternalInterface* arg3, TestExternalInterface* arg4, TestCallbackInterface& arg5, TestCallbackInterface* arg6, const Sequence<OwningNonNull<TestInterface>>& arg7, const Nullable<Sequence<RefPtr<TestInterface>>>& arg8, const Sequence<RefPtr<TestExternalInterface>>& arg9, const Nullable<Sequence<RefPtr<TestExternalInterface>>>& arg10, const Sequence<OwningNonNull<TestCallbackInterface>>& arg11, const Nullable<Sequence<RefPtr<TestCallbackInterface>>>& arg12, ErrorResult& aRv)
3340{
3341 JS::Rooted<JS::Value> rval(cx);
3342 JS::RootedVector<JS::Value> argv(cx);
3343 if (!argv.resize(12)) {
3344 // That threw an exception on the JSContext, and our CallSetup will do
3345 // the right thing with that.
3346 return;
3347 }
3348 unsigned argc = 12;
3349
3350 do {
3351
3352 if (arg12.IsNull()) {
3353 argv[11].setNull();
3354 break;
3355 }
3356
3357 uint32_t length = arg12.Value().Length();
3358 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3359 if (!returnArray) {
3360 aRv.Throw(NS_ERROR_UNEXPECTED);
3361 return;
3362 }
3363 // Scope for 'tmp'
3364 {
3365 JS::Rooted<JS::Value> tmp(cx);
3366 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3367 // Control block to let us common up the JS_DefineElement calls when there
3368 // are different ways to succeed at wrapping the object.
3369 do {
3370 if (arg12.Value()[sequenceIdx0]) {
3371 tmp.setObjectOrNull(GetCallbackFromCallbackObject(cx, arg12.Value()[sequenceIdx0]));
3372 if (!MaybeWrapObjectOrNullValue(cx, &tmp)) {
3373 aRv.Throw(NS_ERROR_UNEXPECTED);
3374 return;
3375 }
3376 break;
3377 } else {
3378 tmp.setNull();
3379 break;
3380 }
3381 } while (false);
3382 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3383 JSPROP_ENUMERATE)) {
3384 aRv.Throw(NS_ERROR_UNEXPECTED);
3385 return;
3386 }
3387 }
3388 }
3389 argv[11].setObject(*returnArray);
3390 break;
3391 } while (false);
3392
3393 do {
3394
3395 uint32_t length = arg11.Length();
3396 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3397 if (!returnArray) {
3398 aRv.Throw(NS_ERROR_UNEXPECTED);
3399 return;
3400 }
3401 // Scope for 'tmp'
3402 {
3403 JS::Rooted<JS::Value> tmp(cx);
3404 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3405 // Control block to let us common up the JS_DefineElement calls when there
3406 // are different ways to succeed at wrapping the object.
3407 do {
3408 tmp.setObjectOrNull(GetCallbackFromCallbackObject(cx, arg11[sequenceIdx0]));
3409 if (!MaybeWrapObjectValue(cx, &tmp)) {
3410 aRv.Throw(NS_ERROR_UNEXPECTED);
3411 return;
3412 }
3413 break;
3414 } while (false);
3415 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3416 JSPROP_ENUMERATE)) {
3417 aRv.Throw(NS_ERROR_UNEXPECTED);
3418 return;
3419 }
3420 }
3421 }
3422 argv[10].setObject(*returnArray);
3423 break;
3424 } while (false);
3425
3426 do {
3427
3428 if (arg10.IsNull()) {
3429 argv[9].setNull();
3430 break;
3431 }
3432
3433 uint32_t length = arg10.Value().Length();
3434 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3435 if (!returnArray) {
3436 aRv.Throw(NS_ERROR_UNEXPECTED);
3437 return;
3438 }
3439 // Scope for 'tmp'
3440 {
3441 JS::Rooted<JS::Value> tmp(cx);
3442 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3443 // Control block to let us common up the JS_DefineElement calls when there
3444 // are different ways to succeed at wrapping the object.
3445 do {
3446 if (!arg10.Value()[sequenceIdx0]) {
3447 tmp.setNull();
3448 break;
3449 }
3450 if (!WrapObject(cx, arg10.Value()[sequenceIdx0], &tmp)) {
3451 aRv.Throw(NS_ERROR_UNEXPECTED);
3452 return;
3453 }
3454 break;
3455 } while (false);
3456 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3457 JSPROP_ENUMERATE)) {
3458 aRv.Throw(NS_ERROR_UNEXPECTED);
3459 return;
3460 }
3461 }
3462 }
3463 argv[9].setObject(*returnArray);
3464 break;
3465 } while (false);
3466
3467 do {
3468
3469 uint32_t length = arg9.Length();
3470 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3471 if (!returnArray) {
3472 aRv.Throw(NS_ERROR_UNEXPECTED);
3473 return;
3474 }
3475 // Scope for 'tmp'
3476 {
3477 JS::Rooted<JS::Value> tmp(cx);
3478 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3479 // Control block to let us common up the JS_DefineElement calls when there
3480 // are different ways to succeed at wrapping the object.
3481 do {
3482 if (!WrapObject(cx, arg9[sequenceIdx0], &tmp)) {
3483 aRv.Throw(NS_ERROR_UNEXPECTED);
3484 return;
3485 }
3486 break;
3487 } while (false);
3488 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3489 JSPROP_ENUMERATE)) {
3490 aRv.Throw(NS_ERROR_UNEXPECTED);
3491 return;
3492 }
3493 }
3494 }
3495 argv[8].setObject(*returnArray);
3496 break;
3497 } while (false);
3498
3499 do {
3500
3501 if (arg8.IsNull()) {
3502 argv[7].setNull();
3503 break;
3504 }
3505
3506 uint32_t length = arg8.Value().Length();
3507 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3508 if (!returnArray) {
3509 aRv.Throw(NS_ERROR_UNEXPECTED);
3510 return;
3511 }
3512 // Scope for 'tmp'
3513 {
3514 JS::Rooted<JS::Value> tmp(cx);
3515 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3516 // Control block to let us common up the JS_DefineElement calls when there
3517 // are different ways to succeed at wrapping the object.
3518 do {
3519 if (!arg8.Value()[sequenceIdx0]) {
3520 tmp.setNull();
3521 break;
3522 }
3523 if (!GetOrCreateDOMReflector(cx, arg8.Value()[sequenceIdx0], &tmp)) {
3524 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 3524); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 3524; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
3525 aRv.Throw(NS_ERROR_UNEXPECTED);
3526 return;
3527 }
3528 break;
3529 } while (false);
3530 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3531 JSPROP_ENUMERATE)) {
3532 aRv.Throw(NS_ERROR_UNEXPECTED);
3533 return;
3534 }
3535 }
3536 }
3537 argv[7].setObject(*returnArray);
3538 break;
3539 } while (false);
3540
3541 do {
3542
3543 uint32_t length = arg7.Length();
3544 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
3545 if (!returnArray) {
3546 aRv.Throw(NS_ERROR_UNEXPECTED);
3547 return;
3548 }
3549 // Scope for 'tmp'
3550 {
3551 JS::Rooted<JS::Value> tmp(cx);
3552 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
3553 // Control block to let us common up the JS_DefineElement calls when there
3554 // are different ways to succeed at wrapping the object.
3555 do {
3556 if (!GetOrCreateDOMReflector(cx, arg7[sequenceIdx0], &tmp)) {
3557 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 3557); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 3557; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
3558 aRv.Throw(NS_ERROR_UNEXPECTED);
3559 return;
3560 }
3561 break;
3562 } while (false);
3563 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
3564 JSPROP_ENUMERATE)) {
3565 aRv.Throw(NS_ERROR_UNEXPECTED);
3566 return;
3567 }
3568 }
3569 }
3570 argv[6].setObject(*returnArray);
3571 break;
3572 } while (false);
3573
3574 do {
3575 if (arg6) {
3576 argv[5].setObjectOrNull(GetCallbackFromCallbackObject(cx, arg6));
3577 if (!MaybeWrapObjectOrNullValue(cx, argv[5])) {
3578 aRv.Throw(NS_ERROR_UNEXPECTED);
3579 return;
3580 }
3581 break;
3582 } else {
3583 argv[5].setNull();
3584 break;
3585 }
3586 } while (false);
3587
3588 do {
3589 argv[4].setObjectOrNull(GetCallbackFromCallbackObject(cx, arg5));
3590 if (!MaybeWrapObjectValue(cx, argv[4])) {
3591 aRv.Throw(NS_ERROR_UNEXPECTED);
3592 return;
3593 }
3594 break;
3595 } while (false);
3596
3597 do {
3598 if (!arg4) {
3599 argv[3].setNull();
3600 break;
3601 }
3602 if (!WrapObject(cx, arg4, argv[3])) {
3603 aRv.Throw(NS_ERROR_UNEXPECTED);
3604 return;
3605 }
3606 break;
3607 } while (false);
3608
3609 do {
3610 if (!WrapObject(cx, arg3, argv[2])) {
3611 aRv.Throw(NS_ERROR_UNEXPECTED);
3612 return;
3613 }
3614 break;
3615 } while (false);
3616
3617 do {
3618 if (!arg2) {
3619 argv[1].setNull();
3620 break;
3621 }
3622 if (!GetOrCreateDOMReflector(cx, arg2, argv[1])) {
3623 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 3623); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 3623; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
3624 aRv.Throw(NS_ERROR_UNEXPECTED);
3625 return;
3626 }
3627 break;
3628 } while (false);
3629
3630 do {
3631 if (!GetOrCreateDOMReflector(cx, arg1, argv[0])) {
3632 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 3632); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 3632; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
3633 aRv.Throw(NS_ERROR_UNEXPECTED);
3634 return;
3635 }
3636 break;
3637 } while (false);
3638
3639 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3640 if (!JS::Call(cx, aThisVal, callable,
3641 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
3642 aRv.NoteJSContextException(cx);
3643 return;
3644 }
3645}
3646
3647
3648
3649MOZ_CAN_RUN_SCRIPT already_AddRefed<TestInterface>
3650TestInterfaceConstruction::Construct(ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
3651{
3652 CallSetup s(this, aRv, "TestInterfaceConstruction", aExceptionHandling, aRealm);
3653 if (aRv.Failed()) {
3654 return nullptr;
3655 }
3656 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 3656); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 3656; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
3657 BindingCallContext& cx = s.GetCallContext();
3658
3659 JS::Rooted<JS::Value> rval(cx);
3660
3661 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
3662 JS::Rooted<JSObject*> constructedObj(cx);
3663 if (!JS::Construct(cx, constructor,
3664 JS::HandleValueArray::empty(), &constructedObj)) {
3665 aRv.NoteJSContextException(cx);
3666 return nullptr;
3667 }
3668 rval.setObject(*constructedObj);
3669 RefPtr<mozilla::dom::TestInterface> rvalDecl;
3670 static_assert(IsRefcounted<mozilla::dom::TestInterface>::value, "We can only store refcounted classes.");
3671 {
3672 // Our JSContext should be in the right global to do unwrapping in.
3673 nsresult rv = UnwrapObject<prototypes::id::TestInterface, mozilla::dom::TestInterface>(rval, rvalDecl, cx);
3674 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
3675 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestInterfaceConstruction", "TestInterface");
3676 aRv.Throw(NS_ERROR_UNEXPECTED);
3677 return nullptr;
3678 }
3679 }
3680 return rvalDecl.forget();
3681}
3682
3683
3684
3685MOZ_CAN_RUN_SCRIPT already_AddRefed<TestInterface>
3686TestInterfaceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3687{
3688 JS::Rooted<JS::Value> rval(cx);
3689
3690 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3691 if (!JS::Call(cx, aThisVal, callable,
3692 JS::HandleValueArray::empty(), &rval)) {
3693 aRv.NoteJSContextException(cx);
3694 return nullptr;
3695 }
3696 RefPtr<mozilla::dom::TestInterface> rvalDecl;
3697 if (rval.isObject()) {
3698 static_assert(IsRefcounted<mozilla::dom::TestInterface>::value, "We can only store refcounted classes.");
3699 {
3700 // Our JSContext should be in the right global to do unwrapping in.
3701 nsresult rv = UnwrapObject<prototypes::id::TestInterface, mozilla::dom::TestInterface>(rval, rvalDecl, cx);
3702 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
3703 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestInterfaceReturn", "TestInterface");
3704 aRv.Throw(NS_ERROR_UNEXPECTED);
3705 return nullptr;
3706 }
3707 }
3708 } else {
3709 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestInterfaceReturn");
3710 aRv.Throw(NS_ERROR_UNEXPECTED);
3711 return nullptr;
3712 }
3713 return rvalDecl.forget();
3714}
3715
3716
3717
3718MOZ_CAN_RUN_SCRIPT already_AddRefed<TestCallbackInterface>
3719TestNullableCallbackInterfaceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3720{
3721 JS::Rooted<JS::Value> rval(cx);
3722
3723 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3724 if (!JS::Call(cx, aThisVal, callable,
3725 JS::HandleValueArray::empty(), &rval)) {
3726 aRv.NoteJSContextException(cx);
3727 return nullptr;
3728 }
3729 RefPtr<TestCallbackInterface> rvalDecl;
3730 if (rval.isObject()) {
3731 { // scope for tempRoot and tempGlobalRoot if needed
3732 JS::Rooted<JSObject*> tempRoot(cx, &rval.toObject());
3733 JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
3734 rvalDecl = new TestCallbackInterface(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
3735 }
3736 } else if (rval.isNullOrUndefined()) {
3737 rvalDecl = nullptr;
3738 } else {
3739 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestNullableCallbackInterfaceReturn");
3740 aRv.Throw(NS_ERROR_UNEXPECTED);
3741 return nullptr;
3742 }
3743 return rvalDecl.forget();
3744}
3745
3746
3747
3748MOZ_CAN_RUN_SCRIPT already_AddRefed<TestCallback>
3749TestNullableCallbackReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3750{
3751 JS::Rooted<JS::Value> rval(cx);
3752
3753 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3754 if (!JS::Call(cx, aThisVal, callable,
3755 JS::HandleValueArray::empty(), &rval)) {
3756 aRv.NoteJSContextException(cx);
3757 return nullptr;
3758 }
3759 RefPtr<TestCallback> rvalDecl;
3760 if (rval.isObject()) {
3761 if (JS::IsCallable(&rval.toObject())) {
3762 { // scope for tempRoot and tempGlobalRoot if needed
3763 JS::Rooted<JSObject*> tempRoot(cx, &rval.toObject());
3764 JS::Rooted<JSObject*> tempGlobalRoot(cx, JS::CurrentGlobalOrNull(cx));
3765 rvalDecl = new TestCallback(cx, tempRoot, tempGlobalRoot, GetIncumbentGlobal());
3766 }
3767 } else {
3768 cx.ThrowErrorMessage<MSG_NOT_CALLABLE>("Return value of TestNullableCallbackReturn");
3769 aRv.Throw(NS_ERROR_UNEXPECTED);
3770 return nullptr;
3771 }
3772 } else if (rval.isNullOrUndefined()) {
3773 rvalDecl = nullptr;
3774 } else {
3775 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestNullableCallbackReturn");
3776 aRv.Throw(NS_ERROR_UNEXPECTED);
3777 return nullptr;
3778 }
3779 return rvalDecl.forget();
3780}
3781
3782
3783
3784MOZ_CAN_RUN_SCRIPT already_AddRefed<TestExternalInterface>
3785TestNullableExternalInterfaceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3786{
3787 JS::Rooted<JS::Value> rval(cx);
3788
3789 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3790 if (!JS::Call(cx, aThisVal, callable,
3791 JS::HandleValueArray::empty(), &rval)) {
3792 aRv.NoteJSContextException(cx);
3793 return nullptr;
3794 }
3795 RefPtr<mozilla::dom::TestExternalInterface> rvalDecl;
3796 if (rval.isObject()) {
3797 static_assert(IsRefcounted<mozilla::dom::TestExternalInterface>::value, "We can only store refcounted classes.");
3798 RefPtr<mozilla::dom::TestExternalInterface> rvalHolder;
3799 JS::Rooted<JSObject*> source(cx, &rval.toObject());
3800 if (NS_FAILED(UnwrapArg<mozilla::dom::TestExternalInterface>(cx, source, getter_AddRefs(rvalHolder)))((bool)(__builtin_expect(!!(NS_FAILED_impl(UnwrapArg<mozilla
::dom::TestExternalInterface>(cx, source, getter_AddRefs(rvalHolder
)))), 0)))
) {
3801 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestNullableExternalInterfaceReturn", "TestExternalInterface");
3802 aRv.Throw(NS_ERROR_UNEXPECTED);
3803 return nullptr;
3804 }
3805 MOZ_ASSERT(rvalHolder)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(rvalHolder)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(rvalHolder))), 0))) { do { }
while (false); MOZ_ReportAssertionFailure("rvalHolder", "../TestCodeGenBinding.cpp"
, 3805); AnnotateMozCrashReason("MOZ_ASSERT" "(" "rvalHolder"
")"); do { *((volatile int*)__null) = 3805; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
3806 rvalDecl = rvalHolder;
3807 } else if (rval.isNullOrUndefined()) {
3808 rvalDecl = nullptr;
3809 } else {
3810 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestNullableExternalInterfaceReturn");
3811 aRv.Throw(NS_ERROR_UNEXPECTED);
3812 return nullptr;
3813 }
3814 return rvalDecl.forget();
3815}
3816
3817
3818
3819MOZ_CAN_RUN_SCRIPT Nullable<int32_t>
3820TestNullableIntegerReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3821{
3822 JS::Rooted<JS::Value> rval(cx);
3823
3824 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3825 if (!JS::Call(cx, aThisVal, callable,
3826 JS::HandleValueArray::empty(), &rval)) {
3827 aRv.NoteJSContextException(cx);
3828 return Nullable<int32_t>();
3829 }
3830 Nullable<int32_t> rvalDecl;
3831 if (rval.isNullOrUndefined()) {
3832 rvalDecl.SetNull();
3833 } else if (!ValueToPrimitive<int32_t, eDefault>(cx, rval, "Return value of TestNullableIntegerReturn", &rvalDecl.SetValue())) {
3834 aRv.Throw(NS_ERROR_UNEXPECTED);
3835 return Nullable<int32_t>();
3836 }
3837 return rvalDecl;
3838}
3839
3840
3841
3842MOZ_CAN_RUN_SCRIPT already_AddRefed<TestInterface>
3843TestNullableInterfaceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
3844{
3845 JS::Rooted<JS::Value> rval(cx);
3846
3847 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3848 if (!JS::Call(cx, aThisVal, callable,
3849 JS::HandleValueArray::empty(), &rval)) {
3850 aRv.NoteJSContextException(cx);
3851 return nullptr;
3852 }
3853 RefPtr<mozilla::dom::TestInterface> rvalDecl;
3854 if (rval.isObject()) {
3855 static_assert(IsRefcounted<mozilla::dom::TestInterface>::value, "We can only store refcounted classes.");
3856 {
3857 // Our JSContext should be in the right global to do unwrapping in.
3858 nsresult rv = UnwrapObject<prototypes::id::TestInterface, mozilla::dom::TestInterface>(rval, rvalDecl, cx);
3859 if (NS_FAILED(rv)((bool)(__builtin_expect(!!(NS_FAILED_impl(rv)), 0)))) {
3860 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestNullableInterfaceReturn", "TestInterface");
3861 aRv.Throw(NS_ERROR_UNEXPECTED);
3862 return nullptr;
3863 }
3864 }
3865 } else if (rval.isNullOrUndefined()) {
3866 rvalDecl = nullptr;
3867 } else {
3868 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestNullableInterfaceReturn");
3869 aRv.Throw(NS_ERROR_UNEXPECTED);
3870 return nullptr;
3871 }
3872 return rvalDecl.forget();
3873}
3874
3875
3876
3877MOZ_CAN_RUN_SCRIPT void
3878TestNullableObjectReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv)
3879{
3880 JS::Rooted<JS::Value> rval(cx);
3881
3882 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3883 if (!JS::Call(cx, aThisVal, callable,
3884 JS::HandleValueArray::empty(), &rval)) {
3885 aRv.NoteJSContextException(cx);
3886 return;
3887 }
3888 JS::Rooted<JSObject*> rvalDecl(cx);
3889 if (rval.isObject()) {
3890#ifdef __clang__1
3891#pragma clang diagnostic push
3892#pragma clang diagnostic ignored "-Wunreachable-code"
3893#pragma clang diagnostic ignored "-Wunreachable-code-return"
3894#endif // __clang__
3895 if ((false) && !CallerSubsumes(rval)) {
3896 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("return value of TestNullableObjectReturn");
3897 aRv.Throw(NS_ERROR_UNEXPECTED);
3898 return;
3899 }
3900#ifdef __clang__1
3901#pragma clang diagnostic pop
3902#endif // __clang__
3903 rvalDecl = &rval.toObject();
3904 } else if (rval.isNullOrUndefined()) {
3905 rvalDecl = nullptr;
3906 } else {
3907 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestNullableObjectReturn");
3908 aRv.Throw(NS_ERROR_UNEXPECTED);
3909 return;
3910 }
3911 aRetVal.set(rvalDecl);
3912}
3913
3914
3915
3916MOZ_CAN_RUN_SCRIPT void
3917TestNullableSequenceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, Nullable<nsTArray<bool>>& aRetVal, ErrorResult& aRv)
3918{
3919 JS::Rooted<JS::Value> rval(cx);
3920
3921 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3922 if (!JS::Call(cx, aThisVal, callable,
3923 JS::HandleValueArray::empty(), &rval)) {
3924 aRv.NoteJSContextException(cx);
3925 return;
3926 }
3927 Nullable<Sequence<bool>> rvalDecl;
3928 if (rval.isObject()) {
3929 JS::ForOfIterator iter(cx);
3930 if (!iter.init(rval, JS::ForOfIterator::AllowNonIterable)) {
3931 aRv.Throw(NS_ERROR_UNEXPECTED);
3932 return;
3933 }
3934 if (!iter.valueIsIterable()) {
3935 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestNullableSequenceReturn", "sequence");
3936 aRv.Throw(NS_ERROR_UNEXPECTED);
3937 return;
3938 }
3939 Sequence<bool> &arr = rvalDecl.SetValue();
3940 JS::Rooted<JS::Value> temp(cx);
3941 while (true) {
3942 bool done;
3943 if (!iter.next(&temp, &done)) {
3944 aRv.Throw(NS_ERROR_UNEXPECTED);
3945 return;
3946 }
3947 if (done) {
3948 break;
3949 }
3950 bool* slotPtr = arr.AppendElement(mozilla::fallible);
3951 if (!slotPtr) {
3952 JS_ReportOutOfMemory(cx);
3953 aRv.Throw(NS_ERROR_UNEXPECTED);
3954 return;
3955 }
3956 bool& slot = *slotPtr;
3957 if (!ValueToPrimitive<bool, eDefault>(cx, temp, "Element of return value of TestNullableSequenceReturn", &slot)) {
3958 aRv.Throw(NS_ERROR_UNEXPECTED);
3959 return;
3960 }
3961 }
3962 } else if (rval.isNullOrUndefined()) {
3963 rvalDecl.SetNull();
3964 } else {
3965 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestNullableSequenceReturn", "sequence");
3966 aRv.Throw(NS_ERROR_UNEXPECTED);
3967 return;
3968 }
3969 if (rvalDecl.IsNull()) {
3970 aRetVal.SetNull();
3971 } else {
3972 aRetVal.SetValue() = std::move(rvalDecl.Value());
3973 }
3974}
3975
3976
3977
3978MOZ_CAN_RUN_SCRIPT void
3979TestNullableTypedArrayReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv)
3980{
3981 JS::Rooted<JS::Value> rval(cx);
3982
3983 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
3984 if (!JS::Call(cx, aThisVal, callable,
3985 JS::HandleValueArray::empty(), &rval)) {
3986 aRv.NoteJSContextException(cx);
3987 return;
3988 }
3989 RootedSpiderMonkeyInterface<Nullable<ArrayBuffer>> rvalDecl(cx);
3990 if (rval.isObject()) {
3991 if (!rvalDecl.SetValue().Init(&rval.toObject())) {
3992 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestNullableTypedArrayReturn", "ArrayBufferOrNull");
3993 aRv.Throw(NS_ERROR_UNEXPECTED);
3994 return;
3995 }
3996 if (JS::IsSharedArrayBufferObject(rvalDecl.SetValue().Obj())) {
3997 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_SHARED>("Return value of TestNullableTypedArrayReturn");
3998 aRv.Throw(NS_ERROR_UNEXPECTED);
3999 return;
4000 }
4001 if (JS::IsLargeArrayBufferMaybeShared(rvalDecl.SetValue().Obj())) {
4002 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_LARGE>("Return value of TestNullableTypedArrayReturn");
4003 aRv.Throw(NS_ERROR_UNEXPECTED);
4004 return;
4005 }
4006 if (JS::IsResizableArrayBufferMaybeShared(rvalDecl.SetValue().Obj())) {
4007 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_RESIZABLE>("Return value of TestNullableTypedArrayReturn");
4008 aRv.Throw(NS_ERROR_UNEXPECTED);
4009 return;
4010 }
4011 } else if (rval.isNullOrUndefined()) {
4012 rvalDecl.SetNull();
4013 } else {
4014 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestNullableTypedArrayReturn");
4015 aRv.Throw(NS_ERROR_UNEXPECTED);
4016 return;
4017 }
4018 aRetVal.set(rvalDecl.IsNull() ? nullptr : rvalDecl.Value().Obj());
4019}
4020
4021
4022
4023MOZ_CAN_RUN_SCRIPT void
4024TestObjectArguments::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, JS::Handle<JSObject*> anObj, JS::Handle<JSObject*> anotherObj, JS::Handle<JSObject*> buf, JS::Handle<JSObject*> buf2, ErrorResult& aRv)
4025{
4026 JS::Rooted<JS::Value> rval(cx);
4027 JS::RootedVector<JS::Value> argv(cx);
4028 if (!argv.resize(4)) {
4029 // That threw an exception on the JSContext, and our CallSetup will do
4030 // the right thing with that.
4031 return;
4032 }
4033 unsigned argc = 4;
4034
4035 do {
4036 if (buf2) {
4037 JS::ExposeObjectToActiveJS(buf2);
4038 }
4039 argv[3].setObjectOrNull(buf2);
4040 if (!MaybeWrapNonDOMObjectOrNullValue(cx, argv[3])) {
4041 aRv.Throw(NS_ERROR_UNEXPECTED);
4042 return;
4043 }
4044 break;
4045 } while (false);
4046
4047 do {
4048 JS::ExposeObjectToActiveJS(buf);
4049 argv[2].setObject(*buf);
4050 if (!MaybeWrapNonDOMObjectValue(cx, argv[2])) {
4051 aRv.Throw(NS_ERROR_UNEXPECTED);
4052 return;
4053 }
4054 break;
4055 } while (false);
4056
4057 do {
4058 if (anotherObj) {
4059 JS::ExposeObjectToActiveJS(anotherObj);
4060 }
4061 argv[1].setObjectOrNull(anotherObj);
4062 if (!MaybeWrapObjectOrNullValue(cx, argv[1])) {
4063 aRv.Throw(NS_ERROR_UNEXPECTED);
4064 return;
4065 }
4066 break;
4067 } while (false);
4068
4069 do {
4070 JS::ExposeObjectToActiveJS(anObj);
4071 argv[0].setObject(*anObj);
4072 if (!MaybeWrapObjectValue(cx, argv[0])) {
4073 aRv.Throw(NS_ERROR_UNEXPECTED);
4074 return;
4075 }
4076 break;
4077 } while (false);
4078
4079 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4080 if (!JS::Call(cx, aThisVal, callable,
4081 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
4082 aRv.NoteJSContextException(cx);
4083 return;
4084 }
4085}
4086
4087
4088
4089MOZ_CAN_RUN_SCRIPT void
4090TestObjectConstruction::Construct(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
4091{
4092 CallSetup s(this, aRv, "TestObjectConstruction", aExceptionHandling, aRealm);
4093 if (aRv.Failed()) {
4094 return;
4095 }
4096 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 4096); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 4096; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
4097 BindingCallContext& cx = s.GetCallContext();
4098
4099 JS::Rooted<JS::Value> rval(cx);
4100
4101 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
4102 JS::Rooted<JSObject*> constructedObj(cx);
4103 if (!JS::Construct(cx, constructor,
4104 JS::HandleValueArray::empty(), &constructedObj)) {
4105 aRv.NoteJSContextException(cx);
4106 return;
4107 }
4108 rval.setObject(*constructedObj);
4109 JS::Rooted<JSObject*> rvalDecl(cx);
4110#ifdef __clang__1
4111#pragma clang diagnostic push
4112#pragma clang diagnostic ignored "-Wunreachable-code"
4113#pragma clang diagnostic ignored "-Wunreachable-code-return"
4114#endif // __clang__
4115 if ((false) && !CallerSubsumes(rval)) {
4116 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("return value of TestObjectConstruction");
4117 aRv.Throw(NS_ERROR_UNEXPECTED);
4118 return;
4119 }
4120#ifdef __clang__1
4121#pragma clang diagnostic pop
4122#endif // __clang__
4123 rvalDecl = &rval.toObject();
4124 aRetVal.set(rvalDecl);
4125}
4126
4127
4128
4129MOZ_CAN_RUN_SCRIPT void
4130TestObjectReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv)
4131{
4132 JS::Rooted<JS::Value> rval(cx);
4133
4134 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4135 if (!JS::Call(cx, aThisVal, callable,
4136 JS::HandleValueArray::empty(), &rval)) {
4137 aRv.NoteJSContextException(cx);
4138 return;
4139 }
4140 JS::Rooted<JSObject*> rvalDecl(cx);
4141 if (rval.isObject()) {
4142#ifdef __clang__1
4143#pragma clang diagnostic push
4144#pragma clang diagnostic ignored "-Wunreachable-code"
4145#pragma clang diagnostic ignored "-Wunreachable-code-return"
4146#endif // __clang__
4147 if ((false) && !CallerSubsumes(rval)) {
4148 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("return value of TestObjectReturn");
4149 aRv.Throw(NS_ERROR_UNEXPECTED);
4150 return;
4151 }
4152#ifdef __clang__1
4153#pragma clang diagnostic pop
4154#endif // __clang__
4155 rvalDecl = &rval.toObject();
4156 } else {
4157 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestObjectReturn");
4158 aRv.Throw(NS_ERROR_UNEXPECTED);
4159 return;
4160 }
4161 aRetVal.set(rvalDecl);
4162}
4163
4164
4165
4166MOZ_CAN_RUN_SCRIPT void
4167TestOptionalArguments::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const Optional<nsAString>& aString, const Optional<JS::Handle<JSObject*>>& something, const Optional<Sequence<OwningNonNull<TestInterface>>>& aSeq, const Optional<TestInterface*>& anInterface, const Optional<NonNull<TestInterface>>& anotherInterface, const Optional<int32_t>& aLong, ErrorResult& aRv)
4168{
4169 JS::Rooted<JS::Value> rval(cx);
4170 JS::RootedVector<JS::Value> argv(cx);
4171 if (!argv.resize(6)) {
4172 // That threw an exception on the JSContext, and our CallSetup will do
4173 // the right thing with that.
4174 return;
4175 }
4176 unsigned argc = 6;
4177
4178 do {
4179 if (aLong.WasPassed()) {
4180 argv[5].setInt32(int32_t(aLong.Value()));
4181 break;
4182 } else if (argc == 6) {
4183 // This is our current trailing argument; reduce argc
4184 --argc;
4185 } else {
4186 argv[5].setUndefined();
4187 }
4188 } while (false);
4189
4190 do {
4191 if (anotherInterface.WasPassed()) {
4192 if (!GetOrCreateDOMReflector(cx, anotherInterface.Value(), argv[4])) {
4193 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 4193); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 4193; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
4194 aRv.Throw(NS_ERROR_UNEXPECTED);
4195 return;
4196 }
4197 break;
4198 } else if (argc == 5) {
4199 // This is our current trailing argument; reduce argc
4200 --argc;
4201 } else {
4202 argv[4].setUndefined();
4203 }
4204 } while (false);
4205
4206 do {
4207 if (anInterface.WasPassed()) {
4208 if (!anInterface.Value()) {
4209 argv[3].setNull();
4210 break;
4211 }
4212 if (!GetOrCreateDOMReflector(cx, anInterface.Value(), argv[3])) {
4213 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 4213); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 4213; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
4214 aRv.Throw(NS_ERROR_UNEXPECTED);
4215 return;
4216 }
4217 break;
4218 } else if (argc == 4) {
4219 // This is our current trailing argument; reduce argc
4220 --argc;
4221 } else {
4222 argv[3].setUndefined();
4223 }
4224 } while (false);
4225
4226 do {
4227 if (aSeq.WasPassed()) {
4228
4229 uint32_t length = aSeq.Value().Length();
4230 JS::Rooted<JSObject*> returnArray(cx, JS::NewArrayObject(cx, length));
4231 if (!returnArray) {
4232 aRv.Throw(NS_ERROR_UNEXPECTED);
4233 return;
4234 }
4235 // Scope for 'tmp'
4236 {
4237 JS::Rooted<JS::Value> tmp(cx);
4238 for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
4239 // Control block to let us common up the JS_DefineElement calls when there
4240 // are different ways to succeed at wrapping the object.
4241 do {
4242 if (!GetOrCreateDOMReflector(cx, aSeq.Value()[sequenceIdx0], &tmp)) {
4243 MOZ_ASSERT(JS_IsExceptionPending(cx))do { static_assert( mozilla::detail::AssertionConditionType<
decltype(JS_IsExceptionPending(cx))>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(JS_IsExceptionPending(cx))))
, 0))) { do { } while (false); MOZ_ReportAssertionFailure("JS_IsExceptionPending(cx)"
, "../TestCodeGenBinding.cpp", 4243); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "JS_IsExceptionPending(cx)" ")"); do { *((volatile
int*)__null) = 4243; __attribute__((nomerge)) ::abort(); } while
(false); } } while (false)
;
4244 aRv.Throw(NS_ERROR_UNEXPECTED);
4245 return;
4246 }
4247 break;
4248 } while (false);
4249 if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
4250 JSPROP_ENUMERATE)) {
4251 aRv.Throw(NS_ERROR_UNEXPECTED);
4252 return;
4253 }
4254 }
4255 }
4256 argv[2].setObject(*returnArray);
4257 break;
4258 } else if (argc == 3) {
4259 // This is our current trailing argument; reduce argc
4260 --argc;
4261 } else {
4262 argv[2].setUndefined();
4263 }
4264 } while (false);
4265
4266 do {
4267 if (something.WasPassed()) {
4268 JS::ExposeObjectToActiveJS(something.Value());
4269 argv[1].setObject(*something.Value());
4270 if (!MaybeWrapObjectValue(cx, argv[1])) {
4271 aRv.Throw(NS_ERROR_UNEXPECTED);
4272 return;
4273 }
4274 break;
4275 } else if (argc == 2) {
4276 // This is our current trailing argument; reduce argc
4277 --argc;
4278 } else {
4279 argv[1].setUndefined();
4280 }
4281 } while (false);
4282
4283 do {
4284 if (aString.WasPassed()) {
4285 if (!xpc::NonVoidStringToJsval(cx, aString.Value(), argv[0])) {
4286 aRv.Throw(NS_ERROR_UNEXPECTED);
4287 return;
4288 }
4289 break;
4290 } else if (argc == 1) {
4291 // This is our current trailing argument; reduce argc
4292 --argc;
4293 } else {
4294 argv[0].setUndefined();
4295 }
4296 } while (false);
4297
4298 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4299 if (!JS::Call(cx, aThisVal, callable,
4300 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
4301 aRv.NoteJSContextException(cx);
4302 return;
4303 }
4304}
4305
4306
4307
4308MOZ_CAN_RUN_SCRIPT void
4309TestSequenceConstruction::Construct(nsTArray<bool>& aRetVal, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
4310{
4311 CallSetup s(this, aRv, "TestSequenceConstruction", aExceptionHandling, aRealm);
4312 if (aRv.Failed()) {
4313 return;
4314 }
4315 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 4315); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 4315; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
4316 BindingCallContext& cx = s.GetCallContext();
4317
4318 JS::Rooted<JS::Value> rval(cx);
4319
4320 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
4321 JS::Rooted<JSObject*> constructedObj(cx);
4322 if (!JS::Construct(cx, constructor,
4323 JS::HandleValueArray::empty(), &constructedObj)) {
4324 aRv.NoteJSContextException(cx);
4325 return;
4326 }
4327 rval.setObject(*constructedObj);
4328 Sequence<bool> rvalDecl;
4329 JS::ForOfIterator iter(cx);
4330 if (!iter.init(rval, JS::ForOfIterator::AllowNonIterable)) {
4331 aRv.Throw(NS_ERROR_UNEXPECTED);
4332 return;
4333 }
4334 if (!iter.valueIsIterable()) {
4335 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestSequenceConstruction", "sequence");
4336 aRv.Throw(NS_ERROR_UNEXPECTED);
4337 return;
4338 }
4339 Sequence<bool> &arr = rvalDecl;
4340 JS::Rooted<JS::Value> temp(cx);
4341 while (true) {
4342 bool done;
4343 if (!iter.next(&temp, &done)) {
4344 aRv.Throw(NS_ERROR_UNEXPECTED);
4345 return;
4346 }
4347 if (done) {
4348 break;
4349 }
4350 bool* slotPtr = arr.AppendElement(mozilla::fallible);
4351 if (!slotPtr) {
4352 JS_ReportOutOfMemory(cx);
4353 aRv.Throw(NS_ERROR_UNEXPECTED);
4354 return;
4355 }
4356 bool& slot = *slotPtr;
4357 if (!ValueToPrimitive<bool, eDefault>(cx, temp, "Element of return value of TestSequenceConstruction", &slot)) {
4358 aRv.Throw(NS_ERROR_UNEXPECTED);
4359 return;
4360 }
4361 }
4362 aRetVal = std::move(rvalDecl);
4363}
4364
4365
4366
4367MOZ_CAN_RUN_SCRIPT void
4368TestSequenceReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, nsTArray<bool>& aRetVal, ErrorResult& aRv)
4369{
4370 JS::Rooted<JS::Value> rval(cx);
4371
4372 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4373 if (!JS::Call(cx, aThisVal, callable,
4374 JS::HandleValueArray::empty(), &rval)) {
4375 aRv.NoteJSContextException(cx);
4376 return;
4377 }
4378 Sequence<bool> rvalDecl;
4379 if (rval.isObject()) {
4380 JS::ForOfIterator iter(cx);
4381 if (!iter.init(rval, JS::ForOfIterator::AllowNonIterable)) {
4382 aRv.Throw(NS_ERROR_UNEXPECTED);
4383 return;
4384 }
4385 if (!iter.valueIsIterable()) {
4386 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestSequenceReturn", "sequence");
4387 aRv.Throw(NS_ERROR_UNEXPECTED);
4388 return;
4389 }
4390 Sequence<bool> &arr = rvalDecl;
4391 JS::Rooted<JS::Value> temp(cx);
4392 while (true) {
4393 bool done;
4394 if (!iter.next(&temp, &done)) {
4395 aRv.Throw(NS_ERROR_UNEXPECTED);
4396 return;
4397 }
4398 if (done) {
4399 break;
4400 }
4401 bool* slotPtr = arr.AppendElement(mozilla::fallible);
4402 if (!slotPtr) {
4403 JS_ReportOutOfMemory(cx);
4404 aRv.Throw(NS_ERROR_UNEXPECTED);
4405 return;
4406 }
4407 bool& slot = *slotPtr;
4408 if (!ValueToPrimitive<bool, eDefault>(cx, temp, "Element of return value of TestSequenceReturn", &slot)) {
4409 aRv.Throw(NS_ERROR_UNEXPECTED);
4410 return;
4411 }
4412 }
4413 } else {
4414 cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>("Return value of TestSequenceReturn", "sequence");
4415 aRv.Throw(NS_ERROR_UNEXPECTED);
4416 return;
4417 }
4418 aRetVal = std::move(rvalDecl);
4419}
4420
4421
4422
4423MOZ_CAN_RUN_SCRIPT void
4424TestStringConstruction::Construct(const Nullable<int32_t>& arg, nsString& aRetVal, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
4425{
4426 CallSetup s(this, aRv, "TestStringConstruction", aExceptionHandling, aRealm);
4427 if (aRv.Failed()) {
4428 return;
4429 }
4430 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 4430); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 4430; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
4431 BindingCallContext& cx = s.GetCallContext();
4432
4433 JS::Rooted<JS::Value> rval(cx);
4434 JS::RootedVector<JS::Value> argv(cx);
4435 if (!argv.resize(1)) {
4436 // That threw an exception on the JSContext, and our CallSetup will do
4437 // the right thing with that.
4438 return;
4439 }
4440 unsigned argc = 1;
4441
4442 do {
4443 if (arg.IsNull()) {
4444 argv[0].setNull();
4445 break;
4446 }
4447 argv[0].setInt32(int32_t(arg.Value()));
4448 break;
4449 } while (false);
4450
4451 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
4452 JS::Rooted<JSObject*> constructedObj(cx);
4453 if (!JS::Construct(cx, constructor,
4454 JS::HandleValueArray::subarray(argv, 0, argc), &constructedObj)) {
4455 aRv.NoteJSContextException(cx);
4456 return;
4457 }
4458 rval.setObject(*constructedObj);
4459 binding_detail::FakeString<char16_t> rvalDecl;
4460 if (!ConvertJSValueToString(cx, rval, eStringify, eStringify, rvalDecl)) {
4461 aRv.Throw(NS_ERROR_UNEXPECTED);
4462 return;
4463 }
4464 aRetVal = rvalDecl;
4465}
4466
4467
4468
4469MOZ_CAN_RUN_SCRIPT void
4470TestStringEnumArguments::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const nsAString& myString, const nsAString& nullString, TestEnum myEnum, ErrorResult& aRv)
4471{
4472 JS::Rooted<JS::Value> rval(cx);
4473 JS::RootedVector<JS::Value> argv(cx);
4474 if (!argv.resize(3)) {
4475 // That threw an exception on the JSContext, and our CallSetup will do
4476 // the right thing with that.
4477 return;
4478 }
4479 unsigned argc = 3;
4480
4481 do {
4482 if (!ToJSValue(cx, myEnum, argv[2])) {
4483 aRv.Throw(NS_ERROR_UNEXPECTED);
4484 return;
4485 }
4486 break;
4487 } while (false);
4488
4489 do {
4490 if (!xpc::StringToJsval(cx, nullString, argv[1])) {
4491 aRv.Throw(NS_ERROR_UNEXPECTED);
4492 return;
4493 }
4494 break;
4495 } while (false);
4496
4497 do {
4498 if (!xpc::NonVoidStringToJsval(cx, myString, argv[0])) {
4499 aRv.Throw(NS_ERROR_UNEXPECTED);
4500 return;
4501 }
4502 break;
4503 } while (false);
4504
4505 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4506 if (!JS::Call(cx, aThisVal, callable,
4507 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
4508 aRv.NoteJSContextException(cx);
4509 return;
4510 }
4511}
4512
4513
4514
4515MOZ_CAN_RUN_SCRIPT void
4516TestStringReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, int32_t arg, nsString& aRetVal, ErrorResult& aRv)
4517{
4518 JS::Rooted<JS::Value> rval(cx);
4519 JS::RootedVector<JS::Value> argv(cx);
4520 if (!argv.resize(1)) {
4521 // That threw an exception on the JSContext, and our CallSetup will do
4522 // the right thing with that.
4523 return;
4524 }
4525 unsigned argc = 1;
4526
4527 do {
4528 argv[0].setInt32(int32_t(arg));
4529 break;
4530 } while (false);
4531
4532 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4533 if (!JS::Call(cx, aThisVal, callable,
4534 JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
4535 aRv.NoteJSContextException(cx);
4536 return;
4537 }
4538 binding_detail::FakeString<char16_t> rvalDecl;
4539 if (!ConvertJSValueToString(cx, rval, eStringify, eStringify, rvalDecl)) {
4540 aRv.Throw(NS_ERROR_UNEXPECTED);
4541 return;
4542 }
4543 aRetVal = rvalDecl;
4544}
4545
4546
4547
4548MOZ_CAN_RUN_SCRIPT void
4549TestTreatAsNullCallback::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv)
4550{
4551 JS::Rooted<JS::Value> rval(cx);
4552
4553 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4554 if (!JS::Call(cx, aThisVal, callable,
4555 JS::HandleValueArray::empty(), &rval)) {
4556 aRv.NoteJSContextException(cx);
4557 return;
4558 }
4559}
4560
4561
4562
4563MOZ_CAN_RUN_SCRIPT void
4564TestTypedArrayConstruction::Construct(JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
4565{
4566 CallSetup s(this, aRv, "TestTypedArrayConstruction", aExceptionHandling, aRealm);
4567 if (aRv.Failed()) {
4568 return;
4569 }
4570 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 4570); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 4570; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
4571 BindingCallContext& cx = s.GetCallContext();
4572
4573 JS::Rooted<JS::Value> rval(cx);
4574
4575 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
4576 JS::Rooted<JSObject*> constructedObj(cx);
4577 if (!JS::Construct(cx, constructor,
4578 JS::HandleValueArray::empty(), &constructedObj)) {
4579 aRv.NoteJSContextException(cx);
4580 return;
4581 }
4582 rval.setObject(*constructedObj);
4583 RootedSpiderMonkeyInterface<ArrayBuffer> rvalDecl(cx);
4584 if (!rvalDecl.Init(&rval.toObject())) {
4585 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestTypedArrayConstruction", "ArrayBuffer");
4586 aRv.Throw(NS_ERROR_UNEXPECTED);
4587 return;
4588 }
4589 if (JS::IsSharedArrayBufferObject(rvalDecl.Obj())) {
4590 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_SHARED>("Return value of TestTypedArrayConstruction");
4591 aRv.Throw(NS_ERROR_UNEXPECTED);
4592 return;
4593 }
4594 if (JS::IsLargeArrayBufferMaybeShared(rvalDecl.Obj())) {
4595 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_LARGE>("Return value of TestTypedArrayConstruction");
4596 aRv.Throw(NS_ERROR_UNEXPECTED);
4597 return;
4598 }
4599 if (JS::IsResizableArrayBufferMaybeShared(rvalDecl.Obj())) {
4600 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_RESIZABLE>("Return value of TestTypedArrayConstruction");
4601 aRv.Throw(NS_ERROR_UNEXPECTED);
4602 return;
4603 }
4604 aRetVal.set(rvalDecl.Obj());
4605}
4606
4607
4608
4609MOZ_CAN_RUN_SCRIPT void
4610TestTypedArrayReturn::Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, JS::MutableHandle<JSObject*> aRetVal, ErrorResult& aRv)
4611{
4612 JS::Rooted<JS::Value> rval(cx);
4613
4614 JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
4615 if (!JS::Call(cx, aThisVal, callable,
4616 JS::HandleValueArray::empty(), &rval)) {
4617 aRv.NoteJSContextException(cx);
4618 return;
4619 }
4620 RootedSpiderMonkeyInterface<ArrayBuffer> rvalDecl(cx);
4621 if (rval.isObject()) {
4622 if (!rvalDecl.Init(&rval.toObject())) {
4623 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("Return value of TestTypedArrayReturn", "ArrayBuffer");
4624 aRv.Throw(NS_ERROR_UNEXPECTED);
4625 return;
4626 }
4627 if (JS::IsSharedArrayBufferObject(rvalDecl.Obj())) {
4628 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_SHARED>("Return value of TestTypedArrayReturn");
4629 aRv.Throw(NS_ERROR_UNEXPECTED);
4630 return;
4631 }
4632 if (JS::IsLargeArrayBufferMaybeShared(rvalDecl.Obj())) {
4633 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_LARGE>("Return value of TestTypedArrayReturn");
4634 aRv.Throw(NS_ERROR_UNEXPECTED);
4635 return;
4636 }
4637 if (JS::IsResizableArrayBufferMaybeShared(rvalDecl.Obj())) {
4638 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_RESIZABLE>("Return value of TestTypedArrayReturn");
4639 aRv.Throw(NS_ERROR_UNEXPECTED);
4640 return;
4641 }
4642 } else {
4643 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("Return value of TestTypedArrayReturn");
4644 aRv.Throw(NS_ERROR_UNEXPECTED);
4645 return;
4646 }
4647 aRetVal.set(rvalDecl.Obj());
4648}
4649
4650
4651
4652MOZ_CAN_RUN_SCRIPT void
4653TestUndefinedConstruction::Construct(const CustomEventInit& arg, ErrorResult& aRv, const char* aExecutionReason, ExceptionHandling aExceptionHandling, JS::Realm* aRealm)
4654{
4655 CallSetup s(this, aRv, "TestUndefinedConstruction", aExceptionHandling, aRealm);
4656 if (aRv.Failed()) {
4657 return;
4658 }
4659 MOZ_ASSERT(s.GetContext())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(s.GetContext())>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(s.GetContext()))), 0))) { do
{ } while (false); MOZ_ReportAssertionFailure("s.GetContext()"
, "../TestCodeGenBinding.cpp", 4659); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "s.GetContext()" ")"); do { *((volatile int*
)__null) = 4659; __attribute__((nomerge)) ::abort(); } while (
false); } } while (false)
;
4660 BindingCallContext& cx = s.GetCallContext();
4661
4662 JS::Rooted<JS::Value> rval(cx);
4663 JS::RootedVector<JS::Value> argv(cx);
4664 if (!argv.resize(1)) {
4665 // That threw an exception on the JSContext, and our CallSetup will do
4666 // the right thing with that.
4667 return;
4668 }
4669 unsigned argc = 1;
4670
4671 do {
4672 if (!arg.ToObjectInternal(cx, argv[0])) {
4673 aRv.Throw(NS_ERROR_UNEXPECTED);
4674 return;
4675 }
4676 break;
4677 } while (false);
4678
4679 JS::Rooted<JS::Value> constructor(cx, JS::ObjectValue(*mCallback));
4680 JS::Rooted<JSObject*> constructedObj(cx);
4681 if (!JS::Construct(cx, constructor,
4682 JS::HandleValueArray::subarray(argv, 0, argc), &constructedObj)) {
4683 aRv.NoteJSContextException(cx);
4684 return;
4685 }
4686 rval.setObject(*constructedObj);
4687}
4688
4689
4690
4691
4692Dict::Dict()
4693 : ParentDict(FastDictionaryInitializer()),
4694 mAnotherObj(nullptr),
4695 mRequiredObject(nullptr)
4696{
4697 // Safe to pass a null context if we pass a null value
4698 Init(nullptr, JS::NullHandleValue);
4699}
4700
4701
4702
4703bool
4704Dict::InitIds(JSContext* cx, DictAtoms* atomsCache)
4705{
4706 MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid())do { static_assert( mozilla::detail::AssertionConditionType<
decltype(reinterpret_cast<jsid*>(atomsCache)->isVoid
())>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(reinterpret_cast<jsid*>(atomsCache)->isVoid
()))), 0))) { do { } while (false); MOZ_ReportAssertionFailure
("reinterpret_cast<jsid*>(atomsCache)->isVoid()", "../TestCodeGenBinding.cpp"
, 4706); AnnotateMozCrashReason("MOZ_ASSERT" "(" "reinterpret_cast<jsid*>(atomsCache)->isVoid()"
")"); do { *((volatile int*)__null) = 4706; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
4707
4708 // Initialize these in reverse order so that any failure leaves the first one
4709 // uninitialized.
4710 if (!atomsCache->z_id.init(cx, "z") ||
4711 !atomsCache->yetAnotherStr_id.init(cx, "yetAnotherStr") ||
4712 !atomsCache->x_id.init(cx, "x") ||
4713 !atomsCache->utf8StringRecord_id.init(cx, "utf8StringRecord") ||
4714 !atomsCache->usvStringRecord_id.init(cx, "usvStringRecord") ||
4715 !atomsCache->urFloat4_id.init(cx, "urFloat4") ||
4716 !atomsCache->urFloat3_id.init(cx, "urFloat3") ||
4717 !atomsCache->urFloat2_id.init(cx, "urFloat2") ||
4718 !atomsCache->urFloat_id.init(cx, "urFloat") ||
4719 !atomsCache->urDouble4_id.init(cx, "urDouble4") ||
4720 !atomsCache->urDouble3_id.init(cx, "urDouble3") ||
4721 !atomsCache->urDouble2_id.init(cx, "urDouble2") ||
4722 !atomsCache->urDouble_id.init(cx, "urDouble") ||
4723 !atomsCache->uint8Array_id.init(cx, "uint8Array") ||
4724 !atomsCache->template_id.init(cx, "template") ||
4725 !atomsCache->str_id.init(cx, "str") ||
4726 !atomsCache->someObj_id.init(cx, "someObj") ||
4727 !atomsCache->someEnum_id.init(cx, "someEnum") ||
4728 !atomsCache->someCallback_id.init(cx, "someCallback") ||
4729 !atomsCache->someAny_id.init(cx, "someAny") ||
4730 !atomsCache->seq5_id.init(cx, "seq5") ||
4731 !atomsCache->seq4_id.init(cx, "seq4") ||
4732 !atomsCache->seq3_id.init(cx, "seq3") ||
4733 !atomsCache->seq2_id.init(cx, "seq2") ||
4734 !atomsCache->seq1_id.init(cx, "seq1") ||
4735 !atomsCache->requiredUTF8Record_id.init(cx, "requiredUTF8Record") ||
4736 !atomsCache->requiredUSVRecord_id.init(cx, "requiredUSVRecord") ||
4737 !atomsCache->requiredRecord_id.init(cx, "requiredRecord") ||
4738 !atomsCache->requiredObject_id.init(cx, "requiredObject") ||
4739 !atomsCache->requiredLong_id.init(cx, "requiredLong") ||
4740 !atomsCache->requiredByteRecord_id.init(cx, "requiredByteRecord") ||
4741 !atomsCache->recordMember_id.init(cx, "recordMember") ||
4742 !atomsCache->prototype_id.init(cx, "prototype") ||
4743 !atomsCache->promiseSequence_id.init(cx, "promiseSequence") ||
4744 !atomsCache->promise_id.init(cx, "promise") ||
4745 !atomsCache->otherStr_id.init(cx, "otherStr") ||
4746 !atomsCache->otherEnum_id.init(cx, "otherEnum") ||
4747 !atomsCache->otherByteStr_id.init(cx, "otherByteStr") ||
4748 !atomsCache->objectSequenceOrLongWithDefaultValue2_id.init(cx, "objectSequenceOrLongWithDefaultValue2") ||
4749 !atomsCache->objectSequenceOrLongWithDefaultValue1_id.init(cx, "objectSequenceOrLongWithDefaultValue1") ||
4750 !atomsCache->objectSequenceOrLong_id.init(cx, "objectSequenceOrLong") ||
4751 !atomsCache->objectOrLong_id.init(cx, "objectOrLong") ||
4752 !atomsCache->nullableUTF8StringRecordWithDefault_id.init(cx, "nullableUTF8StringRecordWithDefault") ||
4753 !atomsCache->nullableUSVStringRecordWithDefault_id.init(cx, "nullableUSVStringRecordWithDefault") ||
4754 !atomsCache->nullableRecordWithDefault_id.init(cx, "nullableRecordWithDefault") ||
4755 !atomsCache->nullableRecord_id.init(cx, "nullableRecord") ||
4756 !atomsCache->nullableObjectSequenceOrLongWithDefaultValue2_id.init(cx, "nullableObjectSequenceOrLongWithDefaultValue2") ||
4757 !atomsCache->nullableObjectSequenceOrLongWithDefaultValue1_id.init(cx, "nullableObjectSequenceOrLongWithDefaultValue1") ||
4758 !atomsCache->nullableObjectSequenceOrLong_id.init(cx, "nullableObjectSequenceOrLong") ||
4759 !atomsCache->nullableHTMLElementOrLong_id.init(cx, "nullableHTMLElementOrLong") ||
4760 !atomsCache->nullableFloatOrString_id.init(cx, "nullableFloatOrString") ||
4761 !atomsCache->nullableEventInitOrLongWithDefaultValue4_id.init(cx, "nullableEventInitOrLongWithDefaultValue4") ||
4762 !atomsCache->nullableEventInitOrLongWithDefaultValue3_id.init(cx, "nullableEventInitOrLongWithDefaultValue3") ||
4763 !atomsCache->nullableEventInitOrLongWithDefaultValue2_id.init(cx, "nullableEventInitOrLongWithDefaultValue2") ||
4764 !atomsCache->nullableEventInitOrLongWithDefaultValue_id.init(cx, "nullableEventInitOrLongWithDefaultValue") ||
4765 !atomsCache->nullableEventInitOrLong2_id.init(cx, "nullableEventInitOrLong2") ||
4766 !atomsCache->nullableEventInitOrLong_id.init(cx, "nullableEventInitOrLong") ||
4767 !atomsCache->nullableByteStringRecordWithDefault_id.init(cx, "nullableByteStringRecordWithDefault") ||
4768 !atomsCache->nullableArrayBuffer_id.init(cx, "nullableArrayBuffer") ||
4769 !atomsCache->negativeInfUrFloat_id.init(cx, "negativeInfUrFloat") ||
4770 !atomsCache->negativeInfUrDouble_id.init(cx, "negativeInfUrDouble") ||
4771 !atomsCache->nanUrFloat_id.init(cx, "nanUrFloat") ||
4772 !atomsCache->nanUrDouble_id.init(cx, "nanUrDouble") ||
4773 !atomsCache->infUrFloat_id.init(cx, "infUrFloat") ||
4774 !atomsCache->infUrDouble_id.init(cx, "infUrDouble") ||
4775 !atomsCache->floatOrString_id.init(cx, "floatOrString") ||
4776 !atomsCache->float64Array_id.init(cx, "float64Array") ||
4777 !atomsCache->eventInitOrLongWithDefaultValue4_id.init(cx, "eventInitOrLongWithDefaultValue4") ||
4778 !atomsCache->eventInitOrLongWithDefaultValue3_id.init(cx, "eventInitOrLongWithDefaultValue3") ||
4779 !atomsCache->eventInitOrLongWithDefaultValue2_id.init(cx, "eventInitOrLongWithDefaultValue2") ||
4780 !atomsCache->eventInitOrLongWithDefaultValue_id.init(cx, "eventInitOrLongWithDefaultValue") ||
4781 !atomsCache->eventInitOrLong2_id.init(cx, "eventInitOrLong2") ||
4782 !atomsCache->eventInitOrLong_id.init(cx, "eventInitOrLong") ||
4783 !atomsCache->enforcedUnsignedLong_id.init(cx, "enforcedUnsignedLong") ||
4784 !atomsCache->emptyByteStr_id.init(cx, "emptyByteStr") ||
4785 !atomsCache->empty_id.init(cx, "empty") ||
4786 !atomsCache->dictionaryTypedef_id.init(cx, "dictionaryTypedef") ||
4787 !atomsCache->dashed_name_id.init(cx, "dashed-name") ||
4788 !atomsCache->customEventInit_id.init(cx, "customEventInit") ||
4789 !atomsCache->clampedUnsignedLong_id.init(cx, "clampedUnsignedLong") ||
4790 !atomsCache->byteStringRecord_id.init(cx, "byteStringRecord") ||
4791 !atomsCache->byteStr_id.init(cx, "byteStr") ||
4792 !atomsCache->b_id.init(cx, "b") ||
4793 !atomsCache->arrayBuffer_id.init(cx, "arrayBuffer") ||
4794 !atomsCache->anotherObj_id.init(cx, "anotherObj") ||
4795 !atomsCache->anotherAny_id.init(cx, "anotherAny") ||
4796 !atomsCache->a_id.init(cx, "a")) {
4797 return false;
4798 }
4799 return true;
4800}
4801
4802bool
4803Dict::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
4804{
4805 // Passing a null JSContext is OK only if we're initing from null,
4806 // Since in that case we will not have to do any property gets
4807 // Also evaluate isNullOrUndefined in order to avoid false-positive
4808 // checkers by static analysis tools
4809 MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined())do { if (!cx) { do { static_assert( mozilla::detail::AssertionConditionType
<decltype(val.isNull() && val.isNullOrUndefined())
>::isValid, "invalid assertion condition"); if ((__builtin_expect
(!!(!(!!(val.isNull() && val.isNullOrUndefined()))), 0
))) { do { } while (false); MOZ_ReportAssertionFailure("val.isNull() && val.isNullOrUndefined()"
, "../TestCodeGenBinding.cpp", 4809); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "val.isNull() && val.isNullOrUndefined()"
")"); do { *((volatile int*)__null) = 4809; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false); } } while (
false)
;
4810 DictAtoms* atomsCache = nullptr;
4811 if (cx) {
4812 atomsCache = GetAtomCache<DictAtoms>(cx);
4813 if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
4814 !InitIds(cx, atomsCache)) {
4815 return false;
4816 }
4817 }
4818
4819 // Per spec, we init the parent's members first
4820 if (!ParentDict::Init(cx, val)) {
4821 return false;
4822 }
4823
4824 bool isNull = val.isNullOrUndefined();
4825 // We only need these if !isNull, in which case we have |cx|.
4826 Maybe<JS::Rooted<JSObject *> > object;
4827 Maybe<JS::Rooted<JS::Value> > temp;
4828 if (!isNull) {
4829 MOZ_ASSERT(cx)do { static_assert( mozilla::detail::AssertionConditionType<
decltype(cx)>::isValid, "invalid assertion condition"); if
((__builtin_expect(!!(!(!!(cx))), 0))) { do { } while (false
); MOZ_ReportAssertionFailure("cx", "../TestCodeGenBinding.cpp"
, 4829); AnnotateMozCrashReason("MOZ_ASSERT" "(" "cx" ")"); do
{ *((volatile int*)__null) = 4829; __attribute__((nomerge)) ::
abort(); } while (false); } } while (false)
;
4830 object.emplace(cx, &val.toObject());
4831 temp.emplace(cx);
4832 }
4833 if (!isNull) {
4834 if (!JS_GetPropertyById(cx, *object, atomsCache->a_id, temp.ptr())) {
4835 return false;
4836 }
4837 }
4838 if (!isNull && !temp->isUndefined()) {
4839 mA.Construct();
4840 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'a' member of Dict", &(mA.Value()))) {
4841 return false;
4842 }
4843 mIsAnyMemberPresent = true;
4844 }
4845
4846 if (!isNull) {
4847 if (!JS_GetPropertyById(cx, *object, atomsCache->anotherAny_id, temp.ptr())) {
4848 return false;
4849 }
4850 }
4851 if (!isNull && !temp->isUndefined()) {
4852#ifdef __clang__1
4853#pragma clang diagnostic push
4854#pragma clang diagnostic ignored "-Wunreachable-code"
4855#pragma clang diagnostic ignored "-Wunreachable-code-return"
4856#endif // __clang__
4857 if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
4858 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("'anotherAny' member of Dict");
4859 return false;
4860 }
4861#ifdef __clang__1
4862#pragma clang diagnostic pop
4863#endif // __clang__
4864 mAnotherAny = temp.ref();
4865 } else {
4866 mAnotherAny = JS::NullValue();
4867 }
4868 mIsAnyMemberPresent = true;
4869
4870 if (!isNull) {
4871 if (!JS_GetPropertyById(cx, *object, atomsCache->anotherObj_id, temp.ptr())) {
4872 return false;
4873 }
4874 }
4875 if (!isNull && !temp->isUndefined()) {
4876 if (temp.ref().isObject()) {
4877#ifdef __clang__1
4878#pragma clang diagnostic push
4879#pragma clang diagnostic ignored "-Wunreachable-code"
4880#pragma clang diagnostic ignored "-Wunreachable-code-return"
4881#endif // __clang__
4882 if ((passedToJSImpl) && !CallerSubsumes(temp.ref())) {
4883 cx.ThrowErrorMessage<MSG_PERMISSION_DENIED_TO_PASS_ARG>("'anotherObj' member of Dict");
4884 return false;
4885 }
4886#ifdef __clang__1
4887#pragma clang diagnostic pop
4888#endif // __clang__
4889 mAnotherObj = &temp.ref().toObject();
4890 } else if (temp.ref().isNullOrUndefined()) {
4891 mAnotherObj = nullptr;
4892 } else {
4893 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'anotherObj' member of Dict");
4894 return false;
4895 }
4896 } else {
4897 mAnotherObj = nullptr;
4898 }
4899 mIsAnyMemberPresent = true;
4900
4901 if (!isNull) {
4902 if (!JS_GetPropertyById(cx, *object, atomsCache->arrayBuffer_id, temp.ptr())) {
4903 return false;
4904 }
4905 }
4906 if (!isNull && !temp->isUndefined()) {
4907 mArrayBuffer.Construct();
4908 if (temp.ref().isObject()) {
4909 if (!(mArrayBuffer.Value()).Init(&temp.ref().toObject())) {
4910 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'arrayBuffer' member of Dict", "ArrayBuffer");
4911 return false;
4912 }
4913 if (JS::IsSharedArrayBufferObject((mArrayBuffer.Value()).Obj())) {
4914 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_SHARED>("'arrayBuffer' member of Dict");
4915 return false;
4916 }
4917 if (JS::IsLargeArrayBufferMaybeShared((mArrayBuffer.Value()).Obj())) {
4918 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_LARGE>("'arrayBuffer' member of Dict");
4919 return false;
4920 }
4921 if (JS::IsResizableArrayBufferMaybeShared((mArrayBuffer.Value()).Obj())) {
4922 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_RESIZABLE>("'arrayBuffer' member of Dict");
4923 return false;
4924 }
4925 } else {
4926 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'arrayBuffer' member of Dict");
4927 return false;
4928 }
4929 mIsAnyMemberPresent = true;
4930 }
4931
4932 if (!isNull) {
4933 if (!JS_GetPropertyById(cx, *object, atomsCache->b_id, temp.ptr())) {
4934 return false;
4935 }
4936 }
4937 if (!isNull && !temp->isUndefined()) {
4938 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'b' member of Dict", &mB)) {
4939 return false;
4940 }
4941 } else {
4942 mB = 8;
4943 }
4944 mIsAnyMemberPresent = true;
4945
4946 if (!isNull) {
4947 if (!JS_GetPropertyById(cx, *object, atomsCache->byteStr_id, temp.ptr())) {
4948 return false;
4949 }
4950 }
4951 if (!isNull && !temp->isUndefined()) {
4952 mByteStr.Construct();
4953 if (!ConvertJSValueToByteString(cx, temp.ref(), false, "'byteStr' member of Dict", (mByteStr.Value()))) {
4954 return false;
4955 }
4956 mIsAnyMemberPresent = true;
4957 }
4958
4959 if (!isNull) {
4960 if (!JS_GetPropertyById(cx, *object, atomsCache->byteStringRecord_id, temp.ptr())) {
4961 return false;
4962 }
4963 }
4964 if (!isNull && !temp->isUndefined()) {
4965 mByteStringRecord.Construct();
4966 if (temp.ref().isObject()) {
4967 auto& recordEntries = (mByteStringRecord.Value()).Entries();
4968
4969 JS::Rooted<JSObject*> recordObj(cx, &temp.ref().toObject());
4970 JS::RootedVector<jsid> ids(cx);
4971 if (!js::GetPropertyKeys(cx, recordObj,
4972 JSITER_OWNONLY0x8 | JSITER_HIDDEN0x10 | JSITER_SYMBOLS0x20, &ids)) {
4973 return false;
4974 }
4975 if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
4976 JS_ReportOutOfMemory(cx);
4977 return false;
4978 }
4979 JS::Rooted<JS::Value> propNameValue(cx);
4980 JS::Rooted<JS::Value> temp(cx);
4981 JS::Rooted<jsid> curId(cx);
4982 JS::Rooted<JS::Value> idVal(cx);
4983 // Use a hashset to keep track of ids seen, to avoid
4984 // introducing nasty O(N^2) behavior scanning for them all the
4985 // time. Ideally we'd use a data structure with O(1) lookup
4986 // _and_ ordering for the MozMap, but we don't have one lying
4987 // around.
4988 nsTHashtable<nsCStringHashKey> idsSeen;
4989 for (size_t i = 0; i < ids.length(); ++i) {
4990 curId = ids[i];
4991
4992 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(cx);
4993 if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
4994 &desc)) {
4995 return false;
4996 }
4997
4998 if (desc.isNothing() || !desc->enumerable()) {
4999 continue;
5000 }
5001
5002 idVal = js::IdToValue(curId);
5003 nsCString propName;
5004 // This will just throw if idVal is a Symbol, like the spec says
5005 // to do.
5006 if (!ConvertJSValueToByteString(cx, idVal, "key of 'byteStringRecord' member of Dict", propName)) {
5007 return false;
5008 }
5009
5010 if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
5011 return false;
5012 }
5013
5014 Record<nsCString, int32_t>::EntryType* entry;
5015 if (!idsSeen.EnsureInserted(propName)) {
5016 // Find the existing entry.
5017 auto idx = recordEntries.IndexOf(propName);
5018 MOZ_ASSERT(idx != recordEntries.NoIndex,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5019); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5019; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5019 "Why is it not found?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5019); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5019; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5020 // Now blow it away to make it look like it was just added
5021 // to the array, because it's not obvious that it's
5022 // safe to write to its already-initialized mValue via our
5023 // normal codegen conversions. For example, the value
5024 // could be a union and this would change its type, but
5025 // codegen assumes we won't do that.
5026 entry = recordEntries.ReconstructElementAt(idx);
5027 } else {
5028 // Safe to do an infallible append here, because we did a
5029 // SetCapacity above to the right capacity.
5030 entry = recordEntries.AppendElement();
5031 }
5032 entry->mKey = propName;
5033 int32_t& slot = entry->mValue;
5034 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Value in 'byteStringRecord' member of Dict", &slot)) {
5035 return false;
5036 }
5037 }
5038 } else {
5039 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'byteStringRecord' member of Dict");
5040 return false;
5041 }
5042 mIsAnyMemberPresent = true;
5043 }
5044
5045 if (!isNull) {
5046 if (!JS_GetPropertyById(cx, *object, atomsCache->clampedUnsignedLong_id, temp.ptr())) {
5047 return false;
5048 }
5049 }
5050 if (!isNull && !temp->isUndefined()) {
5051 mClampedUnsignedLong.Construct();
5052 if (!ValueToPrimitive<uint32_t, eClamp>(cx, temp.ref(), "'clampedUnsignedLong' member of Dict", &(mClampedUnsignedLong.Value()))) {
5053 return false;
5054 }
5055 mIsAnyMemberPresent = true;
5056 }
5057
5058 if (!isNull) {
5059 if (!JS_GetPropertyById(cx, *object, atomsCache->customEventInit_id, temp.ptr())) {
5060 return false;
5061 }
5062 }
5063 if (!isNull && !temp->isUndefined()) {
5064 mCustomEventInit.Construct();
5065 if (!(mCustomEventInit.Value()).Init(cx, temp.ref(), "'customEventInit' member of Dict", passedToJSImpl)) {
5066 return false;
5067 }
5068 mIsAnyMemberPresent = true;
5069 }
5070
5071 if (!isNull) {
5072 if (!JS_GetPropertyById(cx, *object, atomsCache->dashed_name_id, temp.ptr())) {
5073 return false;
5074 }
5075 }
5076 if (!isNull && !temp->isUndefined()) {
5077 mDashed_name.Construct();
5078 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp.ref(), "'dashed-name' member of Dict", &(mDashed_name.Value()))) {
5079 return false;
5080 }
5081 mIsAnyMemberPresent = true;
5082 }
5083
5084 if (!isNull) {
5085 if (!JS_GetPropertyById(cx, *object, atomsCache->dictionaryTypedef_id, temp.ptr())) {
5086 return false;
5087 }
5088 }
5089 if (!isNull && !temp->isUndefined()) {
5090 mDictionaryTypedef.Construct();
5091 if (!(mDictionaryTypedef.Value()).Init(cx, temp.ref(), "'dictionaryTypedef' member of Dict", passedToJSImpl)) {
5092 return false;
5093 }
5094 mIsAnyMemberPresent = true;
5095 }
5096
5097 if (!isNull) {
5098 if (!JS_GetPropertyById(cx, *object, atomsCache->empty_id, temp.ptr())) {
5099 return false;
5100 }
5101 }
5102 if (!isNull && !temp->isUndefined()) {
5103 if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mEmpty)) {
5104 return false;
5105 }
5106 } else {
5107 mEmpty.AssignLiteral(u"");
5108 }
5109 mIsAnyMemberPresent = true;
5110
5111 if (!isNull) {
5112 if (!JS_GetPropertyById(cx, *object, atomsCache->emptyByteStr_id, temp.ptr())) {
5113 return false;
5114 }
5115 }
5116 if (!isNull && !temp->isUndefined()) {
5117 if (!ConvertJSValueToByteString(cx, temp.ref(), false, "'emptyByteStr' member of Dict", mEmptyByteStr)) {
5118 return false;
5119 }
5120 } else {
5121 mEmptyByteStr.AssignLiteral("");
5122 }
5123 mIsAnyMemberPresent = true;
5124
5125 if (!isNull) {
5126 if (!JS_GetPropertyById(cx, *object, atomsCache->enforcedUnsignedLong_id, temp.ptr())) {
5127 return false;
5128 }
5129 }
5130 if (!isNull && !temp->isUndefined()) {
5131 mEnforcedUnsignedLong.Construct();
5132 if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, temp.ref(), "'enforcedUnsignedLong' member of Dict", &(mEnforcedUnsignedLong.Value()))) {
5133 return false;
5134 }
5135 mIsAnyMemberPresent = true;
5136 }
5137
5138 if (!isNull) {
5139 if (!JS_GetPropertyById(cx, *object, atomsCache->eventInitOrLong_id, temp.ptr())) {
5140 return false;
5141 }
5142 }
5143 if (!isNull && !temp->isUndefined()) {
5144 mEventInitOrLong.Construct();
5145 if (!(mEventInitOrLong.Value()).Init(cx, temp.ref(), "'eventInitOrLong' member of Dict", passedToJSImpl)) {
5146 return false;
5147 }
5148 mIsAnyMemberPresent = true;
5149 }
5150
5151 if (!isNull) {
5152 if (!JS_GetPropertyById(cx, *object, atomsCache->eventInitOrLong2_id, temp.ptr())) {
5153 return false;
5154 }
5155 }
5156 if (!isNull && !temp->isUndefined()) {
5157 mEventInitOrLong2.Construct();
5158 if (!(mEventInitOrLong2.Value()).Init(cx, temp.ref(), "'eventInitOrLong2' member of Dict", passedToJSImpl)) {
5159 return false;
5160 }
5161 mIsAnyMemberPresent = true;
5162 }
5163
5164 if (!isNull) {
5165 if (!JS_GetPropertyById(cx, *object, atomsCache->eventInitOrLongWithDefaultValue_id, temp.ptr())) {
5166 return false;
5167 }
5168 }
5169 mEventInitOrLongWithDefaultValue.Uninit();
5170 if (!(!isNull && !temp->isUndefined())) {
5171 if (!mEventInitOrLongWithDefaultValue.RawSetAsEventInit().Init(cx, JS::NullHandleValue, "Member of (EventInit or long)")) {
5172 return false;
5173 }
5174 } else {
5175 if (!mEventInitOrLongWithDefaultValue.Init(cx, temp.ref(), "'eventInitOrLongWithDefaultValue' member of Dict", passedToJSImpl)) {
5176 return false;
5177 }
5178 }
5179 mIsAnyMemberPresent = true;
5180
5181 if (!isNull) {
5182 if (!JS_GetPropertyById(cx, *object, atomsCache->eventInitOrLongWithDefaultValue2_id, temp.ptr())) {
5183 return false;
5184 }
5185 }
5186 mEventInitOrLongWithDefaultValue2.Uninit();
5187 if (!(!isNull && !temp->isUndefined())) {
5188 if (!mEventInitOrLongWithDefaultValue2.RawSetAsCustomEventInit().Init(cx, JS::NullHandleValue, "Member of (CustomEventInit or long)")) {
5189 return false;
5190 }
5191 } else {
5192 if (!mEventInitOrLongWithDefaultValue2.Init(cx, temp.ref(), "'eventInitOrLongWithDefaultValue2' member of Dict", passedToJSImpl)) {
5193 return false;
5194 }
5195 }
5196 mIsAnyMemberPresent = true;
5197
5198 if (!isNull) {
5199 if (!JS_GetPropertyById(cx, *object, atomsCache->eventInitOrLongWithDefaultValue3_id, temp.ptr())) {
5200 return false;
5201 }
5202 }
5203 mEventInitOrLongWithDefaultValue3.Uninit();
5204 if (!(!isNull && !temp->isUndefined())) {
5205 mEventInitOrLongWithDefaultValue3.RawSetAsLong() = 5;
5206 } else {
5207 if (!mEventInitOrLongWithDefaultValue3.Init(cx, temp.ref(), "'eventInitOrLongWithDefaultValue3' member of Dict", passedToJSImpl)) {
5208 return false;
5209 }
5210 }
5211 mIsAnyMemberPresent = true;
5212
5213 if (!isNull) {
5214 if (!JS_GetPropertyById(cx, *object, atomsCache->eventInitOrLongWithDefaultValue4_id, temp.ptr())) {
5215 return false;
5216 }
5217 }
5218 mEventInitOrLongWithDefaultValue4.Uninit();
5219 if (!(!isNull && !temp->isUndefined())) {
5220 mEventInitOrLongWithDefaultValue4.RawSetAsLong() = 5;
5221 } else {
5222 if (!mEventInitOrLongWithDefaultValue4.Init(cx, temp.ref(), "'eventInitOrLongWithDefaultValue4' member of Dict", passedToJSImpl)) {
5223 return false;
5224 }
5225 }
5226 mIsAnyMemberPresent = true;
5227
5228 if (!isNull) {
5229 if (!JS_GetPropertyById(cx, *object, atomsCache->float64Array_id, temp.ptr())) {
5230 return false;
5231 }
5232 }
5233 if (!isNull && !temp->isUndefined()) {
5234 if (temp.ref().isObject()) {
5235 if (!mFloat64Array.SetValue().Init(&temp.ref().toObject())) {
5236 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'float64Array' member of Dict", "Float64ArrayOrNull");
5237 return false;
5238 }
5239 if (JS::IsArrayBufferViewShared(mFloat64Array.SetValue().Obj())) {
5240 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_SHARED>("'float64Array' member of Dict");
5241 return false;
5242 }
5243 if (JS::IsLargeArrayBufferView(mFloat64Array.SetValue().Obj())) {
5244 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_LARGE>("'float64Array' member of Dict");
5245 return false;
5246 }
5247 if (JS::IsResizableArrayBufferView(mFloat64Array.SetValue().Obj())) {
5248 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_RESIZABLE>("'float64Array' member of Dict");
5249 return false;
5250 }
5251 } else if (temp.ref().isNullOrUndefined()) {
5252 mFloat64Array.SetNull();
5253 } else {
5254 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'float64Array' member of Dict");
5255 return false;
5256 }
5257 } else {
5258 mFloat64Array.SetNull();
5259 }
5260 mIsAnyMemberPresent = true;
5261
5262 if (!isNull) {
5263 if (!JS_GetPropertyById(cx, *object, atomsCache->floatOrString_id, temp.ptr())) {
5264 return false;
5265 }
5266 }
5267 mFloatOrString.Uninit();
5268 if (!(!isNull && !temp->isUndefined())) {
5269 mFloatOrString.SetStringLiteral(u"str");
5270 } else {
5271 if (!mFloatOrString.Init(cx, temp.ref(), "'floatOrString' member of Dict", passedToJSImpl)) {
5272 return false;
5273 }
5274 }
5275 mIsAnyMemberPresent = true;
5276
5277 if (!isNull) {
5278 if (!JS_GetPropertyById(cx, *object, atomsCache->infUrDouble_id, temp.ptr())) {
5279 return false;
5280 }
5281 }
5282 if (!isNull && !temp->isUndefined()) {
5283 if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'infUrDouble' member of Dict", &mInfUrDouble)) {
5284 return false;
5285 }
5286 } else {
5287 mInfUrDouble = mozilla::PositiveInfinity<double>();
5288 }
5289 mIsAnyMemberPresent = true;
5290
5291 if (!isNull) {
5292 if (!JS_GetPropertyById(cx, *object, atomsCache->infUrFloat_id, temp.ptr())) {
5293 return false;
5294 }
5295 }
5296 if (!isNull && !temp->isUndefined()) {
5297 if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), "'infUrFloat' member of Dict", &mInfUrFloat)) {
5298 return false;
5299 }
5300 } else {
5301 mInfUrFloat = mozilla::PositiveInfinity<float>();
5302 }
5303 mIsAnyMemberPresent = true;
5304
5305 if (!isNull) {
5306 if (!JS_GetPropertyById(cx, *object, atomsCache->nanUrDouble_id, temp.ptr())) {
5307 return false;
5308 }
5309 }
5310 if (!isNull && !temp->isUndefined()) {
5311 if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'nanUrDouble' member of Dict", &mNanUrDouble)) {
5312 return false;
5313 }
5314 } else {
5315 mNanUrDouble = mozilla::UnspecifiedNaN<double>();
5316 }
5317 mIsAnyMemberPresent = true;
5318
5319 if (!isNull) {
5320 if (!JS_GetPropertyById(cx, *object, atomsCache->nanUrFloat_id, temp.ptr())) {
5321 return false;
5322 }
5323 }
5324 if (!isNull && !temp->isUndefined()) {
5325 if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), "'nanUrFloat' member of Dict", &mNanUrFloat)) {
5326 return false;
5327 }
5328 } else {
5329 mNanUrFloat = mozilla::UnspecifiedNaN<float>();
5330 }
5331 mIsAnyMemberPresent = true;
5332
5333 if (!isNull) {
5334 if (!JS_GetPropertyById(cx, *object, atomsCache->negativeInfUrDouble_id, temp.ptr())) {
5335 return false;
5336 }
5337 }
5338 if (!isNull && !temp->isUndefined()) {
5339 if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'negativeInfUrDouble' member of Dict", &mNegativeInfUrDouble)) {
5340 return false;
5341 }
5342 } else {
5343 mNegativeInfUrDouble = mozilla::NegativeInfinity<double>();
5344 }
5345 mIsAnyMemberPresent = true;
5346
5347 if (!isNull) {
5348 if (!JS_GetPropertyById(cx, *object, atomsCache->negativeInfUrFloat_id, temp.ptr())) {
5349 return false;
5350 }
5351 }
5352 if (!isNull && !temp->isUndefined()) {
5353 if (!ValueToPrimitive<float, eDefault>(cx, temp.ref(), "'negativeInfUrFloat' member of Dict", &mNegativeInfUrFloat)) {
5354 return false;
5355 }
5356 } else {
5357 mNegativeInfUrFloat = mozilla::NegativeInfinity<float>();
5358 }
5359 mIsAnyMemberPresent = true;
5360
5361 if (!isNull) {
5362 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableArrayBuffer_id, temp.ptr())) {
5363 return false;
5364 }
5365 }
5366 if (!isNull && !temp->isUndefined()) {
5367 mNullableArrayBuffer.Construct();
5368 if (temp.ref().isObject()) {
5369 if (!(mNullableArrayBuffer.Value()).SetValue().Init(&temp.ref().toObject())) {
5370 cx.ThrowErrorMessage<MSG_DOES_NOT_IMPLEMENT_INTERFACE>("'nullableArrayBuffer' member of Dict", "ArrayBufferOrNull");
5371 return false;
5372 }
5373 if (JS::IsSharedArrayBufferObject((mNullableArrayBuffer.Value()).SetValue().Obj())) {
5374 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_SHARED>("'nullableArrayBuffer' member of Dict");
5375 return false;
5376 }
5377 if (JS::IsLargeArrayBufferMaybeShared((mNullableArrayBuffer.Value()).SetValue().Obj())) {
5378 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_LARGE>("'nullableArrayBuffer' member of Dict");
5379 return false;
5380 }
5381 if (JS::IsResizableArrayBufferMaybeShared((mNullableArrayBuffer.Value()).SetValue().Obj())) {
5382 cx.ThrowErrorMessage<MSG_TYPEDARRAY_IS_RESIZABLE>("'nullableArrayBuffer' member of Dict");
5383 return false;
5384 }
5385 } else if (temp.ref().isNullOrUndefined()) {
5386 (mNullableArrayBuffer.Value()).SetNull();
5387 } else {
5388 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'nullableArrayBuffer' member of Dict");
5389 return false;
5390 }
5391 mIsAnyMemberPresent = true;
5392 }
5393
5394 if (!isNull) {
5395 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableByteStringRecordWithDefault_id, temp.ptr())) {
5396 return false;
5397 }
5398 }
5399 if (!isNull && !temp->isUndefined()) {
5400 if (temp.ref().isObject()) {
5401 auto& recordEntries = mNullableByteStringRecordWithDefault.SetValue().Entries();
5402
5403 JS::Rooted<JSObject*> recordObj(cx, &temp.ref().toObject());
5404 JS::RootedVector<jsid> ids(cx);
5405 if (!js::GetPropertyKeys(cx, recordObj,
5406 JSITER_OWNONLY0x8 | JSITER_HIDDEN0x10 | JSITER_SYMBOLS0x20, &ids)) {
5407 return false;
5408 }
5409 if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
5410 JS_ReportOutOfMemory(cx);
5411 return false;
5412 }
5413 JS::Rooted<JS::Value> propNameValue(cx);
5414 JS::Rooted<JS::Value> temp(cx);
5415 JS::Rooted<jsid> curId(cx);
5416 JS::Rooted<JS::Value> idVal(cx);
5417 // Use a hashset to keep track of ids seen, to avoid
5418 // introducing nasty O(N^2) behavior scanning for them all the
5419 // time. Ideally we'd use a data structure with O(1) lookup
5420 // _and_ ordering for the MozMap, but we don't have one lying
5421 // around.
5422 nsTHashtable<nsCStringHashKey> idsSeen;
5423 for (size_t i = 0; i < ids.length(); ++i) {
5424 curId = ids[i];
5425
5426 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(cx);
5427 if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
5428 &desc)) {
5429 return false;
5430 }
5431
5432 if (desc.isNothing() || !desc->enumerable()) {
5433 continue;
5434 }
5435
5436 idVal = js::IdToValue(curId);
5437 nsCString propName;
5438 // This will just throw if idVal is a Symbol, like the spec says
5439 // to do.
5440 if (!ConvertJSValueToByteString(cx, idVal, "key of 'nullableByteStringRecordWithDefault' member of Dict", propName)) {
5441 return false;
5442 }
5443
5444 if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
5445 return false;
5446 }
5447
5448 Record<nsCString, int32_t>::EntryType* entry;
5449 if (!idsSeen.EnsureInserted(propName)) {
5450 // Find the existing entry.
5451 auto idx = recordEntries.IndexOf(propName);
5452 MOZ_ASSERT(idx != recordEntries.NoIndex,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5453); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5453; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5453 "Why is it not found?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5453); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5453; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5454 // Now blow it away to make it look like it was just added
5455 // to the array, because it's not obvious that it's
5456 // safe to write to its already-initialized mValue via our
5457 // normal codegen conversions. For example, the value
5458 // could be a union and this would change its type, but
5459 // codegen assumes we won't do that.
5460 entry = recordEntries.ReconstructElementAt(idx);
5461 } else {
5462 // Safe to do an infallible append here, because we did a
5463 // SetCapacity above to the right capacity.
5464 entry = recordEntries.AppendElement();
5465 }
5466 entry->mKey = propName;
5467 int32_t& slot = entry->mValue;
5468 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Value in 'nullableByteStringRecordWithDefault' member of Dict", &slot)) {
5469 return false;
5470 }
5471 }
5472 } else if (temp.ref().isNullOrUndefined()) {
5473 mNullableByteStringRecordWithDefault.SetNull();
5474 } else {
5475 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'nullableByteStringRecordWithDefault' member of Dict");
5476 return false;
5477 }
5478 } else {
5479 mNullableByteStringRecordWithDefault.SetNull();
5480 }
5481 mIsAnyMemberPresent = true;
5482
5483 if (!isNull) {
5484 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableEventInitOrLong_id, temp.ptr())) {
5485 return false;
5486 }
5487 }
5488 if (!isNull && !temp->isUndefined()) {
5489 mNullableEventInitOrLong.Construct();
5490 if (temp.ref().isNullOrUndefined()) {
5491 (mNullableEventInitOrLong.Value()).SetNull();
5492 } else {
5493 if (!(mNullableEventInitOrLong.Value()).SetValue().Init(cx, temp.ref(), "'nullableEventInitOrLong' member of Dict", passedToJSImpl)) {
5494 return false;
5495 }
5496 }
5497 mIsAnyMemberPresent = true;
5498 }
5499
5500 if (!isNull) {
5501 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableEventInitOrLong2_id, temp.ptr())) {
5502 return false;
5503 }
5504 }
5505 if (!isNull && !temp->isUndefined()) {
5506 mNullableEventInitOrLong2.Construct();
5507 if (temp.ref().isNullOrUndefined()) {
5508 (mNullableEventInitOrLong2.Value()).SetNull();
5509 } else {
5510 if (!(mNullableEventInitOrLong2.Value()).SetValue().Init(cx, temp.ref(), "'nullableEventInitOrLong2' member of Dict", passedToJSImpl)) {
5511 return false;
5512 }
5513 }
5514 mIsAnyMemberPresent = true;
5515 }
5516
5517 if (!isNull) {
5518 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableEventInitOrLongWithDefaultValue_id, temp.ptr())) {
5519 return false;
5520 }
5521 }
5522 if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
5523 mNullableEventInitOrLongWithDefaultValue.SetNull();
5524 } else {
5525 if (!mNullableEventInitOrLongWithDefaultValue.SetValue().Init(cx, temp.ref(), "'nullableEventInitOrLongWithDefaultValue' member of Dict", passedToJSImpl)) {
5526 return false;
5527 }
5528 }
5529 mIsAnyMemberPresent = true;
5530
5531 if (!isNull) {
5532 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableEventInitOrLongWithDefaultValue2_id, temp.ptr())) {
5533 return false;
5534 }
5535 }
5536 if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
5537 mNullableEventInitOrLongWithDefaultValue2.SetNull();
5538 } else {
5539 if (!mNullableEventInitOrLongWithDefaultValue2.SetValue().Init(cx, temp.ref(), "'nullableEventInitOrLongWithDefaultValue2' member of Dict", passedToJSImpl)) {
5540 return false;
5541 }
5542 }
5543 mIsAnyMemberPresent = true;
5544
5545 if (!isNull) {
5546 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableEventInitOrLongWithDefaultValue3_id, temp.ptr())) {
5547 return false;
5548 }
5549 }
5550 if (!mNullableEventInitOrLongWithDefaultValue3.IsNull()) {
5551 mNullableEventInitOrLongWithDefaultValue3.Value().Uninit();
5552 }
5553 if ((!isNull && !temp->isUndefined()) && temp.ref().isNullOrUndefined()) {
5554 mNullableEventInitOrLongWithDefaultValue3.SetNull();
5555 } else {
5556 if (!(!isNull && !temp->isUndefined())) {
5557 mNullableEventInitOrLongWithDefaultValue3.SetValue().RawSetAsLong() = 5;
5558 } else {
5559 if (!mNullableEventInitOrLongWithDefaultValue3.SetValue().Init(cx, temp.ref(), "'nullableEventInitOrLongWithDefaultValue3' member of Dict", passedToJSImpl)) {
5560 return false;
5561 }
5562 }
5563 }
5564 mIsAnyMemberPresent = true;
5565
5566 if (!isNull) {
5567 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableEventInitOrLongWithDefaultValue4_id, temp.ptr())) {
5568 return false;
5569 }
5570 }
5571 if (!mNullableEventInitOrLongWithDefaultValue4.IsNull()) {
5572 mNullableEventInitOrLongWithDefaultValue4.Value().Uninit();
5573 }
5574 if ((!isNull && !temp->isUndefined()) && temp.ref().isNullOrUndefined()) {
5575 mNullableEventInitOrLongWithDefaultValue4.SetNull();
5576 } else {
5577 if (!(!isNull && !temp->isUndefined())) {
5578 mNullableEventInitOrLongWithDefaultValue4.SetValue().RawSetAsLong() = 5;
5579 } else {
5580 if (!mNullableEventInitOrLongWithDefaultValue4.SetValue().Init(cx, temp.ref(), "'nullableEventInitOrLongWithDefaultValue4' member of Dict", passedToJSImpl)) {
5581 return false;
5582 }
5583 }
5584 }
5585 mIsAnyMemberPresent = true;
5586
5587 if (!isNull) {
5588 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableFloatOrString_id, temp.ptr())) {
5589 return false;
5590 }
5591 }
5592 if (!mNullableFloatOrString.IsNull()) {
5593 mNullableFloatOrString.Value().Uninit();
5594 }
5595 if ((!isNull && !temp->isUndefined()) && temp.ref().isNullOrUndefined()) {
5596 mNullableFloatOrString.SetNull();
5597 } else {
5598 if (!(!isNull && !temp->isUndefined())) {
5599 mNullableFloatOrString.SetValue().SetStringLiteral(u"str");
5600 } else {
5601 if (!mNullableFloatOrString.SetValue().Init(cx, temp.ref(), "'nullableFloatOrString' member of Dict", passedToJSImpl)) {
5602 return false;
5603 }
5604 }
5605 }
5606 mIsAnyMemberPresent = true;
5607
5608 if (!isNull) {
5609 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableHTMLElementOrLong_id, temp.ptr())) {
5610 return false;
5611 }
5612 }
5613 if (!isNull && !temp->isUndefined()) {
5614 mNullableHTMLElementOrLong.Construct();
5615 if (temp.ref().isNullOrUndefined()) {
5616 (mNullableHTMLElementOrLong.Value()).SetNull();
5617 } else {
5618 if (!(mNullableHTMLElementOrLong.Value()).SetValue().Init(cx, temp.ref(), "'nullableHTMLElementOrLong' member of Dict", passedToJSImpl)) {
5619 return false;
5620 }
5621 }
5622 mIsAnyMemberPresent = true;
5623 }
5624
5625 if (!isNull) {
5626 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableObjectSequenceOrLong_id, temp.ptr())) {
5627 return false;
5628 }
5629 }
5630 if (!isNull && !temp->isUndefined()) {
5631 mNullableObjectSequenceOrLong.Construct();
5632 if (temp.ref().isNullOrUndefined()) {
5633 (mNullableObjectSequenceOrLong.Value()).SetNull();
5634 } else {
5635 if (!(mNullableObjectSequenceOrLong.Value()).SetValue().Init(cx, temp.ref(), "'nullableObjectSequenceOrLong' member of Dict", passedToJSImpl)) {
5636 return false;
5637 }
5638 }
5639 mIsAnyMemberPresent = true;
5640 }
5641
5642 if (!isNull) {
5643 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableObjectSequenceOrLongWithDefaultValue1_id, temp.ptr())) {
5644 return false;
5645 }
5646 }
5647 if (!mNullableObjectSequenceOrLongWithDefaultValue1.IsNull()) {
5648 mNullableObjectSequenceOrLongWithDefaultValue1.Value().Uninit();
5649 }
5650 if ((!isNull && !temp->isUndefined()) && temp.ref().isNullOrUndefined()) {
5651 mNullableObjectSequenceOrLongWithDefaultValue1.SetNull();
5652 } else {
5653 if (!(!isNull && !temp->isUndefined())) {
5654 mNullableObjectSequenceOrLongWithDefaultValue1.SetValue().RawSetAsLong() = 1;
5655 } else {
5656 if (!mNullableObjectSequenceOrLongWithDefaultValue1.SetValue().Init(cx, temp.ref(), "'nullableObjectSequenceOrLongWithDefaultValue1' member of Dict", passedToJSImpl)) {
5657 return false;
5658 }
5659 }
5660 }
5661 mIsAnyMemberPresent = true;
5662
5663 if (!isNull) {
5664 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableObjectSequenceOrLongWithDefaultValue2_id, temp.ptr())) {
5665 return false;
5666 }
5667 }
5668 if (!mNullableObjectSequenceOrLongWithDefaultValue2.IsNull()) {
5669 mNullableObjectSequenceOrLongWithDefaultValue2.Value().Uninit();
5670 }
5671 if ((!isNull && !temp->isUndefined()) && temp.ref().isNullOrUndefined()) {
5672 mNullableObjectSequenceOrLongWithDefaultValue2.SetNull();
5673 } else {
5674 if (!(!isNull && !temp->isUndefined())) {
5675 Unused << mNullableObjectSequenceOrLongWithDefaultValue2.SetValue().RawSetAsObjectSequence();
5676 } else {
5677 if (!mNullableObjectSequenceOrLongWithDefaultValue2.SetValue().Init(cx, temp.ref(), "'nullableObjectSequenceOrLongWithDefaultValue2' member of Dict", passedToJSImpl)) {
5678 return false;
5679 }
5680 }
5681 }
5682 mIsAnyMemberPresent = true;
5683
5684 if (!isNull) {
5685 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableRecord_id, temp.ptr())) {
5686 return false;
5687 }
5688 }
5689 if (!isNull && !temp->isUndefined()) {
5690 mNullableRecord.Construct();
5691 if (temp.ref().isObject()) {
5692 auto& recordEntries = (mNullableRecord.Value()).SetValue().Entries();
5693
5694 JS::Rooted<JSObject*> recordObj(cx, &temp.ref().toObject());
5695 JS::RootedVector<jsid> ids(cx);
5696 if (!js::GetPropertyKeys(cx, recordObj,
5697 JSITER_OWNONLY0x8 | JSITER_HIDDEN0x10 | JSITER_SYMBOLS0x20, &ids)) {
5698 return false;
5699 }
5700 if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
5701 JS_ReportOutOfMemory(cx);
5702 return false;
5703 }
5704 JS::Rooted<JS::Value> propNameValue(cx);
5705 JS::Rooted<JS::Value> temp(cx);
5706 JS::Rooted<jsid> curId(cx);
5707 JS::Rooted<JS::Value> idVal(cx);
5708 // Use a hashset to keep track of ids seen, to avoid
5709 // introducing nasty O(N^2) behavior scanning for them all the
5710 // time. Ideally we'd use a data structure with O(1) lookup
5711 // _and_ ordering for the MozMap, but we don't have one lying
5712 // around.
5713 nsTHashtable<nsStringHashKey> idsSeen;
5714 for (size_t i = 0; i < ids.length(); ++i) {
5715 curId = ids[i];
5716
5717 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(cx);
5718 if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
5719 &desc)) {
5720 return false;
5721 }
5722
5723 if (desc.isNothing() || !desc->enumerable()) {
5724 continue;
5725 }
5726
5727 idVal = js::IdToValue(curId);
5728 nsString propName;
5729 // This will just throw if idVal is a Symbol, like the spec says
5730 // to do.
5731 if (!ConvertJSValueToString(cx, idVal, "key of 'nullableRecord' member of Dict", propName)) {
5732 return false;
5733 }
5734
5735 if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
5736 return false;
5737 }
5738
5739 Record<nsString, int32_t>::EntryType* entry;
5740 if (!idsSeen.EnsureInserted(propName)) {
5741 // Find the existing entry.
5742 auto idx = recordEntries.IndexOf(propName);
5743 MOZ_ASSERT(idx != recordEntries.NoIndex,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5744); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5744; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5744 "Why is it not found?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5744); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5744; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5745 // Now blow it away to make it look like it was just added
5746 // to the array, because it's not obvious that it's
5747 // safe to write to its already-initialized mValue via our
5748 // normal codegen conversions. For example, the value
5749 // could be a union and this would change its type, but
5750 // codegen assumes we won't do that.
5751 entry = recordEntries.ReconstructElementAt(idx);
5752 } else {
5753 // Safe to do an infallible append here, because we did a
5754 // SetCapacity above to the right capacity.
5755 entry = recordEntries.AppendElement();
5756 }
5757 entry->mKey = propName;
5758 int32_t& slot = entry->mValue;
5759 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Value in 'nullableRecord' member of Dict", &slot)) {
5760 return false;
5761 }
5762 }
5763 } else if (temp.ref().isNullOrUndefined()) {
5764 (mNullableRecord.Value()).SetNull();
5765 } else {
5766 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'nullableRecord' member of Dict");
5767 return false;
5768 }
5769 mIsAnyMemberPresent = true;
5770 }
5771
5772 if (!isNull) {
5773 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableRecordWithDefault_id, temp.ptr())) {
5774 return false;
5775 }
5776 }
5777 if (!isNull && !temp->isUndefined()) {
5778 if (temp.ref().isObject()) {
5779 auto& recordEntries = mNullableRecordWithDefault.SetValue().Entries();
5780
5781 JS::Rooted<JSObject*> recordObj(cx, &temp.ref().toObject());
5782 JS::RootedVector<jsid> ids(cx);
5783 if (!js::GetPropertyKeys(cx, recordObj,
5784 JSITER_OWNONLY0x8 | JSITER_HIDDEN0x10 | JSITER_SYMBOLS0x20, &ids)) {
5785 return false;
5786 }
5787 if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
5788 JS_ReportOutOfMemory(cx);
5789 return false;
5790 }
5791 JS::Rooted<JS::Value> propNameValue(cx);
5792 JS::Rooted<JS::Value> temp(cx);
5793 JS::Rooted<jsid> curId(cx);
5794 JS::Rooted<JS::Value> idVal(cx);
5795 // Use a hashset to keep track of ids seen, to avoid
5796 // introducing nasty O(N^2) behavior scanning for them all the
5797 // time. Ideally we'd use a data structure with O(1) lookup
5798 // _and_ ordering for the MozMap, but we don't have one lying
5799 // around.
5800 nsTHashtable<nsStringHashKey> idsSeen;
5801 for (size_t i = 0; i < ids.length(); ++i) {
5802 curId = ids[i];
5803
5804 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(cx);
5805 if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
5806 &desc)) {
5807 return false;
5808 }
5809
5810 if (desc.isNothing() || !desc->enumerable()) {
5811 continue;
5812 }
5813
5814 idVal = js::IdToValue(curId);
5815 nsString propName;
5816 // This will just throw if idVal is a Symbol, like the spec says
5817 // to do.
5818 if (!ConvertJSValueToString(cx, idVal, "key of 'nullableRecordWithDefault' member of Dict", propName)) {
5819 return false;
5820 }
5821
5822 if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
5823 return false;
5824 }
5825
5826 Record<nsString, nsString>::EntryType* entry;
5827 if (!idsSeen.EnsureInserted(propName)) {
5828 // Find the existing entry.
5829 auto idx = recordEntries.IndexOf(propName);
5830 MOZ_ASSERT(idx != recordEntries.NoIndex,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5831); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5831; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5831 "Why is it not found?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5831); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5831; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5832 // Now blow it away to make it look like it was just added
5833 // to the array, because it's not obvious that it's
5834 // safe to write to its already-initialized mValue via our
5835 // normal codegen conversions. For example, the value
5836 // could be a union and this would change its type, but
5837 // codegen assumes we won't do that.
5838 entry = recordEntries.ReconstructElementAt(idx);
5839 } else {
5840 // Safe to do an infallible append here, because we did a
5841 // SetCapacity above to the right capacity.
5842 entry = recordEntries.AppendElement();
5843 }
5844 entry->mKey = propName;
5845 nsString& slot = entry->mValue;
5846 if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
5847 return false;
5848 }
5849 }
5850 } else if (temp.ref().isNullOrUndefined()) {
5851 mNullableRecordWithDefault.SetNull();
5852 } else {
5853 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'nullableRecordWithDefault' member of Dict");
5854 return false;
5855 }
5856 } else {
5857 mNullableRecordWithDefault.SetNull();
5858 }
5859 mIsAnyMemberPresent = true;
5860
5861 if (!isNull) {
5862 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableUSVStringRecordWithDefault_id, temp.ptr())) {
5863 return false;
5864 }
5865 }
5866 if (!isNull && !temp->isUndefined()) {
5867 if (temp.ref().isObject()) {
5868 auto& recordEntries = mNullableUSVStringRecordWithDefault.SetValue().Entries();
5869
5870 JS::Rooted<JSObject*> recordObj(cx, &temp.ref().toObject());
5871 JS::RootedVector<jsid> ids(cx);
5872 if (!js::GetPropertyKeys(cx, recordObj,
5873 JSITER_OWNONLY0x8 | JSITER_HIDDEN0x10 | JSITER_SYMBOLS0x20, &ids)) {
5874 return false;
5875 }
5876 if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
5877 JS_ReportOutOfMemory(cx);
5878 return false;
5879 }
5880 JS::Rooted<JS::Value> propNameValue(cx);
5881 JS::Rooted<JS::Value> temp(cx);
5882 JS::Rooted<jsid> curId(cx);
5883 JS::Rooted<JS::Value> idVal(cx);
5884 // Use a hashset to keep track of ids seen, to avoid
5885 // introducing nasty O(N^2) behavior scanning for them all the
5886 // time. Ideally we'd use a data structure with O(1) lookup
5887 // _and_ ordering for the MozMap, but we don't have one lying
5888 // around.
5889 nsTHashtable<nsStringHashKey> idsSeen;
5890 for (size_t i = 0; i < ids.length(); ++i) {
5891 curId = ids[i];
5892
5893 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(cx);
5894 if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
5895 &desc)) {
5896 return false;
5897 }
5898
5899 if (desc.isNothing() || !desc->enumerable()) {
5900 continue;
5901 }
5902
5903 idVal = js::IdToValue(curId);
5904 nsString propName;
5905 // This will just throw if idVal is a Symbol, like the spec says
5906 // to do.
5907 if (!ConvertJSValueToUSVString(cx, idVal, "key of 'nullableUSVStringRecordWithDefault' member of Dict", propName)) {
5908 return false;
5909 }
5910
5911 if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
5912 return false;
5913 }
5914
5915 Record<nsString, int32_t>::EntryType* entry;
5916 if (!idsSeen.EnsureInserted(propName)) {
5917 // Find the existing entry.
5918 auto idx = recordEntries.IndexOf(propName);
5919 MOZ_ASSERT(idx != recordEntries.NoIndex,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5920); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5920; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
5920 "Why is it not found?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 5920); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 5920; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
5921 // Now blow it away to make it look like it was just added
5922 // to the array, because it's not obvious that it's
5923 // safe to write to its already-initialized mValue via our
5924 // normal codegen conversions. For example, the value
5925 // could be a union and this would change its type, but
5926 // codegen assumes we won't do that.
5927 entry = recordEntries.ReconstructElementAt(idx);
5928 } else {
5929 // Safe to do an infallible append here, because we did a
5930 // SetCapacity above to the right capacity.
5931 entry = recordEntries.AppendElement();
5932 }
5933 entry->mKey = propName;
5934 int32_t& slot = entry->mValue;
5935 if (!ValueToPrimitive<int32_t, eDefault>(cx, temp, "Value in 'nullableUSVStringRecordWithDefault' member of Dict", &slot)) {
5936 return false;
5937 }
5938 }
5939 } else if (temp.ref().isNullOrUndefined()) {
5940 mNullableUSVStringRecordWithDefault.SetNull();
5941 } else {
5942 cx.ThrowErrorMessage<MSG_NOT_OBJECT>("'nullableUSVStringRecordWithDefault' member of Dict");
5943 return false;
5944 }
5945 } else {
5946 mNullableUSVStringRecordWithDefault.SetNull();
5947 }
5948 mIsAnyMemberPresent = true;
5949
5950 if (!isNull) {
5951 if (!JS_GetPropertyById(cx, *object, atomsCache->nullableUTF8StringRecordWithDefault_id, temp.ptr())) {
5952 return false;
5953 }
5954 }
5955 if (!isNull && !temp->isUndefined()) {
5956 if (temp.ref().isObject()) {
5957 auto& recordEntries = mNullableUTF8StringRecordWithDefault.SetValue().Entries();
5958
5959 JS::Rooted<JSObject*> recordObj(cx, &temp.ref().toObject());
5960 JS::RootedVector<jsid> ids(cx);
5961 if (!js::GetPropertyKeys(cx, recordObj,
5962 JSITER_OWNONLY0x8 | JSITER_HIDDEN0x10 | JSITER_SYMBOLS0x20, &ids)) {
5963 return false;
5964 }
5965 if (!recordEntries.SetCapacity(ids.length(), mozilla::fallible)) {
5966 JS_ReportOutOfMemory(cx);
5967 return false;
5968 }
5969 JS::Rooted<JS::Value> propNameValue(cx);
5970 JS::Rooted<JS::Value> temp(cx);
5971 JS::Rooted<jsid> curId(cx);
5972 JS::Rooted<JS::Value> idVal(cx);
5973 // Use a hashset to keep track of ids seen, to avoid
5974 // introducing nasty O(N^2) behavior scanning for them all the
5975 // time. Ideally we'd use a data structure with O(1) lookup
5976 // _and_ ordering for the MozMap, but we don't have one lying
5977 // around.
5978 nsTHashtable<nsCStringHashKey> idsSeen;
5979 for (size_t i = 0; i < ids.length(); ++i) {
5980 curId = ids[i];
5981
5982 JS::Rooted<mozilla::Maybe<JS::PropertyDescriptor>> desc(cx);
5983 if (!JS_GetOwnPropertyDescriptorById(cx, recordObj, curId,
5984 &desc)) {
5985 return false;
5986 }
5987
5988 if (desc.isNothing() || !desc->enumerable()) {
5989 continue;
5990 }
5991
5992 idVal = js::IdToValue(curId);
5993 nsCString propName;
5994 // This will just throw if idVal is a Symbol, like the spec says
5995 // to do.
5996 if (!ConvertJSValueToString(cx, idVal, "key of 'nullableUTF8StringRecordWithDefault' member of Dict", propName)) {
5997 return false;
5998 }
5999
6000 if (!JS_GetPropertyById(cx, recordObj, curId, &temp)) {
6001 return false;
6002 }
6003
6004 Record<nsCString, int32_t>::EntryType* entry;
6005 if (!idsSeen.EnsureInserted(propName)) {
6006 // Find the existing entry.
6007 auto idx = recordEntries.IndexOf(propName);
6008 MOZ_ASSERT(idx != recordEntries.NoIndex,do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 6009); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 6009; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
6009 "Why is it not found?")do { static_assert( mozilla::detail::AssertionConditionType<
decltype(idx != recordEntries.NoIndex)>::isValid, "invalid assertion condition"
); if ((__builtin_expect(!!(!(!!(idx != recordEntries.NoIndex
))), 0))) { do { } while (false); MOZ_ReportAssertionFailure(
"idx != recordEntries.NoIndex" " (" "Why is it not found?" ")"
, "../TestCodeGenBinding.cpp", 6009); AnnotateMozCrashReason(
"MOZ_ASSERT" "(" "idx != recordEntries.NoIndex" ") (" "Why is it not found?"
")"); do { *((volatile int*)__null) = 6009; __attribute__((nomerge
)) ::abort(); } while (false); } } while (false)
;
6010 // Now blow it away to make it look like it was just added
6011 // to the array, because it's not obvious that it's
6012 // safe to write to its already-initialized mValue via our
6013 // normal codegen conversions. For example, the value
6014 // could be a union and this would change its type, but
6015 // codegen assumes we won't do that.