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