/work/obj-fuzz/dist/include/mozilla/dom/PushEventBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM PushEvent.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_PushEventBinding_h |
4 | | #define mozilla_dom_PushEventBinding_h |
5 | | |
6 | | #include "ExtendableEventBinding.h" |
7 | | #include "GeckoProfiler.h" |
8 | | #include "js/RootingAPI.h" |
9 | | #include "jsfriendapi.h" |
10 | | #include "jspubtd.h" |
11 | | #include "mozilla/ErrorResult.h" |
12 | | #include "mozilla/dom/BindingDeclarations.h" |
13 | | #include "mozilla/dom/FakeString.h" |
14 | | #include "mozilla/dom/Nullable.h" |
15 | | #include "mozilla/dom/PrototypeList.h" |
16 | | #include "mozilla/dom/TypedArray.h" |
17 | | #include "mozilla/dom/UnionMember.h" |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | class ArrayBufferViewOrArrayBufferOrUSVString; |
23 | | struct NativePropertyHooks; |
24 | | class OwningArrayBufferViewOrArrayBufferOrUSVString; |
25 | | class ProtoAndIfaceCache; |
26 | | class PushEvent; |
27 | | struct PushEventAtoms; |
28 | | struct PushEventInitAtoms; |
29 | | |
30 | | } // namespace dom |
31 | | } // namespace mozilla |
32 | | |
33 | | namespace mozilla { |
34 | | namespace dom { |
35 | | |
36 | | class ArrayBufferViewOrArrayBufferOrUSVString |
37 | | { |
38 | | friend class ArrayBufferViewOrArrayBufferOrUSVStringArgument; |
39 | | enum Type |
40 | | { |
41 | | eUninitialized, |
42 | | eArrayBufferView, |
43 | | eArrayBuffer, |
44 | | eUSVString |
45 | | }; |
46 | | |
47 | | union Value |
48 | | { |
49 | | UnionMember<RootedSpiderMonkeyInterface<ArrayBufferView> > mArrayBufferView; |
50 | | UnionMember<RootedSpiderMonkeyInterface<ArrayBuffer> > mArrayBuffer; |
51 | | UnionMember<binding_detail::FakeString > mUSVString; |
52 | | |
53 | | }; |
54 | | |
55 | | Type mType; |
56 | | Value mValue; |
57 | | |
58 | | ArrayBufferViewOrArrayBufferOrUSVString(const ArrayBufferViewOrArrayBufferOrUSVString&) = delete; |
59 | | ArrayBufferViewOrArrayBufferOrUSVString& operator=(const ArrayBufferViewOrArrayBufferOrUSVString&) = delete; |
60 | | public: |
61 | | explicit inline ArrayBufferViewOrArrayBufferOrUSVString() |
62 | | : mType(eUninitialized) |
63 | 0 | { |
64 | 0 | } |
65 | | |
66 | | inline ~ArrayBufferViewOrArrayBufferOrUSVString() |
67 | 0 | { |
68 | 0 | Uninit(); |
69 | 0 | } |
70 | | |
71 | | inline RootedSpiderMonkeyInterface<ArrayBufferView>& |
72 | | RawSetAsArrayBufferView(JSContext* cx) |
73 | 0 | { |
74 | 0 | if (mType == eArrayBufferView) { |
75 | 0 | return mValue.mArrayBufferView.Value(); |
76 | 0 | } |
77 | 0 | MOZ_ASSERT(mType == eUninitialized); |
78 | 0 | mType = eArrayBufferView; |
79 | 0 | return mValue.mArrayBufferView.SetValue(cx); |
80 | 0 | } |
81 | | |
82 | | inline RootedSpiderMonkeyInterface<ArrayBufferView>& |
83 | | SetAsArrayBufferView(JSContext* cx) |
84 | 0 | { |
85 | 0 | if (mType == eArrayBufferView) { |
86 | 0 | return mValue.mArrayBufferView.Value(); |
87 | 0 | } |
88 | 0 | Uninit(); |
89 | 0 | mType = eArrayBufferView; |
90 | 0 | return mValue.mArrayBufferView.SetValue(cx); |
91 | 0 | } |
92 | | |
93 | | inline bool |
94 | | IsArrayBufferView() const |
95 | 0 | { |
96 | 0 | return mType == eArrayBufferView; |
97 | 0 | } |
98 | | |
99 | | inline RootedSpiderMonkeyInterface<ArrayBufferView>& |
100 | | GetAsArrayBufferView() |
101 | 0 | { |
102 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
103 | 0 | return mValue.mArrayBufferView.Value(); |
104 | 0 | } |
105 | | |
106 | | inline ArrayBufferView const & |
107 | | GetAsArrayBufferView() const |
108 | 0 | { |
109 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
110 | 0 | return mValue.mArrayBufferView.Value(); |
111 | 0 | } |
112 | | |
113 | | inline RootedSpiderMonkeyInterface<ArrayBuffer>& |
114 | | RawSetAsArrayBuffer(JSContext* cx) |
115 | 0 | { |
116 | 0 | if (mType == eArrayBuffer) { |
117 | 0 | return mValue.mArrayBuffer.Value(); |
118 | 0 | } |
119 | 0 | MOZ_ASSERT(mType == eUninitialized); |
120 | 0 | mType = eArrayBuffer; |
121 | 0 | return mValue.mArrayBuffer.SetValue(cx); |
122 | 0 | } |
123 | | |
124 | | inline RootedSpiderMonkeyInterface<ArrayBuffer>& |
125 | | SetAsArrayBuffer(JSContext* cx) |
126 | 0 | { |
127 | 0 | if (mType == eArrayBuffer) { |
128 | 0 | return mValue.mArrayBuffer.Value(); |
129 | 0 | } |
130 | 0 | Uninit(); |
131 | 0 | mType = eArrayBuffer; |
132 | 0 | return mValue.mArrayBuffer.SetValue(cx); |
133 | 0 | } |
134 | | |
135 | | inline bool |
136 | | IsArrayBuffer() const |
137 | 0 | { |
138 | 0 | return mType == eArrayBuffer; |
139 | 0 | } |
140 | | |
141 | | inline RootedSpiderMonkeyInterface<ArrayBuffer>& |
142 | | GetAsArrayBuffer() |
143 | 0 | { |
144 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
145 | 0 | return mValue.mArrayBuffer.Value(); |
146 | 0 | } |
147 | | |
148 | | inline ArrayBuffer const & |
149 | | GetAsArrayBuffer() const |
150 | 0 | { |
151 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
152 | 0 | return mValue.mArrayBuffer.Value(); |
153 | 0 | } |
154 | | |
155 | | inline binding_detail::FakeString& |
156 | | RawSetAsUSVString() |
157 | 0 | { |
158 | 0 | if (mType == eUSVString) { |
159 | 0 | return mValue.mUSVString.Value(); |
160 | 0 | } |
161 | 0 | MOZ_ASSERT(mType == eUninitialized); |
162 | 0 | mType = eUSVString; |
163 | 0 | return mValue.mUSVString.SetValue(); |
164 | 0 | } |
165 | | |
166 | | inline binding_detail::FakeString& |
167 | | SetAsUSVString() |
168 | 0 | { |
169 | 0 | if (mType == eUSVString) { |
170 | 0 | return mValue.mUSVString.Value(); |
171 | 0 | } |
172 | 0 | Uninit(); |
173 | 0 | mType = eUSVString; |
174 | 0 | return mValue.mUSVString.SetValue(); |
175 | 0 | } |
176 | | |
177 | | inline bool |
178 | | IsUSVString() const |
179 | 0 | { |
180 | 0 | return mType == eUSVString; |
181 | 0 | } |
182 | | |
183 | | inline binding_detail::FakeString& |
184 | | GetAsUSVString() |
185 | 0 | { |
186 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
187 | 0 | return mValue.mUSVString.Value(); |
188 | 0 | } |
189 | | |
190 | | inline const nsAString& |
191 | | GetAsUSVString() const |
192 | 0 | { |
193 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
194 | 0 | return mValue.mUSVString.Value(); |
195 | 0 | } |
196 | | |
197 | | inline void |
198 | | Uninit() |
199 | 0 | { |
200 | 0 | switch (mType) { |
201 | 0 | case eUninitialized: { |
202 | 0 | break; |
203 | 0 | } |
204 | 0 | case eArrayBufferView: { |
205 | 0 | DestroyArrayBufferView(); |
206 | 0 | break; |
207 | 0 | } |
208 | 0 | case eArrayBuffer: { |
209 | 0 | DestroyArrayBuffer(); |
210 | 0 | break; |
211 | 0 | } |
212 | 0 | case eUSVString: { |
213 | 0 | DestroyUSVString(); |
214 | 0 | break; |
215 | 0 | } |
216 | 0 | } |
217 | 0 | } |
218 | | |
219 | | bool |
220 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
221 | | |
222 | | private: |
223 | | inline void |
224 | | DestroyArrayBufferView() |
225 | 0 | { |
226 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
227 | 0 | mValue.mArrayBufferView.Destroy(); |
228 | 0 | mType = eUninitialized; |
229 | 0 | } |
230 | | |
231 | | inline void |
232 | | DestroyArrayBuffer() |
233 | 0 | { |
234 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
235 | 0 | mValue.mArrayBuffer.Destroy(); |
236 | 0 | mType = eUninitialized; |
237 | 0 | } |
238 | | |
239 | | inline void |
240 | | DestroyUSVString() |
241 | 0 | { |
242 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
243 | 0 | mValue.mUSVString.Destroy(); |
244 | 0 | mType = eUninitialized; |
245 | 0 | } |
246 | | }; |
247 | | |
248 | | |
249 | | class OwningArrayBufferViewOrArrayBufferOrUSVString : public AllOwningUnionBase |
250 | | { |
251 | | friend void ImplCycleCollectionUnlink(OwningArrayBufferViewOrArrayBufferOrUSVString& aUnion); |
252 | | enum Type |
253 | | { |
254 | | eUninitialized, |
255 | | eArrayBufferView, |
256 | | eArrayBuffer, |
257 | | eUSVString |
258 | | }; |
259 | | |
260 | | union Value |
261 | | { |
262 | | UnionMember<ArrayBufferView > mArrayBufferView; |
263 | | UnionMember<ArrayBuffer > mArrayBuffer; |
264 | | UnionMember<nsString > mUSVString; |
265 | | |
266 | | }; |
267 | | |
268 | | Type mType; |
269 | | Value mValue; |
270 | | |
271 | | OwningArrayBufferViewOrArrayBufferOrUSVString(const OwningArrayBufferViewOrArrayBufferOrUSVString&) = delete; |
272 | | OwningArrayBufferViewOrArrayBufferOrUSVString& operator=(const OwningArrayBufferViewOrArrayBufferOrUSVString&) = delete; |
273 | | public: |
274 | | explicit inline OwningArrayBufferViewOrArrayBufferOrUSVString() |
275 | | : mType(eUninitialized) |
276 | 0 | { |
277 | 0 | } |
278 | | |
279 | | inline ~OwningArrayBufferViewOrArrayBufferOrUSVString() |
280 | 0 | { |
281 | 0 | Uninit(); |
282 | 0 | } |
283 | | |
284 | | ArrayBufferView& |
285 | | RawSetAsArrayBufferView(); |
286 | | |
287 | | ArrayBufferView& |
288 | | SetAsArrayBufferView(); |
289 | | |
290 | | bool |
291 | | TrySetToArrayBufferView(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
292 | | |
293 | | inline bool |
294 | | IsArrayBufferView() const |
295 | 0 | { |
296 | 0 | return mType == eArrayBufferView; |
297 | 0 | } |
298 | | |
299 | | inline ArrayBufferView& |
300 | | GetAsArrayBufferView() |
301 | 0 | { |
302 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
303 | 0 | return mValue.mArrayBufferView.Value(); |
304 | 0 | } |
305 | | |
306 | | inline ArrayBufferView const & |
307 | | GetAsArrayBufferView() const |
308 | 0 | { |
309 | 0 | MOZ_ASSERT(IsArrayBufferView(), "Wrong type!"); |
310 | 0 | return mValue.mArrayBufferView.Value(); |
311 | 0 | } |
312 | | |
313 | | ArrayBuffer& |
314 | | RawSetAsArrayBuffer(); |
315 | | |
316 | | ArrayBuffer& |
317 | | SetAsArrayBuffer(); |
318 | | |
319 | | bool |
320 | | TrySetToArrayBuffer(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
321 | | |
322 | | inline bool |
323 | | IsArrayBuffer() const |
324 | 0 | { |
325 | 0 | return mType == eArrayBuffer; |
326 | 0 | } |
327 | | |
328 | | inline ArrayBuffer& |
329 | | GetAsArrayBuffer() |
330 | 0 | { |
331 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
332 | 0 | return mValue.mArrayBuffer.Value(); |
333 | 0 | } |
334 | | |
335 | | inline ArrayBuffer const & |
336 | | GetAsArrayBuffer() const |
337 | 0 | { |
338 | 0 | MOZ_ASSERT(IsArrayBuffer(), "Wrong type!"); |
339 | 0 | return mValue.mArrayBuffer.Value(); |
340 | 0 | } |
341 | | |
342 | | nsString& |
343 | | RawSetAsUSVString(); |
344 | | |
345 | | nsString& |
346 | | SetAsUSVString(); |
347 | | |
348 | | bool |
349 | | TrySetToUSVString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
350 | | |
351 | | inline void |
352 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
353 | 0 | { |
354 | 0 | RawSetAsUSVString().Assign(aData, aLength); |
355 | 0 | } |
356 | | |
357 | | inline bool |
358 | | IsUSVString() const |
359 | 0 | { |
360 | 0 | return mType == eUSVString; |
361 | 0 | } |
362 | | |
363 | | inline nsString& |
364 | | GetAsUSVString() |
365 | 0 | { |
366 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
367 | 0 | return mValue.mUSVString.Value(); |
368 | 0 | } |
369 | | |
370 | | inline nsString const & |
371 | | GetAsUSVString() const |
372 | 0 | { |
373 | 0 | MOZ_ASSERT(IsUSVString(), "Wrong type!"); |
374 | 0 | return mValue.mUSVString.Value(); |
375 | 0 | } |
376 | | |
377 | | void |
378 | | Uninit(); |
379 | | |
380 | | bool |
381 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
382 | | |
383 | | void |
384 | | TraceUnion(JSTracer* trc); |
385 | | |
386 | | private: |
387 | | void |
388 | | DestroyArrayBufferView(); |
389 | | |
390 | | void |
391 | | DestroyArrayBuffer(); |
392 | | |
393 | | void |
394 | | DestroyUSVString(); |
395 | | }; |
396 | | |
397 | | |
398 | | struct PushEventInit : public ExtendableEventInit |
399 | | { |
400 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningArrayBufferViewOrArrayBufferOrUSVString> mData; |
401 | | |
402 | | PushEventInit(); |
403 | | |
404 | | explicit inline PushEventInit(const FastDictionaryInitializer& ) |
405 | | : ExtendableEventInit(FastDictionaryInitializer()) |
406 | 0 | { |
407 | 0 | // Do nothing here; this is used by our "Fast" subclass |
408 | 0 | } |
409 | | |
410 | | private: |
411 | | PushEventInit(const PushEventInit&) = delete; |
412 | | PushEventInit& operator=(const PushEventInit&) = delete; |
413 | | |
414 | | static bool |
415 | | InitIds(JSContext* cx, PushEventInitAtoms* atomsCache); |
416 | | |
417 | | public: |
418 | | bool |
419 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
420 | | |
421 | | bool |
422 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
423 | | |
424 | | void |
425 | | TraceDictionary(JSTracer* trc); |
426 | | }; |
427 | | |
428 | | namespace binding_detail { |
429 | | struct FastPushEventInit : public PushEventInit |
430 | | { |
431 | | inline FastPushEventInit() |
432 | | : PushEventInit(FastDictionaryInitializer()) |
433 | 0 | { |
434 | 0 | // Doesn't matter what int we pass to the parent constructor |
435 | 0 | } |
436 | | }; |
437 | | } // namespace binding_detail |
438 | | |
439 | | |
440 | | namespace PushEvent_Binding { |
441 | | |
442 | | typedef mozilla::dom::PushEvent NativeType; |
443 | | |
444 | | bool |
445 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
446 | | |
447 | | const JSClass* |
448 | | GetJSClass(); |
449 | | |
450 | | bool |
451 | | Wrap(JSContext* aCx, mozilla::dom::PushEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
452 | | |
453 | | template <class T> |
454 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
455 | 0 | { |
456 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
457 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
458 | 0 | } |
459 | | |
460 | | void |
461 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
462 | | |
463 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
464 | 0 | { |
465 | 0 | /* Get the interface prototype object for this class. This will create the |
466 | 0 | object as needed. */ |
467 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::PushEvent, |
468 | 0 | &CreateInterfaceObjects, |
469 | 0 | /* aDefineOnGlobal = */ true); |
470 | 0 |
|
471 | 0 | } |
472 | | |
473 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
474 | 0 | { |
475 | 0 | /* Get the interface object for this class. This will create the object as |
476 | 0 | needed. */ |
477 | 0 |
|
478 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::PushEvent, |
479 | 0 | &CreateInterfaceObjects, |
480 | 0 | aDefineOnGlobal); |
481 | 0 | } |
482 | | |
483 | | JSObject* |
484 | | GetConstructorObject(JSContext* aCx); |
485 | | |
486 | | } // namespace PushEvent_Binding |
487 | | |
488 | | |
489 | | |
490 | | } // namespace dom |
491 | | } // namespace mozilla |
492 | | |
493 | | #endif // mozilla_dom_PushEventBinding_h |