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