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