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