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