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