/work/obj-fuzz/dom/bindings/PaintWorkletGlobalScopeBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PaintWorkletGlobalScope.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "FunctionBinding.h" |
4 | | #include "PaintWorkletGlobalScopeBinding.h" |
5 | | #include "WorkletGlobalScopeBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
11 | | #include "mozilla/dom/PaintWorkletGlobalScope.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 PaintWorkletGlobalScope_Binding { |
21 | | |
22 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<WorkletGlobalScope_Binding::NativeType>::value, |
23 | | "Can't inherit from an interface with a different ownership model."); |
24 | | |
25 | | MOZ_CAN_RUN_SCRIPT static bool |
26 | | registerPaint(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PaintWorkletGlobalScope* self, const JSJitMethodCallArgs& args) |
27 | 0 | { |
28 | 0 | AUTO_PROFILER_LABEL_FAST("PaintWorkletGlobalScope.registerPaint", DOM, cx); |
29 | 0 |
|
30 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
31 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PaintWorkletGlobalScope.registerPaint"); |
32 | 0 | } |
33 | 0 | binding_detail::FakeString arg0; |
34 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
35 | 0 | return false; |
36 | 0 | } |
37 | 0 | RootedCallback<OwningNonNull<binding_detail::FastVoidFunction>> arg1(cx); |
38 | 0 | if (args[1].isObject()) { |
39 | 0 | if (JS::IsCallable(&args[1].toObject())) { |
40 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
41 | 0 | arg1 = new binding_detail::FastVoidFunction(&args[1].toObject(), JS::CurrentGlobalOrNull(cx)); |
42 | 0 | } |
43 | 0 | } else { |
44 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of PaintWorkletGlobalScope.registerPaint"); |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | } else { |
48 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of PaintWorkletGlobalScope.registerPaint"); |
49 | 0 | return false; |
50 | 0 | } |
51 | 0 | self->RegisterPaint(NonNullHelper(Constify(arg0)), NonNullHelper(arg1)); |
52 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
53 | 0 | args.rval().setUndefined(); |
54 | 0 | return true; |
55 | 0 | } |
56 | | |
57 | | static const JSJitInfo registerPaint_methodinfo = { |
58 | | { (JSJitGetterOp)registerPaint }, |
59 | | { prototypes::id::PaintWorkletGlobalScope }, |
60 | | { PrototypeTraits<prototypes::id::PaintWorkletGlobalScope>::Depth }, |
61 | | JSJitInfo::Method, |
62 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
63 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
64 | | false, /* isInfallible. False in setters. */ |
65 | | false, /* isMovable. Not relevant for setters. */ |
66 | | false, /* isEliminatable. Not relevant for setters. */ |
67 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
68 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
69 | | false, /* isTypedMethod. Only relevant for methods. */ |
70 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
71 | | }; |
72 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
73 | | static_assert(0 < 1, "There is no slot for us"); |
74 | | |
75 | | static void |
76 | | _finalize(js::FreeOp* fop, JSObject* obj) |
77 | 0 | { |
78 | 0 | mozilla::dom::PaintWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaintWorkletGlobalScope>(obj); |
79 | 0 | if (self) { |
80 | 0 | ClearWrapper(self, self, obj); |
81 | 0 | mozilla::dom::FinalizeGlobal(CastToJSFreeOp(fop), obj); |
82 | 0 | AddForDeferredFinalization<mozilla::dom::PaintWorkletGlobalScope>(self); |
83 | 0 | } |
84 | 0 | } |
85 | | |
86 | | static size_t |
87 | | _objectMoved(JSObject* obj, JSObject* old) |
88 | 0 | { |
89 | 0 | mozilla::dom::PaintWorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PaintWorkletGlobalScope>(obj); |
90 | 0 | if (self) { |
91 | 0 | UpdateWrapper(self, self, obj, old); |
92 | 0 | } |
93 | 0 |
|
94 | 0 | return 0; |
95 | 0 | } |
96 | | |
97 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
98 | | #if defined(__clang__) |
99 | | #pragma clang diagnostic push |
100 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
101 | | #endif |
102 | | static const JSFunctionSpec sMethods_specs[] = { |
103 | | JS_FNSPEC("registerPaint", (GenericMethod<MaybeGlobalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(®isterPaint_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
104 | | JS_FS_END |
105 | | }; |
106 | | #if defined(__clang__) |
107 | | #pragma clang diagnostic pop |
108 | | #endif |
109 | | |
110 | | |
111 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
112 | | { nullptr, &sMethods_specs[0] }, |
113 | | { nullptr, nullptr } |
114 | | }; |
115 | | |
116 | | |
117 | | static const NativePropertiesN<1> sNativeProperties = { |
118 | | false, 0, |
119 | | false, 0, |
120 | | true, 0 /* sMethods */, |
121 | | false, 0, |
122 | | false, 0, |
123 | | false, 0, |
124 | | false, 0, |
125 | | -1, |
126 | | 0, |
127 | | nullptr, |
128 | | { |
129 | | { sMethods, nullptr } |
130 | | } |
131 | | }; |
132 | | |
133 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
134 | | { |
135 | | "Function", |
136 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
137 | | &sBoringInterfaceObjectClassClassOps, |
138 | | JS_NULL_CLASS_SPEC, |
139 | | JS_NULL_CLASS_EXT, |
140 | | &sInterfaceObjectClassObjectOps |
141 | | }, |
142 | | eInterface, |
143 | | true, |
144 | | prototypes::id::PaintWorkletGlobalScope, |
145 | | PrototypeTraits<prototypes::id::PaintWorkletGlobalScope>::Depth, |
146 | | &sEmptyNativePropertyHooks, |
147 | | "function PaintWorkletGlobalScope() {\n [native code]\n}", |
148 | | WorkletGlobalScope_Binding::GetConstructorObject |
149 | | }; |
150 | | |
151 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
152 | | { |
153 | | "PaintWorkletGlobalScopePrototype", |
154 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
155 | | JS_NULL_CLASS_OPS, |
156 | | JS_NULL_CLASS_SPEC, |
157 | | JS_NULL_CLASS_EXT, |
158 | | JS_NULL_OBJECT_OPS |
159 | | }, |
160 | | eGlobalInterfacePrototype, |
161 | | false, |
162 | | prototypes::id::PaintWorkletGlobalScope, |
163 | | PrototypeTraits<prototypes::id::PaintWorkletGlobalScope>::Depth, |
164 | | &sEmptyNativePropertyHooks, |
165 | | "[object PaintWorkletGlobalScopePrototype]", |
166 | | WorkletGlobalScope_Binding::GetProtoObject |
167 | | }; |
168 | | |
169 | | static const js::ClassOps sClassOps = { |
170 | | nullptr, /* addProperty */ |
171 | | nullptr, /* delProperty */ |
172 | | nullptr, /* enumerate */ |
173 | | mozilla::dom::EnumerateGlobal, /* newEnumerate */ |
174 | | mozilla::dom::ResolveGlobal, /* resolve */ |
175 | | mozilla::dom::MayResolveGlobal, /* mayResolve */ |
176 | | _finalize, /* finalize */ |
177 | | nullptr, /* call */ |
178 | | nullptr, /* hasInstance */ |
179 | | nullptr, /* construct */ |
180 | | JS_GlobalObjectTraceHook, /* trace */ |
181 | | }; |
182 | | |
183 | | static const js::ClassExtension sClassExtension = { |
184 | | nullptr, /* weakmapKeyDelegateOp */ |
185 | | _objectMoved /* objectMovedOp */ |
186 | | }; |
187 | | |
188 | | static const DOMJSClass sClass = { |
189 | | { "PaintWorkletGlobalScope", |
190 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS), |
191 | | &sClassOps, |
192 | | JS_NULL_CLASS_SPEC, |
193 | | &sClassExtension, |
194 | | JS_NULL_OBJECT_OPS |
195 | | }, |
196 | | { prototypes::id::WorkletGlobalScope, prototypes::id::PaintWorkletGlobalScope, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
197 | | IsBaseOf<nsISupports, mozilla::dom::PaintWorkletGlobalScope >::value, |
198 | | &sEmptyNativePropertyHooks, |
199 | | FindAssociatedGlobalForNative<mozilla::dom::PaintWorkletGlobalScope>::Get, |
200 | | GetProtoObjectHandle, |
201 | | GetCCParticipant<mozilla::dom::PaintWorkletGlobalScope>::Get() |
202 | | }; |
203 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
204 | | "Must have the right minimal number of reserved slots."); |
205 | | static_assert(JSCLASS_GLOBAL_APPLICATION_SLOTS >= 1, |
206 | | "Must have enough reserved slots."); |
207 | | |
208 | | const JSClass* |
209 | | GetJSClass() |
210 | 0 | { |
211 | 0 | return sClass.ToJSClass(); |
212 | 0 | } |
213 | | |
214 | | bool |
215 | | Wrap(JSContext* aCx, mozilla::dom::PaintWorkletGlobalScope* aObject, nsWrapperCache* aCache, JS::RealmOptions& aOptions, JSPrincipals* aPrincipal, bool aInitStandardClasses, JS::MutableHandle<JSObject*> aReflector) |
216 | 0 | { |
217 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::PaintWorkletGlobalScope*>(aObject) == |
218 | 0 | reinterpret_cast<mozilla::dom::PaintWorkletGlobalScope*>(aObject), |
219 | 0 | "Multiple inheritance for mozilla::dom::PaintWorkletGlobalScope is broken."); |
220 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::WorkletGlobalScope*>(aObject) == |
221 | 0 | reinterpret_cast<mozilla::dom::WorkletGlobalScope*>(aObject), |
222 | 0 | "Multiple inheritance for mozilla::dom::WorkletGlobalScope is broken."); |
223 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
224 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
225 | 0 | "nsISupports must be on our primary inheritance chain"); |
226 | 0 |
|
227 | 0 | if (!CreateGlobal<mozilla::dom::PaintWorkletGlobalScope, GetProtoObjectHandle>(aCx, |
228 | 0 | aObject, |
229 | 0 | aCache, |
230 | 0 | sClass.ToJSClass(), |
231 | 0 | aOptions, |
232 | 0 | aPrincipal, |
233 | 0 | aInitStandardClasses, |
234 | 0 | aReflector)) { |
235 | 0 | aCache->ReleaseWrapper(aObject); |
236 | 0 | aCache->ClearWrapper(); |
237 | 0 | return false; |
238 | 0 | } |
239 | 0 | |
240 | 0 | // aReflector is a new global, so has a new realm. Enter it |
241 | 0 | // before doing anything with it. |
242 | 0 | JSAutoRealm ar(aCx, aReflector); |
243 | 0 |
|
244 | 0 | if (!DefineProperties(aCx, aReflector, sNativeProperties.Upcast(), nullptr)) { |
245 | 0 | aCache->ReleaseWrapper(aObject); |
246 | 0 | aCache->ClearWrapper(); |
247 | 0 | return false; |
248 | 0 | } |
249 | 0 | |
250 | 0 | |
251 | 0 | return true; |
252 | 0 | } |
253 | | |
254 | | void |
255 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
256 | 0 | { |
257 | 0 | JS::Handle<JSObject*> parentProto(WorkletGlobalScope_Binding::GetProtoObjectHandle(aCx)); |
258 | 0 | if (!parentProto) { |
259 | 0 | return; |
260 | 0 | } |
261 | 0 | |
262 | 0 | JS::Handle<JSObject*> constructorProto(WorkletGlobalScope_Binding::GetConstructorObjectHandle(aCx)); |
263 | 0 | if (!constructorProto) { |
264 | 0 | return; |
265 | 0 | } |
266 | 0 | |
267 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PaintWorkletGlobalScope); |
268 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PaintWorkletGlobalScope); |
269 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
270 | 0 | &sPrototypeClass.mBase, protoCache, |
271 | 0 | nullptr, |
272 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
273 | 0 | interfaceCache, |
274 | 0 | sNativeProperties.Upcast(), |
275 | 0 | nullptr, |
276 | 0 | "PaintWorkletGlobalScope", aDefineOnGlobal, |
277 | 0 | nullptr, |
278 | 0 | true); |
279 | 0 |
|
280 | 0 | if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PaintWorkletGlobalScope)) { |
281 | 0 | bool succeeded; |
282 | 0 | JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx); |
283 | 0 | if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) { |
284 | 0 | *protoCache = nullptr; |
285 | 0 | if (interfaceCache) { |
286 | 0 | *interfaceCache = nullptr; |
287 | 0 | } |
288 | 0 | return; |
289 | 0 | } |
290 | 0 |
|
291 | 0 | MOZ_ASSERT(succeeded, |
292 | 0 | "making a fresh prototype object's [[Prototype]] " |
293 | 0 | "immutable can internally fail, but it should " |
294 | 0 | "never be unsuccessful"); |
295 | 0 | } |
296 | 0 | } |
297 | | |
298 | | JSObject* |
299 | | GetConstructorObject(JSContext* aCx) |
300 | 0 | { |
301 | 0 | return GetConstructorObjectHandle(aCx); |
302 | 0 | } |
303 | | |
304 | | } // namespace PaintWorkletGlobalScope_Binding |
305 | | |
306 | | |
307 | | |
308 | | } // namespace dom |
309 | | } // namespace mozilla |