/work/obj-fuzz/dist/include/mozilla/dom/MediaStreamBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM MediaStream.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_MediaStreamBinding_h |
4 | | #define mozilla_dom_MediaStreamBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "MediaStreamTrackBinding.h" |
8 | | #include "js/RootingAPI.h" |
9 | | #include "jspubtd.h" |
10 | | #include "mozilla/ErrorResult.h" |
11 | | #include "mozilla/dom/BindingDeclarations.h" |
12 | | #include "mozilla/dom/FakeString.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrototypeList.h" |
15 | | #include "mozilla/dom/UnionMember.h" |
16 | | |
17 | | namespace mozilla { |
18 | | |
19 | | class DOMMediaStream; |
20 | | struct DOMMediaStreamAtoms; |
21 | | |
22 | | namespace dom { |
23 | | |
24 | | class BooleanOrMediaTrackConstraints; |
25 | | struct MediaStreamConstraintsAtoms; |
26 | | struct NativePropertyHooks; |
27 | | class OwningBooleanOrMediaTrackConstraints; |
28 | | class ProtoAndIfaceCache; |
29 | | |
30 | | } // namespace dom |
31 | | |
32 | | } // namespace mozilla |
33 | | |
34 | | namespace mozilla { |
35 | | namespace dom { |
36 | | |
37 | | class BooleanOrMediaTrackConstraints |
38 | | { |
39 | | friend class BooleanOrMediaTrackConstraintsArgument; |
40 | | enum Type |
41 | | { |
42 | | eUninitialized, |
43 | | eBoolean, |
44 | | eMediaTrackConstraints |
45 | | }; |
46 | | |
47 | | union Value |
48 | | { |
49 | | UnionMember<bool > mBoolean; |
50 | | UnionMember<binding_detail::FastMediaTrackConstraints > mMediaTrackConstraints; |
51 | | |
52 | | }; |
53 | | |
54 | | Type mType; |
55 | | Value mValue; |
56 | | |
57 | | BooleanOrMediaTrackConstraints(const BooleanOrMediaTrackConstraints&) = delete; |
58 | | BooleanOrMediaTrackConstraints& operator=(const BooleanOrMediaTrackConstraints&) = delete; |
59 | | public: |
60 | | explicit inline BooleanOrMediaTrackConstraints() |
61 | | : mType(eUninitialized) |
62 | 0 | { |
63 | 0 | } |
64 | | |
65 | | inline ~BooleanOrMediaTrackConstraints() |
66 | 0 | { |
67 | 0 | Uninit(); |
68 | 0 | } |
69 | | |
70 | | inline bool& |
71 | | RawSetAsBoolean() |
72 | 0 | { |
73 | 0 | if (mType == eBoolean) { |
74 | 0 | return mValue.mBoolean.Value(); |
75 | 0 | } |
76 | 0 | MOZ_ASSERT(mType == eUninitialized); |
77 | 0 | mType = eBoolean; |
78 | 0 | return mValue.mBoolean.SetValue(); |
79 | 0 | } |
80 | | |
81 | | inline bool& |
82 | | SetAsBoolean() |
83 | 0 | { |
84 | 0 | if (mType == eBoolean) { |
85 | 0 | return mValue.mBoolean.Value(); |
86 | 0 | } |
87 | 0 | Uninit(); |
88 | 0 | mType = eBoolean; |
89 | 0 | return mValue.mBoolean.SetValue(); |
90 | 0 | } |
91 | | |
92 | | inline bool |
93 | | IsBoolean() const |
94 | 0 | { |
95 | 0 | return mType == eBoolean; |
96 | 0 | } |
97 | | |
98 | | inline bool& |
99 | | GetAsBoolean() |
100 | 0 | { |
101 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
102 | 0 | return mValue.mBoolean.Value(); |
103 | 0 | } |
104 | | |
105 | | inline bool |
106 | | GetAsBoolean() const |
107 | 0 | { |
108 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
109 | 0 | return mValue.mBoolean.Value(); |
110 | 0 | } |
111 | | |
112 | | inline binding_detail::FastMediaTrackConstraints& |
113 | | RawSetAsMediaTrackConstraints() |
114 | 0 | { |
115 | 0 | if (mType == eMediaTrackConstraints) { |
116 | 0 | return mValue.mMediaTrackConstraints.Value(); |
117 | 0 | } |
118 | 0 | MOZ_ASSERT(mType == eUninitialized); |
119 | 0 | mType = eMediaTrackConstraints; |
120 | 0 | return mValue.mMediaTrackConstraints.SetValue(); |
121 | 0 | } |
122 | | |
123 | | inline binding_detail::FastMediaTrackConstraints& |
124 | | SetAsMediaTrackConstraints() |
125 | 0 | { |
126 | 0 | if (mType == eMediaTrackConstraints) { |
127 | 0 | return mValue.mMediaTrackConstraints.Value(); |
128 | 0 | } |
129 | 0 | Uninit(); |
130 | 0 | mType = eMediaTrackConstraints; |
131 | 0 | return mValue.mMediaTrackConstraints.SetValue(); |
132 | 0 | } |
133 | | |
134 | | inline bool |
135 | | IsMediaTrackConstraints() const |
136 | 0 | { |
137 | 0 | return mType == eMediaTrackConstraints; |
138 | 0 | } |
139 | | |
140 | | inline binding_detail::FastMediaTrackConstraints& |
141 | | GetAsMediaTrackConstraints() |
142 | 0 | { |
143 | 0 | MOZ_ASSERT(IsMediaTrackConstraints(), "Wrong type!"); |
144 | 0 | return mValue.mMediaTrackConstraints.Value(); |
145 | 0 | } |
146 | | |
147 | | inline const MediaTrackConstraints& |
148 | | GetAsMediaTrackConstraints() const |
149 | 0 | { |
150 | 0 | MOZ_ASSERT(IsMediaTrackConstraints(), "Wrong type!"); |
151 | 0 | return mValue.mMediaTrackConstraints.Value(); |
152 | 0 | } |
153 | | |
154 | | inline void |
155 | | Uninit() |
156 | 0 | { |
157 | 0 | switch (mType) { |
158 | 0 | case eUninitialized: { |
159 | 0 | break; |
160 | 0 | } |
161 | 0 | case eBoolean: { |
162 | 0 | DestroyBoolean(); |
163 | 0 | break; |
164 | 0 | } |
165 | 0 | case eMediaTrackConstraints: { |
166 | 0 | DestroyMediaTrackConstraints(); |
167 | 0 | break; |
168 | 0 | } |
169 | 0 | } |
170 | 0 | } |
171 | | |
172 | | bool |
173 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
174 | | |
175 | | private: |
176 | | inline void |
177 | | DestroyBoolean() |
178 | 0 | { |
179 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
180 | 0 | mValue.mBoolean.Destroy(); |
181 | 0 | mType = eUninitialized; |
182 | 0 | } |
183 | | |
184 | | inline void |
185 | | DestroyMediaTrackConstraints() |
186 | 0 | { |
187 | 0 | MOZ_ASSERT(IsMediaTrackConstraints(), "Wrong type!"); |
188 | 0 | mValue.mMediaTrackConstraints.Destroy(); |
189 | 0 | mType = eUninitialized; |
190 | 0 | } |
191 | | }; |
192 | | |
193 | | |
194 | | class OwningBooleanOrMediaTrackConstraints : public AllOwningUnionBase |
195 | | { |
196 | | friend void ImplCycleCollectionUnlink(OwningBooleanOrMediaTrackConstraints& aUnion); |
197 | | enum Type |
198 | | { |
199 | | eUninitialized, |
200 | | eBoolean, |
201 | | eMediaTrackConstraints |
202 | | }; |
203 | | |
204 | | union Value |
205 | | { |
206 | | UnionMember<bool > mBoolean; |
207 | | UnionMember<MediaTrackConstraints > mMediaTrackConstraints; |
208 | | |
209 | | }; |
210 | | |
211 | | Type mType; |
212 | | Value mValue; |
213 | | |
214 | | public: |
215 | | explicit inline OwningBooleanOrMediaTrackConstraints() |
216 | | : mType(eUninitialized) |
217 | 0 | { |
218 | 0 | } |
219 | | |
220 | | explicit inline OwningBooleanOrMediaTrackConstraints(const OwningBooleanOrMediaTrackConstraints& aOther) |
221 | | : mType(eUninitialized) |
222 | 0 | { |
223 | 0 | *this = aOther; |
224 | 0 | } |
225 | | |
226 | | inline ~OwningBooleanOrMediaTrackConstraints() |
227 | 0 | { |
228 | 0 | Uninit(); |
229 | 0 | } |
230 | | |
231 | | bool& |
232 | | RawSetAsBoolean(); |
233 | | |
234 | | bool& |
235 | | SetAsBoolean(); |
236 | | |
237 | | bool |
238 | | TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
239 | | |
240 | | inline bool |
241 | | IsBoolean() const |
242 | 0 | { |
243 | 0 | return mType == eBoolean; |
244 | 0 | } |
245 | | |
246 | | inline bool& |
247 | | GetAsBoolean() |
248 | 0 | { |
249 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
250 | 0 | return mValue.mBoolean.Value(); |
251 | 0 | } |
252 | | |
253 | | inline bool const & |
254 | | GetAsBoolean() const |
255 | 0 | { |
256 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
257 | 0 | return mValue.mBoolean.Value(); |
258 | 0 | } |
259 | | |
260 | | MediaTrackConstraints& |
261 | | RawSetAsMediaTrackConstraints(); |
262 | | |
263 | | MediaTrackConstraints& |
264 | | SetAsMediaTrackConstraints(); |
265 | | |
266 | | bool |
267 | | TrySetToMediaTrackConstraints(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
268 | | |
269 | | inline bool |
270 | | IsMediaTrackConstraints() const |
271 | 0 | { |
272 | 0 | return mType == eMediaTrackConstraints; |
273 | 0 | } |
274 | | |
275 | | inline MediaTrackConstraints& |
276 | | GetAsMediaTrackConstraints() |
277 | 0 | { |
278 | 0 | MOZ_ASSERT(IsMediaTrackConstraints(), "Wrong type!"); |
279 | 0 | return mValue.mMediaTrackConstraints.Value(); |
280 | 0 | } |
281 | | |
282 | | inline MediaTrackConstraints const & |
283 | | GetAsMediaTrackConstraints() const |
284 | 0 | { |
285 | 0 | MOZ_ASSERT(IsMediaTrackConstraints(), "Wrong type!"); |
286 | 0 | return mValue.mMediaTrackConstraints.Value(); |
287 | 0 | } |
288 | | |
289 | | void |
290 | | Uninit(); |
291 | | |
292 | | bool |
293 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
294 | | |
295 | | void |
296 | | TraceUnion(JSTracer* trc); |
297 | | |
298 | | OwningBooleanOrMediaTrackConstraints& |
299 | | operator=(const OwningBooleanOrMediaTrackConstraints& aOther); |
300 | | |
301 | | private: |
302 | | void |
303 | | DestroyBoolean(); |
304 | | |
305 | | void |
306 | | DestroyMediaTrackConstraints(); |
307 | | }; |
308 | | |
309 | | |
310 | | struct MediaStreamConstraints : public DictionaryBase |
311 | | { |
312 | | MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrMediaTrackConstraints mAudio; |
313 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mFake; |
314 | | MOZ_INIT_OUTSIDE_CTOR nsString mPeerIdentity; |
315 | | MOZ_INIT_OUTSIDE_CTOR bool mPicture; |
316 | | MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrMediaTrackConstraints mVideo; |
317 | | |
318 | | MediaStreamConstraints(); |
319 | | |
320 | | explicit inline MediaStreamConstraints(const FastDictionaryInitializer& ) |
321 | 0 | { |
322 | 0 | // Do nothing here; this is used by our "Fast" subclass |
323 | 0 | } |
324 | | |
325 | | explicit inline MediaStreamConstraints(const MediaStreamConstraints& aOther) |
326 | 0 | { |
327 | 0 | *this = aOther; |
328 | 0 | } |
329 | | |
330 | | bool |
331 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
332 | | |
333 | | bool |
334 | | Init(const nsAString& aJSON); |
335 | | |
336 | | bool |
337 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
338 | | |
339 | | bool |
340 | | ToJSON(nsAString& aJSON) const; |
341 | | |
342 | | void |
343 | | TraceDictionary(JSTracer* trc); |
344 | | |
345 | | MediaStreamConstraints& |
346 | | operator=(const MediaStreamConstraints& aOther); |
347 | | |
348 | | private: |
349 | | static bool |
350 | | InitIds(JSContext* cx, MediaStreamConstraintsAtoms* atomsCache); |
351 | | }; |
352 | | |
353 | | namespace binding_detail { |
354 | | struct FastMediaStreamConstraints : public MediaStreamConstraints |
355 | | { |
356 | | inline FastMediaStreamConstraints() |
357 | | : MediaStreamConstraints(FastDictionaryInitializer()) |
358 | 0 | { |
359 | 0 | // Doesn't matter what int we pass to the parent constructor |
360 | 0 | } |
361 | | }; |
362 | | } // namespace binding_detail |
363 | | |
364 | | |
365 | | namespace MediaStream_Binding { |
366 | | |
367 | | typedef mozilla::DOMMediaStream NativeType; |
368 | | |
369 | | const JSClass* |
370 | | GetJSClass(); |
371 | | |
372 | | bool |
373 | | Wrap(JSContext* aCx, mozilla::DOMMediaStream* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
374 | | |
375 | | template <class T> |
376 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
377 | 0 | { |
378 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
379 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
380 | 0 | } |
381 | | |
382 | | // We declare this as an array so that retrieving a pointer to this |
383 | | // binding's property hooks only requires compile/link-time resolvable |
384 | | // address arithmetic. Declaring it as a pointer instead would require |
385 | | // doing a run-time load to fetch a pointer to this binding's property |
386 | | // hooks. And then structures which embedded a pointer to this structure |
387 | | // would require a run-time load for proper initialization, which would |
388 | | // then induce static constructors. Lots of static constructors. |
389 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
390 | | |
391 | | void |
392 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
393 | | |
394 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
395 | 0 | { |
396 | 0 | /* Get the interface prototype object for this class. This will create the |
397 | 0 | object as needed. */ |
398 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::MediaStream, |
399 | 0 | &CreateInterfaceObjects, |
400 | 0 | /* aDefineOnGlobal = */ true); |
401 | 0 |
|
402 | 0 | } |
403 | | |
404 | | JSObject* |
405 | | GetProtoObject(JSContext* aCx); |
406 | | |
407 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
408 | 0 | { |
409 | 0 | /* Get the interface object for this class. This will create the object as |
410 | 0 | needed. */ |
411 | 0 |
|
412 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::MediaStream, |
413 | 0 | &CreateInterfaceObjects, |
414 | 0 | aDefineOnGlobal); |
415 | 0 | } |
416 | | |
417 | | JSObject* |
418 | | GetConstructorObject(JSContext* aCx); |
419 | | |
420 | | } // namespace MediaStream_Binding |
421 | | |
422 | | |
423 | | |
424 | | } // namespace dom |
425 | | } // namespace mozilla |
426 | | |
427 | | #endif // mozilla_dom_MediaStreamBinding_h |