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