/work/obj-fuzz/dom/bindings/SVGLengthBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SVGLength.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "DOMSVGLength.h" |
4 | | #include "SVGLengthBinding.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 SVGLength_Binding { |
22 | | |
23 | | MOZ_CAN_RUN_SCRIPT static bool |
24 | | get_unitType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args) |
25 | 0 | { |
26 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGLength.unitType", DOM, cx); |
27 | 0 |
|
28 | 0 | uint16_t result(self->UnitType()); |
29 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
30 | 0 | args.rval().setInt32(int32_t(result)); |
31 | 0 | return true; |
32 | 0 | } |
33 | | |
34 | | static const JSJitInfo unitType_getterinfo = { |
35 | | { (JSJitGetterOp)get_unitType }, |
36 | | { prototypes::id::SVGLength }, |
37 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
38 | | JSJitInfo::Getter, |
39 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
40 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
41 | | true, /* isInfallible. False in setters. */ |
42 | | false, /* isMovable. Not relevant for setters. */ |
43 | | false, /* isEliminatable. Not relevant for setters. */ |
44 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
45 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
46 | | false, /* isTypedMethod. Only relevant for methods. */ |
47 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
48 | | }; |
49 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
50 | | static_assert(0 < 1, "There is no slot for us"); |
51 | | |
52 | | MOZ_CAN_RUN_SCRIPT static bool |
53 | | get_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args) |
54 | 0 | { |
55 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGLength.value", DOM, cx); |
56 | 0 |
|
57 | 0 | FastErrorResult rv; |
58 | 0 | float result(self->GetValue(rv)); |
59 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
60 | 0 | return false; |
61 | 0 | } |
62 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
63 | 0 | args.rval().set(JS_NumberValue(double(result))); |
64 | 0 | return true; |
65 | 0 | } |
66 | | |
67 | | MOZ_CAN_RUN_SCRIPT static bool |
68 | | set_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitSetterCallArgs args) |
69 | 0 | { |
70 | 0 | AUTO_PROFILER_LABEL_FAST("set SVGLength.value", DOM, cx); |
71 | 0 |
|
72 | 0 | float arg0; |
73 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
74 | 0 | return false; |
75 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
76 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGLength.value"); |
77 | 0 | return false; |
78 | 0 | } |
79 | 0 | FastErrorResult rv; |
80 | 0 | self->SetValue(arg0, rv); |
81 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
82 | 0 | return false; |
83 | 0 | } |
84 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
85 | 0 |
|
86 | 0 | return true; |
87 | 0 | } |
88 | | |
89 | | static const JSJitInfo value_getterinfo = { |
90 | | { (JSJitGetterOp)get_value }, |
91 | | { prototypes::id::SVGLength }, |
92 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
93 | | JSJitInfo::Getter, |
94 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
95 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
96 | | false, /* isInfallible. False in setters. */ |
97 | | false, /* isMovable. Not relevant for setters. */ |
98 | | false, /* isEliminatable. Not relevant for setters. */ |
99 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
100 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
101 | | false, /* isTypedMethod. Only relevant for methods. */ |
102 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
103 | | }; |
104 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
105 | | static_assert(0 < 1, "There is no slot for us"); |
106 | | static const JSJitInfo value_setterinfo = { |
107 | | { (JSJitGetterOp)set_value }, |
108 | | { prototypes::id::SVGLength }, |
109 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
110 | | JSJitInfo::Setter, |
111 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
112 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
113 | | false, /* isInfallible. False in setters. */ |
114 | | false, /* isMovable. Not relevant for setters. */ |
115 | | false, /* isEliminatable. Not relevant for setters. */ |
116 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
117 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
118 | | false, /* isTypedMethod. Only relevant for methods. */ |
119 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
120 | | }; |
121 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
122 | | static_assert(0 < 1, "There is no slot for us"); |
123 | | |
124 | | MOZ_CAN_RUN_SCRIPT static bool |
125 | | get_valueInSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args) |
126 | 0 | { |
127 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGLength.valueInSpecifiedUnits", DOM, cx); |
128 | 0 |
|
129 | 0 | float result(self->ValueInSpecifiedUnits()); |
130 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
131 | 0 | args.rval().set(JS_NumberValue(double(result))); |
132 | 0 | return true; |
133 | 0 | } |
134 | | |
135 | | MOZ_CAN_RUN_SCRIPT static bool |
136 | | set_valueInSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitSetterCallArgs args) |
137 | 0 | { |
138 | 0 | AUTO_PROFILER_LABEL_FAST("set SVGLength.valueInSpecifiedUnits", DOM, cx); |
139 | 0 |
|
140 | 0 | float arg0; |
141 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
142 | 0 | return false; |
143 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
144 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGLength.valueInSpecifiedUnits"); |
145 | 0 | return false; |
146 | 0 | } |
147 | 0 | FastErrorResult rv; |
148 | 0 | self->SetValueInSpecifiedUnits(arg0, rv); |
149 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
150 | 0 | return false; |
151 | 0 | } |
152 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
153 | 0 |
|
154 | 0 | return true; |
155 | 0 | } |
156 | | |
157 | | static const JSJitInfo valueInSpecifiedUnits_getterinfo = { |
158 | | { (JSJitGetterOp)get_valueInSpecifiedUnits }, |
159 | | { prototypes::id::SVGLength }, |
160 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
161 | | JSJitInfo::Getter, |
162 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
163 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
164 | | true, /* isInfallible. False in setters. */ |
165 | | false, /* isMovable. Not relevant for setters. */ |
166 | | false, /* isEliminatable. Not relevant for setters. */ |
167 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
168 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
169 | | false, /* isTypedMethod. Only relevant for methods. */ |
170 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
171 | | }; |
172 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
173 | | static_assert(0 < 1, "There is no slot for us"); |
174 | | static const JSJitInfo valueInSpecifiedUnits_setterinfo = { |
175 | | { (JSJitGetterOp)set_valueInSpecifiedUnits }, |
176 | | { prototypes::id::SVGLength }, |
177 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
178 | | JSJitInfo::Setter, |
179 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
180 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
181 | | false, /* isInfallible. False in setters. */ |
182 | | false, /* isMovable. Not relevant for setters. */ |
183 | | false, /* isEliminatable. Not relevant for setters. */ |
184 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
185 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
186 | | false, /* isTypedMethod. Only relevant for methods. */ |
187 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
188 | | }; |
189 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
190 | | static_assert(0 < 1, "There is no slot for us"); |
191 | | |
192 | | MOZ_CAN_RUN_SCRIPT static bool |
193 | | get_valueAsString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args) |
194 | 0 | { |
195 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGLength.valueAsString", DOM, cx); |
196 | 0 |
|
197 | 0 | DOMString result; |
198 | 0 | self->GetValueAsString(result); |
199 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
200 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
201 | 0 | return false; |
202 | 0 | } |
203 | 0 | return true; |
204 | 0 | } |
205 | | |
206 | | MOZ_CAN_RUN_SCRIPT static bool |
207 | | set_valueAsString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitSetterCallArgs args) |
208 | 0 | { |
209 | 0 | AUTO_PROFILER_LABEL_FAST("set SVGLength.valueAsString", DOM, cx); |
210 | 0 |
|
211 | 0 | binding_detail::FakeString arg0; |
212 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
213 | 0 | return false; |
214 | 0 | } |
215 | 0 | FastErrorResult rv; |
216 | 0 | self->SetValueAsString(NonNullHelper(Constify(arg0)), rv); |
217 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
218 | 0 | return false; |
219 | 0 | } |
220 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
221 | 0 |
|
222 | 0 | return true; |
223 | 0 | } |
224 | | |
225 | | static const JSJitInfo valueAsString_getterinfo = { |
226 | | { (JSJitGetterOp)get_valueAsString }, |
227 | | { prototypes::id::SVGLength }, |
228 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
229 | | JSJitInfo::Getter, |
230 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
231 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
232 | | false, /* isInfallible. False in setters. */ |
233 | | false, /* isMovable. Not relevant for setters. */ |
234 | | false, /* isEliminatable. Not relevant for setters. */ |
235 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
236 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
237 | | false, /* isTypedMethod. Only relevant for methods. */ |
238 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
239 | | }; |
240 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
241 | | static_assert(0 < 1, "There is no slot for us"); |
242 | | static const JSJitInfo valueAsString_setterinfo = { |
243 | | { (JSJitGetterOp)set_valueAsString }, |
244 | | { prototypes::id::SVGLength }, |
245 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
246 | | JSJitInfo::Setter, |
247 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
248 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
249 | | false, /* isInfallible. False in setters. */ |
250 | | false, /* isMovable. Not relevant for setters. */ |
251 | | false, /* isEliminatable. Not relevant for setters. */ |
252 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
253 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
254 | | false, /* isTypedMethod. Only relevant for methods. */ |
255 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
256 | | }; |
257 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
258 | | static_assert(0 < 1, "There is no slot for us"); |
259 | | |
260 | | MOZ_CAN_RUN_SCRIPT static bool |
261 | | newValueSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, const JSJitMethodCallArgs& args) |
262 | 0 | { |
263 | 0 | AUTO_PROFILER_LABEL_FAST("SVGLength.newValueSpecifiedUnits", DOM, cx); |
264 | 0 |
|
265 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
266 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGLength.newValueSpecifiedUnits"); |
267 | 0 | } |
268 | 0 | uint16_t arg0; |
269 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) { |
270 | 0 | return false; |
271 | 0 | } |
272 | 0 | float arg1; |
273 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
274 | 0 | return false; |
275 | 0 | } else if (!mozilla::IsFinite(arg1)) { |
276 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of SVGLength.newValueSpecifiedUnits"); |
277 | 0 | return false; |
278 | 0 | } |
279 | 0 | FastErrorResult rv; |
280 | 0 | self->NewValueSpecifiedUnits(arg0, arg1, rv); |
281 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
282 | 0 | return false; |
283 | 0 | } |
284 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
285 | 0 | args.rval().setUndefined(); |
286 | 0 | return true; |
287 | 0 | } |
288 | | |
289 | | static const JSJitInfo newValueSpecifiedUnits_methodinfo = { |
290 | | { (JSJitGetterOp)newValueSpecifiedUnits }, |
291 | | { prototypes::id::SVGLength }, |
292 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
293 | | JSJitInfo::Method, |
294 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
295 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
296 | | false, /* isInfallible. False in setters. */ |
297 | | false, /* isMovable. Not relevant for setters. */ |
298 | | false, /* isEliminatable. Not relevant for setters. */ |
299 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
300 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
301 | | false, /* isTypedMethod. Only relevant for methods. */ |
302 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
303 | | }; |
304 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
305 | | static_assert(0 < 1, "There is no slot for us"); |
306 | | |
307 | | MOZ_CAN_RUN_SCRIPT static bool |
308 | | convertToSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, const JSJitMethodCallArgs& args) |
309 | 0 | { |
310 | 0 | AUTO_PROFILER_LABEL_FAST("SVGLength.convertToSpecifiedUnits", DOM, cx); |
311 | 0 |
|
312 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
313 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGLength.convertToSpecifiedUnits"); |
314 | 0 | } |
315 | 0 | uint16_t arg0; |
316 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) { |
317 | 0 | return false; |
318 | 0 | } |
319 | 0 | FastErrorResult rv; |
320 | 0 | self->ConvertToSpecifiedUnits(arg0, rv); |
321 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
322 | 0 | return false; |
323 | 0 | } |
324 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
325 | 0 | args.rval().setUndefined(); |
326 | 0 | return true; |
327 | 0 | } |
328 | | |
329 | | static const JSJitInfo convertToSpecifiedUnits_methodinfo = { |
330 | | { (JSJitGetterOp)convertToSpecifiedUnits }, |
331 | | { prototypes::id::SVGLength }, |
332 | | { PrototypeTraits<prototypes::id::SVGLength>::Depth }, |
333 | | JSJitInfo::Method, |
334 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
335 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
336 | | false, /* isInfallible. False in setters. */ |
337 | | false, /* isMovable. Not relevant for setters. */ |
338 | | false, /* isEliminatable. Not relevant for setters. */ |
339 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
340 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
341 | | false, /* isTypedMethod. Only relevant for methods. */ |
342 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
343 | | }; |
344 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
345 | | static_assert(0 < 1, "There is no slot for us"); |
346 | | |
347 | | static bool |
348 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
349 | 0 | { |
350 | 0 | mozilla::DOMSVGLength* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGLength>(obj); |
351 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
352 | 0 | // obviously can't preserve if we're not initialized. |
353 | 0 | if (self && self->GetWrapperPreserveColor()) { |
354 | 0 | PreserveWrapper(self); |
355 | 0 | } |
356 | 0 | return true; |
357 | 0 | } |
358 | | |
359 | | static void |
360 | | _finalize(js::FreeOp* fop, JSObject* obj) |
361 | 0 | { |
362 | 0 | mozilla::DOMSVGLength* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGLength>(obj); |
363 | 0 | if (self) { |
364 | 0 | ClearWrapper(self, self, obj); |
365 | 0 | AddForDeferredFinalization<mozilla::DOMSVGLength>(self); |
366 | 0 | } |
367 | 0 | } |
368 | | |
369 | | static size_t |
370 | | _objectMoved(JSObject* obj, JSObject* old) |
371 | 0 | { |
372 | 0 | mozilla::DOMSVGLength* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGLength>(obj); |
373 | 0 | if (self) { |
374 | 0 | UpdateWrapper(self, self, obj, old); |
375 | 0 | } |
376 | 0 |
|
377 | 0 | return 0; |
378 | 0 | } |
379 | | |
380 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
381 | | #if defined(__clang__) |
382 | | #pragma clang diagnostic push |
383 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
384 | | #endif |
385 | | static const JSFunctionSpec sMethods_specs[] = { |
386 | | JS_FNSPEC("newValueSpecifiedUnits", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&newValueSpecifiedUnits_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
387 | | JS_FNSPEC("convertToSpecifiedUnits", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&convertToSpecifiedUnits_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
388 | | JS_FS_END |
389 | | }; |
390 | | #if defined(__clang__) |
391 | | #pragma clang diagnostic pop |
392 | | #endif |
393 | | |
394 | | |
395 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
396 | | { nullptr, &sMethods_specs[0] }, |
397 | | { nullptr, nullptr } |
398 | | }; |
399 | | |
400 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
401 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
402 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
403 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
404 | | |
405 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
406 | | #if defined(__clang__) |
407 | | #pragma clang diagnostic push |
408 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
409 | | #endif |
410 | | static const JSPropertySpec sAttributes_specs[] = { |
411 | | { "unitType", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &unitType_getterinfo, nullptr, nullptr }, |
412 | | { "value", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &value_getterinfo, GenericSetter<NormalThisPolicy>, &value_setterinfo }, |
413 | | { "valueInSpecifiedUnits", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &valueInSpecifiedUnits_getterinfo, GenericSetter<NormalThisPolicy>, &valueInSpecifiedUnits_setterinfo }, |
414 | | { "valueAsString", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &valueAsString_getterinfo, GenericSetter<NormalThisPolicy>, &valueAsString_setterinfo }, |
415 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
416 | | }; |
417 | | #if defined(__clang__) |
418 | | #pragma clang diagnostic pop |
419 | | #endif |
420 | | |
421 | | |
422 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
423 | | { nullptr, &sAttributes_specs[0] }, |
424 | | { nullptr, nullptr } |
425 | | }; |
426 | | |
427 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
428 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
429 | | static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
430 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
431 | | |
432 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
433 | | #if defined(__clang__) |
434 | | #pragma clang diagnostic push |
435 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
436 | | #endif |
437 | | static const ConstantSpec sConstants_specs[] = { |
438 | | { "SVG_LENGTHTYPE_UNKNOWN", JS::Int32Value(0) }, |
439 | | { "SVG_LENGTHTYPE_NUMBER", JS::Int32Value(1) }, |
440 | | { "SVG_LENGTHTYPE_PERCENTAGE", JS::Int32Value(2) }, |
441 | | { "SVG_LENGTHTYPE_EMS", JS::Int32Value(3) }, |
442 | | { "SVG_LENGTHTYPE_EXS", JS::Int32Value(4) }, |
443 | | { "SVG_LENGTHTYPE_PX", JS::Int32Value(5) }, |
444 | | { "SVG_LENGTHTYPE_CM", JS::Int32Value(6) }, |
445 | | { "SVG_LENGTHTYPE_MM", JS::Int32Value(7) }, |
446 | | { "SVG_LENGTHTYPE_IN", JS::Int32Value(8) }, |
447 | | { "SVG_LENGTHTYPE_PT", JS::Int32Value(9) }, |
448 | | { "SVG_LENGTHTYPE_PC", JS::Int32Value(10) }, |
449 | | { 0, JS::UndefinedValue() } |
450 | | }; |
451 | | #if defined(__clang__) |
452 | | #pragma clang diagnostic pop |
453 | | #endif |
454 | | |
455 | | |
456 | | static const Prefable<const ConstantSpec> sConstants[] = { |
457 | | { nullptr, &sConstants_specs[0] }, |
458 | | { nullptr, nullptr } |
459 | | }; |
460 | | |
461 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
462 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
463 | | static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
464 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
465 | | |
466 | | |
467 | | static uint16_t sNativeProperties_sortedPropertyIndices[17]; |
468 | | static PropertyInfo sNativeProperties_propertyInfos[17]; |
469 | | |
470 | | static const NativePropertiesN<3> sNativeProperties = { |
471 | | false, 0, |
472 | | false, 0, |
473 | | true, 0 /* sMethods */, |
474 | | true, 1 /* sAttributes */, |
475 | | false, 0, |
476 | | false, 0, |
477 | | true, 2 /* sConstants */, |
478 | | -1, |
479 | | 17, |
480 | | sNativeProperties_sortedPropertyIndices, |
481 | | { |
482 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
483 | | { sAttributes, &sNativeProperties_propertyInfos[2] }, |
484 | | { sConstants, &sNativeProperties_propertyInfos[6] } |
485 | | } |
486 | | }; |
487 | | static_assert(17 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
488 | | "We have a property info count that is oversized"); |
489 | | |
490 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
491 | | { |
492 | | "Function", |
493 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
494 | | &sBoringInterfaceObjectClassClassOps, |
495 | | JS_NULL_CLASS_SPEC, |
496 | | JS_NULL_CLASS_EXT, |
497 | | &sInterfaceObjectClassObjectOps |
498 | | }, |
499 | | eInterface, |
500 | | true, |
501 | | prototypes::id::SVGLength, |
502 | | PrototypeTraits<prototypes::id::SVGLength>::Depth, |
503 | | sNativePropertyHooks, |
504 | | "function SVGLength() {\n [native code]\n}", |
505 | | JS::GetRealmFunctionPrototype |
506 | | }; |
507 | | |
508 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
509 | | { |
510 | | "SVGLengthPrototype", |
511 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
512 | | JS_NULL_CLASS_OPS, |
513 | | JS_NULL_CLASS_SPEC, |
514 | | JS_NULL_CLASS_EXT, |
515 | | JS_NULL_OBJECT_OPS |
516 | | }, |
517 | | eInterfacePrototype, |
518 | | false, |
519 | | prototypes::id::SVGLength, |
520 | | PrototypeTraits<prototypes::id::SVGLength>::Depth, |
521 | | sNativePropertyHooks, |
522 | | "[object SVGLengthPrototype]", |
523 | | JS::GetRealmObjectPrototype |
524 | | }; |
525 | | |
526 | | static const js::ClassOps sClassOps = { |
527 | | _addProperty, /* addProperty */ |
528 | | nullptr, /* delProperty */ |
529 | | nullptr, /* enumerate */ |
530 | | nullptr, /* newEnumerate */ |
531 | | nullptr, /* resolve */ |
532 | | nullptr, /* mayResolve */ |
533 | | _finalize, /* finalize */ |
534 | | nullptr, /* call */ |
535 | | nullptr, /* hasInstance */ |
536 | | nullptr, /* construct */ |
537 | | nullptr, /* trace */ |
538 | | }; |
539 | | |
540 | | static const js::ClassExtension sClassExtension = { |
541 | | nullptr, /* weakmapKeyDelegateOp */ |
542 | | _objectMoved /* objectMovedOp */ |
543 | | }; |
544 | | |
545 | | static const DOMJSClass sClass = { |
546 | | { "SVGLength", |
547 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
548 | | &sClassOps, |
549 | | JS_NULL_CLASS_SPEC, |
550 | | &sClassExtension, |
551 | | JS_NULL_OBJECT_OPS |
552 | | }, |
553 | | { prototypes::id::SVGLength, 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 }, |
554 | | IsBaseOf<nsISupports, mozilla::DOMSVGLength >::value, |
555 | | sNativePropertyHooks, |
556 | | FindAssociatedGlobalForNative<mozilla::DOMSVGLength>::Get, |
557 | | GetProtoObjectHandle, |
558 | | GetCCParticipant<mozilla::DOMSVGLength>::Get() |
559 | | }; |
560 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
561 | | "Must have the right minimal number of reserved slots."); |
562 | | static_assert(1 >= 1, |
563 | | "Must have enough reserved slots."); |
564 | | |
565 | | const JSClass* |
566 | | GetJSClass() |
567 | 0 | { |
568 | 0 | return sClass.ToJSClass(); |
569 | 0 | } |
570 | | |
571 | | bool |
572 | | Wrap(JSContext* aCx, mozilla::DOMSVGLength* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
573 | 0 | { |
574 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::DOMSVGLength>::value, |
575 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
576 | 0 | MOZ_ASSERT(static_cast<mozilla::DOMSVGLength*>(aObject) == |
577 | 0 | reinterpret_cast<mozilla::DOMSVGLength*>(aObject), |
578 | 0 | "Multiple inheritance for mozilla::DOMSVGLength is broken."); |
579 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
580 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
581 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
582 | 0 | "You should probably not be using Wrap() directly; use " |
583 | 0 | "GetOrCreateDOMReflector instead"); |
584 | 0 |
|
585 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
586 | 0 | "nsISupports must be on our primary inheritance chain"); |
587 | 0 |
|
588 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
589 | 0 | if (!global) { |
590 | 0 | return false; |
591 | 0 | } |
592 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
593 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
594 | 0 |
|
595 | 0 | // That might have ended up wrapping us already, due to the wonders |
596 | 0 | // of XBL. Check for that, and bail out as needed. |
597 | 0 | aReflector.set(aCache->GetWrapper()); |
598 | 0 | if (aReflector) { |
599 | | #ifdef DEBUG |
600 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
601 | | #endif // DEBUG |
602 | | return true; |
603 | 0 | } |
604 | 0 |
|
605 | 0 | JSAutoRealm ar(aCx, global); |
606 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
607 | 0 | if (!canonicalProto) { |
608 | 0 | return false; |
609 | 0 | } |
610 | 0 | JS::Rooted<JSObject*> proto(aCx); |
611 | 0 | if (aGivenProto) { |
612 | 0 | proto = aGivenProto; |
613 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
614 | 0 | // coming in, we changed compartments to that of "parent" so may need |
615 | 0 | // to wrap the proto here. |
616 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
617 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
618 | 0 | return false; |
619 | 0 | } |
620 | 0 | } |
621 | 0 | } else { |
622 | 0 | proto = canonicalProto; |
623 | 0 | } |
624 | 0 |
|
625 | 0 | BindingJSObjectCreator<mozilla::DOMSVGLength> creator(aCx); |
626 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
627 | 0 | if (!aReflector) { |
628 | 0 | return false; |
629 | 0 | } |
630 | 0 | |
631 | 0 | aCache->SetWrapper(aReflector); |
632 | 0 | creator.InitializationSucceeded(); |
633 | 0 |
|
634 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
635 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
636 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
637 | 0 | // otherwise we won't be able to properly recreate it later, since |
638 | 0 | // we won't know what proto to use. Note that we don't check |
639 | 0 | // aGivenProto here, since it's entirely possible (and even |
640 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
641 | 0 | // same as canonicalProto. |
642 | 0 | if (proto != canonicalProto) { |
643 | 0 | PreserveWrapper(aObject); |
644 | 0 | } |
645 | 0 |
|
646 | 0 | return true; |
647 | 0 | } |
648 | | |
649 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
650 | | nullptr, |
651 | | nullptr, |
652 | | nullptr, |
653 | | { sNativeProperties.Upcast(), nullptr }, |
654 | | prototypes::id::SVGLength, |
655 | | constructors::id::SVGLength, |
656 | | nullptr, |
657 | | &DefaultXrayExpandoObjectClass |
658 | | } }; |
659 | | |
660 | | void |
661 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
662 | 0 | { |
663 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
664 | 0 | if (!parentProto) { |
665 | 0 | return; |
666 | 0 | } |
667 | 0 | |
668 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
669 | 0 | if (!constructorProto) { |
670 | 0 | return; |
671 | 0 | } |
672 | 0 | |
673 | 0 | static bool sIdsInited = false; |
674 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
675 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
676 | 0 | return; |
677 | 0 | } |
678 | 0 | sIdsInited = true; |
679 | 0 | } |
680 | 0 |
|
681 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGLength); |
682 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGLength); |
683 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
684 | 0 | &sPrototypeClass.mBase, protoCache, |
685 | 0 | nullptr, |
686 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
687 | 0 | interfaceCache, |
688 | 0 | sNativeProperties.Upcast(), |
689 | 0 | nullptr, |
690 | 0 | "SVGLength", aDefineOnGlobal, |
691 | 0 | nullptr, |
692 | 0 | false); |
693 | 0 | } |
694 | | |
695 | | JSObject* |
696 | | GetConstructorObject(JSContext* aCx) |
697 | 0 | { |
698 | 0 | return GetConstructorObjectHandle(aCx); |
699 | 0 | } |
700 | | |
701 | | } // namespace SVGLength_Binding |
702 | | |
703 | | |
704 | | |
705 | | } // namespace dom |
706 | | } // namespace mozilla |