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