/work/obj-fuzz/dom/bindings/AnalyserNodeBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM AnalyserNode.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AnalyserNodeBinding.h" |
4 | | #include "AtomList.h" |
5 | | #include "AudioNodeBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "jsfriendapi.h" |
8 | | #include "mozilla/FloatingPoint.h" |
9 | | #include "mozilla/OwningNonNull.h" |
10 | | #include "mozilla/Preferences.h" |
11 | | #include "mozilla/dom/AnalyserNode.h" |
12 | | #include "mozilla/dom/AudioContext.h" |
13 | | #include "mozilla/dom/BindingUtils.h" |
14 | | #include "mozilla/dom/DOMJSClass.h" |
15 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
16 | | #include "mozilla/dom/PrimitiveConversions.h" |
17 | | #include "mozilla/dom/ScriptSettings.h" |
18 | | #include "mozilla/dom/SimpleGlobalObject.h" |
19 | | #include "mozilla/dom/TypedArray.h" |
20 | | #include "mozilla/dom/XrayExpandoClass.h" |
21 | | #include "nsContentUtils.h" |
22 | | |
23 | | namespace mozilla { |
24 | | namespace dom { |
25 | | |
26 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
27 | | using namespace mozilla::dom::binding_detail; |
28 | | |
29 | | |
30 | | |
31 | | AnalyserOptions::AnalyserOptions() |
32 | | : AudioNodeOptions(FastDictionaryInitializer()) |
33 | 0 | { |
34 | 0 | // Safe to pass a null context if we pass a null value |
35 | 0 | Init(nullptr, JS::NullHandleValue); |
36 | 0 | } |
37 | | |
38 | | |
39 | | |
40 | | bool |
41 | | AnalyserOptions::InitIds(JSContext* cx, AnalyserOptionsAtoms* atomsCache) |
42 | 0 | { |
43 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
44 | 0 |
|
45 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
46 | 0 | // uninitialized. |
47 | 0 | if (!atomsCache->smoothingTimeConstant_id.init(cx, "smoothingTimeConstant") || |
48 | 0 | !atomsCache->minDecibels_id.init(cx, "minDecibels") || |
49 | 0 | !atomsCache->maxDecibels_id.init(cx, "maxDecibels") || |
50 | 0 | !atomsCache->fftSize_id.init(cx, "fftSize")) { |
51 | 0 | return false; |
52 | 0 | } |
53 | 0 | return true; |
54 | 0 | } |
55 | | |
56 | | bool |
57 | | AnalyserOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
58 | 0 | { |
59 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
60 | 0 | // Since in that case we will not have to do any property gets |
61 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
62 | 0 | // checkers by static analysis tools |
63 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
64 | 0 | AnalyserOptionsAtoms* atomsCache = nullptr; |
65 | 0 | if (cx) { |
66 | 0 | atomsCache = GetAtomCache<AnalyserOptionsAtoms>(cx); |
67 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
68 | 0 | return false; |
69 | 0 | } |
70 | 0 | } |
71 | 0 | |
72 | 0 | // Per spec, we init the parent's members first |
73 | 0 | if (!AudioNodeOptions::Init(cx, val)) { |
74 | 0 | return false; |
75 | 0 | } |
76 | 0 | |
77 | 0 | bool isNull = val.isNullOrUndefined(); |
78 | 0 | // We only need these if !isNull, in which case we have |cx|. |
79 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
80 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
81 | 0 | if (!isNull) { |
82 | 0 | MOZ_ASSERT(cx); |
83 | 0 | object.emplace(cx, &val.toObject()); |
84 | 0 | temp.emplace(cx); |
85 | 0 | } |
86 | 0 | if (!isNull) { |
87 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->fftSize_id, temp.ptr())) { |
88 | 0 | return false; |
89 | 0 | } |
90 | 0 | } |
91 | 0 | if (!isNull && !temp->isUndefined()) { |
92 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mFftSize)) { |
93 | 0 | return false; |
94 | 0 | } |
95 | 0 | } else { |
96 | 0 | mFftSize = 2048U; |
97 | 0 | } |
98 | 0 | mIsAnyMemberPresent = true; |
99 | 0 |
|
100 | 0 | if (!isNull) { |
101 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->maxDecibels_id, temp.ptr())) { |
102 | 0 | return false; |
103 | 0 | } |
104 | 0 | } |
105 | 0 | if (!isNull && !temp->isUndefined()) { |
106 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mMaxDecibels)) { |
107 | 0 | return false; |
108 | 0 | } else if (!mozilla::IsFinite(mMaxDecibels)) { |
109 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "'maxDecibels' member of AnalyserOptions"); |
110 | 0 | return false; |
111 | 0 | } |
112 | 0 | } else { |
113 | 0 | mMaxDecibels = -30.0; |
114 | 0 | } |
115 | 0 | mIsAnyMemberPresent = true; |
116 | 0 |
|
117 | 0 | if (!isNull) { |
118 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->minDecibels_id, temp.ptr())) { |
119 | 0 | return false; |
120 | 0 | } |
121 | 0 | } |
122 | 0 | if (!isNull && !temp->isUndefined()) { |
123 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mMinDecibels)) { |
124 | 0 | return false; |
125 | 0 | } else if (!mozilla::IsFinite(mMinDecibels)) { |
126 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "'minDecibels' member of AnalyserOptions"); |
127 | 0 | return false; |
128 | 0 | } |
129 | 0 | } else { |
130 | 0 | mMinDecibels = -100.0; |
131 | 0 | } |
132 | 0 | mIsAnyMemberPresent = true; |
133 | 0 |
|
134 | 0 | if (!isNull) { |
135 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->smoothingTimeConstant_id, temp.ptr())) { |
136 | 0 | return false; |
137 | 0 | } |
138 | 0 | } |
139 | 0 | if (!isNull && !temp->isUndefined()) { |
140 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mSmoothingTimeConstant)) { |
141 | 0 | return false; |
142 | 0 | } else if (!mozilla::IsFinite(mSmoothingTimeConstant)) { |
143 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "'smoothingTimeConstant' member of AnalyserOptions"); |
144 | 0 | return false; |
145 | 0 | } |
146 | 0 | } else { |
147 | 0 | mSmoothingTimeConstant = 0.8; |
148 | 0 | } |
149 | 0 | mIsAnyMemberPresent = true; |
150 | 0 | return true; |
151 | 0 | } |
152 | | |
153 | | bool |
154 | | AnalyserOptions::Init(const nsAString& aJSON) |
155 | 0 | { |
156 | 0 | AutoJSAPI jsapi; |
157 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
158 | 0 | if (!cleanGlobal) { |
159 | 0 | return false; |
160 | 0 | } |
161 | 0 | if (!jsapi.Init(cleanGlobal)) { |
162 | 0 | return false; |
163 | 0 | } |
164 | 0 | JSContext* cx = jsapi.cx(); |
165 | 0 | JS::Rooted<JS::Value> json(cx); |
166 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
167 | 0 | NS_ENSURE_TRUE(ok, false); |
168 | 0 | return Init(cx, json); |
169 | 0 | } |
170 | | |
171 | | bool |
172 | | AnalyserOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
173 | 0 | { |
174 | 0 | AnalyserOptionsAtoms* atomsCache = GetAtomCache<AnalyserOptionsAtoms>(cx); |
175 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
176 | 0 | return false; |
177 | 0 | } |
178 | 0 | |
179 | 0 | // Per spec, we define the parent's members first |
180 | 0 | if (!AudioNodeOptions::ToObjectInternal(cx, rval)) { |
181 | 0 | return false; |
182 | 0 | } |
183 | 0 | JS::Rooted<JSObject*> obj(cx, &rval.toObject()); |
184 | 0 |
|
185 | 0 | do { |
186 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
187 | 0 | JS::Rooted<JS::Value> temp(cx); |
188 | 0 | uint32_t const & currentValue = mFftSize; |
189 | 0 | temp.setNumber(currentValue); |
190 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->fftSize_id, temp, JSPROP_ENUMERATE)) { |
191 | 0 | return false; |
192 | 0 | } |
193 | 0 | break; |
194 | 0 | } while(false); |
195 | 0 |
|
196 | 0 | do { |
197 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
198 | 0 | JS::Rooted<JS::Value> temp(cx); |
199 | 0 | double const & currentValue = mMaxDecibels; |
200 | 0 | temp.set(JS_NumberValue(double(currentValue))); |
201 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->maxDecibels_id, temp, JSPROP_ENUMERATE)) { |
202 | 0 | return false; |
203 | 0 | } |
204 | 0 | break; |
205 | 0 | } while(false); |
206 | 0 |
|
207 | 0 | do { |
208 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
209 | 0 | JS::Rooted<JS::Value> temp(cx); |
210 | 0 | double const & currentValue = mMinDecibels; |
211 | 0 | temp.set(JS_NumberValue(double(currentValue))); |
212 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->minDecibels_id, temp, JSPROP_ENUMERATE)) { |
213 | 0 | return false; |
214 | 0 | } |
215 | 0 | break; |
216 | 0 | } while(false); |
217 | 0 |
|
218 | 0 | do { |
219 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
220 | 0 | JS::Rooted<JS::Value> temp(cx); |
221 | 0 | double const & currentValue = mSmoothingTimeConstant; |
222 | 0 | temp.set(JS_NumberValue(double(currentValue))); |
223 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->smoothingTimeConstant_id, temp, JSPROP_ENUMERATE)) { |
224 | 0 | return false; |
225 | 0 | } |
226 | 0 | break; |
227 | 0 | } while(false); |
228 | 0 |
|
229 | 0 | return true; |
230 | 0 | } |
231 | | |
232 | | bool |
233 | | AnalyserOptions::ToJSON(nsAString& aJSON) const |
234 | 0 | { |
235 | 0 | AutoJSAPI jsapi; |
236 | 0 | jsapi.Init(); |
237 | 0 | JSContext *cx = jsapi.cx(); |
238 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
239 | 0 | // because we'll only be creating objects, in ways that have no |
240 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
241 | 0 | // which likewise guarantees no side-effects for the sorts of |
242 | 0 | // things we will pass it. |
243 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
244 | 0 | JS::Rooted<JS::Value> val(cx); |
245 | 0 | if (!ToObjectInternal(cx, &val)) { |
246 | 0 | return false; |
247 | 0 | } |
248 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
249 | 0 | return StringifyToJSON(cx, obj, aJSON); |
250 | 0 | } |
251 | | |
252 | | void |
253 | | AnalyserOptions::TraceDictionary(JSTracer* trc) |
254 | 0 | { |
255 | 0 | AudioNodeOptions::TraceDictionary(trc); |
256 | 0 | } |
257 | | |
258 | | AnalyserOptions& |
259 | | AnalyserOptions::operator=(const AnalyserOptions& aOther) |
260 | 0 | { |
261 | 0 | AudioNodeOptions::operator=(aOther); |
262 | 0 | mFftSize = aOther.mFftSize; |
263 | 0 | mMaxDecibels = aOther.mMaxDecibels; |
264 | 0 | mMinDecibels = aOther.mMinDecibels; |
265 | 0 | mSmoothingTimeConstant = aOther.mSmoothingTimeConstant; |
266 | 0 | return *this; |
267 | 0 | } |
268 | | |
269 | | namespace binding_detail { |
270 | | } // namespace binding_detail |
271 | | |
272 | | |
273 | | namespace AnalyserNode_Binding { |
274 | | |
275 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNode_Binding::NativeType>::value, |
276 | | "Can't inherit from an interface with a different ownership model."); |
277 | | |
278 | | MOZ_CAN_RUN_SCRIPT static bool |
279 | | getFloatFrequencyData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, const JSJitMethodCallArgs& args) |
280 | 0 | { |
281 | 0 | AUTO_PROFILER_LABEL_FAST("AnalyserNode.getFloatFrequencyData", DOM, cx); |
282 | 0 |
|
283 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
284 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnalyserNode.getFloatFrequencyData"); |
285 | 0 | } |
286 | 0 | RootedSpiderMonkeyInterface<Float32Array> arg0(cx); |
287 | 0 | if (args[0].isObject()) { |
288 | 0 | if (!arg0.Init(&args[0].toObject())) { |
289 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AnalyserNode.getFloatFrequencyData", "Float32Array"); |
290 | 0 | return false; |
291 | 0 | } |
292 | 0 | } else { |
293 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AnalyserNode.getFloatFrequencyData"); |
294 | 0 | return false; |
295 | 0 | } |
296 | 0 | self->GetFloatFrequencyData(Constify(arg0)); |
297 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
298 | 0 | args.rval().setUndefined(); |
299 | 0 | return true; |
300 | 0 | } |
301 | | |
302 | | static const JSJitInfo getFloatFrequencyData_methodinfo = { |
303 | | { (JSJitGetterOp)getFloatFrequencyData }, |
304 | | { prototypes::id::AnalyserNode }, |
305 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
306 | | JSJitInfo::Method, |
307 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
308 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
309 | | false, /* isInfallible. False in setters. */ |
310 | | false, /* isMovable. Not relevant for setters. */ |
311 | | false, /* isEliminatable. Not relevant for setters. */ |
312 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
313 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
314 | | false, /* isTypedMethod. Only relevant for methods. */ |
315 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
316 | | }; |
317 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
318 | | static_assert(0 < 1, "There is no slot for us"); |
319 | | |
320 | | MOZ_CAN_RUN_SCRIPT static bool |
321 | | getByteFrequencyData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, const JSJitMethodCallArgs& args) |
322 | 0 | { |
323 | 0 | AUTO_PROFILER_LABEL_FAST("AnalyserNode.getByteFrequencyData", DOM, cx); |
324 | 0 |
|
325 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
326 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnalyserNode.getByteFrequencyData"); |
327 | 0 | } |
328 | 0 | RootedSpiderMonkeyInterface<Uint8Array> arg0(cx); |
329 | 0 | if (args[0].isObject()) { |
330 | 0 | if (!arg0.Init(&args[0].toObject())) { |
331 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AnalyserNode.getByteFrequencyData", "Uint8Array"); |
332 | 0 | return false; |
333 | 0 | } |
334 | 0 | } else { |
335 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AnalyserNode.getByteFrequencyData"); |
336 | 0 | return false; |
337 | 0 | } |
338 | 0 | self->GetByteFrequencyData(Constify(arg0)); |
339 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
340 | 0 | args.rval().setUndefined(); |
341 | 0 | return true; |
342 | 0 | } |
343 | | |
344 | | static const JSJitInfo getByteFrequencyData_methodinfo = { |
345 | | { (JSJitGetterOp)getByteFrequencyData }, |
346 | | { prototypes::id::AnalyserNode }, |
347 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
348 | | JSJitInfo::Method, |
349 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
350 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
351 | | false, /* isInfallible. False in setters. */ |
352 | | false, /* isMovable. Not relevant for setters. */ |
353 | | false, /* isEliminatable. Not relevant for setters. */ |
354 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
355 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
356 | | false, /* isTypedMethod. Only relevant for methods. */ |
357 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
358 | | }; |
359 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
360 | | static_assert(0 < 1, "There is no slot for us"); |
361 | | |
362 | | MOZ_CAN_RUN_SCRIPT static bool |
363 | | getFloatTimeDomainData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, const JSJitMethodCallArgs& args) |
364 | 0 | { |
365 | 0 | AUTO_PROFILER_LABEL_FAST("AnalyserNode.getFloatTimeDomainData", DOM, cx); |
366 | 0 |
|
367 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
368 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnalyserNode.getFloatTimeDomainData"); |
369 | 0 | } |
370 | 0 | RootedSpiderMonkeyInterface<Float32Array> arg0(cx); |
371 | 0 | if (args[0].isObject()) { |
372 | 0 | if (!arg0.Init(&args[0].toObject())) { |
373 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AnalyserNode.getFloatTimeDomainData", "Float32Array"); |
374 | 0 | return false; |
375 | 0 | } |
376 | 0 | } else { |
377 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AnalyserNode.getFloatTimeDomainData"); |
378 | 0 | return false; |
379 | 0 | } |
380 | 0 | self->GetFloatTimeDomainData(Constify(arg0)); |
381 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
382 | 0 | args.rval().setUndefined(); |
383 | 0 | return true; |
384 | 0 | } |
385 | | |
386 | | static const JSJitInfo getFloatTimeDomainData_methodinfo = { |
387 | | { (JSJitGetterOp)getFloatTimeDomainData }, |
388 | | { prototypes::id::AnalyserNode }, |
389 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
390 | | JSJitInfo::Method, |
391 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
392 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
393 | | false, /* isInfallible. False in setters. */ |
394 | | false, /* isMovable. Not relevant for setters. */ |
395 | | false, /* isEliminatable. Not relevant for setters. */ |
396 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
397 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
398 | | false, /* isTypedMethod. Only relevant for methods. */ |
399 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
400 | | }; |
401 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
402 | | static_assert(0 < 1, "There is no slot for us"); |
403 | | |
404 | | MOZ_CAN_RUN_SCRIPT static bool |
405 | | getByteTimeDomainData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, const JSJitMethodCallArgs& args) |
406 | 0 | { |
407 | 0 | AUTO_PROFILER_LABEL_FAST("AnalyserNode.getByteTimeDomainData", DOM, cx); |
408 | 0 |
|
409 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
410 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnalyserNode.getByteTimeDomainData"); |
411 | 0 | } |
412 | 0 | RootedSpiderMonkeyInterface<Uint8Array> arg0(cx); |
413 | 0 | if (args[0].isObject()) { |
414 | 0 | if (!arg0.Init(&args[0].toObject())) { |
415 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AnalyserNode.getByteTimeDomainData", "Uint8Array"); |
416 | 0 | return false; |
417 | 0 | } |
418 | 0 | } else { |
419 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AnalyserNode.getByteTimeDomainData"); |
420 | 0 | return false; |
421 | 0 | } |
422 | 0 | self->GetByteTimeDomainData(Constify(arg0)); |
423 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
424 | 0 | args.rval().setUndefined(); |
425 | 0 | return true; |
426 | 0 | } |
427 | | |
428 | | static const JSJitInfo getByteTimeDomainData_methodinfo = { |
429 | | { (JSJitGetterOp)getByteTimeDomainData }, |
430 | | { prototypes::id::AnalyserNode }, |
431 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
432 | | JSJitInfo::Method, |
433 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
434 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
435 | | false, /* isInfallible. False in setters. */ |
436 | | false, /* isMovable. Not relevant for setters. */ |
437 | | false, /* isEliminatable. Not relevant for setters. */ |
438 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
439 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
440 | | false, /* isTypedMethod. Only relevant for methods. */ |
441 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
442 | | }; |
443 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
444 | | static_assert(0 < 1, "There is no slot for us"); |
445 | | |
446 | | MOZ_CAN_RUN_SCRIPT static bool |
447 | | get_fftSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitGetterCallArgs args) |
448 | 0 | { |
449 | 0 | AUTO_PROFILER_LABEL_FAST("get AnalyserNode.fftSize", DOM, cx); |
450 | 0 |
|
451 | 0 | uint32_t result(self->FftSize()); |
452 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
453 | 0 | args.rval().setNumber(result); |
454 | 0 | return true; |
455 | 0 | } |
456 | | |
457 | | MOZ_CAN_RUN_SCRIPT static bool |
458 | | set_fftSize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitSetterCallArgs args) |
459 | 0 | { |
460 | 0 | AUTO_PROFILER_LABEL_FAST("set AnalyserNode.fftSize", DOM, cx); |
461 | 0 |
|
462 | 0 | uint32_t arg0; |
463 | 0 | if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) { |
464 | 0 | return false; |
465 | 0 | } |
466 | 0 | FastErrorResult rv; |
467 | 0 | self->SetFftSize(arg0, rv); |
468 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
469 | 0 | return false; |
470 | 0 | } |
471 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
472 | 0 |
|
473 | 0 | return true; |
474 | 0 | } |
475 | | |
476 | | static const JSJitInfo fftSize_getterinfo = { |
477 | | { (JSJitGetterOp)get_fftSize }, |
478 | | { prototypes::id::AnalyserNode }, |
479 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
480 | | JSJitInfo::Getter, |
481 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
482 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
483 | | true, /* isInfallible. False in setters. */ |
484 | | true, /* isMovable. Not relevant for setters. */ |
485 | | true, /* isEliminatable. Not relevant for setters. */ |
486 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
487 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
488 | | false, /* isTypedMethod. Only relevant for methods. */ |
489 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
490 | | }; |
491 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
492 | | static_assert(0 < 1, "There is no slot for us"); |
493 | | static const JSJitInfo fftSize_setterinfo = { |
494 | | { (JSJitGetterOp)set_fftSize }, |
495 | | { prototypes::id::AnalyserNode }, |
496 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
497 | | JSJitInfo::Setter, |
498 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
499 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
500 | | false, /* isInfallible. False in setters. */ |
501 | | false, /* isMovable. Not relevant for setters. */ |
502 | | false, /* isEliminatable. Not relevant for setters. */ |
503 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
504 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
505 | | false, /* isTypedMethod. Only relevant for methods. */ |
506 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
507 | | }; |
508 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
509 | | static_assert(0 < 1, "There is no slot for us"); |
510 | | |
511 | | MOZ_CAN_RUN_SCRIPT static bool |
512 | | get_frequencyBinCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitGetterCallArgs args) |
513 | 0 | { |
514 | 0 | AUTO_PROFILER_LABEL_FAST("get AnalyserNode.frequencyBinCount", DOM, cx); |
515 | 0 |
|
516 | 0 | uint32_t result(self->FrequencyBinCount()); |
517 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
518 | 0 | args.rval().setNumber(result); |
519 | 0 | return true; |
520 | 0 | } |
521 | | |
522 | | static const JSJitInfo frequencyBinCount_getterinfo = { |
523 | | { (JSJitGetterOp)get_frequencyBinCount }, |
524 | | { prototypes::id::AnalyserNode }, |
525 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
526 | | JSJitInfo::Getter, |
527 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
528 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
529 | | true, /* isInfallible. False in setters. */ |
530 | | true, /* isMovable. Not relevant for setters. */ |
531 | | true, /* isEliminatable. Not relevant for setters. */ |
532 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
533 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
534 | | false, /* isTypedMethod. Only relevant for methods. */ |
535 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
536 | | }; |
537 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
538 | | static_assert(0 < 1, "There is no slot for us"); |
539 | | |
540 | | MOZ_CAN_RUN_SCRIPT static bool |
541 | | get_minDecibels(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitGetterCallArgs args) |
542 | 0 | { |
543 | 0 | AUTO_PROFILER_LABEL_FAST("get AnalyserNode.minDecibels", DOM, cx); |
544 | 0 |
|
545 | 0 | double result(self->MinDecibels()); |
546 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
547 | 0 | args.rval().set(JS_NumberValue(double(result))); |
548 | 0 | return true; |
549 | 0 | } |
550 | | |
551 | | MOZ_CAN_RUN_SCRIPT static bool |
552 | | set_minDecibels(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitSetterCallArgs args) |
553 | 0 | { |
554 | 0 | AUTO_PROFILER_LABEL_FAST("set AnalyserNode.minDecibels", DOM, cx); |
555 | 0 |
|
556 | 0 | double arg0; |
557 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
558 | 0 | return false; |
559 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
560 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to AnalyserNode.minDecibels"); |
561 | 0 | return false; |
562 | 0 | } |
563 | 0 | FastErrorResult rv; |
564 | 0 | self->SetMinDecibels(arg0, rv); |
565 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
566 | 0 | return false; |
567 | 0 | } |
568 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
569 | 0 |
|
570 | 0 | return true; |
571 | 0 | } |
572 | | |
573 | | static const JSJitInfo minDecibels_getterinfo = { |
574 | | { (JSJitGetterOp)get_minDecibels }, |
575 | | { prototypes::id::AnalyserNode }, |
576 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
577 | | JSJitInfo::Getter, |
578 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
579 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
580 | | true, /* isInfallible. False in setters. */ |
581 | | true, /* isMovable. Not relevant for setters. */ |
582 | | true, /* isEliminatable. Not relevant for setters. */ |
583 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
584 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
585 | | false, /* isTypedMethod. Only relevant for methods. */ |
586 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
587 | | }; |
588 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
589 | | static_assert(0 < 1, "There is no slot for us"); |
590 | | static const JSJitInfo minDecibels_setterinfo = { |
591 | | { (JSJitGetterOp)set_minDecibels }, |
592 | | { prototypes::id::AnalyserNode }, |
593 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
594 | | JSJitInfo::Setter, |
595 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
596 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
597 | | false, /* isInfallible. False in setters. */ |
598 | | false, /* isMovable. Not relevant for setters. */ |
599 | | false, /* isEliminatable. Not relevant for setters. */ |
600 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
601 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
602 | | false, /* isTypedMethod. Only relevant for methods. */ |
603 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
604 | | }; |
605 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
606 | | static_assert(0 < 1, "There is no slot for us"); |
607 | | |
608 | | MOZ_CAN_RUN_SCRIPT static bool |
609 | | get_maxDecibels(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitGetterCallArgs args) |
610 | 0 | { |
611 | 0 | AUTO_PROFILER_LABEL_FAST("get AnalyserNode.maxDecibels", DOM, cx); |
612 | 0 |
|
613 | 0 | double result(self->MaxDecibels()); |
614 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
615 | 0 | args.rval().set(JS_NumberValue(double(result))); |
616 | 0 | return true; |
617 | 0 | } |
618 | | |
619 | | MOZ_CAN_RUN_SCRIPT static bool |
620 | | set_maxDecibels(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitSetterCallArgs args) |
621 | 0 | { |
622 | 0 | AUTO_PROFILER_LABEL_FAST("set AnalyserNode.maxDecibels", DOM, cx); |
623 | 0 |
|
624 | 0 | double arg0; |
625 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
626 | 0 | return false; |
627 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
628 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to AnalyserNode.maxDecibels"); |
629 | 0 | return false; |
630 | 0 | } |
631 | 0 | FastErrorResult rv; |
632 | 0 | self->SetMaxDecibels(arg0, rv); |
633 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
634 | 0 | return false; |
635 | 0 | } |
636 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
637 | 0 |
|
638 | 0 | return true; |
639 | 0 | } |
640 | | |
641 | | static const JSJitInfo maxDecibels_getterinfo = { |
642 | | { (JSJitGetterOp)get_maxDecibels }, |
643 | | { prototypes::id::AnalyserNode }, |
644 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
645 | | JSJitInfo::Getter, |
646 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
647 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
648 | | true, /* isInfallible. False in setters. */ |
649 | | true, /* isMovable. Not relevant for setters. */ |
650 | | true, /* isEliminatable. Not relevant for setters. */ |
651 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
652 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
653 | | false, /* isTypedMethod. Only relevant for methods. */ |
654 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
655 | | }; |
656 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
657 | | static_assert(0 < 1, "There is no slot for us"); |
658 | | static const JSJitInfo maxDecibels_setterinfo = { |
659 | | { (JSJitGetterOp)set_maxDecibels }, |
660 | | { prototypes::id::AnalyserNode }, |
661 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
662 | | JSJitInfo::Setter, |
663 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
664 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
665 | | false, /* isInfallible. False in setters. */ |
666 | | false, /* isMovable. Not relevant for setters. */ |
667 | | false, /* isEliminatable. Not relevant for setters. */ |
668 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
669 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
670 | | false, /* isTypedMethod. Only relevant for methods. */ |
671 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
672 | | }; |
673 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
674 | | static_assert(0 < 1, "There is no slot for us"); |
675 | | |
676 | | MOZ_CAN_RUN_SCRIPT static bool |
677 | | get_smoothingTimeConstant(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitGetterCallArgs args) |
678 | 0 | { |
679 | 0 | AUTO_PROFILER_LABEL_FAST("get AnalyserNode.smoothingTimeConstant", DOM, cx); |
680 | 0 |
|
681 | 0 | double result(self->SmoothingTimeConstant()); |
682 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
683 | 0 | args.rval().set(JS_NumberValue(double(result))); |
684 | 0 | return true; |
685 | 0 | } |
686 | | |
687 | | MOZ_CAN_RUN_SCRIPT static bool |
688 | | set_smoothingTimeConstant(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitSetterCallArgs args) |
689 | 0 | { |
690 | 0 | AUTO_PROFILER_LABEL_FAST("set AnalyserNode.smoothingTimeConstant", DOM, cx); |
691 | 0 |
|
692 | 0 | double arg0; |
693 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
694 | 0 | return false; |
695 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
696 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to AnalyserNode.smoothingTimeConstant"); |
697 | 0 | return false; |
698 | 0 | } |
699 | 0 | FastErrorResult rv; |
700 | 0 | self->SetSmoothingTimeConstant(arg0, rv); |
701 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
702 | 0 | return false; |
703 | 0 | } |
704 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
705 | 0 |
|
706 | 0 | return true; |
707 | 0 | } |
708 | | |
709 | | static const JSJitInfo smoothingTimeConstant_getterinfo = { |
710 | | { (JSJitGetterOp)get_smoothingTimeConstant }, |
711 | | { prototypes::id::AnalyserNode }, |
712 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
713 | | JSJitInfo::Getter, |
714 | | JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */ |
715 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
716 | | true, /* isInfallible. False in setters. */ |
717 | | true, /* isMovable. Not relevant for setters. */ |
718 | | true, /* isEliminatable. Not relevant for setters. */ |
719 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
720 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
721 | | false, /* isTypedMethod. Only relevant for methods. */ |
722 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
723 | | }; |
724 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
725 | | static_assert(0 < 1, "There is no slot for us"); |
726 | | static const JSJitInfo smoothingTimeConstant_setterinfo = { |
727 | | { (JSJitGetterOp)set_smoothingTimeConstant }, |
728 | | { prototypes::id::AnalyserNode }, |
729 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
730 | | JSJitInfo::Setter, |
731 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
732 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
733 | | false, /* isInfallible. False in setters. */ |
734 | | false, /* isMovable. Not relevant for setters. */ |
735 | | false, /* isEliminatable. Not relevant for setters. */ |
736 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
737 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
738 | | false, /* isTypedMethod. Only relevant for methods. */ |
739 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
740 | | }; |
741 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
742 | | static_assert(0 < 1, "There is no slot for us"); |
743 | | |
744 | | MOZ_CAN_RUN_SCRIPT static bool |
745 | | get_passThrough(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitGetterCallArgs args) |
746 | 0 | { |
747 | 0 | AUTO_PROFILER_LABEL_FAST("get AnalyserNode.passThrough", DOM, cx); |
748 | 0 |
|
749 | 0 | bool result(self->PassThrough()); |
750 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
751 | 0 | args.rval().setBoolean(result); |
752 | 0 | return true; |
753 | 0 | } |
754 | | |
755 | | MOZ_CAN_RUN_SCRIPT static bool |
756 | | set_passThrough(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnalyserNode* self, JSJitSetterCallArgs args) |
757 | 0 | { |
758 | 0 | AUTO_PROFILER_LABEL_FAST("set AnalyserNode.passThrough", DOM, cx); |
759 | 0 |
|
760 | 0 | bool arg0; |
761 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) { |
762 | 0 | return false; |
763 | 0 | } |
764 | 0 | self->SetPassThrough(arg0); |
765 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
766 | 0 |
|
767 | 0 | return true; |
768 | 0 | } |
769 | | |
770 | | static const JSJitInfo passThrough_getterinfo = { |
771 | | { (JSJitGetterOp)get_passThrough }, |
772 | | { prototypes::id::AnalyserNode }, |
773 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
774 | | JSJitInfo::Getter, |
775 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
776 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
777 | | true, /* isInfallible. False in setters. */ |
778 | | false, /* isMovable. Not relevant for setters. */ |
779 | | false, /* isEliminatable. Not relevant for setters. */ |
780 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
781 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
782 | | false, /* isTypedMethod. Only relevant for methods. */ |
783 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
784 | | }; |
785 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
786 | | static_assert(0 < 1, "There is no slot for us"); |
787 | | static const JSJitInfo passThrough_setterinfo = { |
788 | | { (JSJitGetterOp)set_passThrough }, |
789 | | { prototypes::id::AnalyserNode }, |
790 | | { PrototypeTraits<prototypes::id::AnalyserNode>::Depth }, |
791 | | JSJitInfo::Setter, |
792 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
793 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
794 | | false, /* isInfallible. False in setters. */ |
795 | | false, /* isMovable. Not relevant for setters. */ |
796 | | false, /* isEliminatable. Not relevant for setters. */ |
797 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
798 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
799 | | false, /* isTypedMethod. Only relevant for methods. */ |
800 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
801 | | }; |
802 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
803 | | static_assert(0 < 1, "There is no slot for us"); |
804 | | |
805 | | static bool |
806 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
807 | 0 | { |
808 | 0 | mozilla::dom::AnalyserNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnalyserNode>(obj); |
809 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
810 | 0 | // obviously can't preserve if we're not initialized. |
811 | 0 | if (self && self->GetWrapperPreserveColor()) { |
812 | 0 | PreserveWrapper(self); |
813 | 0 | } |
814 | 0 | return true; |
815 | 0 | } |
816 | | |
817 | | static void |
818 | | _finalize(js::FreeOp* fop, JSObject* obj) |
819 | 0 | { |
820 | 0 | mozilla::dom::AnalyserNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnalyserNode>(obj); |
821 | 0 | if (self) { |
822 | 0 | ClearWrapper(self, self, obj); |
823 | 0 | AddForDeferredFinalization<mozilla::dom::AnalyserNode>(self); |
824 | 0 | } |
825 | 0 | } |
826 | | |
827 | | static size_t |
828 | | _objectMoved(JSObject* obj, JSObject* old) |
829 | 0 | { |
830 | 0 | mozilla::dom::AnalyserNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnalyserNode>(obj); |
831 | 0 | if (self) { |
832 | 0 | UpdateWrapper(self, self, obj, old); |
833 | 0 | } |
834 | 0 |
|
835 | 0 | return 0; |
836 | 0 | } |
837 | | |
838 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
839 | | #if defined(__clang__) |
840 | | #pragma clang diagnostic push |
841 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
842 | | #endif |
843 | | static const JSFunctionSpec sMethods_specs[] = { |
844 | | JS_FNSPEC("getFloatFrequencyData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFloatFrequencyData_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
845 | | JS_FNSPEC("getByteFrequencyData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getByteFrequencyData_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
846 | | JS_FNSPEC("getFloatTimeDomainData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getFloatTimeDomainData_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
847 | | JS_FNSPEC("getByteTimeDomainData", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getByteTimeDomainData_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
848 | | JS_FS_END |
849 | | }; |
850 | | #if defined(__clang__) |
851 | | #pragma clang diagnostic pop |
852 | | #endif |
853 | | |
854 | | |
855 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
856 | | { nullptr, &sMethods_specs[0] }, |
857 | | { nullptr, nullptr } |
858 | | }; |
859 | | |
860 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
861 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
862 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
863 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
864 | | |
865 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
866 | | #if defined(__clang__) |
867 | | #pragma clang diagnostic push |
868 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
869 | | #endif |
870 | | static const JSPropertySpec sAttributes_specs[] = { |
871 | | { "fftSize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &fftSize_getterinfo, GenericSetter<NormalThisPolicy>, &fftSize_setterinfo }, |
872 | | { "frequencyBinCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &frequencyBinCount_getterinfo, nullptr, nullptr }, |
873 | | { "minDecibels", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &minDecibels_getterinfo, GenericSetter<NormalThisPolicy>, &minDecibels_setterinfo }, |
874 | | { "maxDecibels", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &maxDecibels_getterinfo, GenericSetter<NormalThisPolicy>, &maxDecibels_setterinfo }, |
875 | | { "smoothingTimeConstant", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &smoothingTimeConstant_getterinfo, GenericSetter<NormalThisPolicy>, &smoothingTimeConstant_setterinfo }, |
876 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
877 | | }; |
878 | | #if defined(__clang__) |
879 | | #pragma clang diagnostic pop |
880 | | #endif |
881 | | |
882 | | |
883 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
884 | | { nullptr, &sAttributes_specs[0] }, |
885 | | { nullptr, nullptr } |
886 | | }; |
887 | | |
888 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
889 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
890 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
891 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
892 | | |
893 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
894 | | #if defined(__clang__) |
895 | | #pragma clang diagnostic push |
896 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
897 | | #endif |
898 | | static const JSPropertySpec sChromeAttributes_specs[] = { |
899 | | { "passThrough", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &passThrough_getterinfo, GenericSetter<NormalThisPolicy>, &passThrough_setterinfo }, |
900 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
901 | | }; |
902 | | #if defined(__clang__) |
903 | | #pragma clang diagnostic pop |
904 | | #endif |
905 | | |
906 | | |
907 | | static const Prefable<const JSPropertySpec> sChromeAttributes[] = { |
908 | | { nullptr, &sChromeAttributes_specs[0] }, |
909 | | { nullptr, nullptr } |
910 | | }; |
911 | | |
912 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
913 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
914 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
915 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
916 | | |
917 | | |
918 | | static uint16_t sNativeProperties_sortedPropertyIndices[9]; |
919 | | static PropertyInfo sNativeProperties_propertyInfos[9]; |
920 | | |
921 | | static const NativePropertiesN<2> sNativeProperties = { |
922 | | false, 0, |
923 | | false, 0, |
924 | | true, 0 /* sMethods */, |
925 | | true, 1 /* sAttributes */, |
926 | | false, 0, |
927 | | false, 0, |
928 | | false, 0, |
929 | | -1, |
930 | | 9, |
931 | | sNativeProperties_sortedPropertyIndices, |
932 | | { |
933 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
934 | | { sAttributes, &sNativeProperties_propertyInfos[4] } |
935 | | } |
936 | | }; |
937 | | static_assert(9 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
938 | | "We have a property info count that is oversized"); |
939 | | |
940 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1]; |
941 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1]; |
942 | | |
943 | | static const NativePropertiesN<1> sChromeOnlyNativeProperties = { |
944 | | false, 0, |
945 | | false, 0, |
946 | | false, 0, |
947 | | true, 0 /* sChromeAttributes */, |
948 | | false, 0, |
949 | | false, 0, |
950 | | false, 0, |
951 | | -1, |
952 | | 1, |
953 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
954 | | { |
955 | | { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] } |
956 | | } |
957 | | }; |
958 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
959 | | "We have a property info count that is oversized"); |
960 | | |
961 | | static bool |
962 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
963 | 0 | { |
964 | 0 | AUTO_PROFILER_LABEL_FAST("AnalyserNode constructor", DOM, cx); |
965 | 0 |
|
966 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
967 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
968 | 0 | if (!args.isConstructing()) { |
969 | 0 | // XXXbz wish I could get the name from the callee instead of |
970 | 0 | // Adding more relocations |
971 | 0 | return ThrowConstructorWithoutNew(cx, "AnalyserNode"); |
972 | 0 | } |
973 | 0 | |
974 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
975 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
976 | 0 | return false; |
977 | 0 | } |
978 | 0 | |
979 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
980 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnalyserNode"); |
981 | 0 | } |
982 | 0 | GlobalObject global(cx, obj); |
983 | 0 | if (global.Failed()) { |
984 | 0 | return false; |
985 | 0 | } |
986 | 0 | |
987 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
988 | 0 | NonNull<mozilla::dom::AudioContext> arg0; |
989 | 0 | if (args[0].isObject()) { |
990 | 0 | { |
991 | 0 | nsresult rv = UnwrapObject<prototypes::id::BaseAudioContext, mozilla::dom::AudioContext>(args[0], arg0); |
992 | 0 | if (NS_FAILED(rv)) { |
993 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AnalyserNode.constructor", "BaseAudioContext"); |
994 | 0 | return false; |
995 | 0 | } |
996 | 0 | } |
997 | 0 | } else { |
998 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AnalyserNode.constructor"); |
999 | 0 | return false; |
1000 | 0 | } |
1001 | 0 | binding_detail::FastAnalyserOptions arg1; |
1002 | 0 | if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of AnalyserNode.constructor", false)) { |
1003 | 0 | return false; |
1004 | 0 | } |
1005 | 0 | Maybe<JSAutoRealm> ar; |
1006 | 0 | if (objIsXray) { |
1007 | 0 | obj = js::CheckedUnwrap(obj); |
1008 | 0 | if (!obj) { |
1009 | 0 | return false; |
1010 | 0 | } |
1011 | 0 | ar.emplace(cx, obj); |
1012 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1013 | 0 | return false; |
1014 | 0 | } |
1015 | 0 | } |
1016 | 0 | FastErrorResult rv; |
1017 | 0 | auto result(StrongOrRawPtr<mozilla::dom::AnalyserNode>(mozilla::dom::AnalyserNode::Constructor(global, MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), rv))); |
1018 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1019 | 0 | return false; |
1020 | 0 | } |
1021 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1022 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1023 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1024 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1025 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1026 | 0 | return false; |
1027 | 0 | } |
1028 | 0 | return true; |
1029 | 0 | } |
1030 | | |
1031 | | static const js::ClassOps sInterfaceObjectClassOps = { |
1032 | | nullptr, /* addProperty */ |
1033 | | nullptr, /* delProperty */ |
1034 | | nullptr, /* enumerate */ |
1035 | | nullptr, /* newEnumerate */ |
1036 | | nullptr, /* resolve */ |
1037 | | nullptr, /* mayResolve */ |
1038 | | nullptr, /* finalize */ |
1039 | | _constructor, /* call */ |
1040 | | nullptr, /* hasInstance */ |
1041 | | _constructor, /* construct */ |
1042 | | nullptr, /* trace */ |
1043 | | }; |
1044 | | |
1045 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1046 | | { |
1047 | | "Function", |
1048 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1049 | | &sInterfaceObjectClassOps, |
1050 | | JS_NULL_CLASS_SPEC, |
1051 | | JS_NULL_CLASS_EXT, |
1052 | | &sInterfaceObjectClassObjectOps |
1053 | | }, |
1054 | | eInterface, |
1055 | | true, |
1056 | | prototypes::id::AnalyserNode, |
1057 | | PrototypeTraits<prototypes::id::AnalyserNode>::Depth, |
1058 | | sNativePropertyHooks, |
1059 | | "function AnalyserNode() {\n [native code]\n}", |
1060 | | AudioNode_Binding::GetConstructorObject |
1061 | | }; |
1062 | | |
1063 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1064 | | { |
1065 | | "AnalyserNodePrototype", |
1066 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1067 | | JS_NULL_CLASS_OPS, |
1068 | | JS_NULL_CLASS_SPEC, |
1069 | | JS_NULL_CLASS_EXT, |
1070 | | JS_NULL_OBJECT_OPS |
1071 | | }, |
1072 | | eInterfacePrototype, |
1073 | | false, |
1074 | | prototypes::id::AnalyserNode, |
1075 | | PrototypeTraits<prototypes::id::AnalyserNode>::Depth, |
1076 | | sNativePropertyHooks, |
1077 | | "[object AnalyserNodePrototype]", |
1078 | | AudioNode_Binding::GetProtoObject |
1079 | | }; |
1080 | | |
1081 | | bool |
1082 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1083 | 0 | { |
1084 | 0 | static bool sPrefValue; |
1085 | 0 | static bool sPrefCacheSetUp = false; |
1086 | 0 | if (!sPrefCacheSetUp) { |
1087 | 0 | sPrefCacheSetUp = true; |
1088 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled"); |
1089 | 0 | } |
1090 | 0 |
|
1091 | 0 | return sPrefValue; |
1092 | 0 | } |
1093 | | |
1094 | | static const js::ClassOps sClassOps = { |
1095 | | _addProperty, /* addProperty */ |
1096 | | nullptr, /* delProperty */ |
1097 | | nullptr, /* enumerate */ |
1098 | | nullptr, /* newEnumerate */ |
1099 | | nullptr, /* resolve */ |
1100 | | nullptr, /* mayResolve */ |
1101 | | _finalize, /* finalize */ |
1102 | | nullptr, /* call */ |
1103 | | nullptr, /* hasInstance */ |
1104 | | nullptr, /* construct */ |
1105 | | nullptr, /* trace */ |
1106 | | }; |
1107 | | |
1108 | | static const js::ClassExtension sClassExtension = { |
1109 | | nullptr, /* weakmapKeyDelegateOp */ |
1110 | | _objectMoved /* objectMovedOp */ |
1111 | | }; |
1112 | | |
1113 | | static const DOMJSClass sClass = { |
1114 | | { "AnalyserNode", |
1115 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1116 | | &sClassOps, |
1117 | | JS_NULL_CLASS_SPEC, |
1118 | | &sClassExtension, |
1119 | | JS_NULL_OBJECT_OPS |
1120 | | }, |
1121 | | { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::AnalyserNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1122 | | IsBaseOf<nsISupports, mozilla::dom::AnalyserNode >::value, |
1123 | | sNativePropertyHooks, |
1124 | | FindAssociatedGlobalForNative<mozilla::dom::AnalyserNode>::Get, |
1125 | | GetProtoObjectHandle, |
1126 | | GetCCParticipant<mozilla::dom::AnalyserNode>::Get() |
1127 | | }; |
1128 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1129 | | "Must have the right minimal number of reserved slots."); |
1130 | | static_assert(1 >= 1, |
1131 | | "Must have enough reserved slots."); |
1132 | | |
1133 | | const JSClass* |
1134 | | GetJSClass() |
1135 | 0 | { |
1136 | 0 | return sClass.ToJSClass(); |
1137 | 0 | } |
1138 | | |
1139 | | bool |
1140 | | Wrap(JSContext* aCx, mozilla::dom::AnalyserNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1141 | 0 | { |
1142 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AnalyserNode>::value, |
1143 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1144 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AnalyserNode*>(aObject) == |
1145 | 0 | reinterpret_cast<mozilla::dom::AnalyserNode*>(aObject), |
1146 | 0 | "Multiple inheritance for mozilla::dom::AnalyserNode is broken."); |
1147 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) == |
1148 | 0 | reinterpret_cast<mozilla::dom::AudioNode*>(aObject), |
1149 | 0 | "Multiple inheritance for mozilla::dom::AudioNode is broken."); |
1150 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1151 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1152 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1153 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1154 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1155 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1156 | 0 | "You should probably not be using Wrap() directly; use " |
1157 | 0 | "GetOrCreateDOMReflector instead"); |
1158 | 0 |
|
1159 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1160 | 0 | "nsISupports must be on our primary inheritance chain"); |
1161 | 0 |
|
1162 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1163 | 0 | if (!global) { |
1164 | 0 | return false; |
1165 | 0 | } |
1166 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1167 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1168 | 0 |
|
1169 | 0 | // That might have ended up wrapping us already, due to the wonders |
1170 | 0 | // of XBL. Check for that, and bail out as needed. |
1171 | 0 | aReflector.set(aCache->GetWrapper()); |
1172 | 0 | if (aReflector) { |
1173 | | #ifdef DEBUG |
1174 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1175 | | #endif // DEBUG |
1176 | | return true; |
1177 | 0 | } |
1178 | 0 |
|
1179 | 0 | JSAutoRealm ar(aCx, global); |
1180 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1181 | 0 | if (!canonicalProto) { |
1182 | 0 | return false; |
1183 | 0 | } |
1184 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1185 | 0 | if (aGivenProto) { |
1186 | 0 | proto = aGivenProto; |
1187 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1188 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1189 | 0 | // to wrap the proto here. |
1190 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1191 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1192 | 0 | return false; |
1193 | 0 | } |
1194 | 0 | } |
1195 | 0 | } else { |
1196 | 0 | proto = canonicalProto; |
1197 | 0 | } |
1198 | 0 |
|
1199 | 0 | BindingJSObjectCreator<mozilla::dom::AnalyserNode> creator(aCx); |
1200 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1201 | 0 | if (!aReflector) { |
1202 | 0 | return false; |
1203 | 0 | } |
1204 | 0 | |
1205 | 0 | aCache->SetWrapper(aReflector); |
1206 | 0 | creator.InitializationSucceeded(); |
1207 | 0 |
|
1208 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1209 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1210 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1211 | 0 | // otherwise we won't be able to properly recreate it later, since |
1212 | 0 | // we won't know what proto to use. Note that we don't check |
1213 | 0 | // aGivenProto here, since it's entirely possible (and even |
1214 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1215 | 0 | // same as canonicalProto. |
1216 | 0 | if (proto != canonicalProto) { |
1217 | 0 | PreserveWrapper(aObject); |
1218 | 0 | } |
1219 | 0 |
|
1220 | 0 | return true; |
1221 | 0 | } |
1222 | | |
1223 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1224 | | nullptr, |
1225 | | nullptr, |
1226 | | nullptr, |
1227 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
1228 | | prototypes::id::AnalyserNode, |
1229 | | constructors::id::AnalyserNode, |
1230 | | AudioNode_Binding::sNativePropertyHooks, |
1231 | | &DefaultXrayExpandoObjectClass |
1232 | | } }; |
1233 | | |
1234 | | void |
1235 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1236 | 0 | { |
1237 | 0 | JS::Handle<JSObject*> parentProto(AudioNode_Binding::GetProtoObjectHandle(aCx)); |
1238 | 0 | if (!parentProto) { |
1239 | 0 | return; |
1240 | 0 | } |
1241 | 0 | |
1242 | 0 | JS::Handle<JSObject*> constructorProto(AudioNode_Binding::GetConstructorObjectHandle(aCx)); |
1243 | 0 | if (!constructorProto) { |
1244 | 0 | return; |
1245 | 0 | } |
1246 | 0 | |
1247 | 0 | static bool sIdsInited = false; |
1248 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1249 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1250 | 0 | return; |
1251 | 0 | } |
1252 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
1253 | 0 | return; |
1254 | 0 | } |
1255 | 0 | sIdsInited = true; |
1256 | 0 | } |
1257 | 0 |
|
1258 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnalyserNode); |
1259 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnalyserNode); |
1260 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1261 | 0 | &sPrototypeClass.mBase, protoCache, |
1262 | 0 | nullptr, |
1263 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr, |
1264 | 0 | interfaceCache, |
1265 | 0 | sNativeProperties.Upcast(), |
1266 | 0 | sChromeOnlyNativeProperties.Upcast(), |
1267 | 0 | "AnalyserNode", aDefineOnGlobal, |
1268 | 0 | nullptr, |
1269 | 0 | false); |
1270 | 0 | } |
1271 | | |
1272 | | JSObject* |
1273 | | GetConstructorObject(JSContext* aCx) |
1274 | 0 | { |
1275 | 0 | return GetConstructorObjectHandle(aCx); |
1276 | 0 | } |
1277 | | |
1278 | | } // namespace AnalyserNode_Binding |
1279 | | |
1280 | | |
1281 | | |
1282 | | } // namespace dom |
1283 | | } // namespace mozilla |