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