/work/obj-fuzz/dom/bindings/BatteryManagerBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM BatteryManager.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "BatteryManager.h" |
4 | | #include "BatteryManagerBinding.h" |
5 | | #include "EventHandlerBinding.h" |
6 | | #include "EventTargetBinding.h" |
7 | | #include "WrapperFactory.h" |
8 | | #include "mozilla/FloatingPoint.h" |
9 | | #include "mozilla/OwningNonNull.h" |
10 | | #include "mozilla/dom/BindingUtils.h" |
11 | | #include "mozilla/dom/DOMJSClass.h" |
12 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrimitiveConversions.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 BatteryManager_Binding { |
25 | | |
26 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
27 | | "Can't inherit from an interface with a different ownership model."); |
28 | | |
29 | | MOZ_CAN_RUN_SCRIPT static bool |
30 | | get_charging(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
31 | 0 | { |
32 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.charging", DOM, cx); |
33 | 0 |
|
34 | 0 | bool result(self->Charging()); |
35 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
36 | 0 | args.rval().setBoolean(result); |
37 | 0 | return true; |
38 | 0 | } |
39 | | |
40 | | static const JSJitInfo charging_getterinfo = { |
41 | | { (JSJitGetterOp)get_charging }, |
42 | | { prototypes::id::BatteryManager }, |
43 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
44 | | JSJitInfo::Getter, |
45 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
46 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
47 | | true, /* isInfallible. False in setters. */ |
48 | | false, /* isMovable. Not relevant for setters. */ |
49 | | false, /* isEliminatable. Not relevant for setters. */ |
50 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
51 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
52 | | false, /* isTypedMethod. Only relevant for methods. */ |
53 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
54 | | }; |
55 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
56 | | static_assert(0 < 1, "There is no slot for us"); |
57 | | |
58 | | MOZ_CAN_RUN_SCRIPT static bool |
59 | | get_chargingTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
60 | 0 | { |
61 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.chargingTime", DOM, cx); |
62 | 0 |
|
63 | 0 | double result(self->ChargingTime()); |
64 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
65 | 0 | args.rval().set(JS_NumberValue(double(result))); |
66 | 0 | return true; |
67 | 0 | } |
68 | | |
69 | | static const JSJitInfo chargingTime_getterinfo = { |
70 | | { (JSJitGetterOp)get_chargingTime }, |
71 | | { prototypes::id::BatteryManager }, |
72 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
73 | | JSJitInfo::Getter, |
74 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
75 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
76 | | true, /* isInfallible. False in setters. */ |
77 | | false, /* isMovable. Not relevant for setters. */ |
78 | | false, /* isEliminatable. Not relevant for setters. */ |
79 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
80 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
81 | | false, /* isTypedMethod. Only relevant for methods. */ |
82 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
83 | | }; |
84 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
85 | | static_assert(0 < 1, "There is no slot for us"); |
86 | | |
87 | | MOZ_CAN_RUN_SCRIPT static bool |
88 | | get_dischargingTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
89 | 0 | { |
90 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.dischargingTime", DOM, cx); |
91 | 0 |
|
92 | 0 | double result(self->DischargingTime()); |
93 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
94 | 0 | args.rval().set(JS_NumberValue(double(result))); |
95 | 0 | return true; |
96 | 0 | } |
97 | | |
98 | | static const JSJitInfo dischargingTime_getterinfo = { |
99 | | { (JSJitGetterOp)get_dischargingTime }, |
100 | | { prototypes::id::BatteryManager }, |
101 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
102 | | JSJitInfo::Getter, |
103 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
104 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
105 | | true, /* isInfallible. False in setters. */ |
106 | | false, /* isMovable. Not relevant for setters. */ |
107 | | false, /* isEliminatable. Not relevant for setters. */ |
108 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
109 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
110 | | false, /* isTypedMethod. Only relevant for methods. */ |
111 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
112 | | }; |
113 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
114 | | static_assert(0 < 1, "There is no slot for us"); |
115 | | |
116 | | MOZ_CAN_RUN_SCRIPT static bool |
117 | | get_level(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
118 | 0 | { |
119 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.level", DOM, cx); |
120 | 0 |
|
121 | 0 | double result(self->Level()); |
122 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
123 | 0 | args.rval().set(JS_NumberValue(double(result))); |
124 | 0 | return true; |
125 | 0 | } |
126 | | |
127 | | static const JSJitInfo level_getterinfo = { |
128 | | { (JSJitGetterOp)get_level }, |
129 | | { prototypes::id::BatteryManager }, |
130 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
131 | | JSJitInfo::Getter, |
132 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
133 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
134 | | true, /* isInfallible. False in setters. */ |
135 | | false, /* isMovable. Not relevant for setters. */ |
136 | | false, /* isEliminatable. Not relevant for setters. */ |
137 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
138 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
139 | | false, /* isTypedMethod. Only relevant for methods. */ |
140 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
141 | | }; |
142 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
143 | | static_assert(0 < 1, "There is no slot for us"); |
144 | | |
145 | | MOZ_CAN_RUN_SCRIPT static bool |
146 | | get_onchargingchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
147 | 0 | { |
148 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.onchargingchange", DOM, cx); |
149 | 0 |
|
150 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnchargingchange()); |
151 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
152 | 0 | if (result) { |
153 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
154 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
155 | 0 | return false; |
156 | 0 | } |
157 | 0 | return true; |
158 | 0 | } else { |
159 | 0 | args.rval().setNull(); |
160 | 0 | return true; |
161 | 0 | } |
162 | 0 | } |
163 | | |
164 | | MOZ_CAN_RUN_SCRIPT static bool |
165 | | set_onchargingchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitSetterCallArgs args) |
166 | 0 | { |
167 | 0 | AUTO_PROFILER_LABEL_FAST("set BatteryManager.onchargingchange", DOM, cx); |
168 | 0 |
|
169 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
170 | 0 | if (args[0].isObject()) { |
171 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
172 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
173 | 0 | } |
174 | 0 | } else { |
175 | 0 | arg0 = nullptr; |
176 | 0 | } |
177 | 0 | self->SetOnchargingchange(Constify(arg0)); |
178 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
179 | 0 |
|
180 | 0 | return true; |
181 | 0 | } |
182 | | |
183 | | static const JSJitInfo onchargingchange_getterinfo = { |
184 | | { (JSJitGetterOp)get_onchargingchange }, |
185 | | { prototypes::id::BatteryManager }, |
186 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
187 | | JSJitInfo::Getter, |
188 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
189 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
190 | | false, /* isInfallible. False in setters. */ |
191 | | false, /* isMovable. Not relevant for setters. */ |
192 | | false, /* isEliminatable. Not relevant for setters. */ |
193 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
194 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
195 | | false, /* isTypedMethod. Only relevant for methods. */ |
196 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
197 | | }; |
198 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
199 | | static_assert(0 < 1, "There is no slot for us"); |
200 | | static const JSJitInfo onchargingchange_setterinfo = { |
201 | | { (JSJitGetterOp)set_onchargingchange }, |
202 | | { prototypes::id::BatteryManager }, |
203 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
204 | | JSJitInfo::Setter, |
205 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
206 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
207 | | false, /* isInfallible. False in setters. */ |
208 | | false, /* isMovable. Not relevant for setters. */ |
209 | | false, /* isEliminatable. Not relevant for setters. */ |
210 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
211 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
212 | | false, /* isTypedMethod. Only relevant for methods. */ |
213 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
214 | | }; |
215 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
216 | | static_assert(0 < 1, "There is no slot for us"); |
217 | | |
218 | | MOZ_CAN_RUN_SCRIPT static bool |
219 | | get_onchargingtimechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
220 | 0 | { |
221 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.onchargingtimechange", DOM, cx); |
222 | 0 |
|
223 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnchargingtimechange()); |
224 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
225 | 0 | if (result) { |
226 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
227 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
228 | 0 | return false; |
229 | 0 | } |
230 | 0 | return true; |
231 | 0 | } else { |
232 | 0 | args.rval().setNull(); |
233 | 0 | return true; |
234 | 0 | } |
235 | 0 | } |
236 | | |
237 | | MOZ_CAN_RUN_SCRIPT static bool |
238 | | set_onchargingtimechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitSetterCallArgs args) |
239 | 0 | { |
240 | 0 | AUTO_PROFILER_LABEL_FAST("set BatteryManager.onchargingtimechange", DOM, cx); |
241 | 0 |
|
242 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
243 | 0 | if (args[0].isObject()) { |
244 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
245 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
246 | 0 | } |
247 | 0 | } else { |
248 | 0 | arg0 = nullptr; |
249 | 0 | } |
250 | 0 | self->SetOnchargingtimechange(Constify(arg0)); |
251 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
252 | 0 |
|
253 | 0 | return true; |
254 | 0 | } |
255 | | |
256 | | static const JSJitInfo onchargingtimechange_getterinfo = { |
257 | | { (JSJitGetterOp)get_onchargingtimechange }, |
258 | | { prototypes::id::BatteryManager }, |
259 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
260 | | JSJitInfo::Getter, |
261 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
262 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
263 | | false, /* isInfallible. False in setters. */ |
264 | | false, /* isMovable. Not relevant for setters. */ |
265 | | false, /* isEliminatable. Not relevant for setters. */ |
266 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
267 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
268 | | false, /* isTypedMethod. Only relevant for methods. */ |
269 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
270 | | }; |
271 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
272 | | static_assert(0 < 1, "There is no slot for us"); |
273 | | static const JSJitInfo onchargingtimechange_setterinfo = { |
274 | | { (JSJitGetterOp)set_onchargingtimechange }, |
275 | | { prototypes::id::BatteryManager }, |
276 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
277 | | JSJitInfo::Setter, |
278 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
279 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
280 | | false, /* isInfallible. False in setters. */ |
281 | | false, /* isMovable. Not relevant for setters. */ |
282 | | false, /* isEliminatable. Not relevant for setters. */ |
283 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
284 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
285 | | false, /* isTypedMethod. Only relevant for methods. */ |
286 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
287 | | }; |
288 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
289 | | static_assert(0 < 1, "There is no slot for us"); |
290 | | |
291 | | MOZ_CAN_RUN_SCRIPT static bool |
292 | | get_ondischargingtimechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
293 | 0 | { |
294 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.ondischargingtimechange", DOM, cx); |
295 | 0 |
|
296 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOndischargingtimechange()); |
297 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
298 | 0 | if (result) { |
299 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
300 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
301 | 0 | return false; |
302 | 0 | } |
303 | 0 | return true; |
304 | 0 | } else { |
305 | 0 | args.rval().setNull(); |
306 | 0 | return true; |
307 | 0 | } |
308 | 0 | } |
309 | | |
310 | | MOZ_CAN_RUN_SCRIPT static bool |
311 | | set_ondischargingtimechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitSetterCallArgs args) |
312 | 0 | { |
313 | 0 | AUTO_PROFILER_LABEL_FAST("set BatteryManager.ondischargingtimechange", DOM, cx); |
314 | 0 |
|
315 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
316 | 0 | if (args[0].isObject()) { |
317 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
318 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
319 | 0 | } |
320 | 0 | } else { |
321 | 0 | arg0 = nullptr; |
322 | 0 | } |
323 | 0 | self->SetOndischargingtimechange(Constify(arg0)); |
324 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
325 | 0 |
|
326 | 0 | return true; |
327 | 0 | } |
328 | | |
329 | | static const JSJitInfo ondischargingtimechange_getterinfo = { |
330 | | { (JSJitGetterOp)get_ondischargingtimechange }, |
331 | | { prototypes::id::BatteryManager }, |
332 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
333 | | JSJitInfo::Getter, |
334 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
335 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
336 | | false, /* isInfallible. False in setters. */ |
337 | | false, /* isMovable. Not relevant for setters. */ |
338 | | false, /* isEliminatable. Not relevant for setters. */ |
339 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
340 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
341 | | false, /* isTypedMethod. Only relevant for methods. */ |
342 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
343 | | }; |
344 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
345 | | static_assert(0 < 1, "There is no slot for us"); |
346 | | static const JSJitInfo ondischargingtimechange_setterinfo = { |
347 | | { (JSJitGetterOp)set_ondischargingtimechange }, |
348 | | { prototypes::id::BatteryManager }, |
349 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
350 | | JSJitInfo::Setter, |
351 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
352 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
353 | | false, /* isInfallible. False in setters. */ |
354 | | false, /* isMovable. Not relevant for setters. */ |
355 | | false, /* isEliminatable. Not relevant for setters. */ |
356 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
357 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
358 | | false, /* isTypedMethod. Only relevant for methods. */ |
359 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
360 | | }; |
361 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
362 | | static_assert(0 < 1, "There is no slot for us"); |
363 | | |
364 | | MOZ_CAN_RUN_SCRIPT static bool |
365 | | get_onlevelchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitGetterCallArgs args) |
366 | 0 | { |
367 | 0 | AUTO_PROFILER_LABEL_FAST("get BatteryManager.onlevelchange", DOM, cx); |
368 | 0 |
|
369 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnlevelchange()); |
370 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
371 | 0 | if (result) { |
372 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
373 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
374 | 0 | return false; |
375 | 0 | } |
376 | 0 | return true; |
377 | 0 | } else { |
378 | 0 | args.rval().setNull(); |
379 | 0 | return true; |
380 | 0 | } |
381 | 0 | } |
382 | | |
383 | | MOZ_CAN_RUN_SCRIPT static bool |
384 | | set_onlevelchange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::battery::BatteryManager* self, JSJitSetterCallArgs args) |
385 | 0 | { |
386 | 0 | AUTO_PROFILER_LABEL_FAST("set BatteryManager.onlevelchange", DOM, cx); |
387 | 0 |
|
388 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
389 | 0 | if (args[0].isObject()) { |
390 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
391 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
392 | 0 | } |
393 | 0 | } else { |
394 | 0 | arg0 = nullptr; |
395 | 0 | } |
396 | 0 | self->SetOnlevelchange(Constify(arg0)); |
397 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
398 | 0 |
|
399 | 0 | return true; |
400 | 0 | } |
401 | | |
402 | | static const JSJitInfo onlevelchange_getterinfo = { |
403 | | { (JSJitGetterOp)get_onlevelchange }, |
404 | | { prototypes::id::BatteryManager }, |
405 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
406 | | JSJitInfo::Getter, |
407 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
408 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
409 | | false, /* isInfallible. False in setters. */ |
410 | | false, /* isMovable. Not relevant for setters. */ |
411 | | false, /* isEliminatable. Not relevant for setters. */ |
412 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
413 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
414 | | false, /* isTypedMethod. Only relevant for methods. */ |
415 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
416 | | }; |
417 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
418 | | static_assert(0 < 1, "There is no slot for us"); |
419 | | static const JSJitInfo onlevelchange_setterinfo = { |
420 | | { (JSJitGetterOp)set_onlevelchange }, |
421 | | { prototypes::id::BatteryManager }, |
422 | | { PrototypeTraits<prototypes::id::BatteryManager>::Depth }, |
423 | | JSJitInfo::Setter, |
424 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
425 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
426 | | false, /* isInfallible. False in setters. */ |
427 | | false, /* isMovable. Not relevant for setters. */ |
428 | | false, /* isEliminatable. Not relevant for setters. */ |
429 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
430 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
431 | | false, /* isTypedMethod. Only relevant for methods. */ |
432 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
433 | | }; |
434 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
435 | | static_assert(0 < 1, "There is no slot for us"); |
436 | | |
437 | | static bool |
438 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
439 | 0 | { |
440 | 0 | mozilla::dom::battery::BatteryManager* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::battery::BatteryManager>(obj); |
441 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
442 | 0 | // obviously can't preserve if we're not initialized. |
443 | 0 | if (self && self->GetWrapperPreserveColor()) { |
444 | 0 | PreserveWrapper(self); |
445 | 0 | } |
446 | 0 | return true; |
447 | 0 | } |
448 | | |
449 | | static void |
450 | | _finalize(js::FreeOp* fop, JSObject* obj) |
451 | 0 | { |
452 | 0 | mozilla::dom::battery::BatteryManager* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::battery::BatteryManager>(obj); |
453 | 0 | if (self) { |
454 | 0 | ClearWrapper(self, self, obj); |
455 | 0 | AddForDeferredFinalization<mozilla::dom::battery::BatteryManager>(self); |
456 | 0 | } |
457 | 0 | } |
458 | | |
459 | | static size_t |
460 | | _objectMoved(JSObject* obj, JSObject* old) |
461 | 0 | { |
462 | 0 | mozilla::dom::battery::BatteryManager* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::battery::BatteryManager>(obj); |
463 | 0 | if (self) { |
464 | 0 | UpdateWrapper(self, self, obj, old); |
465 | 0 | } |
466 | 0 |
|
467 | 0 | return 0; |
468 | 0 | } |
469 | | |
470 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
471 | | #if defined(__clang__) |
472 | | #pragma clang diagnostic push |
473 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
474 | | #endif |
475 | | static const JSPropertySpec sAttributes_specs[] = { |
476 | | { "charging", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &charging_getterinfo, nullptr, nullptr }, |
477 | | { "chargingTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &chargingTime_getterinfo, nullptr, nullptr }, |
478 | | { "dischargingTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &dischargingTime_getterinfo, nullptr, nullptr }, |
479 | | { "level", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &level_getterinfo, nullptr, nullptr }, |
480 | | { "onchargingchange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onchargingchange_getterinfo, GenericSetter<NormalThisPolicy>, &onchargingchange_setterinfo }, |
481 | | { "onchargingtimechange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onchargingtimechange_getterinfo, GenericSetter<NormalThisPolicy>, &onchargingtimechange_setterinfo }, |
482 | | { "ondischargingtimechange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &ondischargingtimechange_getterinfo, GenericSetter<NormalThisPolicy>, &ondischargingtimechange_setterinfo }, |
483 | | { "onlevelchange", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onlevelchange_getterinfo, GenericSetter<NormalThisPolicy>, &onlevelchange_setterinfo }, |
484 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
485 | | }; |
486 | | #if defined(__clang__) |
487 | | #pragma clang diagnostic pop |
488 | | #endif |
489 | | |
490 | | |
491 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
492 | | { nullptr, &sAttributes_specs[0] }, |
493 | | { nullptr, nullptr } |
494 | | }; |
495 | | |
496 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
497 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
498 | | static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
499 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
500 | | |
501 | | |
502 | | static uint16_t sNativeProperties_sortedPropertyIndices[8]; |
503 | | static PropertyInfo sNativeProperties_propertyInfos[8]; |
504 | | |
505 | | static const NativePropertiesN<1> sNativeProperties = { |
506 | | false, 0, |
507 | | false, 0, |
508 | | false, 0, |
509 | | true, 0 /* sAttributes */, |
510 | | false, 0, |
511 | | false, 0, |
512 | | false, 0, |
513 | | -1, |
514 | | 8, |
515 | | sNativeProperties_sortedPropertyIndices, |
516 | | { |
517 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
518 | | } |
519 | | }; |
520 | | static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
521 | | "We have a property info count that is oversized"); |
522 | | |
523 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
524 | | { |
525 | | "Function", |
526 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
527 | | &sBoringInterfaceObjectClassClassOps, |
528 | | JS_NULL_CLASS_SPEC, |
529 | | JS_NULL_CLASS_EXT, |
530 | | &sInterfaceObjectClassObjectOps |
531 | | }, |
532 | | eInterface, |
533 | | true, |
534 | | prototypes::id::BatteryManager, |
535 | | PrototypeTraits<prototypes::id::BatteryManager>::Depth, |
536 | | sNativePropertyHooks, |
537 | | "function BatteryManager() {\n [native code]\n}", |
538 | | EventTarget_Binding::GetConstructorObject |
539 | | }; |
540 | | |
541 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
542 | | { |
543 | | "BatteryManagerPrototype", |
544 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
545 | | JS_NULL_CLASS_OPS, |
546 | | JS_NULL_CLASS_SPEC, |
547 | | JS_NULL_CLASS_EXT, |
548 | | JS_NULL_OBJECT_OPS |
549 | | }, |
550 | | eInterfacePrototype, |
551 | | false, |
552 | | prototypes::id::BatteryManager, |
553 | | PrototypeTraits<prototypes::id::BatteryManager>::Depth, |
554 | | sNativePropertyHooks, |
555 | | "[object BatteryManagerPrototype]", |
556 | | EventTarget_Binding::GetProtoObject |
557 | | }; |
558 | | |
559 | | static const js::ClassOps sClassOps = { |
560 | | _addProperty, /* addProperty */ |
561 | | nullptr, /* delProperty */ |
562 | | nullptr, /* enumerate */ |
563 | | nullptr, /* newEnumerate */ |
564 | | nullptr, /* resolve */ |
565 | | nullptr, /* mayResolve */ |
566 | | _finalize, /* finalize */ |
567 | | nullptr, /* call */ |
568 | | nullptr, /* hasInstance */ |
569 | | nullptr, /* construct */ |
570 | | nullptr, /* trace */ |
571 | | }; |
572 | | |
573 | | static const js::ClassExtension sClassExtension = { |
574 | | nullptr, /* weakmapKeyDelegateOp */ |
575 | | _objectMoved /* objectMovedOp */ |
576 | | }; |
577 | | |
578 | | static const DOMJSClass sClass = { |
579 | | { "BatteryManager", |
580 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
581 | | &sClassOps, |
582 | | JS_NULL_CLASS_SPEC, |
583 | | &sClassExtension, |
584 | | JS_NULL_OBJECT_OPS |
585 | | }, |
586 | | { prototypes::id::EventTarget, prototypes::id::BatteryManager, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
587 | | IsBaseOf<nsISupports, mozilla::dom::battery::BatteryManager >::value, |
588 | | sNativePropertyHooks, |
589 | | FindAssociatedGlobalForNative<mozilla::dom::battery::BatteryManager>::Get, |
590 | | GetProtoObjectHandle, |
591 | | GetCCParticipant<mozilla::dom::battery::BatteryManager>::Get() |
592 | | }; |
593 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
594 | | "Must have the right minimal number of reserved slots."); |
595 | | static_assert(1 >= 1, |
596 | | "Must have enough reserved slots."); |
597 | | |
598 | | const JSClass* |
599 | | GetJSClass() |
600 | 0 | { |
601 | 0 | return sClass.ToJSClass(); |
602 | 0 | } |
603 | | |
604 | | bool |
605 | | Wrap(JSContext* aCx, mozilla::dom::battery::BatteryManager* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
606 | 0 | { |
607 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::battery::BatteryManager>::value, |
608 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
609 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::battery::BatteryManager*>(aObject) == |
610 | 0 | reinterpret_cast<mozilla::dom::battery::BatteryManager*>(aObject), |
611 | 0 | "Multiple inheritance for mozilla::dom::battery::BatteryManager is broken."); |
612 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
613 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
614 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
615 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
616 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
617 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
618 | 0 | "You should probably not be using Wrap() directly; use " |
619 | 0 | "GetOrCreateDOMReflector instead"); |
620 | 0 |
|
621 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
622 | 0 | "nsISupports must be on our primary inheritance chain"); |
623 | 0 |
|
624 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
625 | 0 | if (!global) { |
626 | 0 | return false; |
627 | 0 | } |
628 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
629 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
630 | 0 |
|
631 | 0 | // That might have ended up wrapping us already, due to the wonders |
632 | 0 | // of XBL. Check for that, and bail out as needed. |
633 | 0 | aReflector.set(aCache->GetWrapper()); |
634 | 0 | if (aReflector) { |
635 | | #ifdef DEBUG |
636 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
637 | | #endif // DEBUG |
638 | | return true; |
639 | 0 | } |
640 | 0 |
|
641 | 0 | JSAutoRealm ar(aCx, global); |
642 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
643 | 0 | if (!canonicalProto) { |
644 | 0 | return false; |
645 | 0 | } |
646 | 0 | JS::Rooted<JSObject*> proto(aCx); |
647 | 0 | if (aGivenProto) { |
648 | 0 | proto = aGivenProto; |
649 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
650 | 0 | // coming in, we changed compartments to that of "parent" so may need |
651 | 0 | // to wrap the proto here. |
652 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
653 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
654 | 0 | return false; |
655 | 0 | } |
656 | 0 | } |
657 | 0 | } else { |
658 | 0 | proto = canonicalProto; |
659 | 0 | } |
660 | 0 |
|
661 | 0 | BindingJSObjectCreator<mozilla::dom::battery::BatteryManager> creator(aCx); |
662 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
663 | 0 | if (!aReflector) { |
664 | 0 | return false; |
665 | 0 | } |
666 | 0 | |
667 | 0 | aCache->SetWrapper(aReflector); |
668 | 0 | creator.InitializationSucceeded(); |
669 | 0 |
|
670 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
671 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
672 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
673 | 0 | // otherwise we won't be able to properly recreate it later, since |
674 | 0 | // we won't know what proto to use. Note that we don't check |
675 | 0 | // aGivenProto here, since it's entirely possible (and even |
676 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
677 | 0 | // same as canonicalProto. |
678 | 0 | if (proto != canonicalProto) { |
679 | 0 | PreserveWrapper(aObject); |
680 | 0 | } |
681 | 0 |
|
682 | 0 | return true; |
683 | 0 | } |
684 | | |
685 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
686 | | nullptr, |
687 | | nullptr, |
688 | | nullptr, |
689 | | { sNativeProperties.Upcast(), nullptr }, |
690 | | prototypes::id::BatteryManager, |
691 | | constructors::id::BatteryManager, |
692 | | EventTarget_Binding::sNativePropertyHooks, |
693 | | &DefaultXrayExpandoObjectClass |
694 | | } }; |
695 | | |
696 | | void |
697 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
698 | 0 | { |
699 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
700 | 0 | if (!parentProto) { |
701 | 0 | return; |
702 | 0 | } |
703 | 0 | |
704 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
705 | 0 | if (!constructorProto) { |
706 | 0 | return; |
707 | 0 | } |
708 | 0 | |
709 | 0 | static bool sIdsInited = false; |
710 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
711 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
712 | 0 | return; |
713 | 0 | } |
714 | 0 | sIdsInited = true; |
715 | 0 | } |
716 | 0 |
|
717 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::BatteryManager); |
718 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::BatteryManager); |
719 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
720 | 0 | &sPrototypeClass.mBase, protoCache, |
721 | 0 | nullptr, |
722 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
723 | 0 | interfaceCache, |
724 | 0 | sNativeProperties.Upcast(), |
725 | 0 | nullptr, |
726 | 0 | "BatteryManager", aDefineOnGlobal, |
727 | 0 | nullptr, |
728 | 0 | false); |
729 | 0 | } |
730 | | |
731 | | JSObject* |
732 | | GetConstructorObject(JSContext* aCx) |
733 | 0 | { |
734 | 0 | return GetConstructorObjectHandle(aCx); |
735 | 0 | } |
736 | | |
737 | | } // namespace BatteryManager_Binding |
738 | | |
739 | | |
740 | | |
741 | | } // namespace dom |
742 | | } // namespace mozilla |