/work/obj-fuzz/dist/include/mozilla/dom/BaseAudioContextBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM BaseAudioContext.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_BaseAudioContextBinding_h |
4 | | #define mozilla_dom_BaseAudioContextBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "js/RootingAPI.h" |
8 | | #include "jspubtd.h" |
9 | | #include "mozilla/ErrorResult.h" |
10 | | #include "mozilla/dom/BindingDeclarations.h" |
11 | | #include "mozilla/dom/CallbackFunction.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "mozilla/dom/PrototypeList.h" |
14 | | #include "mozilla/dom/ToJSValue.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | class AudioBuffer; |
20 | | class AudioContext; |
21 | | struct AudioContextAtoms; |
22 | | class DOMException; |
23 | | class DecodeErrorCallback; |
24 | | class DecodeSuccessCallback; |
25 | | struct NativePropertyHooks; |
26 | | class ProtoAndIfaceCache; |
27 | | |
28 | | } // namespace dom |
29 | | } // namespace mozilla |
30 | | |
31 | | namespace mozilla { |
32 | | namespace dom { |
33 | | |
34 | | enum class AudioContextState : uint8_t { |
35 | | Suspended, |
36 | | Running, |
37 | | Closed, |
38 | | EndGuard_ |
39 | | }; |
40 | | |
41 | | namespace AudioContextStateValues { |
42 | | extern const EnumEntry strings[4]; |
43 | | } // namespace AudioContextStateValues |
44 | | |
45 | | bool |
46 | | ToJSValue(JSContext* aCx, AudioContextState aArgument, JS::MutableHandle<JS::Value> aValue); |
47 | | |
48 | | |
49 | | class DecodeSuccessCallback : public CallbackFunction |
50 | | { |
51 | | public: |
52 | | explicit inline DecodeSuccessCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
53 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
54 | 0 | { |
55 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
56 | 0 | } |
57 | | |
58 | | explicit inline DecodeSuccessCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
59 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
60 | 0 | { |
61 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
62 | 0 | } |
63 | | |
64 | | explicit inline DecodeSuccessCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
65 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
66 | 0 | { |
67 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
68 | 0 | } |
69 | | |
70 | | explicit inline DecodeSuccessCallback(CallbackFunction* aOther) |
71 | | : CallbackFunction(aOther) |
72 | 0 | { |
73 | 0 | } |
74 | | |
75 | | template <typename T> |
76 | | inline void |
77 | | Call(const T& thisVal, AudioBuffer& decodedData, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
78 | | { |
79 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
80 | | if (!aExecutionReason) { |
81 | | aExecutionReason = "DecodeSuccessCallback"; |
82 | | } |
83 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
84 | | if (!s.GetContext()) { |
85 | | MOZ_ASSERT(aRv.Failed()); |
86 | | return; |
87 | | } |
88 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
89 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
90 | | aRv.Throw(NS_ERROR_FAILURE); |
91 | | return; |
92 | | } |
93 | | return Call(s.GetContext(), thisValJS, decodedData, aRv); |
94 | | } |
95 | | |
96 | | inline void |
97 | | Call(AudioBuffer& decodedData, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
98 | 0 | { |
99 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
100 | 0 | if (!aExecutionReason) { |
101 | 0 | aExecutionReason = "DecodeSuccessCallback"; |
102 | 0 | } |
103 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
104 | 0 | if (!s.GetContext()) { |
105 | 0 | MOZ_ASSERT(aRv.Failed()); |
106 | 0 | return; |
107 | 0 | } |
108 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, decodedData, aRv); |
109 | 0 | } |
110 | | |
111 | | template <typename T> |
112 | | inline void |
113 | | Call(const T& thisVal, AudioBuffer& decodedData, const char* aExecutionReason = nullptr) |
114 | | { |
115 | | return Call(thisVal, decodedData, IgnoreErrors(), aExecutionReason); |
116 | | } |
117 | | |
118 | | inline void |
119 | | Call(AudioBuffer& decodedData, const char* aExecutionReason = nullptr) |
120 | 0 | { |
121 | 0 | return Call(decodedData, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
122 | 0 | } |
123 | | |
124 | | inline bool |
125 | | operator==(const DecodeSuccessCallback& aOther) const |
126 | 0 | { |
127 | 0 | return CallbackFunction::operator==(aOther); |
128 | 0 | } |
129 | | |
130 | | private: |
131 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, AudioBuffer& decodedData, ErrorResult& aRv); |
132 | | }; |
133 | | |
134 | | |
135 | | class DecodeErrorCallback : public CallbackFunction |
136 | | { |
137 | | public: |
138 | | explicit inline DecodeErrorCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
139 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
140 | 0 | { |
141 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
142 | 0 | } |
143 | | |
144 | | explicit inline DecodeErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
145 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
146 | 0 | { |
147 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
148 | 0 | } |
149 | | |
150 | | explicit inline DecodeErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
151 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
152 | 0 | { |
153 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
154 | 0 | } |
155 | | |
156 | | explicit inline DecodeErrorCallback(CallbackFunction* aOther) |
157 | | : CallbackFunction(aOther) |
158 | 0 | { |
159 | 0 | } |
160 | | |
161 | | template <typename T> |
162 | | inline void |
163 | | Call(const T& thisVal, DOMException& error, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
164 | | { |
165 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
166 | | if (!aExecutionReason) { |
167 | | aExecutionReason = "DecodeErrorCallback"; |
168 | | } |
169 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
170 | | if (!s.GetContext()) { |
171 | | MOZ_ASSERT(aRv.Failed()); |
172 | | return; |
173 | | } |
174 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
175 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
176 | | aRv.Throw(NS_ERROR_FAILURE); |
177 | | return; |
178 | | } |
179 | | return Call(s.GetContext(), thisValJS, error, aRv); |
180 | | } |
181 | | |
182 | | inline void |
183 | | Call(DOMException& error, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
184 | 0 | { |
185 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
186 | 0 | if (!aExecutionReason) { |
187 | 0 | aExecutionReason = "DecodeErrorCallback"; |
188 | 0 | } |
189 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
190 | 0 | if (!s.GetContext()) { |
191 | 0 | MOZ_ASSERT(aRv.Failed()); |
192 | 0 | return; |
193 | 0 | } |
194 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, error, aRv); |
195 | 0 | } |
196 | | |
197 | | template <typename T> |
198 | | inline void |
199 | | Call(const T& thisVal, DOMException& error, const char* aExecutionReason = nullptr) |
200 | | { |
201 | | return Call(thisVal, error, IgnoreErrors(), aExecutionReason); |
202 | | } |
203 | | |
204 | | inline void |
205 | | Call(DOMException& error, const char* aExecutionReason = nullptr) |
206 | 0 | { |
207 | 0 | return Call(error, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
208 | 0 | } |
209 | | |
210 | | inline bool |
211 | | operator==(const DecodeErrorCallback& aOther) const |
212 | 0 | { |
213 | 0 | return CallbackFunction::operator==(aOther); |
214 | 0 | } |
215 | | |
216 | | private: |
217 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, DOMException& error, ErrorResult& aRv); |
218 | | }; |
219 | | |
220 | | |
221 | | namespace binding_detail { |
222 | | class FastDecodeSuccessCallback : public DecodeSuccessCallback |
223 | | { |
224 | | public: |
225 | | explicit inline FastDecodeSuccessCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
226 | | : DecodeSuccessCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
227 | 0 | { |
228 | 0 | } |
229 | | |
230 | | inline void |
231 | | Trace(JSTracer* aTracer) |
232 | 0 | { |
233 | 0 | DecodeSuccessCallback::Trace(aTracer); |
234 | 0 | } |
235 | | |
236 | | inline void |
237 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
238 | 0 | { |
239 | 0 | DecodeSuccessCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
240 | 0 | } |
241 | | }; |
242 | | } // namespace binding_detail |
243 | | |
244 | | |
245 | | namespace binding_detail { |
246 | | class FastDecodeErrorCallback : public DecodeErrorCallback |
247 | | { |
248 | | public: |
249 | | explicit inline FastDecodeErrorCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
250 | | : DecodeErrorCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
251 | 0 | { |
252 | 0 | } |
253 | | |
254 | | inline void |
255 | | Trace(JSTracer* aTracer) |
256 | 0 | { |
257 | 0 | DecodeErrorCallback::Trace(aTracer); |
258 | 0 | } |
259 | | |
260 | | inline void |
261 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
262 | 0 | { |
263 | 0 | DecodeErrorCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
264 | 0 | } |
265 | | }; |
266 | | } // namespace binding_detail |
267 | | |
268 | | |
269 | | namespace BaseAudioContext_Binding { |
270 | | |
271 | | typedef mozilla::dom::AudioContext NativeType; |
272 | | |
273 | | const JSClass* |
274 | | GetJSClass(); |
275 | | |
276 | | bool |
277 | | Wrap(JSContext* aCx, mozilla::dom::AudioContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
278 | | |
279 | | template <class T> |
280 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
281 | | { |
282 | | JS::Rooted<JSObject*> reflector(aCx); |
283 | | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
284 | | } |
285 | | |
286 | | // We declare this as an array so that retrieving a pointer to this |
287 | | // binding's property hooks only requires compile/link-time resolvable |
288 | | // address arithmetic. Declaring it as a pointer instead would require |
289 | | // doing a run-time load to fetch a pointer to this binding's property |
290 | | // hooks. And then structures which embedded a pointer to this structure |
291 | | // would require a run-time load for proper initialization, which would |
292 | | // then induce static constructors. Lots of static constructors. |
293 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
294 | | |
295 | | void |
296 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
297 | | |
298 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
299 | 0 | { |
300 | 0 | /* Get the interface prototype object for this class. This will create the |
301 | 0 | object as needed. */ |
302 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::BaseAudioContext, |
303 | 0 | &CreateInterfaceObjects, |
304 | 0 | /* aDefineOnGlobal = */ true); |
305 | 0 |
|
306 | 0 | } |
307 | | |
308 | | JSObject* |
309 | | GetProtoObject(JSContext* aCx); |
310 | | |
311 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
312 | 0 | { |
313 | 0 | /* Get the interface object for this class. This will create the object as |
314 | 0 | needed. */ |
315 | 0 |
|
316 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::BaseAudioContext, |
317 | 0 | &CreateInterfaceObjects, |
318 | 0 | aDefineOnGlobal); |
319 | 0 | } |
320 | | |
321 | | JSObject* |
322 | | GetConstructorObject(JSContext* aCx); |
323 | | |
324 | | } // namespace BaseAudioContext_Binding |
325 | | |
326 | | |
327 | | |
328 | | } // namespace dom |
329 | | } // namespace mozilla |
330 | | |
331 | | #endif // mozilla_dom_BaseAudioContextBinding_h |