/work/obj-fuzz/dist/include/mozilla/dom/FunctionBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Function.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_FunctionBinding_h |
4 | | #define mozilla_dom_FunctionBinding_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/ToJSValue.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace dom { |
17 | | |
18 | | class Function; |
19 | | struct NativePropertyHooks; |
20 | | class ProtoAndIfaceCache; |
21 | | class VoidFunction; |
22 | | |
23 | | } // namespace dom |
24 | | } // namespace mozilla |
25 | | |
26 | | namespace mozilla { |
27 | | namespace dom { |
28 | | |
29 | | class Function : public CallbackFunction |
30 | | { |
31 | | public: |
32 | | explicit inline Function(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
33 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
34 | 0 | { |
35 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
36 | 0 | } |
37 | | |
38 | | explicit inline Function(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
39 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
40 | 0 | { |
41 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
42 | 0 | } |
43 | | |
44 | | explicit inline Function(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
45 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
46 | 0 | { |
47 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
48 | 0 | } |
49 | | |
50 | | explicit inline Function(CallbackFunction* aOther) |
51 | | : CallbackFunction(aOther) |
52 | 0 | { |
53 | 0 | } |
54 | | |
55 | | template <typename T> |
56 | | inline void |
57 | | Call(const T& thisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
58 | 0 | { |
59 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
60 | 0 | if (!aExecutionReason) { |
61 | 0 | aExecutionReason = "Function"; |
62 | 0 | } |
63 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
64 | 0 | if (!s.GetContext()) { |
65 | 0 | MOZ_ASSERT(aRv.Failed()); |
66 | 0 | return; |
67 | 0 | } |
68 | 0 | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
69 | 0 | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
70 | 0 | aRv.Throw(NS_ERROR_FAILURE); |
71 | 0 | return; |
72 | 0 | } |
73 | 0 | return Call(s.GetContext(), thisValJS, arguments, aRetVal, aRv); |
74 | 0 | } Unexecuted instantiation: void mozilla::dom::Function::Call<nsCOMPtr<nsISupports> >(nsCOMPtr<nsISupports> const&, nsTArray<JS::Value> const&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObject::ExceptionHandling, JS::Realm*) Unexecuted instantiation: void mozilla::dom::Function::Call<mozilla::dom::WorkerGlobalScope*>(mozilla::dom::WorkerGlobalScope* const&, nsTArray<JS::Value> const&, JS::MutableHandle<JS::Value>, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObject::ExceptionHandling, JS::Realm*) |
75 | | |
76 | | inline void |
77 | | Call(const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
78 | 0 | { |
79 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
80 | 0 | if (!aExecutionReason) { |
81 | 0 | aExecutionReason = "Function"; |
82 | 0 | } |
83 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
84 | 0 | if (!s.GetContext()) { |
85 | 0 | MOZ_ASSERT(aRv.Failed()); |
86 | 0 | return; |
87 | 0 | } |
88 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, arguments, aRetVal, aRv); |
89 | 0 | } |
90 | | |
91 | | template <typename T> |
92 | | inline void |
93 | | Call(const T& thisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
94 | | { |
95 | | return Call(thisVal, arguments, aRetVal, IgnoreErrors(), aExecutionReason); |
96 | | } |
97 | | |
98 | | inline void |
99 | | Call(const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, const char* aExecutionReason = nullptr) |
100 | 0 | { |
101 | 0 | return Call(arguments, aRetVal, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
102 | 0 | } |
103 | | |
104 | | inline bool |
105 | | operator==(const Function& aOther) const |
106 | 0 | { |
107 | 0 | return CallbackFunction::operator==(aOther); |
108 | 0 | } |
109 | | |
110 | | private: |
111 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsTArray<JS::Value>& arguments, JS::MutableHandle<JS::Value> aRetVal, ErrorResult& aRv); |
112 | | }; |
113 | | |
114 | | |
115 | | class VoidFunction : public CallbackFunction |
116 | | { |
117 | | public: |
118 | | explicit inline VoidFunction(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
119 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
120 | 0 | { |
121 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
122 | 0 | } |
123 | | |
124 | | explicit inline VoidFunction(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
125 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
126 | 0 | { |
127 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
128 | 0 | } |
129 | | |
130 | | explicit inline VoidFunction(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
131 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
132 | 0 | { |
133 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
134 | 0 | } |
135 | | |
136 | | explicit inline VoidFunction(CallbackFunction* aOther) |
137 | | : CallbackFunction(aOther) |
138 | 0 | { |
139 | 0 | } |
140 | | |
141 | | template <typename T> |
142 | | inline void |
143 | | Call(const T& thisVal, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
144 | | { |
145 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
146 | | if (!aExecutionReason) { |
147 | | aExecutionReason = "VoidFunction"; |
148 | | } |
149 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
150 | | if (!s.GetContext()) { |
151 | | MOZ_ASSERT(aRv.Failed()); |
152 | | return; |
153 | | } |
154 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
155 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
156 | | aRv.Throw(NS_ERROR_FAILURE); |
157 | | return; |
158 | | } |
159 | | return Call(s.GetContext(), thisValJS, aRv); |
160 | | } |
161 | | |
162 | | inline void |
163 | | Call(ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
164 | 0 | { |
165 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
166 | 0 | if (!aExecutionReason) { |
167 | 0 | aExecutionReason = "VoidFunction"; |
168 | 0 | } |
169 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
170 | 0 | if (!s.GetContext()) { |
171 | 0 | MOZ_ASSERT(aRv.Failed()); |
172 | 0 | return; |
173 | 0 | } |
174 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, aRv); |
175 | 0 | } |
176 | | |
177 | | template <typename T> |
178 | | inline void |
179 | | Call(const T& thisVal, const char* aExecutionReason = nullptr) |
180 | | { |
181 | | return Call(thisVal, IgnoreErrors(), aExecutionReason); |
182 | | } |
183 | | |
184 | | inline void |
185 | | Call(const char* aExecutionReason = nullptr) |
186 | 0 | { |
187 | 0 | return Call(IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
188 | 0 | } |
189 | | |
190 | | inline bool |
191 | | operator==(const VoidFunction& aOther) const |
192 | 0 | { |
193 | 0 | return CallbackFunction::operator==(aOther); |
194 | 0 | } |
195 | | |
196 | | private: |
197 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, ErrorResult& aRv); |
198 | | }; |
199 | | |
200 | | |
201 | | namespace binding_detail { |
202 | | class FastFunction : public Function |
203 | | { |
204 | | public: |
205 | | explicit inline FastFunction(JSObject* aCallback, JSObject* aCallbackGlobal) |
206 | | : Function(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
207 | 0 | { |
208 | 0 | } |
209 | | |
210 | | inline void |
211 | | Trace(JSTracer* aTracer) |
212 | 0 | { |
213 | 0 | Function::Trace(aTracer); |
214 | 0 | } |
215 | | |
216 | | inline void |
217 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
218 | 0 | { |
219 | 0 | Function::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
220 | 0 | } |
221 | | }; |
222 | | } // namespace binding_detail |
223 | | |
224 | | |
225 | | namespace binding_detail { |
226 | | class FastVoidFunction : public VoidFunction |
227 | | { |
228 | | public: |
229 | | explicit inline FastVoidFunction(JSObject* aCallback, JSObject* aCallbackGlobal) |
230 | | : VoidFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
231 | 0 | { |
232 | 0 | } |
233 | | |
234 | | inline void |
235 | | Trace(JSTracer* aTracer) |
236 | 0 | { |
237 | 0 | VoidFunction::Trace(aTracer); |
238 | 0 | } |
239 | | |
240 | | inline void |
241 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
242 | 0 | { |
243 | 0 | VoidFunction::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
244 | 0 | } |
245 | | }; |
246 | | } // namespace binding_detail |
247 | | |
248 | | |
249 | | } // namespace dom |
250 | | } // namespace mozilla |
251 | | |
252 | | #endif // mozilla_dom_FunctionBinding_h |