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