/work/obj-fuzz/dom/bindings/GamepadHapticActuatorBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM GamepadHapticActuator.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "GamepadHapticActuatorBinding.h" |
4 | | #include "WrapperFactory.h" |
5 | | #include "jsapi.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/GamepadHapticActuator.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/PrimitiveConversions.h" |
14 | | #include "mozilla/dom/Promise.h" |
15 | | #include "mozilla/dom/ToJSValue.h" |
16 | | #include "mozilla/dom/XrayExpandoClass.h" |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
22 | | using namespace mozilla::dom::binding_detail; |
23 | | |
24 | | |
25 | | namespace GamepadHapticActuatorTypeValues { |
26 | | extern const EnumEntry strings[2] = { |
27 | | {"vibration", 9}, |
28 | | { nullptr, 0 } |
29 | | }; |
30 | | } // namespace GamepadHapticActuatorTypeValues |
31 | | |
32 | | bool |
33 | | ToJSValue(JSContext* aCx, GamepadHapticActuatorType aArgument, JS::MutableHandle<JS::Value> aValue) |
34 | 0 | { |
35 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(GamepadHapticActuatorTypeValues::strings)); |
36 | 0 | JSString* resultStr = |
37 | 0 | JS_NewStringCopyN(aCx, GamepadHapticActuatorTypeValues::strings[uint32_t(aArgument)].value, |
38 | 0 | GamepadHapticActuatorTypeValues::strings[uint32_t(aArgument)].length); |
39 | 0 | if (!resultStr) { |
40 | 0 | return false; |
41 | 0 | } |
42 | 0 | aValue.setString(resultStr); |
43 | 0 | return true; |
44 | 0 | } |
45 | | |
46 | | |
47 | | namespace GamepadHapticActuator_Binding { |
48 | | |
49 | | MOZ_CAN_RUN_SCRIPT static bool |
50 | | get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadHapticActuator* self, JSJitGetterCallArgs args) |
51 | 0 | { |
52 | 0 | AUTO_PROFILER_LABEL_FAST("get GamepadHapticActuator.type", DOM, cx); |
53 | 0 |
|
54 | 0 | GamepadHapticActuatorType result(self->Type()); |
55 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
56 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
57 | 0 | return false; |
58 | 0 | } |
59 | 0 | return true; |
60 | 0 | } |
61 | | |
62 | | static const JSJitInfo type_getterinfo = { |
63 | | { (JSJitGetterOp)get_type }, |
64 | | { prototypes::id::GamepadHapticActuator }, |
65 | | { PrototypeTraits<prototypes::id::GamepadHapticActuator>::Depth }, |
66 | | JSJitInfo::Getter, |
67 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
68 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
69 | | false, /* isInfallible. False in setters. */ |
70 | | false, /* isMovable. Not relevant for setters. */ |
71 | | false, /* isEliminatable. Not relevant for setters. */ |
72 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
73 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
74 | | false, /* isTypedMethod. Only relevant for methods. */ |
75 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
76 | | }; |
77 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
78 | | static_assert(0 < 1, "There is no slot for us"); |
79 | | |
80 | | MOZ_CAN_RUN_SCRIPT static bool |
81 | | pulse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadHapticActuator* self, const JSJitMethodCallArgs& args) |
82 | 0 | { |
83 | 0 | AUTO_PROFILER_LABEL_FAST("GamepadHapticActuator.pulse", DOM, cx); |
84 | 0 |
|
85 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
86 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "GamepadHapticActuator.pulse"); |
87 | 0 | } |
88 | 0 | double arg0; |
89 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
90 | 0 | return false; |
91 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
92 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of GamepadHapticActuator.pulse"); |
93 | 0 | return false; |
94 | 0 | } |
95 | 0 | double arg1; |
96 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) { |
97 | 0 | return false; |
98 | 0 | } else if (!mozilla::IsFinite(arg1)) { |
99 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of GamepadHapticActuator.pulse"); |
100 | 0 | return false; |
101 | 0 | } |
102 | 0 | FastErrorResult rv; |
103 | 0 | auto result(StrongOrRawPtr<Promise>(self->Pulse(arg0, arg1, rv))); |
104 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
105 | 0 | return false; |
106 | 0 | } |
107 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
108 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
109 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
110 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
111 | 0 | return false; |
112 | 0 | } |
113 | 0 | return true; |
114 | 0 | } |
115 | | |
116 | | MOZ_CAN_RUN_SCRIPT static bool |
117 | | pulse_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::GamepadHapticActuator* self, const JSJitMethodCallArgs& args) |
118 | 0 | { |
119 | 0 | bool ok = pulse(cx, obj, self, args); |
120 | 0 | if (ok) { |
121 | 0 | return true; |
122 | 0 | } |
123 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
124 | 0 | } |
125 | | |
126 | | static const JSJitInfo pulse_methodinfo = { |
127 | | { (JSJitGetterOp)pulse_promiseWrapper }, |
128 | | { prototypes::id::GamepadHapticActuator }, |
129 | | { PrototypeTraits<prototypes::id::GamepadHapticActuator>::Depth }, |
130 | | JSJitInfo::Method, |
131 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
132 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
133 | | false, /* isInfallible. False in setters. */ |
134 | | false, /* isMovable. Not relevant for setters. */ |
135 | | false, /* isEliminatable. Not relevant for setters. */ |
136 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
137 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
138 | | false, /* isTypedMethod. Only relevant for methods. */ |
139 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
140 | | }; |
141 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
142 | | static_assert(0 < 1, "There is no slot for us"); |
143 | | |
144 | | static bool |
145 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
146 | 0 | { |
147 | 0 | mozilla::dom::GamepadHapticActuator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GamepadHapticActuator>(obj); |
148 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
149 | 0 | // obviously can't preserve if we're not initialized. |
150 | 0 | if (self && self->GetWrapperPreserveColor()) { |
151 | 0 | PreserveWrapper(self); |
152 | 0 | } |
153 | 0 | return true; |
154 | 0 | } |
155 | | |
156 | | static void |
157 | | _finalize(js::FreeOp* fop, JSObject* obj) |
158 | 0 | { |
159 | 0 | mozilla::dom::GamepadHapticActuator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GamepadHapticActuator>(obj); |
160 | 0 | if (self) { |
161 | 0 | ClearWrapper(self, self, obj); |
162 | 0 | AddForDeferredFinalization<mozilla::dom::GamepadHapticActuator>(self); |
163 | 0 | } |
164 | 0 | } |
165 | | |
166 | | static size_t |
167 | | _objectMoved(JSObject* obj, JSObject* old) |
168 | 0 | { |
169 | 0 | mozilla::dom::GamepadHapticActuator* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::GamepadHapticActuator>(obj); |
170 | 0 | if (self) { |
171 | 0 | UpdateWrapper(self, self, obj, old); |
172 | 0 | } |
173 | 0 |
|
174 | 0 | return 0; |
175 | 0 | } |
176 | | |
177 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
178 | | #if defined(__clang__) |
179 | | #pragma clang diagnostic push |
180 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
181 | | #endif |
182 | | static const JSFunctionSpec sMethods_specs[] = { |
183 | | JS_FNSPEC("pulse", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&pulse_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
184 | | JS_FS_END |
185 | | }; |
186 | | #if defined(__clang__) |
187 | | #pragma clang diagnostic pop |
188 | | #endif |
189 | | |
190 | | |
191 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
192 | | { nullptr, &sMethods_specs[0] }, |
193 | | { nullptr, nullptr } |
194 | | }; |
195 | | |
196 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
197 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
198 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
199 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
200 | | |
201 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
202 | | #if defined(__clang__) |
203 | | #pragma clang diagnostic push |
204 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
205 | | #endif |
206 | | static const JSPropertySpec sAttributes_specs[] = { |
207 | | { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr }, |
208 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
209 | | }; |
210 | | #if defined(__clang__) |
211 | | #pragma clang diagnostic pop |
212 | | #endif |
213 | | |
214 | | |
215 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
216 | | { nullptr, &sAttributes_specs[0] }, |
217 | | { nullptr, nullptr } |
218 | | }; |
219 | | |
220 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
221 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
222 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
223 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
224 | | |
225 | | |
226 | | static uint16_t sNativeProperties_sortedPropertyIndices[2]; |
227 | | static PropertyInfo sNativeProperties_propertyInfos[2]; |
228 | | |
229 | | static const NativePropertiesN<2> sNativeProperties = { |
230 | | false, 0, |
231 | | false, 0, |
232 | | true, 0 /* sMethods */, |
233 | | true, 1 /* sAttributes */, |
234 | | false, 0, |
235 | | false, 0, |
236 | | false, 0, |
237 | | -1, |
238 | | 2, |
239 | | sNativeProperties_sortedPropertyIndices, |
240 | | { |
241 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
242 | | { sAttributes, &sNativeProperties_propertyInfos[1] } |
243 | | } |
244 | | }; |
245 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
246 | | "We have a property info count that is oversized"); |
247 | | |
248 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
249 | | { |
250 | | "Function", |
251 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
252 | | &sBoringInterfaceObjectClassClassOps, |
253 | | JS_NULL_CLASS_SPEC, |
254 | | JS_NULL_CLASS_EXT, |
255 | | &sInterfaceObjectClassObjectOps |
256 | | }, |
257 | | eInterface, |
258 | | true, |
259 | | prototypes::id::GamepadHapticActuator, |
260 | | PrototypeTraits<prototypes::id::GamepadHapticActuator>::Depth, |
261 | | sNativePropertyHooks, |
262 | | "function GamepadHapticActuator() {\n [native code]\n}", |
263 | | JS::GetRealmFunctionPrototype |
264 | | }; |
265 | | |
266 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
267 | | { |
268 | | "GamepadHapticActuatorPrototype", |
269 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
270 | | JS_NULL_CLASS_OPS, |
271 | | JS_NULL_CLASS_SPEC, |
272 | | JS_NULL_CLASS_EXT, |
273 | | JS_NULL_OBJECT_OPS |
274 | | }, |
275 | | eInterfacePrototype, |
276 | | false, |
277 | | prototypes::id::GamepadHapticActuator, |
278 | | PrototypeTraits<prototypes::id::GamepadHapticActuator>::Depth, |
279 | | sNativePropertyHooks, |
280 | | "[object GamepadHapticActuatorPrototype]", |
281 | | JS::GetRealmObjectPrototype |
282 | | }; |
283 | | |
284 | | bool |
285 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
286 | 0 | { |
287 | 0 | static bool sPrefValue; |
288 | 0 | static bool sPrefCacheSetUp = false; |
289 | 0 | if (!sPrefCacheSetUp) { |
290 | 0 | sPrefCacheSetUp = true; |
291 | 0 | Preferences::AddBoolVarCache(&sPrefValue, "dom.gamepad.extensions.enabled"); |
292 | 0 | } |
293 | 0 |
|
294 | 0 | return sPrefValue; |
295 | 0 | } |
296 | | |
297 | | static const js::ClassOps sClassOps = { |
298 | | _addProperty, /* addProperty */ |
299 | | nullptr, /* delProperty */ |
300 | | nullptr, /* enumerate */ |
301 | | nullptr, /* newEnumerate */ |
302 | | nullptr, /* resolve */ |
303 | | nullptr, /* mayResolve */ |
304 | | _finalize, /* finalize */ |
305 | | nullptr, /* call */ |
306 | | nullptr, /* hasInstance */ |
307 | | nullptr, /* construct */ |
308 | | nullptr, /* trace */ |
309 | | }; |
310 | | |
311 | | static const js::ClassExtension sClassExtension = { |
312 | | nullptr, /* weakmapKeyDelegateOp */ |
313 | | _objectMoved /* objectMovedOp */ |
314 | | }; |
315 | | |
316 | | static const DOMJSClass sClass = { |
317 | | { "GamepadHapticActuator", |
318 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
319 | | &sClassOps, |
320 | | JS_NULL_CLASS_SPEC, |
321 | | &sClassExtension, |
322 | | JS_NULL_OBJECT_OPS |
323 | | }, |
324 | | { prototypes::id::GamepadHapticActuator, 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 }, |
325 | | IsBaseOf<nsISupports, mozilla::dom::GamepadHapticActuator >::value, |
326 | | sNativePropertyHooks, |
327 | | FindAssociatedGlobalForNative<mozilla::dom::GamepadHapticActuator>::Get, |
328 | | GetProtoObjectHandle, |
329 | | GetCCParticipant<mozilla::dom::GamepadHapticActuator>::Get() |
330 | | }; |
331 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
332 | | "Must have the right minimal number of reserved slots."); |
333 | | static_assert(1 >= 1, |
334 | | "Must have enough reserved slots."); |
335 | | |
336 | | const JSClass* |
337 | | GetJSClass() |
338 | 0 | { |
339 | 0 | return sClass.ToJSClass(); |
340 | 0 | } |
341 | | |
342 | | bool |
343 | | Wrap(JSContext* aCx, mozilla::dom::GamepadHapticActuator* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
344 | 0 | { |
345 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::GamepadHapticActuator>::value, |
346 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
347 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::GamepadHapticActuator*>(aObject) == |
348 | 0 | reinterpret_cast<mozilla::dom::GamepadHapticActuator*>(aObject), |
349 | 0 | "Multiple inheritance for mozilla::dom::GamepadHapticActuator is broken."); |
350 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
351 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
352 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
353 | 0 | "You should probably not be using Wrap() directly; use " |
354 | 0 | "GetOrCreateDOMReflector instead"); |
355 | 0 |
|
356 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
357 | 0 | "nsISupports must be on our primary inheritance chain"); |
358 | 0 |
|
359 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
360 | 0 | if (!global) { |
361 | 0 | return false; |
362 | 0 | } |
363 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
364 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
365 | 0 |
|
366 | 0 | // That might have ended up wrapping us already, due to the wonders |
367 | 0 | // of XBL. Check for that, and bail out as needed. |
368 | 0 | aReflector.set(aCache->GetWrapper()); |
369 | 0 | if (aReflector) { |
370 | | #ifdef DEBUG |
371 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
372 | | #endif // DEBUG |
373 | | return true; |
374 | 0 | } |
375 | 0 |
|
376 | 0 | JSAutoRealm ar(aCx, global); |
377 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
378 | 0 | if (!canonicalProto) { |
379 | 0 | return false; |
380 | 0 | } |
381 | 0 | JS::Rooted<JSObject*> proto(aCx); |
382 | 0 | if (aGivenProto) { |
383 | 0 | proto = aGivenProto; |
384 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
385 | 0 | // coming in, we changed compartments to that of "parent" so may need |
386 | 0 | // to wrap the proto here. |
387 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
388 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
389 | 0 | return false; |
390 | 0 | } |
391 | 0 | } |
392 | 0 | } else { |
393 | 0 | proto = canonicalProto; |
394 | 0 | } |
395 | 0 |
|
396 | 0 | BindingJSObjectCreator<mozilla::dom::GamepadHapticActuator> creator(aCx); |
397 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
398 | 0 | if (!aReflector) { |
399 | 0 | return false; |
400 | 0 | } |
401 | 0 | |
402 | 0 | aCache->SetWrapper(aReflector); |
403 | 0 | creator.InitializationSucceeded(); |
404 | 0 |
|
405 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
406 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
407 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
408 | 0 | // otherwise we won't be able to properly recreate it later, since |
409 | 0 | // we won't know what proto to use. Note that we don't check |
410 | 0 | // aGivenProto here, since it's entirely possible (and even |
411 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
412 | 0 | // same as canonicalProto. |
413 | 0 | if (proto != canonicalProto) { |
414 | 0 | PreserveWrapper(aObject); |
415 | 0 | } |
416 | 0 |
|
417 | 0 | return true; |
418 | 0 | } |
419 | | |
420 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
421 | | nullptr, |
422 | | nullptr, |
423 | | nullptr, |
424 | | { sNativeProperties.Upcast(), nullptr }, |
425 | | prototypes::id::GamepadHapticActuator, |
426 | | constructors::id::GamepadHapticActuator, |
427 | | nullptr, |
428 | | &DefaultXrayExpandoObjectClass |
429 | | } }; |
430 | | |
431 | | void |
432 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
433 | 0 | { |
434 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
435 | 0 | if (!parentProto) { |
436 | 0 | return; |
437 | 0 | } |
438 | 0 | |
439 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
440 | 0 | if (!constructorProto) { |
441 | 0 | return; |
442 | 0 | } |
443 | 0 | |
444 | 0 | static bool sIdsInited = false; |
445 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
446 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
447 | 0 | return; |
448 | 0 | } |
449 | 0 | sIdsInited = true; |
450 | 0 | } |
451 | 0 |
|
452 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::GamepadHapticActuator); |
453 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::GamepadHapticActuator); |
454 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
455 | 0 | &sPrototypeClass.mBase, protoCache, |
456 | 0 | nullptr, |
457 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
458 | 0 | interfaceCache, |
459 | 0 | sNativeProperties.Upcast(), |
460 | 0 | nullptr, |
461 | 0 | "GamepadHapticActuator", aDefineOnGlobal, |
462 | 0 | nullptr, |
463 | 0 | false); |
464 | 0 | } |
465 | | |
466 | | JSObject* |
467 | | GetConstructorObject(JSContext* aCx) |
468 | 0 | { |
469 | 0 | return GetConstructorObjectHandle(aCx); |
470 | 0 | } |
471 | | |
472 | | } // namespace GamepadHapticActuator_Binding |
473 | | |
474 | | |
475 | | |
476 | | } // namespace dom |
477 | | } // namespace mozilla |