/work/obj-fuzz/dist/include/mozilla/dom/L10nUtilsBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM L10nUtils.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_L10nUtilsBinding_h |
4 | | #define mozilla_dom_L10nUtilsBinding_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 | | struct AttributeNameValue; |
19 | | struct AttributeNameValueAtoms; |
20 | | class L10nCallback; |
21 | | struct L10nElement; |
22 | | struct L10nElementAtoms; |
23 | | struct L10nValueAtoms; |
24 | | struct NativePropertyHooks; |
25 | | class Promise; |
26 | | class ProtoAndIfaceCache; |
27 | | |
28 | | } // namespace dom |
29 | | } // namespace mozilla |
30 | | |
31 | | namespace mozilla { |
32 | | namespace dom { |
33 | | |
34 | | struct AttributeNameValue : public DictionaryBase |
35 | | { |
36 | | MOZ_INIT_OUTSIDE_CTOR nsString mName; |
37 | | MOZ_INIT_OUTSIDE_CTOR nsString mValue; |
38 | | |
39 | | AttributeNameValue(); |
40 | | |
41 | | explicit inline AttributeNameValue(const FastDictionaryInitializer& ) |
42 | 0 | { |
43 | 0 | // Do nothing here; this is used by our "Fast" subclass |
44 | 0 | } |
45 | | |
46 | | explicit inline AttributeNameValue(const AttributeNameValue& aOther) |
47 | 0 | { |
48 | 0 | *this = aOther; |
49 | 0 | } |
50 | | |
51 | | bool |
52 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
53 | | |
54 | | bool |
55 | | Init(const nsAString& aJSON); |
56 | | |
57 | | bool |
58 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
59 | | |
60 | | bool |
61 | | ToJSON(nsAString& aJSON) const; |
62 | | |
63 | | void |
64 | | TraceDictionary(JSTracer* trc); |
65 | | |
66 | | AttributeNameValue& |
67 | | operator=(const AttributeNameValue& aOther); |
68 | | |
69 | | private: |
70 | | static bool |
71 | | InitIds(JSContext* cx, AttributeNameValueAtoms* atomsCache); |
72 | | }; |
73 | | |
74 | | namespace binding_detail { |
75 | | struct FastAttributeNameValue : public AttributeNameValue |
76 | | { |
77 | | inline FastAttributeNameValue() |
78 | | : AttributeNameValue(FastDictionaryInitializer()) |
79 | 0 | { |
80 | 0 | // Doesn't matter what int we pass to the parent constructor |
81 | 0 | } |
82 | | }; |
83 | | } // namespace binding_detail |
84 | | |
85 | | |
86 | | struct L10nElement : public DictionaryBase |
87 | | { |
88 | | MOZ_INIT_OUTSIDE_CTOR JSObject* mL10nArgs; |
89 | | MOZ_INIT_OUTSIDE_CTOR nsString mL10nAttrs; |
90 | | MOZ_INIT_OUTSIDE_CTOR nsString mL10nId; |
91 | | MOZ_INIT_OUTSIDE_CTOR nsString mLocalName; |
92 | | MOZ_INIT_OUTSIDE_CTOR nsString mNamespaceURI; |
93 | | MOZ_INIT_OUTSIDE_CTOR nsString mType; |
94 | | |
95 | | L10nElement(); |
96 | | |
97 | | explicit inline L10nElement(const FastDictionaryInitializer& ) |
98 | | : mL10nArgs(nullptr) |
99 | 0 | { |
100 | 0 | // Do nothing here; this is used by our "Fast" subclass |
101 | 0 | } |
102 | | |
103 | | private: |
104 | | L10nElement(const L10nElement&) = delete; |
105 | | L10nElement& operator=(const L10nElement&) = delete; |
106 | | |
107 | | static bool |
108 | | InitIds(JSContext* cx, L10nElementAtoms* atomsCache); |
109 | | |
110 | | public: |
111 | | bool |
112 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
113 | | |
114 | | bool |
115 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
116 | | |
117 | | void |
118 | | TraceDictionary(JSTracer* trc); |
119 | | }; |
120 | | |
121 | | namespace binding_detail { |
122 | | struct FastL10nElement : public L10nElement |
123 | | { |
124 | | inline FastL10nElement() |
125 | | : L10nElement(FastDictionaryInitializer()) |
126 | 0 | { |
127 | 0 | // Doesn't matter what int we pass to the parent constructor |
128 | 0 | } |
129 | | }; |
130 | | } // namespace binding_detail |
131 | | |
132 | | |
133 | | struct L10nValue : public DictionaryBase |
134 | | { |
135 | | MOZ_INIT_OUTSIDE_CTOR Nullable<Sequence<AttributeNameValue>> mAttributes; |
136 | | MOZ_INIT_OUTSIDE_CTOR nsString mValue; |
137 | | |
138 | | L10nValue(); |
139 | | |
140 | | explicit inline L10nValue(const FastDictionaryInitializer& ) |
141 | 0 | { |
142 | 0 | // Do nothing here; this is used by our "Fast" subclass |
143 | 0 | } |
144 | | |
145 | | explicit inline L10nValue(const L10nValue& aOther) |
146 | 0 | { |
147 | 0 | *this = aOther; |
148 | 0 | } |
149 | | |
150 | | bool |
151 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
152 | | |
153 | | bool |
154 | | Init(const nsAString& aJSON); |
155 | | |
156 | | bool |
157 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
158 | | |
159 | | bool |
160 | | ToJSON(nsAString& aJSON) const; |
161 | | |
162 | | void |
163 | | TraceDictionary(JSTracer* trc); |
164 | | |
165 | | L10nValue& |
166 | | operator=(const L10nValue& aOther); |
167 | | |
168 | | private: |
169 | | static bool |
170 | | InitIds(JSContext* cx, L10nValueAtoms* atomsCache); |
171 | | }; |
172 | | |
173 | | namespace binding_detail { |
174 | | struct FastL10nValue : public L10nValue |
175 | | { |
176 | | inline FastL10nValue() |
177 | | : L10nValue(FastDictionaryInitializer()) |
178 | 0 | { |
179 | 0 | // Doesn't matter what int we pass to the parent constructor |
180 | 0 | } |
181 | | }; |
182 | | } // namespace binding_detail |
183 | | |
184 | | |
185 | | class L10nCallback : public CallbackFunction |
186 | | { |
187 | | public: |
188 | | explicit inline L10nCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
189 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
190 | 0 | { |
191 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
192 | 0 | } |
193 | | |
194 | | explicit inline L10nCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
195 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
196 | 0 | { |
197 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
198 | 0 | } |
199 | | |
200 | | explicit inline L10nCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
201 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
202 | 0 | { |
203 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
204 | 0 | } |
205 | | |
206 | | explicit inline L10nCallback(CallbackFunction* aOther) |
207 | | : CallbackFunction(aOther) |
208 | 0 | { |
209 | 0 | } |
210 | | |
211 | | template <typename T> |
212 | | inline already_AddRefed<Promise> |
213 | | Call(const T& thisVal, const Sequence<L10nElement>& l10nElements, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
214 | | { |
215 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
216 | | if (!aExecutionReason) { |
217 | | aExecutionReason = "L10nCallback"; |
218 | | } |
219 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
220 | | if (!s.GetContext()) { |
221 | | MOZ_ASSERT(aRv.Failed()); |
222 | | return nullptr; |
223 | | } |
224 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
225 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
226 | | aRv.Throw(NS_ERROR_FAILURE); |
227 | | return nullptr; |
228 | | } |
229 | | return Call(s.GetContext(), thisValJS, l10nElements, aRv); |
230 | | } |
231 | | |
232 | | inline already_AddRefed<Promise> |
233 | | Call(const Sequence<L10nElement>& l10nElements, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
234 | 0 | { |
235 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
236 | 0 | if (!aExecutionReason) { |
237 | 0 | aExecutionReason = "L10nCallback"; |
238 | 0 | } |
239 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
240 | 0 | if (!s.GetContext()) { |
241 | 0 | MOZ_ASSERT(aRv.Failed()); |
242 | 0 | return nullptr; |
243 | 0 | } |
244 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, l10nElements, aRv); |
245 | 0 | } |
246 | | |
247 | | template <typename T> |
248 | | inline already_AddRefed<Promise> |
249 | | Call(const T& thisVal, const Sequence<L10nElement>& l10nElements, const char* aExecutionReason = nullptr) |
250 | | { |
251 | | return Call(thisVal, l10nElements, IgnoreErrors(), aExecutionReason); |
252 | | } |
253 | | |
254 | | inline already_AddRefed<Promise> |
255 | | Call(const Sequence<L10nElement>& l10nElements, const char* aExecutionReason = nullptr) |
256 | 0 | { |
257 | 0 | return Call(l10nElements, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
258 | 0 | } |
259 | | |
260 | | inline bool |
261 | | operator==(const L10nCallback& aOther) const |
262 | 0 | { |
263 | 0 | return CallbackFunction::operator==(aOther); |
264 | 0 | } |
265 | | |
266 | | private: |
267 | | already_AddRefed<Promise> Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const Sequence<L10nElement>& l10nElements, ErrorResult& aRv); |
268 | | }; |
269 | | |
270 | | |
271 | | namespace binding_detail { |
272 | | class FastL10nCallback : public L10nCallback |
273 | | { |
274 | | public: |
275 | | explicit inline FastL10nCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
276 | | : L10nCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
277 | 0 | { |
278 | 0 | } |
279 | | |
280 | | inline void |
281 | | Trace(JSTracer* aTracer) |
282 | 0 | { |
283 | 0 | L10nCallback::Trace(aTracer); |
284 | 0 | } |
285 | | |
286 | | inline void |
287 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
288 | 0 | { |
289 | 0 | L10nCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
290 | 0 | } |
291 | | }; |
292 | | } // namespace binding_detail |
293 | | |
294 | | |
295 | | } // namespace dom |
296 | | } // namespace mozilla |
297 | | |
298 | | #endif // mozilla_dom_L10nUtilsBinding_h |