Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM AudioWorkletGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AudioWorkletGlobalScopeBinding.h"
4 : #include "FunctionBinding.h"
5 : #include "WorkletGlobalScopeBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/AudioWorkletGlobalScope.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : namespace AudioWorkletGlobalScopeBinding {
17 :
18 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<WorkletGlobalScopeBinding::NativeType>::value,
19 : "Can't inherit from an interface with a different ownership model.");
20 :
21 : static bool
22 0 : registerProcessor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioWorkletGlobalScope* self, const JSJitMethodCallArgs& args)
23 : {
24 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
25 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AudioWorkletGlobalScope.registerProcessor");
26 : }
27 0 : binding_detail::FakeString arg0;
28 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
29 0 : return false;
30 : }
31 0 : RootedCallback<OwningNonNull<binding_detail::FastVoidFunction>> arg1(cx);
32 0 : if (args[1].isObject()) {
33 0 : if (JS::IsCallable(&args[1].toObject())) {
34 : { // scope for tempRoot
35 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[1].toObject());
36 0 : arg1 = new binding_detail::FastVoidFunction(tempRoot);
37 : }
38 : } else {
39 0 : ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of AudioWorkletGlobalScope.registerProcessor");
40 0 : return false;
41 : }
42 : } else {
43 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of AudioWorkletGlobalScope.registerProcessor");
44 0 : return false;
45 : }
46 0 : self->RegisterProcessor(NonNullHelper(Constify(arg0)), NonNullHelper(arg1));
47 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
48 0 : args.rval().setUndefined();
49 0 : return true;
50 : }
51 :
52 : static const JSJitInfo registerProcessor_methodinfo = {
53 : { (JSJitGetterOp)registerProcessor },
54 : { prototypes::id::AudioWorkletGlobalScope },
55 : { PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth },
56 : JSJitInfo::Method,
57 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
58 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
59 : false, /* isInfallible. False in setters. */
60 : false, /* isMovable. Not relevant for setters. */
61 : false, /* isEliminatable. Not relevant for setters. */
62 : false, /* isAlwaysInSlot. Only relevant for getters. */
63 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
64 : false, /* isTypedMethod. Only relevant for methods. */
65 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
66 : };
67 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
68 : static_assert(0 < 1, "There is no slot for us");
69 :
70 : static bool
71 0 : genericMethod(JSContext* cx, unsigned argc, JS::Value* vp)
72 : {
73 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
74 0 : if (!args.thisv().isNullOrUndefined() && !args.thisv().isObject()) {
75 0 : return ThrowInvalidThis(cx, args, false, "AudioWorkletGlobalScope");
76 : }
77 0 : JS::Rooted<JSObject*> obj(cx, args.thisv().isObject() ? &args.thisv().toObject() : js::GetGlobalForObjectCrossCompartment(&args.callee()));
78 :
79 : mozilla::dom::AudioWorkletGlobalScope* self;
80 0 : JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
81 : {
82 0 : nsresult rv = UnwrapObject<prototypes::id::AudioWorkletGlobalScope, mozilla::dom::AudioWorkletGlobalScope>(&rootSelf, self);
83 0 : if (NS_FAILED(rv)) {
84 0 : return ThrowInvalidThis(cx, args, rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "AudioWorkletGlobalScope");
85 : }
86 : }
87 0 : const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
88 0 : MOZ_ASSERT(info->type() == JSJitInfo::Method);
89 0 : JSJitMethodOp method = info->method;
90 0 : bool ok = method(cx, obj, self, JSJitMethodCallArgs(args));
91 : #ifdef DEBUG
92 0 : if (ok) {
93 0 : AssertReturnTypeMatchesJitinfo(info, args.rval());
94 : }
95 : #endif
96 0 : return ok;
97 : }
98 :
99 : static void
100 0 : _finalize(js::FreeOp* fop, JSObject* obj)
101 : {
102 0 : mozilla::dom::AudioWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletGlobalScope>(obj);
103 0 : if (self) {
104 0 : ClearWrapper(self, self, obj);
105 0 : mozilla::dom::FinalizeGlobal(CastToJSFreeOp(fop), obj);
106 0 : AddForDeferredFinalization<mozilla::dom::AudioWorkletGlobalScope>(self);
107 : }
108 0 : }
109 :
110 : static void
111 0 : _objectMoved(JSObject* obj, const JSObject* old)
112 : {
113 0 : mozilla::dom::AudioWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioWorkletGlobalScope>(obj);
114 0 : if (self) {
115 0 : UpdateWrapper(self, self, obj, old);
116 : }
117 0 : }
118 :
119 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
120 : #if defined(__clang__)
121 : #pragma clang diagnostic push
122 : #pragma clang diagnostic ignored "-Wmissing-braces"
123 : #endif
124 : static const JSFunctionSpec sMethods_specs[] = {
125 : JS_FNSPEC("registerProcessor", genericMethod, reinterpret_cast<const JSJitInfo*>(®isterProcessor_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
126 : JS_FS_END
127 : };
128 : #if defined(__clang__)
129 : #pragma clang diagnostic pop
130 : #endif
131 :
132 :
133 : // Can't be const because the pref-enabled boolean needs to be writable
134 : static Prefable<const JSFunctionSpec> sMethods[] = {
135 : { nullptr, &sMethods_specs[0] },
136 : { nullptr, nullptr }
137 : };
138 :
139 :
140 : static const NativePropertiesN<1> sNativeProperties = {
141 : false, 0,
142 : false, 0,
143 : true, 0 /* sMethods */,
144 : false, 0,
145 : false, 0,
146 : false, 0,
147 : false, 0,
148 : -1,
149 : 0,
150 : nullptr,
151 : {
152 : { sMethods, nullptr }
153 : }
154 : };
155 :
156 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
157 : {
158 : "Function",
159 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
160 : &sBoringInterfaceObjectClassClassOps,
161 : JS_NULL_CLASS_SPEC,
162 : JS_NULL_CLASS_EXT,
163 : &sInterfaceObjectClassObjectOps
164 : },
165 : eInterface,
166 : true,
167 : prototypes::id::AudioWorkletGlobalScope,
168 : PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth,
169 : &sEmptyNativePropertyHooks,
170 : "function AudioWorkletGlobalScope() {\n [native code]\n}",
171 : WorkletGlobalScopeBinding::GetConstructorObject
172 : };
173 :
174 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
175 : {
176 : "AudioWorkletGlobalScopePrototype",
177 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
178 : JS_NULL_CLASS_OPS,
179 : JS_NULL_CLASS_SPEC,
180 : JS_NULL_CLASS_EXT,
181 : JS_NULL_OBJECT_OPS
182 : },
183 : eGlobalInterfacePrototype,
184 : false,
185 : prototypes::id::AudioWorkletGlobalScope,
186 : PrototypeTraits<prototypes::id::AudioWorkletGlobalScope>::Depth,
187 : &sEmptyNativePropertyHooks,
188 : "[object AudioWorkletGlobalScopePrototype]",
189 : WorkletGlobalScopeBinding::GetProtoObject
190 : };
191 :
192 : static const js::ClassOps sClassOps = {
193 : nullptr, /* addProperty */
194 : nullptr, /* delProperty */
195 : nullptr, /* getProperty */
196 : nullptr, /* setProperty */
197 : nullptr, /* enumerate */
198 : mozilla::dom::EnumerateGlobal, /* newEnumerate */
199 : mozilla::dom::ResolveGlobal, /* resolve */
200 : mozilla::dom::MayResolveGlobal, /* mayResolve */
201 : _finalize, /* finalize */
202 : nullptr, /* call */
203 : nullptr, /* hasInstance */
204 : nullptr, /* construct */
205 : JS_GlobalObjectTraceHook, /* trace */
206 : };
207 :
208 : static const js::ClassExtension sClassExtension = {
209 : nullptr, /* weakmapKeyDelegateOp */
210 : _objectMoved /* objectMovedOp */
211 : };
212 :
213 : static const DOMJSClass sClass = {
214 : { "AudioWorkletGlobalScope",
215 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS),
216 : &sClassOps,
217 : JS_NULL_CLASS_SPEC,
218 : &sClassExtension,
219 : JS_NULL_OBJECT_OPS
220 : },
221 : { prototypes::id::WorkletGlobalScope, prototypes::id::AudioWorkletGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
222 : IsBaseOf<nsISupports, mozilla::dom::AudioWorkletGlobalScope >::value,
223 : &sEmptyNativePropertyHooks,
224 : FindAssociatedGlobalForNative<mozilla::dom::AudioWorkletGlobalScope>::Get,
225 : GetProtoObjectHandle,
226 : GetCCParticipant<mozilla::dom::AudioWorkletGlobalScope>::Get()
227 : };
228 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
229 : "Must have the right minimal number of reserved slots.");
230 : static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 1,
231 : "Must have enough reserved slots.");
232 :
233 : const JSClass*
234 0 : GetJSClass()
235 : {
236 0 : return sClass.ToJSClass();
237 : }
238 :
239 : bool
240 0 : Wrap(JSContext* aCx, mozilla::dom::AudioWorkletGlobalScope* aObject, nsWrapperCache* aCache, JS::CompartmentOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector)
241 : {
242 : MOZ_ASSERT(static_cast<mozilla::dom::AudioWorkletGlobalScope*>(aObject) ==
243 : reinterpret_cast<mozilla::dom::AudioWorkletGlobalScope*>(aObject),
244 : "Multiple inheritance for mozilla::dom::AudioWorkletGlobalScope is broken.");
245 : MOZ_ASSERT(static_cast<mozilla::dom::WorkletGlobalScope*>(aObject) ==
246 : reinterpret_cast<mozilla::dom::WorkletGlobalScope*>(aObject),
247 : "Multiple inheritance for mozilla::dom::WorkletGlobalScope is broken.");
248 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
249 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
250 : "nsISupports must be on our primary inheritance chain");
251 :
252 0 : if (!CreateGlobal<mozilla::dom::AudioWorkletGlobalScope, GetProtoObjectHandle>(aCx,
253 : aObject,
254 : aCache,
255 : sClass.ToJSClass(),
256 : aOptions,
257 : aPrincipal,
258 : aInitStandardClasses,
259 : aReflector)) {
260 0 : aCache->ReleaseWrapper(aObject);
261 0 : aCache->ClearWrapper();
262 0 : return false;
263 : }
264 :
265 : // aReflector is a new global, so has a new compartment. Enter it
266 : // before doing anything with it.
267 0 : JSAutoCompartment ac(aCx, aReflector);
268 :
269 0 : if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) {
270 0 : aCache->ReleaseWrapper(aObject);
271 0 : aCache->ClearWrapper();
272 0 : return false;
273 : }
274 :
275 :
276 0 : return true;
277 : }
278 :
279 : void
280 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
281 : {
282 0 : JS::Handle<JSObject*> parentProto(WorkletGlobalScopeBinding::GetProtoObjectHandle(aCx));
283 0 : if (!parentProto) {
284 0 : return;
285 : }
286 :
287 0 : JS::Handle<JSObject*> constructorProto(WorkletGlobalScopeBinding::GetConstructorObjectHandle(aCx));
288 0 : if (!constructorProto) {
289 0 : return;
290 : }
291 :
292 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioWorkletGlobalScope);
293 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioWorkletGlobalScope);
294 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
295 : &sPrototypeClass.mBase, protoCache,
296 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
297 : interfaceCache,
298 : sNativeProperties.Upcast(),
299 : nullptr,
300 : "AudioWorkletGlobalScope", aDefineOnGlobal,
301 : nullptr,
302 0 : true);
303 :
304 0 : if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioWorkletGlobalScope)) {
305 : bool succeeded;
306 0 : JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx);
307 0 : if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
308 0 : *protoCache = nullptr;
309 0 : if (interfaceCache) {
310 0 : *interfaceCache = nullptr;
311 : }
312 0 : return;
313 : }
314 :
315 0 : MOZ_ASSERT(succeeded,
316 : "making a fresh prototype object's [[Prototype]] "
317 : "immutable can internally fail, but it should "
318 : "never be unsuccessful");
319 : }
320 : }
321 :
322 : JS::Handle<JSObject*>
323 0 : GetProtoObjectHandle(JSContext* aCx)
324 : {
325 : /* Get the interface prototype object for this class. This will create the
326 : object as needed. */
327 0 : bool aDefineOnGlobal = true;
328 :
329 : /* Make sure our global is sane. Hopefully we can remove this sometime */
330 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
331 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
332 0 : return nullptr;
333 : }
334 :
335 : /* Check to see whether the interface objects are already installed */
336 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
337 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AudioWorkletGlobalScope)) {
338 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
339 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
340 : }
341 :
342 : /*
343 : * The object might _still_ be null, but that's OK.
344 : *
345 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
346 : * traced by TraceProtoAndIfaceCache() and its contents are never
347 : * changed after they have been set.
348 : *
349 : * Calling address() avoids the read read barrier that does gray
350 : * unmarking, but it's not possible for the object to be gray here.
351 : */
352 :
353 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AudioWorkletGlobalScope);
354 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
355 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
356 : }
357 :
358 : JS::Handle<JSObject*>
359 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
360 : {
361 : /* Get the interface object for this class. This will create the object as
362 : needed. */
363 :
364 : /* Make sure our global is sane. Hopefully we can remove this sometime */
365 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
366 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
367 0 : return nullptr;
368 : }
369 :
370 : /* Check to see whether the interface objects are already installed */
371 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
372 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AudioWorkletGlobalScope)) {
373 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
374 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
375 : }
376 :
377 : /*
378 : * The object might _still_ be null, but that's OK.
379 : *
380 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
381 : * traced by TraceProtoAndIfaceCache() and its contents are never
382 : * changed after they have been set.
383 : *
384 : * Calling address() avoids the read read barrier that does gray
385 : * unmarking, but it's not possible for the object to be gray here.
386 : */
387 :
388 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AudioWorkletGlobalScope);
389 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
390 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
391 : }
392 :
393 : JSObject*
394 0 : GetConstructorObject(JSContext* aCx)
395 : {
396 0 : return GetConstructorObjectHandle(aCx);
397 : }
398 :
399 : } // namespace AudioWorkletGlobalScopeBinding
400 :
401 :
402 :
403 : } // namespace dom
404 : } // namespace mozilla
|