Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM PresentationConnectionList.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "EventHandlerBinding.h"
4 : #include "EventTargetBinding.h"
5 : #include "PresentationConnectionListBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "XrayWrapper.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/Preferences.h"
10 : #include "mozilla/dom/BindingUtils.h"
11 : #include "mozilla/dom/DOMJSClass.h"
12 : #include "mozilla/dom/NonRefcountedDOMObject.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/PresentationConnection.h"
15 : #include "mozilla/dom/PresentationConnectionList.h"
16 : #include "mozilla/dom/XrayExpandoClass.h"
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : namespace PresentationConnectionListBinding {
22 :
23 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
24 : "Can't inherit from an interface with a different ownership model.");
25 :
26 : static bool
27 0 : get_connections(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnectionList* self, JSJitGetterCallArgs args)
28 : {
29 : // Have to either root across the getter call or reget after.
30 : bool isXray;
31 0 : JS::Rooted<JSObject*> slotStorage(cx, GetCachedSlotStorageObject(cx, obj, &isXray));
32 0 : if (!slotStorage) {
33 0 : return false;
34 : }
35 0 : const size_t slotIndex = isXray ? (xpc::JSSLOT_EXPANDO_COUNT + 0) : (DOM_INSTANCE_RESERVED_SLOTS + 0);
36 0 : MOZ_ASSERT(JSCLASS_RESERVED_SLOTS(js::GetObjectClass(slotStorage)) > slotIndex);
37 : {
38 : // Scope for cachedVal
39 0 : JS::Value cachedVal = js::GetReservedSlot(slotStorage, slotIndex);
40 0 : if (!cachedVal.isUndefined()) {
41 0 : args.rval().set(cachedVal);
42 : // The cached value is in the compartment of slotStorage,
43 : // so wrap into the caller compartment as needed.
44 0 : return MaybeWrapNonDOMObjectValue(cx, args.rval());
45 : }
46 : }
47 :
48 0 : nsTArray<StrongPtrForMember<mozilla::dom::PresentationConnection>::Type> result;
49 0 : self->GetConnections(result);
50 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
51 : {
52 0 : JS::Rooted<JSObject*> conversionScope(cx, isXray ? obj : slotStorage);
53 0 : JSAutoCompartment ac(cx, conversionScope);
54 : do { // block we break out of when done wrapping
55 :
56 0 : uint32_t length = result.Length();
57 0 : JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
58 0 : if (!returnArray) {
59 0 : return false;
60 : }
61 : // Scope for 'tmp'
62 : {
63 0 : JS::Rooted<JS::Value> tmp(cx);
64 0 : for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
65 : // Control block to let us common up the JS_DefineElement calls when there
66 : // are different ways to succeed at wrapping the object.
67 : do {
68 0 : if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) {
69 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
70 0 : return false;
71 : }
72 0 : break;
73 : } while (0);
74 0 : if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
75 : JSPROP_ENUMERATE)) {
76 0 : return false;
77 : }
78 : }
79 : }
80 0 : args.rval().setObject(*returnArray);
81 0 : break;
82 : } while (0);
83 0 : JS::Rooted<JSObject*> rvalObj(cx, &args.rval().toObject());
84 0 : if (!JS_FreezeObject(cx, rvalObj)) {
85 0 : return false;
86 : }
87 : }
88 : { // And now store things in the compartment of our slotStorage.
89 0 : JSAutoCompartment ac(cx, slotStorage);
90 : // Make a copy so that we don't do unnecessary wrapping on args.rval().
91 0 : JS::Rooted<JS::Value> storedVal(cx, args.rval());
92 0 : if (!MaybeWrapNonDOMObjectValue(cx, &storedVal)) {
93 0 : return false;
94 : }
95 0 : js::SetReservedSlot(slotStorage, slotIndex, storedVal);
96 0 : if (!isXray) {
97 : // In the Xray case we don't need to do this, because getting the
98 : // expando object already preserved our wrapper.
99 0 : PreserveWrapper(self);
100 : }
101 : }
102 : // And now make sure args.rval() is in the caller compartment
103 0 : return MaybeWrapNonDOMObjectValue(cx, args.rval());
104 : }
105 :
106 : static const JSJitInfo connections_getterinfo = {
107 : { (JSJitGetterOp)get_connections },
108 : { prototypes::id::PresentationConnectionList },
109 : { PrototypeTraits<prototypes::id::PresentationConnectionList>::Depth },
110 : JSJitInfo::Getter,
111 : JSJitInfo::AliasDOMSets, /* aliasSet. Not relevant for setters. */
112 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
113 : false, /* isInfallible. False in setters. */
114 : true, /* isMovable. Not relevant for setters. */
115 : true, /* isEliminatable. Not relevant for setters. */
116 : false, /* isAlwaysInSlot. Only relevant for getters. */
117 : true, /* isLazilyCachedInSlot. Only relevant for getters. */
118 : false, /* isTypedMethod. Only relevant for methods. */
119 : (DOM_INSTANCE_RESERVED_SLOTS + 0) /* Reserved slot index, if we're stored in a slot, else 0. */
120 : };
121 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) <= JSJitInfo::maxSlotIndex, "We won't fit");
122 : static_assert((DOM_INSTANCE_RESERVED_SLOTS + 0) < 2, "There is no slot for us");
123 :
124 : static bool
125 0 : get_onconnectionavailable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnectionList* self, JSJitGetterCallArgs args)
126 : {
127 0 : RefPtr<EventHandlerNonNull> result(self->GetOnconnectionavailable());
128 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
129 0 : if (result) {
130 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
131 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
132 0 : return false;
133 : }
134 0 : return true;
135 : } else {
136 0 : args.rval().setNull();
137 0 : return true;
138 : }
139 : }
140 :
141 : static bool
142 0 : set_onconnectionavailable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnectionList* self, JSJitSetterCallArgs args)
143 : {
144 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
145 0 : if (args[0].isObject()) {
146 : { // scope for tempRoot
147 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
148 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
149 : }
150 : } else {
151 0 : arg0 = nullptr;
152 : }
153 0 : self->SetOnconnectionavailable(Constify(arg0));
154 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
155 :
156 0 : return true;
157 : }
158 :
159 : static const JSJitInfo onconnectionavailable_getterinfo = {
160 : { (JSJitGetterOp)get_onconnectionavailable },
161 : { prototypes::id::PresentationConnectionList },
162 : { PrototypeTraits<prototypes::id::PresentationConnectionList>::Depth },
163 : JSJitInfo::Getter,
164 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
165 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
166 : false, /* isInfallible. False in setters. */
167 : false, /* isMovable. Not relevant for setters. */
168 : false, /* isEliminatable. Not relevant for setters. */
169 : false, /* isAlwaysInSlot. Only relevant for getters. */
170 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
171 : false, /* isTypedMethod. Only relevant for methods. */
172 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
173 : };
174 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
175 : static_assert(0 < 2, "There is no slot for us");
176 : static const JSJitInfo onconnectionavailable_setterinfo = {
177 : { (JSJitGetterOp)set_onconnectionavailable },
178 : { prototypes::id::PresentationConnectionList },
179 : { PrototypeTraits<prototypes::id::PresentationConnectionList>::Depth },
180 : JSJitInfo::Setter,
181 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
182 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
183 : false, /* isInfallible. False in setters. */
184 : false, /* isMovable. Not relevant for setters. */
185 : false, /* isEliminatable. Not relevant for setters. */
186 : false, /* isAlwaysInSlot. Only relevant for getters. */
187 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
188 : false, /* isTypedMethod. Only relevant for methods. */
189 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
190 : };
191 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
192 : static_assert(0 < 2, "There is no slot for us");
193 :
194 : static bool
195 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
196 : {
197 0 : mozilla::dom::PresentationConnectionList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnectionList>(obj);
198 : // We don't want to preserve if we don't have a wrapper, and we
199 : // obviously can't preserve if we're not initialized.
200 0 : if (self && self->GetWrapperPreserveColor()) {
201 0 : PreserveWrapper(self);
202 : }
203 0 : return true;
204 : }
205 :
206 : static void
207 0 : _finalize(js::FreeOp* fop, JSObject* obj)
208 : {
209 0 : mozilla::dom::PresentationConnectionList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnectionList>(obj);
210 0 : if (self) {
211 0 : ClearWrapper(self, self, obj);
212 0 : AddForDeferredFinalization<mozilla::dom::PresentationConnectionList>(self);
213 : }
214 0 : }
215 :
216 : static void
217 0 : _objectMoved(JSObject* obj, const JSObject* old)
218 : {
219 0 : mozilla::dom::PresentationConnectionList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnectionList>(obj);
220 0 : if (self) {
221 0 : UpdateWrapper(self, self, obj, old);
222 : }
223 0 : }
224 :
225 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
226 : #if defined(__clang__)
227 : #pragma clang diagnostic push
228 : #pragma clang diagnostic ignored "-Wmissing-braces"
229 : #endif
230 : static const JSPropertySpec sAttributes_specs[] = {
231 : { "connections", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &connections_getterinfo, nullptr, nullptr },
232 : { "onconnectionavailable", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onconnectionavailable_getterinfo, GenericBindingSetter, &onconnectionavailable_setterinfo },
233 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
234 : };
235 : #if defined(__clang__)
236 : #pragma clang diagnostic pop
237 : #endif
238 :
239 :
240 : // Can't be const because the pref-enabled boolean needs to be writable
241 : static Prefable<const JSPropertySpec> sAttributes[] = {
242 : { nullptr, &sAttributes_specs[0] },
243 : { nullptr, nullptr }
244 : };
245 :
246 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
247 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
248 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
249 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
250 :
251 :
252 : static uint16_t sNativeProperties_sortedPropertyIndices[2];
253 : static PropertyInfo sNativeProperties_propertyInfos[2];
254 :
255 : static const NativePropertiesN<1> sNativeProperties = {
256 : false, 0,
257 : false, 0,
258 : false, 0,
259 : true, 0 /* sAttributes */,
260 : false, 0,
261 : false, 0,
262 : false, 0,
263 : -1,
264 : 2,
265 : sNativeProperties_sortedPropertyIndices,
266 : {
267 : { sAttributes, &sNativeProperties_propertyInfos[0] }
268 : }
269 : };
270 : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
271 : "We have a property info count that is oversized");
272 :
273 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
274 : {
275 : "Function",
276 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
277 : &sBoringInterfaceObjectClassClassOps,
278 : JS_NULL_CLASS_SPEC,
279 : JS_NULL_CLASS_EXT,
280 : &sInterfaceObjectClassObjectOps
281 : },
282 : eInterface,
283 : true,
284 : prototypes::id::PresentationConnectionList,
285 : PrototypeTraits<prototypes::id::PresentationConnectionList>::Depth,
286 : sNativePropertyHooks,
287 : "function PresentationConnectionList() {\n [native code]\n}",
288 : EventTargetBinding::GetConstructorObject
289 : };
290 :
291 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
292 : {
293 : "PresentationConnectionListPrototype",
294 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
295 : JS_NULL_CLASS_OPS,
296 : JS_NULL_CLASS_SPEC,
297 : JS_NULL_CLASS_EXT,
298 : JS_NULL_OBJECT_OPS
299 : },
300 : eInterfacePrototype,
301 : false,
302 : prototypes::id::PresentationConnectionList,
303 : PrototypeTraits<prototypes::id::PresentationConnectionList>::Depth,
304 : sNativePropertyHooks,
305 : "[object PresentationConnectionListPrototype]",
306 : EventTargetBinding::GetProtoObject
307 : };
308 :
309 : bool
310 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
311 : {
312 : static bool sPrefValue;
313 : static bool sPrefCacheSetUp = false;
314 0 : if (!sPrefCacheSetUp) {
315 0 : sPrefCacheSetUp = true;
316 0 : Preferences::AddBoolVarCache(&sPrefValue, "dom.presentation.receiver.enabled");
317 : }
318 :
319 0 : return sPrefValue;
320 : }
321 :
322 : JSObject*
323 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
324 : {
325 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
326 : }
327 :
328 : static const js::ClassOps sClassOps = {
329 : _addProperty, /* addProperty */
330 : nullptr, /* delProperty */
331 : nullptr, /* getProperty */
332 : nullptr, /* setProperty */
333 : nullptr, /* enumerate */
334 : nullptr, /* newEnumerate */
335 : nullptr, /* resolve */
336 : nullptr, /* mayResolve */
337 : _finalize, /* finalize */
338 : nullptr, /* call */
339 : nullptr, /* hasInstance */
340 : nullptr, /* construct */
341 : nullptr, /* trace */
342 : };
343 :
344 : static const js::ClassExtension sClassExtension = {
345 : nullptr, /* weakmapKeyDelegateOp */
346 : _objectMoved /* objectMovedOp */
347 : };
348 :
349 : static const DOMJSClass sClass = {
350 : { "PresentationConnectionList",
351 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
352 : &sClassOps,
353 : JS_NULL_CLASS_SPEC,
354 : &sClassExtension,
355 : JS_NULL_OBJECT_OPS
356 : },
357 : { prototypes::id::EventTarget, prototypes::id::PresentationConnectionList, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
358 : IsBaseOf<nsISupports, mozilla::dom::PresentationConnectionList >::value,
359 : sNativePropertyHooks,
360 : FindAssociatedGlobalForNative<mozilla::dom::PresentationConnectionList>::Get,
361 : GetProtoObjectHandle,
362 : GetCCParticipant<mozilla::dom::PresentationConnectionList>::Get()
363 : };
364 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
365 : "Must have the right minimal number of reserved slots.");
366 : static_assert(2 >= 2,
367 : "Must have enough reserved slots.");
368 :
369 : const JSClass*
370 0 : GetJSClass()
371 : {
372 0 : return sClass.ToJSClass();
373 : }
374 :
375 : bool
376 0 : Wrap(JSContext* aCx, mozilla::dom::PresentationConnectionList* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
377 : {
378 : MOZ_ASSERT(static_cast<mozilla::dom::PresentationConnectionList*>(aObject) ==
379 : reinterpret_cast<mozilla::dom::PresentationConnectionList*>(aObject),
380 : "Multiple inheritance for mozilla::dom::PresentationConnectionList is broken.");
381 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
382 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
383 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
384 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
385 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
386 0 : MOZ_ASSERT(!aCache->GetWrapper(),
387 : "You should probably not be using Wrap() directly; use "
388 : "GetOrCreateDOMReflector instead");
389 :
390 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
391 : "nsISupports must be on our primary inheritance chain");
392 :
393 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
394 0 : if (!global) {
395 0 : return false;
396 : }
397 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
398 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
399 :
400 : // That might have ended up wrapping us already, due to the wonders
401 : // of XBL. Check for that, and bail out as needed.
402 0 : aReflector.set(aCache->GetWrapper());
403 0 : if (aReflector) {
404 : #ifdef DEBUG
405 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
406 : #endif // DEBUG
407 0 : return true;
408 : }
409 :
410 0 : JSAutoCompartment ac(aCx, global);
411 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
412 0 : if (!canonicalProto) {
413 0 : return false;
414 : }
415 0 : JS::Rooted<JSObject*> proto(aCx);
416 0 : if (aGivenProto) {
417 0 : proto = aGivenProto;
418 : // Unfortunately, while aGivenProto was in the compartment of aCx
419 : // coming in, we changed compartments to that of "parent" so may need
420 : // to wrap the proto here.
421 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
422 0 : if (!JS_WrapObject(aCx, &proto)) {
423 0 : return false;
424 : }
425 : }
426 : } else {
427 0 : proto = canonicalProto;
428 : }
429 :
430 0 : BindingJSObjectCreator<mozilla::dom::PresentationConnectionList> creator(aCx);
431 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
432 0 : if (!aReflector) {
433 0 : return false;
434 : }
435 :
436 0 : aCache->SetWrapper(aReflector);
437 0 : creator.InitializationSucceeded();
438 :
439 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
440 : aCache->GetWrapperPreserveColor() == aReflector);
441 : // If proto != canonicalProto, we have to preserve our wrapper;
442 : // otherwise we won't be able to properly recreate it later, since
443 : // we won't know what proto to use. Note that we don't check
444 : // aGivenProto here, since it's entirely possible (and even
445 : // somewhat common) to have a non-null aGivenProto which is the
446 : // same as canonicalProto.
447 0 : if (proto != canonicalProto) {
448 0 : PreserveWrapper(aObject);
449 : }
450 :
451 0 : return true;
452 : }
453 :
454 : // This may allocate too many slots, because we only really need
455 : // slots for our non-interface-typed members that we cache. But
456 : // allocating slots only for those would make the slot index
457 : // computations much more complicated, so let's do this the simple
458 : // way for now.
459 : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
460 :
461 : const NativePropertyHooks sNativePropertyHooks[] = { {
462 : nullptr,
463 : nullptr,
464 : nullptr,
465 : { sNativeProperties.Upcast(), nullptr },
466 : prototypes::id::PresentationConnectionList,
467 : constructors::id::PresentationConnectionList,
468 : EventTargetBinding::sNativePropertyHooks,
469 : &sXrayExpandoObjectClass
470 : } };
471 :
472 : void
473 0 : ClearCachedConnectionsValue(mozilla::dom::PresentationConnectionList* aObject)
474 : {
475 : JSObject* obj;
476 0 : obj = aObject->GetWrapper();
477 0 : if (!obj) {
478 0 : return;
479 : }
480 0 : js::SetReservedSlot(obj, (DOM_INSTANCE_RESERVED_SLOTS + 0), JS::UndefinedValue());
481 0 : xpc::ClearXrayExpandoSlots(obj, (xpc::JSSLOT_EXPANDO_COUNT + 0));
482 : }
483 :
484 : void
485 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
486 : {
487 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
488 0 : if (!parentProto) {
489 0 : return;
490 : }
491 :
492 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
493 0 : if (!constructorProto) {
494 0 : return;
495 : }
496 :
497 : static bool sIdsInited = false;
498 0 : if (!sIdsInited && NS_IsMainThread()) {
499 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
500 0 : return;
501 : }
502 0 : sIdsInited = true;
503 : }
504 :
505 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PresentationConnectionList);
506 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PresentationConnectionList);
507 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
508 : &sPrototypeClass.mBase, protoCache,
509 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
510 : interfaceCache,
511 : sNativeProperties.Upcast(),
512 : nullptr,
513 : "PresentationConnectionList", aDefineOnGlobal,
514 : nullptr,
515 0 : false);
516 : }
517 :
518 : JS::Handle<JSObject*>
519 0 : GetProtoObjectHandle(JSContext* aCx)
520 : {
521 : /* Get the interface prototype object for this class. This will create the
522 : object as needed. */
523 0 : bool aDefineOnGlobal = true;
524 :
525 : /* Make sure our global is sane. Hopefully we can remove this sometime */
526 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
527 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
528 0 : return nullptr;
529 : }
530 :
531 : /* Check to see whether the interface objects are already installed */
532 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
533 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PresentationConnectionList)) {
534 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
535 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
536 : }
537 :
538 : /*
539 : * The object might _still_ be null, but that's OK.
540 : *
541 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
542 : * traced by TraceProtoAndIfaceCache() and its contents are never
543 : * changed after they have been set.
544 : *
545 : * Calling address() avoids the read read barrier that does gray
546 : * unmarking, but it's not possible for the object to be gray here.
547 : */
548 :
549 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PresentationConnectionList);
550 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
551 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
552 : }
553 :
554 : JS::Handle<JSObject*>
555 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
556 : {
557 : /* Get the interface object for this class. This will create the object as
558 : needed. */
559 :
560 : /* Make sure our global is sane. Hopefully we can remove this sometime */
561 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
562 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
563 0 : return nullptr;
564 : }
565 :
566 : /* Check to see whether the interface objects are already installed */
567 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
568 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::PresentationConnectionList)) {
569 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
570 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
571 : }
572 :
573 : /*
574 : * The object might _still_ be null, but that's OK.
575 : *
576 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
577 : * traced by TraceProtoAndIfaceCache() and its contents are never
578 : * changed after they have been set.
579 : *
580 : * Calling address() avoids the read read barrier that does gray
581 : * unmarking, but it's not possible for the object to be gray here.
582 : */
583 :
584 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::PresentationConnectionList);
585 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
586 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
587 : }
588 :
589 : JSObject*
590 0 : GetConstructorObject(JSContext* aCx)
591 : {
592 0 : return GetConstructorObjectHandle(aCx);
593 : }
594 :
595 : } // namespace PresentationConnectionListBinding
596 :
597 :
598 :
599 : } // namespace dom
600 : } // namespace mozilla
|