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