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