/work/obj-fuzz/dom/bindings/AudioWorkletProcessorBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM AudioWorkletProcessor.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "AudioWorkletNodeBinding.h" |
4 | | #include "AudioWorkletProcessorBinding.h" |
5 | | #include "WrapperFactory.h" |
6 | | #include "mozilla/OwningNonNull.h" |
7 | | #include "mozilla/dom/AudioWorkletProcessor.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/MessagePort.h" |
11 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
17 | | using namespace mozilla::dom::binding_detail; |
18 | | |
19 | | |
20 | | namespace AudioWorkletProcessor_Binding { |
21 | | |
22 | | MOZ_CAN_RUN_SCRIPT static bool |
23 | | get_port(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioWorkletProcessor* self, JSJitGetterCallArgs args) |
24 | 0 | { |
25 | 0 | AUTO_PROFILER_LABEL_FAST("get AudioWorkletProcessor.port", DOM, cx); |
26 | 0 |
|
27 | 0 | FastErrorResult rv; |
28 | 0 | auto result(StrongOrRawPtr<mozilla::dom::MessagePort>(self->GetPort(rv))); |
29 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
30 | 0 | return false; |
31 | 0 | } |
32 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
33 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
34 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
35 | 0 | return false; |
36 | 0 | } |
37 | 0 | return true; |
38 | 0 | } |
39 | | |
40 | | static const JSJitInfo port_getterinfo = { |
41 | | { (JSJitGetterOp)get_port }, |
42 | | { prototypes::id::AudioWorkletProcessor }, |
43 | | { PrototypeTraits<prototypes::id::AudioWorkletProcessor>::Depth }, |
44 | | JSJitInfo::Getter, |
45 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
46 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
47 | | false, /* 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 | | static bool |
59 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
60 | 0 | { |
61 | 0 | mozilla::dom::AudioWorkletProcessor* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletProcessor>(obj); |
62 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
63 | 0 | // obviously can't preserve if we're not initialized. |
64 | 0 | if (self && self->GetWrapperPreserveColor()) { |
65 | 0 | PreserveWrapper(self); |
66 | 0 | } |
67 | 0 | return true; |
68 | 0 | } |
69 | | |
70 | | static void |
71 | | _finalize(js::FreeOp* fop, JSObject* obj) |
72 | 0 | { |
73 | 0 | mozilla::dom::AudioWorkletProcessor* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletProcessor>(obj); |
74 | 0 | if (self) { |
75 | 0 | ClearWrapper(self, self, obj); |
76 | 0 | AddForDeferredFinalization<mozilla::dom::AudioWorkletProcessor>(self); |
77 | 0 | } |
78 | 0 | } |
79 | | |
80 | | static size_t |
81 | | _objectMoved(JSObject* obj, JSObject* old) |
82 | 0 | { |
83 | 0 | mozilla::dom::AudioWorkletProcessor* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletProcessor>(obj); |
84 | 0 | if (self) { |
85 | 0 | UpdateWrapper(self, self, obj, old); |
86 | 0 | } |
87 | 0 |
|
88 | 0 | return 0; |
89 | 0 | } |
90 | | |
91 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
92 | | #if defined(__clang__) |
93 | | #pragma clang diagnostic push |
94 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
95 | | #endif |
96 | | static const JSPropertySpec sAttributes_specs[] = { |
97 | | { "port", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &port_getterinfo, nullptr, nullptr }, |
98 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
99 | | }; |
100 | | #if defined(__clang__) |
101 | | #pragma clang diagnostic pop |
102 | | #endif |
103 | | |
104 | | |
105 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
106 | | { nullptr, &sAttributes_specs[0] }, |
107 | | { nullptr, nullptr } |
108 | | }; |
109 | | |
110 | | |
111 | | static const NativePropertiesN<1> sNativeProperties = { |
112 | | false, 0, |
113 | | false, 0, |
114 | | false, 0, |
115 | | true, 0 /* sAttributes */, |
116 | | false, 0, |
117 | | false, 0, |
118 | | false, 0, |
119 | | -1, |
120 | | 0, |
121 | | nullptr, |
122 | | { |
123 | | { sAttributes, nullptr } |
124 | | } |
125 | | }; |
126 | | |
127 | | static bool |
128 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
129 | 0 | { |
130 | 0 | AUTO_PROFILER_LABEL_FAST("AudioWorkletProcessor constructor", DOM, cx); |
131 | 0 |
|
132 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
133 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
134 | 0 | if (!args.isConstructing()) { |
135 | 0 | // XXXbz wish I could get the name from the callee instead of |
136 | 0 | // Adding more relocations |
137 | 0 | return ThrowConstructorWithoutNew(cx, "AudioWorkletProcessor"); |
138 | 0 | } |
139 | 0 | |
140 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
141 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
142 | 0 | return false; |
143 | 0 | } |
144 | 0 | |
145 | 0 | GlobalObject global(cx, obj); |
146 | 0 | if (global.Failed()) { |
147 | 0 | return false; |
148 | 0 | } |
149 | 0 | |
150 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
151 | 0 | RootedDictionary<binding_detail::FastAudioWorkletNodeOptions> arg0(cx); |
152 | 0 | if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1 of AudioWorkletProcessor.constructor", false)) { |
153 | 0 | return false; |
154 | 0 | } |
155 | 0 | Maybe<JSAutoRealm> ar; |
156 | 0 | if (objIsXray) { |
157 | 0 | obj = js::CheckedUnwrap(obj); |
158 | 0 | if (!obj) { |
159 | 0 | return false; |
160 | 0 | } |
161 | 0 | ar.emplace(cx, obj); |
162 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
163 | 0 | return false; |
164 | 0 | } |
165 | 0 | if (!JS_WrapObject(cx, JS::MutableHandle<JSObject*>::fromMarkedLocation(&arg0.mProcessorOptions))) { |
166 | 0 | return false; |
167 | 0 | } |
168 | 0 | } |
169 | 0 | FastErrorResult rv; |
170 | 0 | auto result(StrongOrRawPtr<mozilla::dom::AudioWorkletProcessor>(mozilla::dom::AudioWorkletProcessor::Constructor(global, Constify(arg0), rv))); |
171 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
172 | 0 | return false; |
173 | 0 | } |
174 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
175 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
176 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
177 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
178 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
179 | 0 | return false; |
180 | 0 | } |
181 | 0 | return true; |
182 | 0 | } |
183 | | |
184 | | static const js::ClassOps sInterfaceObjectClassOps = { |
185 | | nullptr, /* addProperty */ |
186 | | nullptr, /* delProperty */ |
187 | | nullptr, /* enumerate */ |
188 | | nullptr, /* newEnumerate */ |
189 | | nullptr, /* resolve */ |
190 | | nullptr, /* mayResolve */ |
191 | | nullptr, /* finalize */ |
192 | | _constructor, /* call */ |
193 | | nullptr, /* hasInstance */ |
194 | | _constructor, /* construct */ |
195 | | nullptr, /* trace */ |
196 | | }; |
197 | | |
198 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
199 | | { |
200 | | "Function", |
201 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
202 | | &sInterfaceObjectClassOps, |
203 | | JS_NULL_CLASS_SPEC, |
204 | | JS_NULL_CLASS_EXT, |
205 | | &sInterfaceObjectClassObjectOps |
206 | | }, |
207 | | eInterface, |
208 | | true, |
209 | | prototypes::id::AudioWorkletProcessor, |
210 | | PrototypeTraits<prototypes::id::AudioWorkletProcessor>::Depth, |
211 | | &sEmptyNativePropertyHooks, |
212 | | "function AudioWorkletProcessor() {\n [native code]\n}", |
213 | | JS::GetRealmFunctionPrototype |
214 | | }; |
215 | | |
216 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
217 | | { |
218 | | "AudioWorkletProcessorPrototype", |
219 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
220 | | JS_NULL_CLASS_OPS, |
221 | | JS_NULL_CLASS_SPEC, |
222 | | JS_NULL_CLASS_EXT, |
223 | | JS_NULL_OBJECT_OPS |
224 | | }, |
225 | | eInterfacePrototype, |
226 | | false, |
227 | | prototypes::id::AudioWorkletProcessor, |
228 | | PrototypeTraits<prototypes::id::AudioWorkletProcessor>::Depth, |
229 | | &sEmptyNativePropertyHooks, |
230 | | "[object AudioWorkletProcessorPrototype]", |
231 | | JS::GetRealmObjectPrototype |
232 | | }; |
233 | | |
234 | | static const js::ClassOps sClassOps = { |
235 | | _addProperty, /* addProperty */ |
236 | | nullptr, /* delProperty */ |
237 | | nullptr, /* enumerate */ |
238 | | nullptr, /* newEnumerate */ |
239 | | nullptr, /* resolve */ |
240 | | nullptr, /* mayResolve */ |
241 | | _finalize, /* finalize */ |
242 | | nullptr, /* call */ |
243 | | nullptr, /* hasInstance */ |
244 | | nullptr, /* construct */ |
245 | | nullptr, /* trace */ |
246 | | }; |
247 | | |
248 | | static const js::ClassExtension sClassExtension = { |
249 | | nullptr, /* weakmapKeyDelegateOp */ |
250 | | _objectMoved /* objectMovedOp */ |
251 | | }; |
252 | | |
253 | | static const DOMJSClass sClass = { |
254 | | { "AudioWorkletProcessor", |
255 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
256 | | &sClassOps, |
257 | | JS_NULL_CLASS_SPEC, |
258 | | &sClassExtension, |
259 | | JS_NULL_OBJECT_OPS |
260 | | }, |
261 | | { prototypes::id::AudioWorkletProcessor, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
262 | | IsBaseOf<nsISupports, mozilla::dom::AudioWorkletProcessor >::value, |
263 | | &sEmptyNativePropertyHooks, |
264 | | FindAssociatedGlobalForNative<mozilla::dom::AudioWorkletProcessor>::Get, |
265 | | GetProtoObjectHandle, |
266 | | GetCCParticipant<mozilla::dom::AudioWorkletProcessor>::Get() |
267 | | }; |
268 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
269 | | "Must have the right minimal number of reserved slots."); |
270 | | static_assert(1 >= 1, |
271 | | "Must have enough reserved slots."); |
272 | | |
273 | | const JSClass* |
274 | | GetJSClass() |
275 | 0 | { |
276 | 0 | return sClass.ToJSClass(); |
277 | 0 | } |
278 | | |
279 | | bool |
280 | | Wrap(JSContext* aCx, mozilla::dom::AudioWorkletProcessor* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
281 | 0 | { |
282 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AudioWorkletProcessor>::value, |
283 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
284 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::AudioWorkletProcessor*>(aObject) == |
285 | 0 | reinterpret_cast<mozilla::dom::AudioWorkletProcessor*>(aObject), |
286 | 0 | "Multiple inheritance for mozilla::dom::AudioWorkletProcessor is broken."); |
287 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
288 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
289 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
290 | 0 | "You should probably not be using Wrap() directly; use " |
291 | 0 | "GetOrCreateDOMReflector instead"); |
292 | 0 |
|
293 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
294 | 0 | "nsISupports must be on our primary inheritance chain"); |
295 | 0 |
|
296 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
297 | 0 | if (!global) { |
298 | 0 | return false; |
299 | 0 | } |
300 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
301 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
302 | 0 |
|
303 | 0 | // That might have ended up wrapping us already, due to the wonders |
304 | 0 | // of XBL. Check for that, and bail out as needed. |
305 | 0 | aReflector.set(aCache->GetWrapper()); |
306 | 0 | if (aReflector) { |
307 | | #ifdef DEBUG |
308 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
309 | | #endif // DEBUG |
310 | | return true; |
311 | 0 | } |
312 | 0 |
|
313 | 0 | JSAutoRealm ar(aCx, global); |
314 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
315 | 0 | if (!canonicalProto) { |
316 | 0 | return false; |
317 | 0 | } |
318 | 0 | JS::Rooted<JSObject*> proto(aCx); |
319 | 0 | if (aGivenProto) { |
320 | 0 | proto = aGivenProto; |
321 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
322 | 0 | // coming in, we changed compartments to that of "parent" so may need |
323 | 0 | // to wrap the proto here. |
324 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
325 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
326 | 0 | return false; |
327 | 0 | } |
328 | 0 | } |
329 | 0 | } else { |
330 | 0 | proto = canonicalProto; |
331 | 0 | } |
332 | 0 |
|
333 | 0 | BindingJSObjectCreator<mozilla::dom::AudioWorkletProcessor> creator(aCx); |
334 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
335 | 0 | if (!aReflector) { |
336 | 0 | return false; |
337 | 0 | } |
338 | 0 | |
339 | 0 | aCache->SetWrapper(aReflector); |
340 | 0 | creator.InitializationSucceeded(); |
341 | 0 |
|
342 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
343 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
344 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
345 | 0 | // otherwise we won't be able to properly recreate it later, since |
346 | 0 | // we won't know what proto to use. Note that we don't check |
347 | 0 | // aGivenProto here, since it's entirely possible (and even |
348 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
349 | 0 | // same as canonicalProto. |
350 | 0 | if (proto != canonicalProto) { |
351 | 0 | PreserveWrapper(aObject); |
352 | 0 | } |
353 | 0 |
|
354 | 0 | return true; |
355 | 0 | } |
356 | | |
357 | | void |
358 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
359 | 0 | { |
360 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
361 | 0 | if (!parentProto) { |
362 | 0 | return; |
363 | 0 | } |
364 | 0 | |
365 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
366 | 0 | if (!constructorProto) { |
367 | 0 | return; |
368 | 0 | } |
369 | 0 | |
370 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioWorkletProcessor); |
371 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioWorkletProcessor); |
372 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
373 | 0 | &sPrototypeClass.mBase, protoCache, |
374 | 0 | nullptr, |
375 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
376 | 0 | interfaceCache, |
377 | 0 | sNativeProperties.Upcast(), |
378 | 0 | nullptr, |
379 | 0 | "AudioWorkletProcessor", aDefineOnGlobal, |
380 | 0 | nullptr, |
381 | 0 | false); |
382 | 0 | } |
383 | | |
384 | | JSObject* |
385 | | GetConstructorObject(JSContext* aCx) |
386 | 0 | { |
387 | 0 | return GetConstructorObjectHandle(aCx); |
388 | 0 | } |
389 | | |
390 | | } // namespace AudioWorkletProcessor_Binding |
391 | | |
392 | | |
393 | | |
394 | | } // namespace dom |
395 | | } // namespace mozilla |