Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM GamepadPose.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "GamepadPoseBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "jsfriendapi.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/Preferences.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/GamepadPose.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/PrimitiveConversions.h"
14 : #include "mozilla/dom/TypedArray.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : namespace GamepadPoseBinding {
21 :
22 : static bool
23 0 : get_hasOrientation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
24 : {
25 0 : bool result(self->HasOrientation());
26 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
27 0 : args.rval().setBoolean(result);
28 0 : return true;
29 : }
30 :
31 : static const JSJitInfo hasOrientation_getterinfo = {
32 : { (JSJitGetterOp)get_hasOrientation },
33 : { prototypes::id::GamepadPose },
34 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
35 : JSJitInfo::Getter,
36 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
37 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
38 : true, /* isInfallible. False in setters. */
39 : false, /* isMovable. Not relevant for setters. */
40 : false, /* isEliminatable. Not relevant for setters. */
41 : false, /* isAlwaysInSlot. Only relevant for getters. */
42 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
43 : false, /* isTypedMethod. Only relevant for methods. */
44 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
45 : };
46 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
47 : static_assert(0 < 1, "There is no slot for us");
48 :
49 : static bool
50 0 : get_hasPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
51 : {
52 0 : bool result(self->HasPosition());
53 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
54 0 : args.rval().setBoolean(result);
55 0 : return true;
56 : }
57 :
58 : static const JSJitInfo hasPosition_getterinfo = {
59 : { (JSJitGetterOp)get_hasPosition },
60 : { prototypes::id::GamepadPose },
61 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
62 : JSJitInfo::Getter,
63 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
64 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
65 : true, /* isInfallible. False in setters. */
66 : false, /* isMovable. Not relevant for setters. */
67 : false, /* isEliminatable. Not relevant for setters. */
68 : false, /* isAlwaysInSlot. Only relevant for getters. */
69 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
70 : false, /* isTypedMethod. Only relevant for methods. */
71 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
72 : };
73 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
74 : static_assert(0 < 1, "There is no slot for us");
75 :
76 : static bool
77 0 : get_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
78 : {
79 0 : binding_detail::FastErrorResult rv;
80 0 : JS::Rooted<JSObject*> result(cx);
81 0 : self->GetPosition(cx, &result, rv);
82 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
83 0 : return false;
84 : }
85 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
86 0 : if (result) {
87 0 : JS::ExposeObjectToActiveJS(result);
88 : }
89 0 : args.rval().setObjectOrNull(result);
90 0 : if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
91 0 : return false;
92 : }
93 0 : return true;
94 : }
95 :
96 : static const JSJitInfo position_getterinfo = {
97 : { (JSJitGetterOp)get_position },
98 : { prototypes::id::GamepadPose },
99 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
100 : JSJitInfo::Getter,
101 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
102 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
103 : false, /* isInfallible. False in setters. */
104 : false, /* isMovable. Not relevant for setters. */
105 : false, /* isEliminatable. Not relevant for setters. */
106 : false, /* isAlwaysInSlot. Only relevant for getters. */
107 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
108 : false, /* isTypedMethod. Only relevant for methods. */
109 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
110 : };
111 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
112 : static_assert(0 < 1, "There is no slot for us");
113 :
114 : static bool
115 0 : get_linearVelocity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
116 : {
117 0 : binding_detail::FastErrorResult rv;
118 0 : JS::Rooted<JSObject*> result(cx);
119 0 : self->GetLinearVelocity(cx, &result, rv);
120 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
121 0 : return false;
122 : }
123 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
124 0 : if (result) {
125 0 : JS::ExposeObjectToActiveJS(result);
126 : }
127 0 : args.rval().setObjectOrNull(result);
128 0 : if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
129 0 : return false;
130 : }
131 0 : return true;
132 : }
133 :
134 : static const JSJitInfo linearVelocity_getterinfo = {
135 : { (JSJitGetterOp)get_linearVelocity },
136 : { prototypes::id::GamepadPose },
137 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
138 : JSJitInfo::Getter,
139 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
140 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
141 : false, /* isInfallible. False in setters. */
142 : false, /* isMovable. Not relevant for setters. */
143 : false, /* isEliminatable. Not relevant for setters. */
144 : false, /* isAlwaysInSlot. Only relevant for getters. */
145 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
146 : false, /* isTypedMethod. Only relevant for methods. */
147 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
148 : };
149 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
150 : static_assert(0 < 1, "There is no slot for us");
151 :
152 : static bool
153 0 : get_linearAcceleration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
154 : {
155 0 : binding_detail::FastErrorResult rv;
156 0 : JS::Rooted<JSObject*> result(cx);
157 0 : self->GetLinearAcceleration(cx, &result, rv);
158 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
159 0 : return false;
160 : }
161 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
162 0 : if (result) {
163 0 : JS::ExposeObjectToActiveJS(result);
164 : }
165 0 : args.rval().setObjectOrNull(result);
166 0 : if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
167 0 : return false;
168 : }
169 0 : return true;
170 : }
171 :
172 : static const JSJitInfo linearAcceleration_getterinfo = {
173 : { (JSJitGetterOp)get_linearAcceleration },
174 : { prototypes::id::GamepadPose },
175 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
176 : JSJitInfo::Getter,
177 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
178 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
179 : false, /* isInfallible. False in setters. */
180 : false, /* isMovable. Not relevant for setters. */
181 : false, /* isEliminatable. Not relevant for setters. */
182 : false, /* isAlwaysInSlot. Only relevant for getters. */
183 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
184 : false, /* isTypedMethod. Only relevant for methods. */
185 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
186 : };
187 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
188 : static_assert(0 < 1, "There is no slot for us");
189 :
190 : static bool
191 0 : get_orientation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
192 : {
193 0 : binding_detail::FastErrorResult rv;
194 0 : JS::Rooted<JSObject*> result(cx);
195 0 : self->GetOrientation(cx, &result, rv);
196 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
197 0 : return false;
198 : }
199 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
200 0 : if (result) {
201 0 : JS::ExposeObjectToActiveJS(result);
202 : }
203 0 : args.rval().setObjectOrNull(result);
204 0 : if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
205 0 : return false;
206 : }
207 0 : return true;
208 : }
209 :
210 : static const JSJitInfo orientation_getterinfo = {
211 : { (JSJitGetterOp)get_orientation },
212 : { prototypes::id::GamepadPose },
213 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
214 : JSJitInfo::Getter,
215 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
216 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
217 : false, /* isInfallible. False in setters. */
218 : false, /* isMovable. Not relevant for setters. */
219 : false, /* isEliminatable. Not relevant for setters. */
220 : false, /* isAlwaysInSlot. Only relevant for getters. */
221 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
222 : false, /* isTypedMethod. Only relevant for methods. */
223 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
224 : };
225 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
226 : static_assert(0 < 1, "There is no slot for us");
227 :
228 : static bool
229 0 : get_angularVelocity(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
230 : {
231 0 : binding_detail::FastErrorResult rv;
232 0 : JS::Rooted<JSObject*> result(cx);
233 0 : self->GetAngularVelocity(cx, &result, rv);
234 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
235 0 : return false;
236 : }
237 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
238 0 : if (result) {
239 0 : JS::ExposeObjectToActiveJS(result);
240 : }
241 0 : args.rval().setObjectOrNull(result);
242 0 : if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
243 0 : return false;
244 : }
245 0 : return true;
246 : }
247 :
248 : static const JSJitInfo angularVelocity_getterinfo = {
249 : { (JSJitGetterOp)get_angularVelocity },
250 : { prototypes::id::GamepadPose },
251 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
252 : JSJitInfo::Getter,
253 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
254 : JSVAL_TYPE_UNKNOWN, /* 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 : static bool
267 0 : get_angularAcceleration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadPose* self, JSJitGetterCallArgs args)
268 : {
269 0 : binding_detail::FastErrorResult rv;
270 0 : JS::Rooted<JSObject*> result(cx);
271 0 : self->GetAngularAcceleration(cx, &result, rv);
272 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
273 0 : return false;
274 : }
275 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
276 0 : if (result) {
277 0 : JS::ExposeObjectToActiveJS(result);
278 : }
279 0 : args.rval().setObjectOrNull(result);
280 0 : if (!MaybeWrapNonDOMObjectOrNullValue(cx, args.rval())) {
281 0 : return false;
282 : }
283 0 : return true;
284 : }
285 :
286 : static const JSJitInfo angularAcceleration_getterinfo = {
287 : { (JSJitGetterOp)get_angularAcceleration },
288 : { prototypes::id::GamepadPose },
289 : { PrototypeTraits<prototypes::id::GamepadPose>::Depth },
290 : JSJitInfo::Getter,
291 : JSJitInfo::AliasNone, /* 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 :
304 : static bool
305 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
306 : {
307 0 : mozilla::dom::GamepadPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GamepadPose>(obj);
308 : // We don't want to preserve if we don't have a wrapper, and we
309 : // obviously can't preserve if we're not initialized.
310 0 : if (self && self->GetWrapperPreserveColor()) {
311 0 : PreserveWrapper(self);
312 : }
313 0 : return true;
314 : }
315 :
316 : static void
317 0 : _finalize(js::FreeOp* fop, JSObject* obj)
318 : {
319 0 : mozilla::dom::GamepadPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GamepadPose>(obj);
320 0 : if (self) {
321 0 : ClearWrapper(self, self, obj);
322 0 : AddForDeferredFinalization<mozilla::dom::GamepadPose>(self);
323 : }
324 0 : }
325 :
326 : static void
327 0 : _objectMoved(JSObject* obj, const JSObject* old)
328 : {
329 0 : mozilla::dom::GamepadPose* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GamepadPose>(obj);
330 0 : if (self) {
331 0 : UpdateWrapper(self, self, obj, old);
332 : }
333 0 : }
334 :
335 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
336 : #if defined(__clang__)
337 : #pragma clang diagnostic push
338 : #pragma clang diagnostic ignored "-Wmissing-braces"
339 : #endif
340 : static const JSPropertySpec sAttributes_specs[] = {
341 : { "hasOrientation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hasOrientation_getterinfo, nullptr, nullptr },
342 : { "hasPosition", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &hasPosition_getterinfo, nullptr, nullptr },
343 : { "position", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &position_getterinfo, nullptr, nullptr },
344 : { "linearVelocity", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &linearVelocity_getterinfo, nullptr, nullptr },
345 : { "linearAcceleration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &linearAcceleration_getterinfo, nullptr, nullptr },
346 : { "orientation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &orientation_getterinfo, nullptr, nullptr },
347 : { "angularVelocity", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &angularVelocity_getterinfo, nullptr, nullptr },
348 : { "angularAcceleration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &angularAcceleration_getterinfo, nullptr, nullptr },
349 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
350 : };
351 : #if defined(__clang__)
352 : #pragma clang diagnostic pop
353 : #endif
354 :
355 :
356 : // Can't be const because the pref-enabled boolean needs to be writable
357 : static Prefable<const JSPropertySpec> sAttributes[] = {
358 : { nullptr, &sAttributes_specs[0] },
359 : { nullptr, nullptr }
360 : };
361 :
362 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
363 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
364 : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
365 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
366 :
367 :
368 : static uint16_t sNativeProperties_sortedPropertyIndices[8];
369 : static PropertyInfo sNativeProperties_propertyInfos[8];
370 :
371 : static const NativePropertiesN<1> sNativeProperties = {
372 : false, 0,
373 : false, 0,
374 : false, 0,
375 : true, 0 /* sAttributes */,
376 : false, 0,
377 : false, 0,
378 : false, 0,
379 : -1,
380 : 8,
381 : sNativeProperties_sortedPropertyIndices,
382 : {
383 : { sAttributes, &sNativeProperties_propertyInfos[0] }
384 : }
385 : };
386 : static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
387 : "We have a property info count that is oversized");
388 :
389 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
390 : {
391 : "Function",
392 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
393 : &sBoringInterfaceObjectClassClassOps,
394 : JS_NULL_CLASS_SPEC,
395 : JS_NULL_CLASS_EXT,
396 : &sInterfaceObjectClassObjectOps
397 : },
398 : eInterface,
399 : true,
400 : prototypes::id::GamepadPose,
401 : PrototypeTraits<prototypes::id::GamepadPose>::Depth,
402 : sNativePropertyHooks,
403 : "function GamepadPose() {\n [native code]\n}",
404 : JS::GetRealmFunctionPrototype
405 : };
406 :
407 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
408 : {
409 : "GamepadPosePrototype",
410 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
411 : JS_NULL_CLASS_OPS,
412 : JS_NULL_CLASS_SPEC,
413 : JS_NULL_CLASS_EXT,
414 : JS_NULL_OBJECT_OPS
415 : },
416 : eInterfacePrototype,
417 : false,
418 : prototypes::id::GamepadPose,
419 : PrototypeTraits<prototypes::id::GamepadPose>::Depth,
420 : sNativePropertyHooks,
421 : "[object GamepadPosePrototype]",
422 : JS::GetRealmObjectPrototype
423 : };
424 :
425 : bool
426 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
427 : {
428 : static bool sPrefValue;
429 : static bool sPrefCacheSetUp = false;
430 0 : if (!sPrefCacheSetUp) {
431 0 : sPrefCacheSetUp = true;
432 0 : Preferences::AddBoolVarCache(&sPrefValue, "dom.gamepad.extensions.enabled");
433 : }
434 :
435 0 : return sPrefValue;
436 : }
437 :
438 : JSObject*
439 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
440 : {
441 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
442 : }
443 :
444 : static const js::ClassOps sClassOps = {
445 : _addProperty, /* addProperty */
446 : nullptr, /* delProperty */
447 : nullptr, /* getProperty */
448 : nullptr, /* setProperty */
449 : nullptr, /* enumerate */
450 : nullptr, /* newEnumerate */
451 : nullptr, /* resolve */
452 : nullptr, /* mayResolve */
453 : _finalize, /* finalize */
454 : nullptr, /* call */
455 : nullptr, /* hasInstance */
456 : nullptr, /* construct */
457 : nullptr, /* trace */
458 : };
459 :
460 : static const js::ClassExtension sClassExtension = {
461 : nullptr, /* weakmapKeyDelegateOp */
462 : _objectMoved /* objectMovedOp */
463 : };
464 :
465 : static const DOMJSClass sClass = {
466 : { "GamepadPose",
467 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
468 : &sClassOps,
469 : JS_NULL_CLASS_SPEC,
470 : &sClassExtension,
471 : JS_NULL_OBJECT_OPS
472 : },
473 : { prototypes::id::GamepadPose, 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 },
474 : IsBaseOf<nsISupports, mozilla::dom::GamepadPose >::value,
475 : sNativePropertyHooks,
476 : FindAssociatedGlobalForNative<mozilla::dom::GamepadPose>::Get,
477 : GetProtoObjectHandle,
478 : GetCCParticipant<mozilla::dom::GamepadPose>::Get()
479 : };
480 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
481 : "Must have the right minimal number of reserved slots.");
482 : static_assert(1 >= 1,
483 : "Must have enough reserved slots.");
484 :
485 : const JSClass*
486 0 : GetJSClass()
487 : {
488 0 : return sClass.ToJSClass();
489 : }
490 :
491 : bool
492 0 : Wrap(JSContext* aCx, mozilla::dom::GamepadPose* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
493 : {
494 : MOZ_ASSERT(static_cast<mozilla::dom::GamepadPose*>(aObject) ==
495 : reinterpret_cast<mozilla::dom::GamepadPose*>(aObject),
496 : "Multiple inheritance for mozilla::dom::GamepadPose is broken.");
497 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
498 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
499 0 : MOZ_ASSERT(!aCache->GetWrapper(),
500 : "You should probably not be using Wrap() directly; use "
501 : "GetOrCreateDOMReflector instead");
502 :
503 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
504 : "nsISupports must be on our primary inheritance chain");
505 :
506 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
507 0 : if (!global) {
508 0 : return false;
509 : }
510 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
511 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
512 :
513 : // That might have ended up wrapping us already, due to the wonders
514 : // of XBL. Check for that, and bail out as needed.
515 0 : aReflector.set(aCache->GetWrapper());
516 0 : if (aReflector) {
517 : #ifdef DEBUG
518 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
519 : #endif // DEBUG
520 0 : return true;
521 : }
522 :
523 0 : JSAutoCompartment ac(aCx, global);
524 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
525 0 : if (!canonicalProto) {
526 0 : return false;
527 : }
528 0 : JS::Rooted<JSObject*> proto(aCx);
529 0 : if (aGivenProto) {
530 0 : proto = aGivenProto;
531 : // Unfortunately, while aGivenProto was in the compartment of aCx
532 : // coming in, we changed compartments to that of "parent" so may need
533 : // to wrap the proto here.
534 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
535 0 : if (!JS_WrapObject(aCx, &proto)) {
536 0 : return false;
537 : }
538 : }
539 : } else {
540 0 : proto = canonicalProto;
541 : }
542 :
543 0 : BindingJSObjectCreator<mozilla::dom::GamepadPose> creator(aCx);
544 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
545 0 : if (!aReflector) {
546 0 : return false;
547 : }
548 :
549 0 : aCache->SetWrapper(aReflector);
550 0 : creator.InitializationSucceeded();
551 :
552 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
553 : aCache->GetWrapperPreserveColor() == aReflector);
554 : // If proto != canonicalProto, we have to preserve our wrapper;
555 : // otherwise we won't be able to properly recreate it later, since
556 : // we won't know what proto to use. Note that we don't check
557 : // aGivenProto here, since it's entirely possible (and even
558 : // somewhat common) to have a non-null aGivenProto which is the
559 : // same as canonicalProto.
560 0 : if (proto != canonicalProto) {
561 0 : PreserveWrapper(aObject);
562 : }
563 :
564 0 : return true;
565 : }
566 :
567 : const NativePropertyHooks sNativePropertyHooks[] = { {
568 : nullptr,
569 : nullptr,
570 : nullptr,
571 : { sNativeProperties.Upcast(), nullptr },
572 : prototypes::id::GamepadPose,
573 : constructors::id::GamepadPose,
574 : nullptr,
575 : &DefaultXrayExpandoObjectClass
576 : } };
577 :
578 : void
579 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
580 : {
581 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
582 0 : if (!parentProto) {
583 0 : return;
584 : }
585 :
586 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
587 0 : if (!constructorProto) {
588 0 : return;
589 : }
590 :
591 : static bool sIdsInited = false;
592 0 : if (!sIdsInited && NS_IsMainThread()) {
593 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
594 0 : return;
595 : }
596 0 : sIdsInited = true;
597 : }
598 :
599 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GamepadPose);
600 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GamepadPose);
601 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
602 : &sPrototypeClass.mBase, protoCache,
603 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
604 : interfaceCache,
605 : sNativeProperties.Upcast(),
606 : nullptr,
607 : "GamepadPose", aDefineOnGlobal,
608 : nullptr,
609 0 : false);
610 : }
611 :
612 : JS::Handle<JSObject*>
613 0 : GetProtoObjectHandle(JSContext* aCx)
614 : {
615 : /* Get the interface prototype object for this class. This will create the
616 : object as needed. */
617 0 : bool aDefineOnGlobal = true;
618 :
619 : /* Make sure our global is sane. Hopefully we can remove this sometime */
620 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
621 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
622 0 : return nullptr;
623 : }
624 :
625 : /* Check to see whether the interface objects are already installed */
626 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
627 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::GamepadPose)) {
628 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
629 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
630 : }
631 :
632 : /*
633 : * The object might _still_ be null, but that's OK.
634 : *
635 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
636 : * traced by TraceProtoAndIfaceCache() and its contents are never
637 : * changed after they have been set.
638 : *
639 : * Calling address() avoids the read read barrier that does gray
640 : * unmarking, but it's not possible for the object to be gray here.
641 : */
642 :
643 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::GamepadPose);
644 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
645 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
646 : }
647 :
648 : JS::Handle<JSObject*>
649 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
650 : {
651 : /* Get the interface object for this class. This will create the object as
652 : needed. */
653 :
654 : /* Make sure our global is sane. Hopefully we can remove this sometime */
655 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
656 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
657 0 : return nullptr;
658 : }
659 :
660 : /* Check to see whether the interface objects are already installed */
661 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
662 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::GamepadPose)) {
663 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
664 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
665 : }
666 :
667 : /*
668 : * The object might _still_ be null, but that's OK.
669 : *
670 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
671 : * traced by TraceProtoAndIfaceCache() and its contents are never
672 : * changed after they have been set.
673 : *
674 : * Calling address() avoids the read read barrier that does gray
675 : * unmarking, but it's not possible for the object to be gray here.
676 : */
677 :
678 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::GamepadPose);
679 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
680 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
681 : }
682 :
683 : JSObject*
684 0 : GetConstructorObject(JSContext* aCx)
685 : {
686 0 : return GetConstructorObjectHandle(aCx);
687 : }
688 :
689 : } // namespace GamepadPoseBinding
690 :
691 :
692 :
693 : } // namespace dom
694 : } // namespace mozilla
|