/work/obj-fuzz/dom/bindings/SVGAnimatedEnumerationBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SVGAnimatedEnumeration.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "SVGAnimatedEnumerationBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "mozilla/OwningNonNull.h" |
6 | | #include "mozilla/dom/BindingUtils.h" |
7 | | #include "mozilla/dom/DOMJSClass.h" |
8 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
9 | | #include "mozilla/dom/PrimitiveConversions.h" |
10 | | #include "mozilla/dom/SVGAnimatedEnumeration.h" |
11 | | #include "mozilla/dom/XrayExpandoClass.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 SVGAnimatedEnumeration_Binding { |
21 | | |
22 | | MOZ_CAN_RUN_SCRIPT static bool |
23 | | get_baseVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedEnumeration* self, JSJitGetterCallArgs args) |
24 | 0 | { |
25 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGAnimatedEnumeration.baseVal", DOM, cx); |
26 | 0 |
|
27 | 0 | uint16_t result(self->BaseVal()); |
28 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
29 | 0 | args.rval().setInt32(int32_t(result)); |
30 | 0 | return true; |
31 | 0 | } |
32 | | |
33 | | MOZ_CAN_RUN_SCRIPT static bool |
34 | | set_baseVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedEnumeration* self, JSJitSetterCallArgs args) |
35 | 0 | { |
36 | 0 | AUTO_PROFILER_LABEL_FAST("set SVGAnimatedEnumeration.baseVal", DOM, cx); |
37 | 0 |
|
38 | 0 | uint16_t arg0; |
39 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) { |
40 | 0 | return false; |
41 | 0 | } |
42 | 0 | FastErrorResult rv; |
43 | 0 | self->SetBaseVal(arg0, rv); |
44 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
48 | 0 |
|
49 | 0 | return true; |
50 | 0 | } |
51 | | |
52 | | static const JSJitInfo baseVal_getterinfo = { |
53 | | { (JSJitGetterOp)get_baseVal }, |
54 | | { prototypes::id::SVGAnimatedEnumeration }, |
55 | | { PrototypeTraits<prototypes::id::SVGAnimatedEnumeration>::Depth }, |
56 | | JSJitInfo::Getter, |
57 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
58 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
59 | | true, /* 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 | | static const JSJitInfo baseVal_setterinfo = { |
70 | | { (JSJitGetterOp)set_baseVal }, |
71 | | { prototypes::id::SVGAnimatedEnumeration }, |
72 | | { PrototypeTraits<prototypes::id::SVGAnimatedEnumeration>::Depth }, |
73 | | JSJitInfo::Setter, |
74 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
75 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
76 | | false, /* isInfallible. False in setters. */ |
77 | | false, /* isMovable. Not relevant for setters. */ |
78 | | false, /* isEliminatable. Not relevant for setters. */ |
79 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
80 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
81 | | false, /* isTypedMethod. Only relevant for methods. */ |
82 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
83 | | }; |
84 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
85 | | static_assert(0 < 1, "There is no slot for us"); |
86 | | |
87 | | MOZ_CAN_RUN_SCRIPT static bool |
88 | | get_animVal(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGAnimatedEnumeration* self, JSJitGetterCallArgs args) |
89 | 0 | { |
90 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGAnimatedEnumeration.animVal", DOM, cx); |
91 | 0 |
|
92 | 0 | uint16_t result(self->AnimVal()); |
93 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
94 | 0 | args.rval().setInt32(int32_t(result)); |
95 | 0 | return true; |
96 | 0 | } |
97 | | |
98 | | static const JSJitInfo animVal_getterinfo = { |
99 | | { (JSJitGetterOp)get_animVal }, |
100 | | { prototypes::id::SVGAnimatedEnumeration }, |
101 | | { PrototypeTraits<prototypes::id::SVGAnimatedEnumeration>::Depth }, |
102 | | JSJitInfo::Getter, |
103 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
104 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
105 | | true, /* isInfallible. False in setters. */ |
106 | | false, /* isMovable. Not relevant for setters. */ |
107 | | false, /* isEliminatable. Not relevant for setters. */ |
108 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
109 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
110 | | false, /* isTypedMethod. Only relevant for methods. */ |
111 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
112 | | }; |
113 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
114 | | static_assert(0 < 1, "There is no slot for us"); |
115 | | |
116 | | static bool |
117 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
118 | 0 | { |
119 | 0 | mozilla::dom::SVGAnimatedEnumeration* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedEnumeration>(obj); |
120 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
121 | 0 | // obviously can't preserve if we're not initialized. |
122 | 0 | if (self && self->GetWrapperPreserveColor()) { |
123 | 0 | PreserveWrapper(self); |
124 | 0 | } |
125 | 0 | return true; |
126 | 0 | } |
127 | | |
128 | | static void |
129 | | _finalize(js::FreeOp* fop, JSObject* obj) |
130 | 0 | { |
131 | 0 | mozilla::dom::SVGAnimatedEnumeration* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedEnumeration>(obj); |
132 | 0 | if (self) { |
133 | 0 | ClearWrapper(self, self, obj); |
134 | 0 | AddForDeferredFinalization<mozilla::dom::SVGAnimatedEnumeration>(self); |
135 | 0 | } |
136 | 0 | } |
137 | | |
138 | | static size_t |
139 | | _objectMoved(JSObject* obj, JSObject* old) |
140 | 0 | { |
141 | 0 | mozilla::dom::SVGAnimatedEnumeration* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGAnimatedEnumeration>(obj); |
142 | 0 | if (self) { |
143 | 0 | UpdateWrapper(self, self, obj, old); |
144 | 0 | } |
145 | 0 |
|
146 | 0 | return 0; |
147 | 0 | } |
148 | | |
149 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
150 | | #if defined(__clang__) |
151 | | #pragma clang diagnostic push |
152 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
153 | | #endif |
154 | | static const JSPropertySpec sAttributes_specs[] = { |
155 | | { "baseVal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &baseVal_getterinfo, GenericSetter<NormalThisPolicy>, &baseVal_setterinfo }, |
156 | | { "animVal", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &animVal_getterinfo, nullptr, nullptr }, |
157 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
158 | | }; |
159 | | #if defined(__clang__) |
160 | | #pragma clang diagnostic pop |
161 | | #endif |
162 | | |
163 | | |
164 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
165 | | { nullptr, &sAttributes_specs[0] }, |
166 | | { nullptr, nullptr } |
167 | | }; |
168 | | |
169 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
170 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
171 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
172 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
173 | | |
174 | | |
175 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
176 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
177 | | |
178 | | static const NativePropertiesN<1> sNativeProperties = { |
179 | | false, 0, |
180 | | false, 0, |
181 | | false, 0, |
182 | | true, 0 /* sAttributes */, |
183 | | false, 0, |
184 | | false, 0, |
185 | | false, 0, |
186 | | -1, |
187 | | 2, |
188 | | sNativeProperties_sortedPropertyIndices, |
189 | | { |
190 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
191 | | } |
192 | | }; |
193 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
194 | | "We have a property info count that is oversized"); |
195 | | |
196 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
197 | | { |
198 | | "Function", |
199 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
200 | | &sBoringInterfaceObjectClassClassOps, |
201 | | JS_NULL_CLASS_SPEC, |
202 | | JS_NULL_CLASS_EXT, |
203 | | &sInterfaceObjectClassObjectOps |
204 | | }, |
205 | | eInterface, |
206 | | true, |
207 | | prototypes::id::SVGAnimatedEnumeration, |
208 | | PrototypeTraits<prototypes::id::SVGAnimatedEnumeration>::Depth, |
209 | | sNativePropertyHooks, |
210 | | "function SVGAnimatedEnumeration() {\n [native code]\n}", |
211 | | JS::GetRealmFunctionPrototype |
212 | | }; |
213 | | |
214 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
215 | | { |
216 | | "SVGAnimatedEnumerationPrototype", |
217 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
218 | | JS_NULL_CLASS_OPS, |
219 | | JS_NULL_CLASS_SPEC, |
220 | | JS_NULL_CLASS_EXT, |
221 | | JS_NULL_OBJECT_OPS |
222 | | }, |
223 | | eInterfacePrototype, |
224 | | false, |
225 | | prototypes::id::SVGAnimatedEnumeration, |
226 | | PrototypeTraits<prototypes::id::SVGAnimatedEnumeration>::Depth, |
227 | | sNativePropertyHooks, |
228 | | "[object SVGAnimatedEnumerationPrototype]", |
229 | | JS::GetRealmObjectPrototype |
230 | | }; |
231 | | |
232 | | static const js::ClassOps sClassOps = { |
233 | | _addProperty, /* addProperty */ |
234 | | nullptr, /* delProperty */ |
235 | | nullptr, /* enumerate */ |
236 | | nullptr, /* newEnumerate */ |
237 | | nullptr, /* resolve */ |
238 | | nullptr, /* mayResolve */ |
239 | | _finalize, /* finalize */ |
240 | | nullptr, /* call */ |
241 | | nullptr, /* hasInstance */ |
242 | | nullptr, /* construct */ |
243 | | nullptr, /* trace */ |
244 | | }; |
245 | | |
246 | | static const js::ClassExtension sClassExtension = { |
247 | | nullptr, /* weakmapKeyDelegateOp */ |
248 | | _objectMoved /* objectMovedOp */ |
249 | | }; |
250 | | |
251 | | static const DOMJSClass sClass = { |
252 | | { "SVGAnimatedEnumeration", |
253 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
254 | | &sClassOps, |
255 | | JS_NULL_CLASS_SPEC, |
256 | | &sClassExtension, |
257 | | JS_NULL_OBJECT_OPS |
258 | | }, |
259 | | { prototypes::id::SVGAnimatedEnumeration, 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 }, |
260 | | IsBaseOf<nsISupports, mozilla::dom::SVGAnimatedEnumeration >::value, |
261 | | sNativePropertyHooks, |
262 | | FindAssociatedGlobalForNative<mozilla::dom::SVGAnimatedEnumeration>::Get, |
263 | | GetProtoObjectHandle, |
264 | | GetCCParticipant<mozilla::dom::SVGAnimatedEnumeration>::Get() |
265 | | }; |
266 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
267 | | "Must have the right minimal number of reserved slots."); |
268 | | static_assert(1 >= 1, |
269 | | "Must have enough reserved slots."); |
270 | | |
271 | | const JSClass* |
272 | | GetJSClass() |
273 | 0 | { |
274 | 0 | return sClass.ToJSClass(); |
275 | 0 | } |
276 | | |
277 | | bool |
278 | | Wrap(JSContext* aCx, mozilla::dom::SVGAnimatedEnumeration* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
279 | 0 | { |
280 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGAnimatedEnumeration>::value, |
281 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
282 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SVGAnimatedEnumeration*>(aObject) == |
283 | 0 | reinterpret_cast<mozilla::dom::SVGAnimatedEnumeration*>(aObject), |
284 | 0 | "Multiple inheritance for mozilla::dom::SVGAnimatedEnumeration is broken."); |
285 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
286 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
287 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
288 | 0 | "You should probably not be using Wrap() directly; use " |
289 | 0 | "GetOrCreateDOMReflector instead"); |
290 | 0 |
|
291 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
292 | 0 | "nsISupports must be on our primary inheritance chain"); |
293 | 0 |
|
294 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
295 | 0 | if (!global) { |
296 | 0 | return false; |
297 | 0 | } |
298 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
299 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
300 | 0 |
|
301 | 0 | // That might have ended up wrapping us already, due to the wonders |
302 | 0 | // of XBL. Check for that, and bail out as needed. |
303 | 0 | aReflector.set(aCache->GetWrapper()); |
304 | 0 | if (aReflector) { |
305 | | #ifdef DEBUG |
306 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
307 | | #endif // DEBUG |
308 | | return true; |
309 | 0 | } |
310 | 0 |
|
311 | 0 | JSAutoRealm ar(aCx, global); |
312 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
313 | 0 | if (!canonicalProto) { |
314 | 0 | return false; |
315 | 0 | } |
316 | 0 | JS::Rooted<JSObject*> proto(aCx); |
317 | 0 | if (aGivenProto) { |
318 | 0 | proto = aGivenProto; |
319 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
320 | 0 | // coming in, we changed compartments to that of "parent" so may need |
321 | 0 | // to wrap the proto here. |
322 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
323 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
324 | 0 | return false; |
325 | 0 | } |
326 | 0 | } |
327 | 0 | } else { |
328 | 0 | proto = canonicalProto; |
329 | 0 | } |
330 | 0 |
|
331 | 0 | BindingJSObjectCreator<mozilla::dom::SVGAnimatedEnumeration> creator(aCx); |
332 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
333 | 0 | if (!aReflector) { |
334 | 0 | return false; |
335 | 0 | } |
336 | 0 | |
337 | 0 | aCache->SetWrapper(aReflector); |
338 | 0 | creator.InitializationSucceeded(); |
339 | 0 |
|
340 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
341 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
342 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
343 | 0 | // otherwise we won't be able to properly recreate it later, since |
344 | 0 | // we won't know what proto to use. Note that we don't check |
345 | 0 | // aGivenProto here, since it's entirely possible (and even |
346 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
347 | 0 | // same as canonicalProto. |
348 | 0 | if (proto != canonicalProto) { |
349 | 0 | PreserveWrapper(aObject); |
350 | 0 | } |
351 | 0 |
|
352 | 0 | return true; |
353 | 0 | } |
354 | | |
355 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
356 | | nullptr, |
357 | | nullptr, |
358 | | nullptr, |
359 | | { sNativeProperties.Upcast(), nullptr }, |
360 | | prototypes::id::SVGAnimatedEnumeration, |
361 | | constructors::id::SVGAnimatedEnumeration, |
362 | | nullptr, |
363 | | &DefaultXrayExpandoObjectClass |
364 | | } }; |
365 | | |
366 | | void |
367 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
368 | 0 | { |
369 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
370 | 0 | if (!parentProto) { |
371 | 0 | return; |
372 | 0 | } |
373 | 0 | |
374 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
375 | 0 | if (!constructorProto) { |
376 | 0 | return; |
377 | 0 | } |
378 | 0 | |
379 | 0 | static bool sIdsInited = false; |
380 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
381 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
382 | 0 | return; |
383 | 0 | } |
384 | 0 | sIdsInited = true; |
385 | 0 | } |
386 | 0 |
|
387 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGAnimatedEnumeration); |
388 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGAnimatedEnumeration); |
389 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
390 | 0 | &sPrototypeClass.mBase, protoCache, |
391 | 0 | nullptr, |
392 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
393 | 0 | interfaceCache, |
394 | 0 | sNativeProperties.Upcast(), |
395 | 0 | nullptr, |
396 | 0 | "SVGAnimatedEnumeration", aDefineOnGlobal, |
397 | 0 | nullptr, |
398 | 0 | false); |
399 | 0 | } |
400 | | |
401 | | JSObject* |
402 | | GetConstructorObject(JSContext* aCx) |
403 | 0 | { |
404 | 0 | return GetConstructorObjectHandle(aCx); |
405 | 0 | } |
406 | | |
407 | | } // namespace SVGAnimatedEnumeration_Binding |
408 | | |
409 | | |
410 | | |
411 | | } // namespace dom |
412 | | } // namespace mozilla |