/work/obj-fuzz/dom/bindings/AudioScheduledSourceNodeBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM AudioScheduledSourceNode.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AudioNodeBinding.h" |
4 | | #include "AudioScheduledSourceNodeBinding.h" |
5 | | #include "EventHandlerBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/FloatingPoint.h" |
8 | | #include "mozilla/OwningNonNull.h" |
9 | | #include "mozilla/dom/AudioScheduledSourceNode.h" |
10 | | #include "mozilla/dom/BindingUtils.h" |
11 | | #include "mozilla/dom/DOMJSClass.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrimitiveConversions.h" |
15 | | #include "mozilla/dom/XrayExpandoClass.h" |
16 | | |
17 | | namespace mozilla { |
18 | | namespace dom { |
19 | | |
20 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
21 | | using namespace mozilla::dom::binding_detail; |
22 | | |
23 | | |
24 | | namespace AudioScheduledSourceNode_Binding { |
25 | | |
26 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNode_Binding::NativeType>::value, |
27 | | "Can't inherit from an interface with a different ownership model."); |
28 | | |
29 | | MOZ_CAN_RUN_SCRIPT static bool |
30 | | get_onended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, JSJitGetterCallArgs args) |
31 | 0 | { |
32 | 0 | AUTO_PROFILER_LABEL_FAST("get AudioScheduledSourceNode.onended", DOM, cx); |
33 | 0 |
|
34 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnended()); |
35 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
36 | 0 | if (result) { |
37 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
38 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
39 | 0 | return false; |
40 | 0 | } |
41 | 0 | return true; |
42 | 0 | } else { |
43 | 0 | args.rval().setNull(); |
44 | 0 | return true; |
45 | 0 | } |
46 | 0 | } |
47 | | |
48 | | MOZ_CAN_RUN_SCRIPT static bool |
49 | | set_onended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, JSJitSetterCallArgs args) |
50 | 0 | { |
51 | 0 | AUTO_PROFILER_LABEL_FAST("set AudioScheduledSourceNode.onended", DOM, cx); |
52 | 0 |
|
53 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
54 | 0 | if (args[0].isObject()) { |
55 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
56 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
57 | 0 | } |
58 | 0 | } else { |
59 | 0 | arg0 = nullptr; |
60 | 0 | } |
61 | 0 | self->SetOnended(Constify(arg0)); |
62 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
63 | 0 |
|
64 | 0 | return true; |
65 | 0 | } |
66 | | |
67 | | static const JSJitInfo onended_getterinfo = { |
68 | | { (JSJitGetterOp)get_onended }, |
69 | | { prototypes::id::AudioScheduledSourceNode }, |
70 | | { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth }, |
71 | | JSJitInfo::Getter, |
72 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
73 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
74 | | false, /* isInfallible. False in setters. */ |
75 | | false, /* isMovable. Not relevant for setters. */ |
76 | | false, /* isEliminatable. Not relevant for setters. */ |
77 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
78 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
79 | | false, /* isTypedMethod. Only relevant for methods. */ |
80 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
81 | | }; |
82 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
83 | | static_assert(0 < 1, "There is no slot for us"); |
84 | | static const JSJitInfo onended_setterinfo = { |
85 | | { (JSJitGetterOp)set_onended }, |
86 | | { prototypes::id::AudioScheduledSourceNode }, |
87 | | { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth }, |
88 | | JSJitInfo::Setter, |
89 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
90 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
91 | | false, /* isInfallible. False in setters. */ |
92 | | false, /* isMovable. Not relevant for setters. */ |
93 | | false, /* isEliminatable. Not relevant for setters. */ |
94 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
95 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
96 | | false, /* isTypedMethod. Only relevant for methods. */ |
97 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
98 | | }; |
99 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
100 | | static_assert(0 < 1, "There is no slot for us"); |
101 | | |
102 | | MOZ_CAN_RUN_SCRIPT static bool |
103 | | start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, const JSJitMethodCallArgs& args) |
104 | 0 | { |
105 | 0 | AUTO_PROFILER_LABEL_FAST("AudioScheduledSourceNode.start", DOM, cx); |
106 | 0 |
|
107 | 0 | double arg0; |
108 | 0 | if (args.hasDefined(0)) { |
109 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
110 | 0 | return false; |
111 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
112 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of AudioScheduledSourceNode.start"); |
113 | 0 | return false; |
114 | 0 | } |
115 | 0 | } else { |
116 | 0 | arg0 = 0.0; |
117 | 0 | } |
118 | 0 | FastErrorResult rv; |
119 | 0 | self->Start(arg0, rv); |
120 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
121 | 0 | return false; |
122 | 0 | } |
123 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
124 | 0 | args.rval().setUndefined(); |
125 | 0 | return true; |
126 | 0 | } |
127 | | |
128 | | static const JSJitInfo start_methodinfo = { |
129 | | { (JSJitGetterOp)start }, |
130 | | { prototypes::id::AudioScheduledSourceNode }, |
131 | | { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth }, |
132 | | JSJitInfo::Method, |
133 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
134 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
135 | | false, /* isInfallible. False in setters. */ |
136 | | false, /* isMovable. Not relevant for setters. */ |
137 | | false, /* isEliminatable. Not relevant for setters. */ |
138 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
139 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
140 | | false, /* isTypedMethod. Only relevant for methods. */ |
141 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
142 | | }; |
143 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
144 | | static_assert(0 < 1, "There is no slot for us"); |
145 | | |
146 | | MOZ_CAN_RUN_SCRIPT static bool |
147 | | stop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, const JSJitMethodCallArgs& args) |
148 | 0 | { |
149 | 0 | AUTO_PROFILER_LABEL_FAST("AudioScheduledSourceNode.stop", DOM, cx); |
150 | 0 |
|
151 | 0 | double arg0; |
152 | 0 | if (args.hasDefined(0)) { |
153 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
154 | 0 | return false; |
155 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
156 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of AudioScheduledSourceNode.stop"); |
157 | 0 | return false; |
158 | 0 | } |
159 | 0 | } else { |
160 | 0 | arg0 = 0.0; |
161 | 0 | } |
162 | 0 | FastErrorResult rv; |
163 | 0 | self->Stop(arg0, rv); |
164 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
165 | 0 | return false; |
166 | 0 | } |
167 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
168 | 0 | args.rval().setUndefined(); |
169 | 0 | return true; |
170 | 0 | } |
171 | | |
172 | | static const JSJitInfo stop_methodinfo = { |
173 | | { (JSJitGetterOp)stop }, |
174 | | { prototypes::id::AudioScheduledSourceNode }, |
175 | | { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth }, |
176 | | JSJitInfo::Method, |
177 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
178 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
179 | | false, /* isInfallible. False in setters. */ |
180 | | false, /* isMovable. Not relevant for setters. */ |
181 | | false, /* isEliminatable. Not relevant for setters. */ |
182 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
183 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
184 | | false, /* isTypedMethod. Only relevant for methods. */ |
185 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
186 | | }; |
187 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
188 | | static_assert(0 < 1, "There is no slot for us"); |
189 | | |
190 | | static bool |
191 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
192 | 0 | { |
193 | 0 | mozilla::dom::AudioScheduledSourceNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioScheduledSourceNode>(obj); |
194 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
195 | 0 | // obviously can't preserve if we're not initialized. |
196 | 0 | if (self && self->GetWrapperPreserveColor()) { |
197 | 0 | PreserveWrapper(self); |
198 | 0 | } |
199 | 0 | return true; |
200 | 0 | } |
201 | | |
202 | | static void |
203 | | _finalize(js::FreeOp* fop, JSObject* obj) |
204 | 0 | { |
205 | 0 | mozilla::dom::AudioScheduledSourceNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioScheduledSourceNode>(obj); |
206 | 0 | if (self) { |
207 | 0 | ClearWrapper(self, self, obj); |
208 | 0 | AddForDeferredFinalization<mozilla::dom::AudioScheduledSourceNode>(self); |
209 | 0 | } |
210 | 0 | } |
211 | | |
212 | | static size_t |
213 | | _objectMoved(JSObject* obj, JSObject* old) |
214 | 0 | { |
215 | 0 | mozilla::dom::AudioScheduledSourceNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioScheduledSourceNode>(obj); |
216 | 0 | if (self) { |
217 | 0 | UpdateWrapper(self, self, obj, old); |
218 | 0 | } |
219 | 0 |
|
220 | 0 | return 0; |
221 | 0 | } |
222 | | |
223 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
224 | | #if defined(__clang__) |
225 | | #pragma clang diagnostic push |
226 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
227 | | #endif |
228 | | static const JSFunctionSpec sMethods_specs[] = { |
229 | | JS_FNSPEC("start", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&start_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
230 | | JS_FNSPEC("stop", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&stop_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
231 | | JS_FS_END |
232 | | }; |
233 | | #if defined(__clang__) |
234 | | #pragma clang diagnostic pop |
235 | | #endif |
236 | | |
237 | | |
238 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
239 | | { nullptr, &sMethods_specs[0] }, |
240 | | { nullptr, nullptr } |
241 | | }; |
242 | | |
243 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
244 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
245 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
246 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
247 | | |
248 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
249 | | #if defined(__clang__) |
250 | | #pragma clang diagnostic push |
251 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
252 | | #endif |
253 | | static const JSPropertySpec sAttributes_specs[] = { |
254 | | { "onended", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onended_getterinfo, GenericSetter<NormalThisPolicy>, &onended_setterinfo }, |
255 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
256 | | }; |
257 | | #if defined(__clang__) |
258 | | #pragma clang diagnostic pop |
259 | | #endif |
260 | | |
261 | | |
262 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
263 | | { nullptr, &sAttributes_specs[0] }, |
264 | | { nullptr, nullptr } |
265 | | }; |
266 | | |
267 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
268 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
269 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
270 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
271 | | |
272 | | |
273 | | static uint16_t sNativeProperties_sortedPropertyIndices[3]; |
274 | | static PropertyInfo sNativeProperties_propertyInfos[3]; |
275 | | |
276 | | static const NativePropertiesN<2> sNativeProperties = { |
277 | | false, 0, |
278 | | false, 0, |
279 | | true, 0 /* sMethods */, |
280 | | true, 1 /* sAttributes */, |
281 | | false, 0, |
282 | | false, 0, |
283 | | false, 0, |
284 | | -1, |
285 | | 3, |
286 | | sNativeProperties_sortedPropertyIndices, |
287 | | { |
288 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
289 | | { sAttributes, &sNativeProperties_propertyInfos[2] } |
290 | | } |
291 | | }; |
292 | | static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
293 | | "We have a property info count that is oversized"); |
294 | | |
295 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
296 | | { |
297 | | "Function", |
298 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
299 | | &sBoringInterfaceObjectClassClassOps, |
300 | | JS_NULL_CLASS_SPEC, |
301 | | JS_NULL_CLASS_EXT, |
302 | | &sInterfaceObjectClassObjectOps |
303 | | }, |
304 | | eInterface, |
305 | | true, |
306 | | prototypes::id::AudioScheduledSourceNode, |
307 | | PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth, |
308 | | sNativePropertyHooks, |
309 | | "function AudioScheduledSourceNode() {\n [native code]\n}", |
310 | | AudioNode_Binding::GetConstructorObject |
311 | | }; |
312 | | |
313 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
314 | | { |
315 | | "AudioScheduledSourceNodePrototype", |
316 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
317 | | JS_NULL_CLASS_OPS, |
318 | | JS_NULL_CLASS_SPEC, |
319 | | JS_NULL_CLASS_EXT, |
320 | | JS_NULL_OBJECT_OPS |
321 | | }, |
322 | | eInterfacePrototype, |
323 | | false, |
324 | | prototypes::id::AudioScheduledSourceNode, |
325 | | PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth, |
326 | | sNativePropertyHooks, |
327 | | "[object AudioScheduledSourceNodePrototype]", |
328 | | AudioNode_Binding::GetProtoObject |
329 | | }; |
330 | | |
331 | | static const js::ClassOps sClassOps = { |
332 | | _addProperty, /* addProperty */ |
333 | | nullptr, /* delProperty */ |
334 | | nullptr, /* enumerate */ |
335 | | nullptr, /* newEnumerate */ |
336 | | nullptr, /* resolve */ |
337 | | nullptr, /* mayResolve */ |
338 | | _finalize, /* finalize */ |
339 | | nullptr, /* call */ |
340 | | nullptr, /* hasInstance */ |
341 | | nullptr, /* construct */ |
342 | | nullptr, /* trace */ |
343 | | }; |
344 | | |
345 | | static const js::ClassExtension sClassExtension = { |
346 | | nullptr, /* weakmapKeyDelegateOp */ |
347 | | _objectMoved /* objectMovedOp */ |
348 | | }; |
349 | | |
350 | | static const DOMJSClass sClass = { |
351 | | { "AudioScheduledSourceNode", |
352 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
353 | | &sClassOps, |
354 | | JS_NULL_CLASS_SPEC, |
355 | | &sClassExtension, |
356 | | JS_NULL_OBJECT_OPS |
357 | | }, |
358 | | { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::AudioScheduledSourceNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
359 | | IsBaseOf<nsISupports, mozilla::dom::AudioScheduledSourceNode >::value, |
360 | | sNativePropertyHooks, |
361 | | FindAssociatedGlobalForNative<mozilla::dom::AudioScheduledSourceNode>::Get, |
362 | | GetProtoObjectHandle, |
363 | | GetCCParticipant<mozilla::dom::AudioScheduledSourceNode>::Get() |
364 | | }; |
365 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
366 | | "Must have the right minimal number of reserved slots."); |
367 | | static_assert(1 >= 1, |
368 | | "Must have enough reserved slots."); |
369 | | |
370 | | const JSClass* |
371 | | GetJSClass() |
372 | 0 | { |
373 | 0 | return sClass.ToJSClass(); |
374 | 0 | } |
375 | | |
376 | | bool |
377 | | Wrap(JSContext* aCx, mozilla::dom::AudioScheduledSourceNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
378 | 0 | { |
379 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AudioScheduledSourceNode>::value, |
380 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
381 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AudioScheduledSourceNode*>(aObject) == |
382 | 0 | reinterpret_cast<mozilla::dom::AudioScheduledSourceNode*>(aObject), |
383 | 0 | "Multiple inheritance for mozilla::dom::AudioScheduledSourceNode is broken."); |
384 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) == |
385 | 0 | reinterpret_cast<mozilla::dom::AudioNode*>(aObject), |
386 | 0 | "Multiple inheritance for mozilla::dom::AudioNode is broken."); |
387 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
388 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
389 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
390 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
391 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
392 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
393 | 0 | "You should probably not be using Wrap() directly; use " |
394 | 0 | "GetOrCreateDOMReflector instead"); |
395 | 0 |
|
396 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
397 | 0 | "nsISupports must be on our primary inheritance chain"); |
398 | 0 |
|
399 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
400 | 0 | if (!global) { |
401 | 0 | return false; |
402 | 0 | } |
403 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
404 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
405 | 0 |
|
406 | 0 | // That might have ended up wrapping us already, due to the wonders |
407 | 0 | // of XBL. Check for that, and bail out as needed. |
408 | 0 | aReflector.set(aCache->GetWrapper()); |
409 | 0 | if (aReflector) { |
410 | | #ifdef DEBUG |
411 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
412 | | #endif // DEBUG |
413 | | return true; |
414 | 0 | } |
415 | 0 |
|
416 | 0 | JSAutoRealm ar(aCx, global); |
417 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
418 | 0 | if (!canonicalProto) { |
419 | 0 | return false; |
420 | 0 | } |
421 | 0 | JS::Rooted<JSObject*> proto(aCx); |
422 | 0 | if (aGivenProto) { |
423 | 0 | proto = aGivenProto; |
424 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
425 | 0 | // coming in, we changed compartments to that of "parent" so may need |
426 | 0 | // to wrap the proto here. |
427 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
428 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
429 | 0 | return false; |
430 | 0 | } |
431 | 0 | } |
432 | 0 | } else { |
433 | 0 | proto = canonicalProto; |
434 | 0 | } |
435 | 0 |
|
436 | 0 | BindingJSObjectCreator<mozilla::dom::AudioScheduledSourceNode> creator(aCx); |
437 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
438 | 0 | if (!aReflector) { |
439 | 0 | return false; |
440 | 0 | } |
441 | 0 | |
442 | 0 | aCache->SetWrapper(aReflector); |
443 | 0 | creator.InitializationSucceeded(); |
444 | 0 |
|
445 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
446 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
447 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
448 | 0 | // otherwise we won't be able to properly recreate it later, since |
449 | 0 | // we won't know what proto to use. Note that we don't check |
450 | 0 | // aGivenProto here, since it's entirely possible (and even |
451 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
452 | 0 | // same as canonicalProto. |
453 | 0 | if (proto != canonicalProto) { |
454 | 0 | PreserveWrapper(aObject); |
455 | 0 | } |
456 | 0 |
|
457 | 0 | return true; |
458 | 0 | } |
459 | | |
460 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
461 | | nullptr, |
462 | | nullptr, |
463 | | nullptr, |
464 | | { sNativeProperties.Upcast(), nullptr }, |
465 | | prototypes::id::AudioScheduledSourceNode, |
466 | | constructors::id::AudioScheduledSourceNode, |
467 | | AudioNode_Binding::sNativePropertyHooks, |
468 | | &DefaultXrayExpandoObjectClass |
469 | | } }; |
470 | | |
471 | | void |
472 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
473 | 0 | { |
474 | 0 | JS::Handle<JSObject*> parentProto(AudioNode_Binding::GetProtoObjectHandle(aCx)); |
475 | 0 | if (!parentProto) { |
476 | 0 | return; |
477 | 0 | } |
478 | 0 | |
479 | 0 | JS::Handle<JSObject*> constructorProto(AudioNode_Binding::GetConstructorObjectHandle(aCx)); |
480 | 0 | if (!constructorProto) { |
481 | 0 | return; |
482 | 0 | } |
483 | 0 | |
484 | 0 | static bool sIdsInited = false; |
485 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
486 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
487 | 0 | return; |
488 | 0 | } |
489 | 0 | sIdsInited = true; |
490 | 0 | } |
491 | 0 |
|
492 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioScheduledSourceNode); |
493 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioScheduledSourceNode); |
494 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
495 | 0 | &sPrototypeClass.mBase, protoCache, |
496 | 0 | nullptr, |
497 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
498 | 0 | interfaceCache, |
499 | 0 | sNativeProperties.Upcast(), |
500 | 0 | nullptr, |
501 | 0 | "AudioScheduledSourceNode", aDefineOnGlobal, |
502 | 0 | nullptr, |
503 | 0 | false); |
504 | 0 | } |
505 | | |
506 | | JSObject* |
507 | | GetProtoObject(JSContext* aCx) |
508 | 0 | { |
509 | 0 | return GetProtoObjectHandle(aCx); |
510 | 0 | } |
511 | | |
512 | | JSObject* |
513 | | GetConstructorObject(JSContext* aCx) |
514 | 0 | { |
515 | 0 | return GetConstructorObjectHandle(aCx); |
516 | 0 | } |
517 | | |
518 | | } // namespace AudioScheduledSourceNode_Binding |
519 | | |
520 | | |
521 | | |
522 | | } // namespace dom |
523 | | } // namespace mozilla |