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