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