/work/obj-fuzz/dom/bindings/MediaKeyStatusMapBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM MediaKeyStatusMap.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "MediaKeyStatusMapBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "jsapi.h" |
6 | | #include "jsfriendapi.h" |
7 | | #include "mozilla/OwningNonNull.h" |
8 | | #include "mozilla/dom/BindingUtils.h" |
9 | | #include "mozilla/dom/DOMJSClass.h" |
10 | | #include "mozilla/dom/IterableIterator.h" |
11 | | #include "mozilla/dom/MediaKeyStatusMap.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/PrimitiveConversions.h" |
14 | | #include "mozilla/dom/ToJSValue.h" |
15 | | #include "mozilla/dom/TypedArray.h" |
16 | | #include "mozilla/dom/UnionConversions.h" |
17 | | #include "mozilla/dom/UnionTypes.h" |
18 | | #include "mozilla/dom/XrayExpandoClass.h" |
19 | | |
20 | | namespace mozilla { |
21 | | namespace dom { |
22 | | |
23 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
24 | | using namespace mozilla::dom::binding_detail; |
25 | | |
26 | | |
27 | | namespace MediaKeyStatusValues { |
28 | | extern const EnumEntry strings[8] = { |
29 | | {"usable", 6}, |
30 | | {"expired", 7}, |
31 | | {"released", 8}, |
32 | | {"output-restricted", 17}, |
33 | | {"output-downscaled", 17}, |
34 | | {"status-pending", 14}, |
35 | | {"internal-error", 14}, |
36 | | { nullptr, 0 } |
37 | | }; |
38 | | } // namespace MediaKeyStatusValues |
39 | | |
40 | | bool |
41 | | ToJSValue(JSContext* aCx, MediaKeyStatus aArgument, JS::MutableHandle<JS::Value> aValue) |
42 | 0 | { |
43 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(MediaKeyStatusValues::strings)); |
44 | 0 | JSString* resultStr = |
45 | 0 | JS_NewStringCopyN(aCx, MediaKeyStatusValues::strings[uint32_t(aArgument)].value, |
46 | 0 | MediaKeyStatusValues::strings[uint32_t(aArgument)].length); |
47 | 0 | if (!resultStr) { |
48 | 0 | return false; |
49 | 0 | } |
50 | 0 | aValue.setString(resultStr); |
51 | 0 | return true; |
52 | 0 | } |
53 | | |
54 | | |
55 | | namespace MediaKeyStatusMap_Binding { |
56 | | |
57 | | MOZ_CAN_RUN_SCRIPT static bool |
58 | | get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, JSJitGetterCallArgs args) |
59 | 0 | { |
60 | 0 | AUTO_PROFILER_LABEL_FAST("get MediaKeyStatusMap.size", DOM, cx); |
61 | 0 |
|
62 | 0 | uint32_t result(self->Size()); |
63 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
64 | 0 | args.rval().setNumber(result); |
65 | 0 | return true; |
66 | 0 | } |
67 | | |
68 | | static const JSJitInfo size_getterinfo = { |
69 | | { (JSJitGetterOp)get_size }, |
70 | | { prototypes::id::MediaKeyStatusMap }, |
71 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
72 | | JSJitInfo::Getter, |
73 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
74 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
75 | | true, /* isInfallible. False in setters. */ |
76 | | false, /* isMovable. Not relevant for setters. */ |
77 | | false, /* isEliminatable. Not relevant for setters. */ |
78 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
79 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
80 | | false, /* isTypedMethod. Only relevant for methods. */ |
81 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
82 | | }; |
83 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
84 | | static_assert(0 < 1, "There is no slot for us"); |
85 | | |
86 | | MOZ_CAN_RUN_SCRIPT static bool |
87 | | has(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args) |
88 | 0 | { |
89 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMap.has", DOM, cx); |
90 | 0 |
|
91 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
92 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeyStatusMap.has"); |
93 | 0 | } |
94 | 0 | ArrayBufferViewOrArrayBuffer arg0; |
95 | 0 | ArrayBufferViewOrArrayBufferArgument arg0_holder(arg0); |
96 | 0 | { |
97 | 0 | bool done = false, failed = false, tryNext; |
98 | 0 | if (args[0].isObject()) { |
99 | 0 | done = (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext || |
100 | 0 | (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext; |
101 | 0 |
|
102 | 0 | } |
103 | 0 | if (failed) { |
104 | 0 | return false; |
105 | 0 | } |
106 | 0 | if (!done) { |
107 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of MediaKeyStatusMap.has", "ArrayBufferView, ArrayBuffer"); |
108 | 0 | return false; |
109 | 0 | } |
110 | 0 | } |
111 | 0 | bool result(self->Has(Constify(arg0))); |
112 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
113 | 0 | args.rval().setBoolean(result); |
114 | 0 | return true; |
115 | 0 | } |
116 | | |
117 | | static const JSJitInfo has_methodinfo = { |
118 | | { (JSJitGetterOp)has }, |
119 | | { prototypes::id::MediaKeyStatusMap }, |
120 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
121 | | JSJitInfo::Method, |
122 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
123 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
124 | | false, /* isInfallible. False in setters. */ |
125 | | false, /* isMovable. Not relevant for setters. */ |
126 | | false, /* isEliminatable. Not relevant for setters. */ |
127 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
128 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
129 | | false, /* isTypedMethod. Only relevant for methods. */ |
130 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
131 | | }; |
132 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
133 | | static_assert(0 < 1, "There is no slot for us"); |
134 | | |
135 | | MOZ_CAN_RUN_SCRIPT static bool |
136 | | get(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args) |
137 | 0 | { |
138 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMap.get", DOM, cx); |
139 | 0 |
|
140 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
141 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaKeyStatusMap.get"); |
142 | 0 | } |
143 | 0 | ArrayBufferViewOrArrayBuffer arg0; |
144 | 0 | ArrayBufferViewOrArrayBufferArgument arg0_holder(arg0); |
145 | 0 | { |
146 | 0 | bool done = false, failed = false, tryNext; |
147 | 0 | if (args[0].isObject()) { |
148 | 0 | done = (failed = !arg0_holder.TrySetToArrayBufferView(cx, args[0], tryNext, false)) || !tryNext || |
149 | 0 | (failed = !arg0_holder.TrySetToArrayBuffer(cx, args[0], tryNext, false)) || !tryNext; |
150 | 0 |
|
151 | 0 | } |
152 | 0 | if (failed) { |
153 | 0 | return false; |
154 | 0 | } |
155 | 0 | if (!done) { |
156 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of MediaKeyStatusMap.get", "ArrayBufferView, ArrayBuffer"); |
157 | 0 | return false; |
158 | 0 | } |
159 | 0 | } |
160 | 0 | FastErrorResult rv; |
161 | 0 | JS::Rooted<JS::Value> result(cx); |
162 | 0 | self->Get(cx, Constify(arg0), &result, rv); |
163 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
164 | 0 | return false; |
165 | 0 | } |
166 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
167 | 0 | JS::ExposeValueToActiveJS(result); |
168 | 0 | args.rval().set(result); |
169 | 0 | if (!MaybeWrapValue(cx, args.rval())) { |
170 | 0 | return false; |
171 | 0 | } |
172 | 0 | return true; |
173 | 0 | } |
174 | | |
175 | | static const JSJitInfo get_methodinfo = { |
176 | | { (JSJitGetterOp)get }, |
177 | | { prototypes::id::MediaKeyStatusMap }, |
178 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
179 | | JSJitInfo::Method, |
180 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
181 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
182 | | false, /* isInfallible. False in setters. */ |
183 | | false, /* isMovable. Not relevant for setters. */ |
184 | | false, /* isEliminatable. Not relevant for setters. */ |
185 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
186 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
187 | | false, /* isTypedMethod. Only relevant for methods. */ |
188 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
189 | | }; |
190 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
191 | | static_assert(0 < 1, "There is no slot for us"); |
192 | | |
193 | | MOZ_CAN_RUN_SCRIPT static bool |
194 | | entries(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args) |
195 | 0 | { |
196 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMap.entries", DOM, cx); |
197 | 0 |
|
198 | 0 | typedef mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> itrType; |
199 | 0 | RefPtr<itrType> result(new itrType(self, |
200 | 0 | itrType::IterableIteratorType::Entries, |
201 | 0 | &MediaKeyStatusMapIterator_Binding::Wrap)); |
202 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
203 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
204 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) { |
205 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
206 | 0 | return false; |
207 | 0 | } |
208 | 0 | return true; |
209 | 0 | } |
210 | | |
211 | | static const JSJitInfo::ArgType entries_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
212 | | static const JSTypedMethodJitInfo entries_methodinfo = { |
213 | | { |
214 | | { (JSJitGetterOp)entries }, |
215 | | { prototypes::id::MediaKeyStatusMap }, |
216 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
217 | | JSJitInfo::Method, |
218 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
219 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
220 | | false, /* isInfallible. False in setters. */ |
221 | | false, /* isMovable. Not relevant for setters. */ |
222 | | false, /* isEliminatable. Not relevant for setters. */ |
223 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
224 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
225 | | true, /* isTypedMethod. Only relevant for methods. */ |
226 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
227 | | }, |
228 | | entries_methodinfo_argTypes |
229 | | }; |
230 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
231 | | static_assert(0 < 1, "There is no slot for us"); |
232 | | |
233 | | MOZ_CAN_RUN_SCRIPT static bool |
234 | | keys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args) |
235 | 0 | { |
236 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMap.keys", DOM, cx); |
237 | 0 |
|
238 | 0 | typedef mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> itrType; |
239 | 0 | RefPtr<itrType> result(new itrType(self, |
240 | 0 | itrType::IterableIteratorType::Keys, |
241 | 0 | &MediaKeyStatusMapIterator_Binding::Wrap)); |
242 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
243 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
244 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) { |
245 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
246 | 0 | return false; |
247 | 0 | } |
248 | 0 | return true; |
249 | 0 | } |
250 | | |
251 | | static const JSJitInfo::ArgType keys_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
252 | | static const JSTypedMethodJitInfo keys_methodinfo = { |
253 | | { |
254 | | { (JSJitGetterOp)keys }, |
255 | | { prototypes::id::MediaKeyStatusMap }, |
256 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
257 | | JSJitInfo::Method, |
258 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
259 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
260 | | false, /* isInfallible. False in setters. */ |
261 | | false, /* isMovable. Not relevant for setters. */ |
262 | | false, /* isEliminatable. Not relevant for setters. */ |
263 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
264 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
265 | | true, /* isTypedMethod. Only relevant for methods. */ |
266 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
267 | | }, |
268 | | keys_methodinfo_argTypes |
269 | | }; |
270 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
271 | | static_assert(0 < 1, "There is no slot for us"); |
272 | | |
273 | | MOZ_CAN_RUN_SCRIPT static bool |
274 | | values(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args) |
275 | 0 | { |
276 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMap.values", DOM, cx); |
277 | 0 |
|
278 | 0 | typedef mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> itrType; |
279 | 0 | RefPtr<itrType> result(new itrType(self, |
280 | 0 | itrType::IterableIteratorType::Values, |
281 | 0 | &MediaKeyStatusMapIterator_Binding::Wrap)); |
282 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
283 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
284 | 0 | if (!WrapNewBindingNonWrapperCachedObject(cx, obj, result, args.rval())) { |
285 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
286 | 0 | return false; |
287 | 0 | } |
288 | 0 | return true; |
289 | 0 | } |
290 | | |
291 | | static const JSJitInfo::ArgType values_methodinfo_argTypes[] = { JSJitInfo::ArgTypeListEnd }; |
292 | | static const JSTypedMethodJitInfo values_methodinfo = { |
293 | | { |
294 | | { (JSJitGetterOp)values }, |
295 | | { prototypes::id::MediaKeyStatusMap }, |
296 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
297 | | JSJitInfo::Method, |
298 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
299 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
300 | | false, /* isInfallible. False in setters. */ |
301 | | false, /* isMovable. Not relevant for setters. */ |
302 | | false, /* isEliminatable. Not relevant for setters. */ |
303 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
304 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
305 | | true, /* isTypedMethod. Only relevant for methods. */ |
306 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
307 | | }, |
308 | | values_methodinfo_argTypes |
309 | | }; |
310 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
311 | | static_assert(0 < 1, "There is no slot for us"); |
312 | | |
313 | | MOZ_CAN_RUN_SCRIPT static bool |
314 | | forEach(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaKeyStatusMap* self, const JSJitMethodCallArgs& args) |
315 | 0 | { |
316 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMap.forEach", DOM, cx); |
317 | 0 |
|
318 | 0 | JS::Rooted<JSObject*> arg0(cx); |
319 | 0 | if (args.get(0).isObject()) { |
320 | 0 | arg0 = &args.get(0).toObject(); |
321 | 0 | } else { |
322 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MediaKeyStatusMap.forEach"); |
323 | 0 | return false; |
324 | 0 | } |
325 | 0 | JS::Rooted<JS::Value> arg1(cx); |
326 | 0 | if (args.hasDefined(1)) { |
327 | 0 | arg1 = args.get(1); |
328 | 0 | } else { |
329 | 0 | arg1 = JS::UndefinedValue(); |
330 | 0 | } |
331 | 0 | if (!JS::IsCallable(arg0)) { |
332 | 0 | ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 1 of MediaKeyStatusMap.forEach"); |
333 | 0 | return false; |
334 | 0 | } |
335 | 0 | JS::AutoValueArray<3> callArgs(cx); |
336 | 0 | callArgs[2].setObject(*obj); |
337 | 0 | JS::Rooted<JS::Value> ignoredReturnVal(cx); |
338 | 0 | auto GetKeyAtIndex = &mozilla::dom::MediaKeyStatusMap::GetKeyAtIndex; |
339 | 0 | auto GetValueAtIndex = &mozilla::dom::MediaKeyStatusMap::GetValueAtIndex; |
340 | 0 | for (size_t i = 0; i < self->GetIterableLength(); ++i) { |
341 | 0 | if (!CallIterableGetter(cx, GetValueAtIndex, self, i, |
342 | 0 | callArgs[0])) { |
343 | 0 | return false; |
344 | 0 | } |
345 | 0 | if (!CallIterableGetter(cx, GetKeyAtIndex, self, i, |
346 | 0 | callArgs[1])) { |
347 | 0 | return false; |
348 | 0 | } |
349 | 0 | if (!JS::Call(cx, arg1, arg0, JS::HandleValueArray(callArgs), |
350 | 0 | &ignoredReturnVal)) { |
351 | 0 | return false; |
352 | 0 | } |
353 | 0 | } |
354 | 0 | args.rval().setUndefined(); |
355 | 0 | return true; |
356 | 0 | } |
357 | | |
358 | | static const JSJitInfo forEach_methodinfo = { |
359 | | { (JSJitGetterOp)forEach }, |
360 | | { prototypes::id::MediaKeyStatusMap }, |
361 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth }, |
362 | | JSJitInfo::Method, |
363 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
364 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
365 | | false, /* isInfallible. False in setters. */ |
366 | | false, /* isMovable. Not relevant for setters. */ |
367 | | false, /* isEliminatable. Not relevant for setters. */ |
368 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
369 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
370 | | false, /* isTypedMethod. Only relevant for methods. */ |
371 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
372 | | }; |
373 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
374 | | static_assert(0 < 1, "There is no slot for us"); |
375 | | |
376 | | static bool |
377 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
378 | 0 | { |
379 | 0 | mozilla::dom::MediaKeyStatusMap* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyStatusMap>(obj); |
380 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
381 | 0 | // obviously can't preserve if we're not initialized. |
382 | 0 | if (self && self->GetWrapperPreserveColor()) { |
383 | 0 | PreserveWrapper(self); |
384 | 0 | } |
385 | 0 | return true; |
386 | 0 | } |
387 | | |
388 | | static void |
389 | | _finalize(js::FreeOp* fop, JSObject* obj) |
390 | 0 | { |
391 | 0 | mozilla::dom::MediaKeyStatusMap* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyStatusMap>(obj); |
392 | 0 | if (self) { |
393 | 0 | ClearWrapper(self, self, obj); |
394 | 0 | AddForDeferredFinalization<mozilla::dom::MediaKeyStatusMap>(self); |
395 | 0 | } |
396 | 0 | } |
397 | | |
398 | | static size_t |
399 | | _objectMoved(JSObject* obj, JSObject* old) |
400 | 0 | { |
401 | 0 | mozilla::dom::MediaKeyStatusMap* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaKeyStatusMap>(obj); |
402 | 0 | if (self) { |
403 | 0 | UpdateWrapper(self, self, obj, old); |
404 | 0 | } |
405 | 0 |
|
406 | 0 | return 0; |
407 | 0 | } |
408 | | |
409 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
410 | | #if defined(__clang__) |
411 | | #pragma clang diagnostic push |
412 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
413 | | #endif |
414 | | static const JSFunctionSpec sMethods_specs[] = { |
415 | | JS_FNSPEC("has", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&has_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
416 | | JS_FNSPEC("get", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&get_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
417 | | JS_FNSPEC("entries", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&entries_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
418 | | JS_FNSPEC("keys", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&keys_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
419 | | JS_FNSPEC("values", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&values_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
420 | | JS_FNSPEC("forEach", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&forEach_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
421 | | JS_FS_END |
422 | | }; |
423 | | #if defined(__clang__) |
424 | | #pragma clang diagnostic pop |
425 | | #endif |
426 | | |
427 | | |
428 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
429 | | { nullptr, &sMethods_specs[0] }, |
430 | | { nullptr, nullptr } |
431 | | }; |
432 | | |
433 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
434 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
435 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
436 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
437 | | |
438 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
439 | | #if defined(__clang__) |
440 | | #pragma clang diagnostic push |
441 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
442 | | #endif |
443 | | static const JSPropertySpec sAttributes_specs[] = { |
444 | | { "size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, nullptr, nullptr }, |
445 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
446 | | }; |
447 | | #if defined(__clang__) |
448 | | #pragma clang diagnostic pop |
449 | | #endif |
450 | | |
451 | | |
452 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
453 | | { nullptr, &sAttributes_specs[0] }, |
454 | | { nullptr, nullptr } |
455 | | }; |
456 | | |
457 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
458 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
459 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
460 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
461 | | |
462 | | |
463 | | static uint16_t sNativeProperties_sortedPropertyIndices[7]; |
464 | | static PropertyInfo sNativeProperties_propertyInfos[7]; |
465 | | |
466 | | static const NativePropertiesN<2> sNativeProperties = { |
467 | | false, 0, |
468 | | false, 0, |
469 | | true, 0 /* sMethods */, |
470 | | true, 1 /* sAttributes */, |
471 | | false, 0, |
472 | | false, 0, |
473 | | false, 0, |
474 | | 2, |
475 | | 7, |
476 | | sNativeProperties_sortedPropertyIndices, |
477 | | { |
478 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
479 | | { sAttributes, &sNativeProperties_propertyInfos[6] } |
480 | | } |
481 | | }; |
482 | | static_assert(2 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.iteratorAliasMethodIndex) - 1), |
483 | | "We have an iterator alias index that is oversized"); |
484 | | static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
485 | | "We have a property info count that is oversized"); |
486 | | |
487 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
488 | | { |
489 | | "Function", |
490 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
491 | | &sBoringInterfaceObjectClassClassOps, |
492 | | JS_NULL_CLASS_SPEC, |
493 | | JS_NULL_CLASS_EXT, |
494 | | &sInterfaceObjectClassObjectOps |
495 | | }, |
496 | | eInterface, |
497 | | true, |
498 | | prototypes::id::MediaKeyStatusMap, |
499 | | PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth, |
500 | | sNativePropertyHooks, |
501 | | "function MediaKeyStatusMap() {\n [native code]\n}", |
502 | | JS::GetRealmFunctionPrototype |
503 | | }; |
504 | | |
505 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
506 | | { |
507 | | "MediaKeyStatusMapPrototype", |
508 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
509 | | JS_NULL_CLASS_OPS, |
510 | | JS_NULL_CLASS_SPEC, |
511 | | JS_NULL_CLASS_EXT, |
512 | | JS_NULL_OBJECT_OPS |
513 | | }, |
514 | | eInterfacePrototype, |
515 | | false, |
516 | | prototypes::id::MediaKeyStatusMap, |
517 | | PrototypeTraits<prototypes::id::MediaKeyStatusMap>::Depth, |
518 | | sNativePropertyHooks, |
519 | | "[object MediaKeyStatusMapPrototype]", |
520 | | JS::GetRealmObjectPrototype |
521 | | }; |
522 | | |
523 | | static const js::ClassOps sClassOps = { |
524 | | _addProperty, /* addProperty */ |
525 | | nullptr, /* delProperty */ |
526 | | nullptr, /* enumerate */ |
527 | | nullptr, /* newEnumerate */ |
528 | | nullptr, /* resolve */ |
529 | | nullptr, /* mayResolve */ |
530 | | _finalize, /* finalize */ |
531 | | nullptr, /* call */ |
532 | | nullptr, /* hasInstance */ |
533 | | nullptr, /* construct */ |
534 | | nullptr, /* trace */ |
535 | | }; |
536 | | |
537 | | static const js::ClassExtension sClassExtension = { |
538 | | nullptr, /* weakmapKeyDelegateOp */ |
539 | | _objectMoved /* objectMovedOp */ |
540 | | }; |
541 | | |
542 | | static const DOMJSClass sClass = { |
543 | | { "MediaKeyStatusMap", |
544 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
545 | | &sClassOps, |
546 | | JS_NULL_CLASS_SPEC, |
547 | | &sClassExtension, |
548 | | JS_NULL_OBJECT_OPS |
549 | | }, |
550 | | { prototypes::id::MediaKeyStatusMap, 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 }, |
551 | | IsBaseOf<nsISupports, mozilla::dom::MediaKeyStatusMap >::value, |
552 | | sNativePropertyHooks, |
553 | | FindAssociatedGlobalForNative<mozilla::dom::MediaKeyStatusMap>::Get, |
554 | | GetProtoObjectHandle, |
555 | | GetCCParticipant<mozilla::dom::MediaKeyStatusMap>::Get() |
556 | | }; |
557 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
558 | | "Must have the right minimal number of reserved slots."); |
559 | | static_assert(1 >= 1, |
560 | | "Must have enough reserved slots."); |
561 | | |
562 | | const JSClass* |
563 | | GetJSClass() |
564 | 0 | { |
565 | 0 | return sClass.ToJSClass(); |
566 | 0 | } |
567 | | |
568 | | bool |
569 | | Wrap(JSContext* aCx, mozilla::dom::MediaKeyStatusMap* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
570 | 0 | { |
571 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::MediaKeyStatusMap>::value, |
572 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
573 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::MediaKeyStatusMap*>(aObject) == |
574 | 0 | reinterpret_cast<mozilla::dom::MediaKeyStatusMap*>(aObject), |
575 | 0 | "Multiple inheritance for mozilla::dom::MediaKeyStatusMap is broken."); |
576 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
577 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
578 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
579 | 0 | "You should probably not be using Wrap() directly; use " |
580 | 0 | "GetOrCreateDOMReflector instead"); |
581 | 0 |
|
582 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
583 | 0 | "nsISupports must be on our primary inheritance chain"); |
584 | 0 |
|
585 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
586 | 0 | if (!global) { |
587 | 0 | return false; |
588 | 0 | } |
589 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
590 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
591 | 0 |
|
592 | 0 | // That might have ended up wrapping us already, due to the wonders |
593 | 0 | // of XBL. Check for that, and bail out as needed. |
594 | 0 | aReflector.set(aCache->GetWrapper()); |
595 | 0 | if (aReflector) { |
596 | | #ifdef DEBUG |
597 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
598 | | #endif // DEBUG |
599 | | return true; |
600 | 0 | } |
601 | 0 |
|
602 | 0 | JSAutoRealm ar(aCx, global); |
603 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
604 | 0 | if (!canonicalProto) { |
605 | 0 | return false; |
606 | 0 | } |
607 | 0 | JS::Rooted<JSObject*> proto(aCx); |
608 | 0 | if (aGivenProto) { |
609 | 0 | proto = aGivenProto; |
610 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
611 | 0 | // coming in, we changed compartments to that of "parent" so may need |
612 | 0 | // to wrap the proto here. |
613 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
614 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
615 | 0 | return false; |
616 | 0 | } |
617 | 0 | } |
618 | 0 | } else { |
619 | 0 | proto = canonicalProto; |
620 | 0 | } |
621 | 0 |
|
622 | 0 | BindingJSObjectCreator<mozilla::dom::MediaKeyStatusMap> creator(aCx); |
623 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
624 | 0 | if (!aReflector) { |
625 | 0 | return false; |
626 | 0 | } |
627 | 0 | |
628 | 0 | aCache->SetWrapper(aReflector); |
629 | 0 | creator.InitializationSucceeded(); |
630 | 0 |
|
631 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
632 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
633 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
634 | 0 | // otherwise we won't be able to properly recreate it later, since |
635 | 0 | // we won't know what proto to use. Note that we don't check |
636 | 0 | // aGivenProto here, since it's entirely possible (and even |
637 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
638 | 0 | // same as canonicalProto. |
639 | 0 | if (proto != canonicalProto) { |
640 | 0 | PreserveWrapper(aObject); |
641 | 0 | } |
642 | 0 |
|
643 | 0 | return true; |
644 | 0 | } |
645 | | |
646 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
647 | | nullptr, |
648 | | nullptr, |
649 | | nullptr, |
650 | | { sNativeProperties.Upcast(), nullptr }, |
651 | | prototypes::id::MediaKeyStatusMap, |
652 | | constructors::id::MediaKeyStatusMap, |
653 | | nullptr, |
654 | | &DefaultXrayExpandoObjectClass |
655 | | } }; |
656 | | |
657 | | void |
658 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
659 | 0 | { |
660 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
661 | 0 | if (!parentProto) { |
662 | 0 | return; |
663 | 0 | } |
664 | 0 | |
665 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
666 | 0 | if (!constructorProto) { |
667 | 0 | return; |
668 | 0 | } |
669 | 0 | |
670 | 0 | static bool sIdsInited = false; |
671 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
672 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
673 | 0 | return; |
674 | 0 | } |
675 | 0 | sIdsInited = true; |
676 | 0 | } |
677 | 0 |
|
678 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeyStatusMap); |
679 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaKeyStatusMap); |
680 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
681 | 0 | &sPrototypeClass.mBase, protoCache, |
682 | 0 | nullptr, |
683 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
684 | 0 | interfaceCache, |
685 | 0 | sNativeProperties.Upcast(), |
686 | 0 | nullptr, |
687 | 0 | "MediaKeyStatusMap", aDefineOnGlobal, |
688 | 0 | nullptr, |
689 | 0 | false); |
690 | 0 |
|
691 | 0 | // Set up aliases on the interface prototype object we just created. |
692 | 0 | JS::Handle<JSObject*> proto = GetProtoObjectHandle(aCx); |
693 | 0 | if (!proto) { |
694 | 0 | *protoCache = nullptr; |
695 | 0 | if (interfaceCache) { |
696 | 0 | *interfaceCache = nullptr; |
697 | 0 | } |
698 | 0 | return; |
699 | 0 | } |
700 | 0 |
|
701 | 0 | JS::Rooted<JS::Value> aliasedVal(aCx); |
702 | 0 |
|
703 | 0 | if (!JS_GetProperty(aCx, proto, "entries", &aliasedVal)) { |
704 | 0 | *protoCache = nullptr; |
705 | 0 | if (interfaceCache) { |
706 | 0 | *interfaceCache = nullptr; |
707 | 0 | } |
708 | 0 | return; |
709 | 0 | } |
710 | 0 | JS::Rooted<jsid> iteratorId(aCx, SYMBOL_TO_JSID(JS::GetWellKnownSymbol(aCx, JS::SymbolCode::iterator))); |
711 | 0 | if (!JS_DefinePropertyById(aCx, proto, iteratorId, aliasedVal, 0)) { |
712 | 0 | *protoCache = nullptr; |
713 | 0 | if (interfaceCache) { |
714 | 0 | *interfaceCache = nullptr; |
715 | 0 | } |
716 | 0 | return; |
717 | 0 | } |
718 | 0 | } |
719 | | |
720 | | JSObject* |
721 | | GetConstructorObject(JSContext* aCx) |
722 | 0 | { |
723 | 0 | return GetConstructorObjectHandle(aCx); |
724 | 0 | } |
725 | | |
726 | | } // namespace MediaKeyStatusMap_Binding |
727 | | |
728 | | |
729 | | |
730 | | namespace MediaKeyStatusMapIterator_Binding { |
731 | | |
732 | | MOZ_CAN_RUN_SCRIPT static bool |
733 | | next(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>* self, const JSJitMethodCallArgs& args) |
734 | 0 | { |
735 | 0 | AUTO_PROFILER_LABEL_FAST("MediaKeyStatusMapIterator.next", DOM, cx); |
736 | 0 |
|
737 | 0 | FastErrorResult rv; |
738 | 0 | JS::Rooted<JSObject*> result(cx); |
739 | 0 | self->Next(cx, &result, rv); |
740 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
741 | 0 | return false; |
742 | 0 | } |
743 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
744 | 0 | JS::ExposeObjectToActiveJS(result); |
745 | 0 | args.rval().setObject(*result); |
746 | 0 | if (!MaybeWrapObjectValue(cx, args.rval())) { |
747 | 0 | return false; |
748 | 0 | } |
749 | 0 | return true; |
750 | 0 | } |
751 | | |
752 | | static const JSJitInfo next_methodinfo = { |
753 | | { (JSJitGetterOp)next }, |
754 | | { prototypes::id::MediaKeyStatusMapIterator }, |
755 | | { PrototypeTraits<prototypes::id::MediaKeyStatusMapIterator>::Depth }, |
756 | | JSJitInfo::Method, |
757 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
758 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
759 | | false, /* isInfallible. False in setters. */ |
760 | | false, /* isMovable. Not relevant for setters. */ |
761 | | false, /* isEliminatable. Not relevant for setters. */ |
762 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
763 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
764 | | false, /* isTypedMethod. Only relevant for methods. */ |
765 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
766 | | }; |
767 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
768 | | static_assert(0 < 1, "There is no slot for us"); |
769 | | |
770 | | static void |
771 | | _finalize(js::FreeOp* fop, JSObject* obj) |
772 | 0 | { |
773 | 0 | mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>(obj); |
774 | 0 | if (self) { |
775 | 0 | AddForDeferredFinalization<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>(self); |
776 | 0 | } |
777 | 0 | } |
778 | | |
779 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
780 | | #if defined(__clang__) |
781 | | #pragma clang diagnostic push |
782 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
783 | | #endif |
784 | | static const JSFunctionSpec sMethods_specs[] = { |
785 | | JS_FNSPEC("next", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&next_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
786 | | JS_FS_END |
787 | | }; |
788 | | #if defined(__clang__) |
789 | | #pragma clang diagnostic pop |
790 | | #endif |
791 | | |
792 | | |
793 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
794 | | { nullptr, &sMethods_specs[0] }, |
795 | | { nullptr, nullptr } |
796 | | }; |
797 | | |
798 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
799 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
800 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
801 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
802 | | |
803 | | |
804 | | static uint16_t sNativeProperties_sortedPropertyIndices[1]; |
805 | | static PropertyInfo sNativeProperties_propertyInfos[1]; |
806 | | |
807 | | static const NativePropertiesN<1> sNativeProperties = { |
808 | | false, 0, |
809 | | false, 0, |
810 | | true, 0 /* sMethods */, |
811 | | false, 0, |
812 | | false, 0, |
813 | | false, 0, |
814 | | false, 0, |
815 | | -1, |
816 | | 1, |
817 | | sNativeProperties_sortedPropertyIndices, |
818 | | { |
819 | | { sMethods, &sNativeProperties_propertyInfos[0] } |
820 | | } |
821 | | }; |
822 | | static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
823 | | "We have a property info count that is oversized"); |
824 | | |
825 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
826 | | { |
827 | | "MediaKeyStatusMap IteratorPrototype", |
828 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
829 | | JS_NULL_CLASS_OPS, |
830 | | JS_NULL_CLASS_SPEC, |
831 | | JS_NULL_CLASS_EXT, |
832 | | JS_NULL_OBJECT_OPS |
833 | | }, |
834 | | eInterfacePrototype, |
835 | | false, |
836 | | prototypes::id::MediaKeyStatusMapIterator, |
837 | | PrototypeTraits<prototypes::id::MediaKeyStatusMapIterator>::Depth, |
838 | | sNativePropertyHooks, |
839 | | "[object MediaKeyStatusMap IteratorPrototype]", |
840 | | JS::GetRealmIteratorPrototype |
841 | | }; |
842 | | |
843 | | static const js::ClassOps sClassOps = { |
844 | | nullptr, /* addProperty */ |
845 | | nullptr, /* delProperty */ |
846 | | nullptr, /* enumerate */ |
847 | | nullptr, /* newEnumerate */ |
848 | | nullptr, /* resolve */ |
849 | | nullptr, /* mayResolve */ |
850 | | _finalize, /* finalize */ |
851 | | nullptr, /* call */ |
852 | | nullptr, /* hasInstance */ |
853 | | nullptr, /* construct */ |
854 | | nullptr, /* trace */ |
855 | | }; |
856 | | |
857 | | static const js::ClassExtension sClassExtension = { |
858 | | nullptr, /* weakmapKeyDelegateOp */ |
859 | | nullptr /* objectMovedOp */ |
860 | | }; |
861 | | |
862 | | static const DOMJSClass sClass = { |
863 | | { "MediaKeyStatusMap Iterator", |
864 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
865 | | &sClassOps, |
866 | | JS_NULL_CLASS_SPEC, |
867 | | &sClassExtension, |
868 | | JS_NULL_OBJECT_OPS |
869 | | }, |
870 | | { prototypes::id::MediaKeyStatusMapIterator, 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 }, |
871 | | IsBaseOf<nsISupports, mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> >::value, |
872 | | sNativePropertyHooks, |
873 | | FindAssociatedGlobalForNative<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>::Get, |
874 | | GetProtoObjectHandle, |
875 | | GetCCParticipant<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>>::Get() |
876 | | }; |
877 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
878 | | "Must have the right minimal number of reserved slots."); |
879 | | static_assert(1 >= 1, |
880 | | "Must have enough reserved slots."); |
881 | | |
882 | | const JSClass* |
883 | | GetJSClass() |
884 | 0 | { |
885 | 0 | return sClass.ToJSClass(); |
886 | 0 | } |
887 | | |
888 | | bool |
889 | | Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
890 | 0 | { |
891 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>*>(aObject) == |
892 | 0 | reinterpret_cast<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>*>(aObject), |
893 | 0 | "Multiple inheritance for mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap> is broken."); |
894 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
895 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
896 | 0 |
|
897 | 0 | JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx)); |
898 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
899 | 0 | if (!canonicalProto) { |
900 | 0 | return false; |
901 | 0 | } |
902 | 0 | JS::Rooted<JSObject*> proto(aCx); |
903 | 0 | if (aGivenProto) { |
904 | 0 | proto = aGivenProto; |
905 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
906 | 0 | // coming in, we changed compartments to that of "parent" so may need |
907 | 0 | // to wrap the proto here. |
908 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
909 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
910 | 0 | return false; |
911 | 0 | } |
912 | 0 | } |
913 | 0 | } else { |
914 | 0 | proto = canonicalProto; |
915 | 0 | } |
916 | 0 |
|
917 | 0 | BindingJSObjectCreator<mozilla::dom::IterableIterator<mozilla::dom::MediaKeyStatusMap>> creator(aCx); |
918 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
919 | 0 | if (!aReflector) { |
920 | 0 | return false; |
921 | 0 | } |
922 | 0 | |
923 | 0 | |
924 | 0 | |
925 | 0 | creator.InitializationSucceeded(); |
926 | 0 | return true; |
927 | 0 | } |
928 | | |
929 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
930 | | nullptr, |
931 | | nullptr, |
932 | | nullptr, |
933 | | { sNativeProperties.Upcast(), nullptr }, |
934 | | prototypes::id::MediaKeyStatusMapIterator, |
935 | | constructors::id::_ID_Count, |
936 | | nullptr, |
937 | | &DefaultXrayExpandoObjectClass |
938 | | } }; |
939 | | |
940 | | void |
941 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
942 | 0 | { |
943 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmIteratorPrototype(aCx)); |
944 | 0 | if (!parentProto) { |
945 | 0 | return; |
946 | 0 | } |
947 | 0 | |
948 | 0 | static bool sIdsInited = false; |
949 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
950 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
951 | 0 | return; |
952 | 0 | } |
953 | 0 | sIdsInited = true; |
954 | 0 | } |
955 | 0 |
|
956 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaKeyStatusMapIterator); |
957 | 0 | JS::Heap<JSObject*>* interfaceCache = nullptr; |
958 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
959 | 0 | &sPrototypeClass.mBase, protoCache, |
960 | 0 | "MediaKeyStatusMap Iterator", |
961 | 0 | nullptr, nullptr, 0, nullptr, |
962 | 0 | interfaceCache, |
963 | 0 | sNativeProperties.Upcast(), |
964 | 0 | nullptr, |
965 | 0 | nullptr, aDefineOnGlobal, |
966 | 0 | nullptr, |
967 | 0 | false); |
968 | 0 | } |
969 | | |
970 | | } // namespace MediaKeyStatusMapIterator_Binding |
971 | | |
972 | | |
973 | | |
974 | | } // namespace dom |
975 | | } // namespace mozilla |