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