/work/obj-fuzz/dom/bindings/ChannelMergerNodeBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM ChannelMergerNode.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AtomList.h" |
4 | | #include "AudioNodeBinding.h" |
5 | | #include "ChannelMergerNodeBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/Preferences.h" |
9 | | #include "mozilla/dom/AudioContext.h" |
10 | | #include "mozilla/dom/BindingUtils.h" |
11 | | #include "mozilla/dom/ChannelMergerNode.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
14 | | #include "mozilla/dom/PrimitiveConversions.h" |
15 | | #include "mozilla/dom/ScriptSettings.h" |
16 | | #include "mozilla/dom/SimpleGlobalObject.h" |
17 | | #include "mozilla/dom/XrayExpandoClass.h" |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
23 | | using namespace mozilla::dom::binding_detail; |
24 | | |
25 | | |
26 | | |
27 | | ChannelMergerOptions::ChannelMergerOptions() |
28 | | : AudioNodeOptions(FastDictionaryInitializer()) |
29 | 0 | { |
30 | 0 | // Safe to pass a null context if we pass a null value |
31 | 0 | Init(nullptr, JS::NullHandleValue); |
32 | 0 | } |
33 | | |
34 | | |
35 | | |
36 | | bool |
37 | | ChannelMergerOptions::InitIds(JSContext* cx, ChannelMergerOptionsAtoms* atomsCache) |
38 | 0 | { |
39 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
40 | 0 |
|
41 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
42 | 0 | // uninitialized. |
43 | 0 | if (!atomsCache->numberOfInputs_id.init(cx, "numberOfInputs")) { |
44 | 0 | return false; |
45 | 0 | } |
46 | 0 | return true; |
47 | 0 | } |
48 | | |
49 | | bool |
50 | | ChannelMergerOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
51 | 0 | { |
52 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
53 | 0 | // Since in that case we will not have to do any property gets |
54 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
55 | 0 | // checkers by static analysis tools |
56 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
57 | 0 | ChannelMergerOptionsAtoms* atomsCache = nullptr; |
58 | 0 | if (cx) { |
59 | 0 | atomsCache = GetAtomCache<ChannelMergerOptionsAtoms>(cx); |
60 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
61 | 0 | return false; |
62 | 0 | } |
63 | 0 | } |
64 | 0 | |
65 | 0 | // Per spec, we init the parent's members first |
66 | 0 | if (!AudioNodeOptions::Init(cx, val)) { |
67 | 0 | return false; |
68 | 0 | } |
69 | 0 | |
70 | 0 | bool isNull = val.isNullOrUndefined(); |
71 | 0 | // We only need these if !isNull, in which case we have |cx|. |
72 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
73 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
74 | 0 | if (!isNull) { |
75 | 0 | MOZ_ASSERT(cx); |
76 | 0 | object.emplace(cx, &val.toObject()); |
77 | 0 | temp.emplace(cx); |
78 | 0 | } |
79 | 0 | if (!isNull) { |
80 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->numberOfInputs_id, temp.ptr())) { |
81 | 0 | return false; |
82 | 0 | } |
83 | 0 | } |
84 | 0 | if (!isNull && !temp->isUndefined()) { |
85 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mNumberOfInputs)) { |
86 | 0 | return false; |
87 | 0 | } |
88 | 0 | } else { |
89 | 0 | mNumberOfInputs = 6U; |
90 | 0 | } |
91 | 0 | mIsAnyMemberPresent = true; |
92 | 0 | return true; |
93 | 0 | } |
94 | | |
95 | | bool |
96 | | ChannelMergerOptions::Init(const nsAString& aJSON) |
97 | 0 | { |
98 | 0 | AutoJSAPI jsapi; |
99 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
100 | 0 | if (!cleanGlobal) { |
101 | 0 | return false; |
102 | 0 | } |
103 | 0 | if (!jsapi.Init(cleanGlobal)) { |
104 | 0 | return false; |
105 | 0 | } |
106 | 0 | JSContext* cx = jsapi.cx(); |
107 | 0 | JS::Rooted<JS::Value> json(cx); |
108 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
109 | 0 | NS_ENSURE_TRUE(ok, false); |
110 | 0 | return Init(cx, json); |
111 | 0 | } |
112 | | |
113 | | bool |
114 | | ChannelMergerOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
115 | 0 | { |
116 | 0 | ChannelMergerOptionsAtoms* atomsCache = GetAtomCache<ChannelMergerOptionsAtoms>(cx); |
117 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
118 | 0 | return false; |
119 | 0 | } |
120 | 0 | |
121 | 0 | // Per spec, we define the parent's members first |
122 | 0 | if (!AudioNodeOptions::ToObjectInternal(cx, rval)) { |
123 | 0 | return false; |
124 | 0 | } |
125 | 0 | JS::Rooted<JSObject*> obj(cx, &rval.toObject()); |
126 | 0 |
|
127 | 0 | do { |
128 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
129 | 0 | JS::Rooted<JS::Value> temp(cx); |
130 | 0 | uint32_t const & currentValue = mNumberOfInputs; |
131 | 0 | temp.setNumber(currentValue); |
132 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->numberOfInputs_id, temp, JSPROP_ENUMERATE)) { |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | break; |
136 | 0 | } while(false); |
137 | 0 |
|
138 | 0 | return true; |
139 | 0 | } |
140 | | |
141 | | bool |
142 | | ChannelMergerOptions::ToJSON(nsAString& aJSON) const |
143 | 0 | { |
144 | 0 | AutoJSAPI jsapi; |
145 | 0 | jsapi.Init(); |
146 | 0 | JSContext *cx = jsapi.cx(); |
147 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
148 | 0 | // because we'll only be creating objects, in ways that have no |
149 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
150 | 0 | // which likewise guarantees no side-effects for the sorts of |
151 | 0 | // things we will pass it. |
152 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
153 | 0 | JS::Rooted<JS::Value> val(cx); |
154 | 0 | if (!ToObjectInternal(cx, &val)) { |
155 | 0 | return false; |
156 | 0 | } |
157 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
158 | 0 | return StringifyToJSON(cx, obj, aJSON); |
159 | 0 | } |
160 | | |
161 | | void |
162 | | ChannelMergerOptions::TraceDictionary(JSTracer* trc) |
163 | 0 | { |
164 | 0 | AudioNodeOptions::TraceDictionary(trc); |
165 | 0 | } |
166 | | |
167 | | ChannelMergerOptions& |
168 | | ChannelMergerOptions::operator=(const ChannelMergerOptions& aOther) |
169 | 0 | { |
170 | 0 | AudioNodeOptions::operator=(aOther); |
171 | 0 | mNumberOfInputs = aOther.mNumberOfInputs; |
172 | 0 | return *this; |
173 | 0 | } |
174 | | |
175 | | namespace binding_detail { |
176 | | } // namespace binding_detail |
177 | | |
178 | | |
179 | | namespace ChannelMergerNode_Binding { |
180 | | |
181 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNode_Binding::NativeType>::value, |
182 | | "Can't inherit from an interface with a different ownership model."); |
183 | | |
184 | | static bool |
185 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
186 | 0 | { |
187 | 0 | mozilla::dom::ChannelMergerNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ChannelMergerNode>(obj); |
188 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
189 | 0 | // obviously can't preserve if we're not initialized. |
190 | 0 | if (self && self->GetWrapperPreserveColor()) { |
191 | 0 | PreserveWrapper(self); |
192 | 0 | } |
193 | 0 | return true; |
194 | 0 | } |
195 | | |
196 | | static void |
197 | | _finalize(js::FreeOp* fop, JSObject* obj) |
198 | 0 | { |
199 | 0 | mozilla::dom::ChannelMergerNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ChannelMergerNode>(obj); |
200 | 0 | if (self) { |
201 | 0 | ClearWrapper(self, self, obj); |
202 | 0 | AddForDeferredFinalization<mozilla::dom::ChannelMergerNode>(self); |
203 | 0 | } |
204 | 0 | } |
205 | | |
206 | | static size_t |
207 | | _objectMoved(JSObject* obj, JSObject* old) |
208 | 0 | { |
209 | 0 | mozilla::dom::ChannelMergerNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ChannelMergerNode>(obj); |
210 | 0 | if (self) { |
211 | 0 | UpdateWrapper(self, self, obj, old); |
212 | 0 | } |
213 | 0 |
|
214 | 0 | return 0; |
215 | 0 | } |
216 | | |
217 | | static bool |
218 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
219 | 0 | { |
220 | 0 | AUTO_PROFILER_LABEL_FAST("ChannelMergerNode constructor", DOM, cx); |
221 | 0 |
|
222 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
223 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
224 | 0 | if (!args.isConstructing()) { |
225 | 0 | // XXXbz wish I could get the name from the callee instead of |
226 | 0 | // Adding more relocations |
227 | 0 | return ThrowConstructorWithoutNew(cx, "ChannelMergerNode"); |
228 | 0 | } |
229 | 0 | |
230 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
231 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
232 | 0 | return false; |
233 | 0 | } |
234 | 0 | |
235 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
236 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelMergerNode"); |
237 | 0 | } |
238 | 0 | GlobalObject global(cx, obj); |
239 | 0 | if (global.Failed()) { |
240 | 0 | return false; |
241 | 0 | } |
242 | 0 | |
243 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
244 | 0 | NonNull<mozilla::dom::AudioContext> arg0; |
245 | 0 | if (args[0].isObject()) { |
246 | 0 | { |
247 | 0 | nsresult rv = UnwrapObject<prototypes::id::BaseAudioContext, mozilla::dom::AudioContext>(args[0], arg0); |
248 | 0 | if (NS_FAILED(rv)) { |
249 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ChannelMergerNode.constructor", "BaseAudioContext"); |
250 | 0 | return false; |
251 | 0 | } |
252 | 0 | } |
253 | 0 | } else { |
254 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ChannelMergerNode.constructor"); |
255 | 0 | return false; |
256 | 0 | } |
257 | 0 | binding_detail::FastChannelMergerOptions arg1; |
258 | 0 | if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of ChannelMergerNode.constructor", false)) { |
259 | 0 | return false; |
260 | 0 | } |
261 | 0 | Maybe<JSAutoRealm> ar; |
262 | 0 | if (objIsXray) { |
263 | 0 | obj = js::CheckedUnwrap(obj); |
264 | 0 | if (!obj) { |
265 | 0 | return false; |
266 | 0 | } |
267 | 0 | ar.emplace(cx, obj); |
268 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
269 | 0 | return false; |
270 | 0 | } |
271 | 0 | } |
272 | 0 | FastErrorResult rv; |
273 | 0 | auto result(StrongOrRawPtr<mozilla::dom::ChannelMergerNode>(mozilla::dom::ChannelMergerNode::Constructor(global, MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), rv))); |
274 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
275 | 0 | return false; |
276 | 0 | } |
277 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
278 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
279 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
280 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
281 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
282 | 0 | return false; |
283 | 0 | } |
284 | 0 | return true; |
285 | 0 | } |
286 | | |
287 | | static const js::ClassOps sInterfaceObjectClassOps = { |
288 | | nullptr, /* addProperty */ |
289 | | nullptr, /* delProperty */ |
290 | | nullptr, /* enumerate */ |
291 | | nullptr, /* newEnumerate */ |
292 | | nullptr, /* resolve */ |
293 | | nullptr, /* mayResolve */ |
294 | | nullptr, /* finalize */ |
295 | | _constructor, /* call */ |
296 | | nullptr, /* hasInstance */ |
297 | | _constructor, /* construct */ |
298 | | nullptr, /* trace */ |
299 | | }; |
300 | | |
301 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
302 | | { |
303 | | "Function", |
304 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
305 | | &sInterfaceObjectClassOps, |
306 | | JS_NULL_CLASS_SPEC, |
307 | | JS_NULL_CLASS_EXT, |
308 | | &sInterfaceObjectClassObjectOps |
309 | | }, |
310 | | eInterface, |
311 | | true, |
312 | | prototypes::id::ChannelMergerNode, |
313 | | PrototypeTraits<prototypes::id::ChannelMergerNode>::Depth, |
314 | | sNativePropertyHooks, |
315 | | "function ChannelMergerNode() {\n [native code]\n}", |
316 | | AudioNode_Binding::GetConstructorObject |
317 | | }; |
318 | | |
319 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
320 | | { |
321 | | "ChannelMergerNodePrototype", |
322 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
323 | | JS_NULL_CLASS_OPS, |
324 | | JS_NULL_CLASS_SPEC, |
325 | | JS_NULL_CLASS_EXT, |
326 | | JS_NULL_OBJECT_OPS |
327 | | }, |
328 | | eInterfacePrototype, |
329 | | false, |
330 | | prototypes::id::ChannelMergerNode, |
331 | | PrototypeTraits<prototypes::id::ChannelMergerNode>::Depth, |
332 | | sNativePropertyHooks, |
333 | | "[object ChannelMergerNodePrototype]", |
334 | | AudioNode_Binding::GetProtoObject |
335 | | }; |
336 | | |
337 | | bool |
338 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
339 | 0 | { |
340 | 0 | static bool sPrefValue; |
341 | 0 | static bool sPrefCacheSetUp = false; |
342 | 0 | if (!sPrefCacheSetUp) { |
343 | 0 | sPrefCacheSetUp = true; |
344 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled"); |
345 | 0 | } |
346 | 0 |
|
347 | 0 | return sPrefValue; |
348 | 0 | } |
349 | | |
350 | | static const js::ClassOps sClassOps = { |
351 | | _addProperty, /* addProperty */ |
352 | | nullptr, /* delProperty */ |
353 | | nullptr, /* enumerate */ |
354 | | nullptr, /* newEnumerate */ |
355 | | nullptr, /* resolve */ |
356 | | nullptr, /* mayResolve */ |
357 | | _finalize, /* finalize */ |
358 | | nullptr, /* call */ |
359 | | nullptr, /* hasInstance */ |
360 | | nullptr, /* construct */ |
361 | | nullptr, /* trace */ |
362 | | }; |
363 | | |
364 | | static const js::ClassExtension sClassExtension = { |
365 | | nullptr, /* weakmapKeyDelegateOp */ |
366 | | _objectMoved /* objectMovedOp */ |
367 | | }; |
368 | | |
369 | | static const DOMJSClass sClass = { |
370 | | { "ChannelMergerNode", |
371 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
372 | | &sClassOps, |
373 | | JS_NULL_CLASS_SPEC, |
374 | | &sClassExtension, |
375 | | JS_NULL_OBJECT_OPS |
376 | | }, |
377 | | { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::ChannelMergerNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
378 | | IsBaseOf<nsISupports, mozilla::dom::ChannelMergerNode >::value, |
379 | | sNativePropertyHooks, |
380 | | FindAssociatedGlobalForNative<mozilla::dom::ChannelMergerNode>::Get, |
381 | | GetProtoObjectHandle, |
382 | | GetCCParticipant<mozilla::dom::ChannelMergerNode>::Get() |
383 | | }; |
384 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
385 | | "Must have the right minimal number of reserved slots."); |
386 | | static_assert(1 >= 1, |
387 | | "Must have enough reserved slots."); |
388 | | |
389 | | const JSClass* |
390 | | GetJSClass() |
391 | 0 | { |
392 | 0 | return sClass.ToJSClass(); |
393 | 0 | } |
394 | | |
395 | | bool |
396 | | Wrap(JSContext* aCx, mozilla::dom::ChannelMergerNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
397 | 0 | { |
398 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ChannelMergerNode>::value, |
399 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
400 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::ChannelMergerNode*>(aObject) == |
401 | 0 | reinterpret_cast<mozilla::dom::ChannelMergerNode*>(aObject), |
402 | 0 | "Multiple inheritance for mozilla::dom::ChannelMergerNode is broken."); |
403 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) == |
404 | 0 | reinterpret_cast<mozilla::dom::AudioNode*>(aObject), |
405 | 0 | "Multiple inheritance for mozilla::dom::AudioNode is broken."); |
406 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
407 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
408 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
409 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
410 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
411 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
412 | 0 | "You should probably not be using Wrap() directly; use " |
413 | 0 | "GetOrCreateDOMReflector instead"); |
414 | 0 |
|
415 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
416 | 0 | "nsISupports must be on our primary inheritance chain"); |
417 | 0 |
|
418 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
419 | 0 | if (!global) { |
420 | 0 | return false; |
421 | 0 | } |
422 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
423 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
424 | 0 |
|
425 | 0 | // That might have ended up wrapping us already, due to the wonders |
426 | 0 | // of XBL. Check for that, and bail out as needed. |
427 | 0 | aReflector.set(aCache->GetWrapper()); |
428 | 0 | if (aReflector) { |
429 | | #ifdef DEBUG |
430 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
431 | | #endif // DEBUG |
432 | | return true; |
433 | 0 | } |
434 | 0 |
|
435 | 0 | JSAutoRealm ar(aCx, global); |
436 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
437 | 0 | if (!canonicalProto) { |
438 | 0 | return false; |
439 | 0 | } |
440 | 0 | JS::Rooted<JSObject*> proto(aCx); |
441 | 0 | if (aGivenProto) { |
442 | 0 | proto = aGivenProto; |
443 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
444 | 0 | // coming in, we changed compartments to that of "parent" so may need |
445 | 0 | // to wrap the proto here. |
446 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
447 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
448 | 0 | return false; |
449 | 0 | } |
450 | 0 | } |
451 | 0 | } else { |
452 | 0 | proto = canonicalProto; |
453 | 0 | } |
454 | 0 |
|
455 | 0 | BindingJSObjectCreator<mozilla::dom::ChannelMergerNode> creator(aCx); |
456 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
457 | 0 | if (!aReflector) { |
458 | 0 | return false; |
459 | 0 | } |
460 | 0 | |
461 | 0 | aCache->SetWrapper(aReflector); |
462 | 0 | creator.InitializationSucceeded(); |
463 | 0 |
|
464 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
465 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
466 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
467 | 0 | // otherwise we won't be able to properly recreate it later, since |
468 | 0 | // we won't know what proto to use. Note that we don't check |
469 | 0 | // aGivenProto here, since it's entirely possible (and even |
470 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
471 | 0 | // same as canonicalProto. |
472 | 0 | if (proto != canonicalProto) { |
473 | 0 | PreserveWrapper(aObject); |
474 | 0 | } |
475 | 0 |
|
476 | 0 | return true; |
477 | 0 | } |
478 | | |
479 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
480 | | nullptr, |
481 | | nullptr, |
482 | | nullptr, |
483 | | { nullptr, nullptr }, |
484 | | prototypes::id::ChannelMergerNode, |
485 | | constructors::id::ChannelMergerNode, |
486 | | AudioNode_Binding::sNativePropertyHooks, |
487 | | &DefaultXrayExpandoObjectClass |
488 | | } }; |
489 | | |
490 | | void |
491 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
492 | 0 | { |
493 | 0 | JS::Handle<JSObject*> parentProto(AudioNode_Binding::GetProtoObjectHandle(aCx)); |
494 | 0 | if (!parentProto) { |
495 | 0 | return; |
496 | 0 | } |
497 | 0 | |
498 | 0 | JS::Handle<JSObject*> constructorProto(AudioNode_Binding::GetConstructorObjectHandle(aCx)); |
499 | 0 | if (!constructorProto) { |
500 | 0 | return; |
501 | 0 | } |
502 | 0 | |
503 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ChannelMergerNode); |
504 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ChannelMergerNode); |
505 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
506 | 0 | &sPrototypeClass.mBase, protoCache, |
507 | 0 | nullptr, |
508 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
509 | 0 | interfaceCache, |
510 | 0 | nullptr, |
511 | 0 | nullptr, |
512 | 0 | "ChannelMergerNode", aDefineOnGlobal, |
513 | 0 | nullptr, |
514 | 0 | false); |
515 | 0 | } |
516 | | |
517 | | JSObject* |
518 | | GetConstructorObject(JSContext* aCx) |
519 | 0 | { |
520 | 0 | return GetConstructorObjectHandle(aCx); |
521 | 0 | } |
522 | | |
523 | | } // namespace ChannelMergerNode_Binding |
524 | | |
525 | | |
526 | | |
527 | | } // namespace dom |
528 | | } // namespace mozilla |