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