/work/obj-fuzz/dist/include/mozilla/dom/ChromeUtilsBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM ChromeUtils.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_ChromeUtilsBinding_h |
4 | | #define mozilla_dom_ChromeUtilsBinding_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/FakeString.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "mozilla/dom/PrototypeList.h" |
14 | | #include "mozilla/dom/UnionMember.h" |
15 | | |
16 | | class nsIJSID; |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | struct Base64URLDecodeOptionsAtoms; |
22 | | struct Base64URLEncodeOptionsAtoms; |
23 | | struct CategoryDispatchDictionary; |
24 | | struct CategoryDispatchDictionaryAtoms; |
25 | | class ChromeUtils; |
26 | | struct ChromeUtilsAtoms; |
27 | | struct CompileScriptOptionsDictionaryAtoms; |
28 | | struct HeapSnapshotBoundariesAtoms; |
29 | | struct IOActivityDataDictionaryAtoms; |
30 | | class MozQueryInterface; |
31 | | struct MozQueryInterfaceAtoms; |
32 | | struct NativePropertyHooks; |
33 | | struct OriginAttributesDictionaryAtoms; |
34 | | struct OriginAttributesPatternDictionaryAtoms; |
35 | | class OwningStringOrIID; |
36 | | struct PerformanceInfoDictionaryAtoms; |
37 | | class ProtoAndIfaceCache; |
38 | | |
39 | | } // namespace dom |
40 | | } // namespace mozilla |
41 | | |
42 | | namespace mozilla { |
43 | | namespace dom { |
44 | | |
45 | | enum class Base64URLDecodePadding : uint8_t { |
46 | | Require, |
47 | | Ignore, |
48 | | Reject, |
49 | | EndGuard_ |
50 | | }; |
51 | | |
52 | | namespace Base64URLDecodePaddingValues { |
53 | | extern const EnumEntry strings[4]; |
54 | | } // namespace Base64URLDecodePaddingValues |
55 | | |
56 | | bool |
57 | | ToJSValue(JSContext* aCx, Base64URLDecodePadding aArgument, JS::MutableHandle<JS::Value> aValue); |
58 | | |
59 | | |
60 | | void |
61 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningStringOrIID& aUnion, const char* aName, uint32_t aFlags = 0); |
62 | | |
63 | | |
64 | | void |
65 | | ImplCycleCollectionUnlink(OwningStringOrIID& aUnion); |
66 | | |
67 | | |
68 | | struct Base64URLDecodeOptions : public DictionaryBase |
69 | | { |
70 | | MOZ_INIT_OUTSIDE_CTOR Base64URLDecodePadding mPadding; |
71 | | |
72 | | Base64URLDecodeOptions(); |
73 | | |
74 | | explicit inline Base64URLDecodeOptions(const FastDictionaryInitializer& ) |
75 | 0 | { |
76 | 0 | // Do nothing here; this is used by our "Fast" subclass |
77 | 0 | } |
78 | | |
79 | | explicit inline Base64URLDecodeOptions(const Base64URLDecodeOptions& aOther) |
80 | 0 | { |
81 | 0 | *this = aOther; |
82 | 0 | } |
83 | | |
84 | | bool |
85 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
86 | | |
87 | | bool |
88 | | Init(const nsAString& aJSON); |
89 | | |
90 | | bool |
91 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
92 | | |
93 | | bool |
94 | | ToJSON(nsAString& aJSON) const; |
95 | | |
96 | | void |
97 | | TraceDictionary(JSTracer* trc); |
98 | | |
99 | | Base64URLDecodeOptions& |
100 | | operator=(const Base64URLDecodeOptions& aOther); |
101 | | |
102 | | private: |
103 | | static bool |
104 | | InitIds(JSContext* cx, Base64URLDecodeOptionsAtoms* atomsCache); |
105 | | }; |
106 | | |
107 | | namespace binding_detail { |
108 | | struct FastBase64URLDecodeOptions : public Base64URLDecodeOptions |
109 | | { |
110 | | inline FastBase64URLDecodeOptions() |
111 | | : Base64URLDecodeOptions(FastDictionaryInitializer()) |
112 | 0 | { |
113 | 0 | // Doesn't matter what int we pass to the parent constructor |
114 | 0 | } |
115 | | }; |
116 | | } // namespace binding_detail |
117 | | |
118 | | |
119 | | struct Base64URLEncodeOptions : public DictionaryBase |
120 | | { |
121 | | MOZ_INIT_OUTSIDE_CTOR bool mPad; |
122 | | |
123 | | Base64URLEncodeOptions(); |
124 | | |
125 | | explicit inline Base64URLEncodeOptions(const FastDictionaryInitializer& ) |
126 | 0 | { |
127 | 0 | // Do nothing here; this is used by our "Fast" subclass |
128 | 0 | } |
129 | | |
130 | | explicit inline Base64URLEncodeOptions(const Base64URLEncodeOptions& aOther) |
131 | 0 | { |
132 | 0 | *this = aOther; |
133 | 0 | } |
134 | | |
135 | | bool |
136 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
137 | | |
138 | | bool |
139 | | Init(const nsAString& aJSON); |
140 | | |
141 | | bool |
142 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
143 | | |
144 | | bool |
145 | | ToJSON(nsAString& aJSON) const; |
146 | | |
147 | | void |
148 | | TraceDictionary(JSTracer* trc); |
149 | | |
150 | | Base64URLEncodeOptions& |
151 | | operator=(const Base64URLEncodeOptions& aOther); |
152 | | |
153 | | private: |
154 | | static bool |
155 | | InitIds(JSContext* cx, Base64URLEncodeOptionsAtoms* atomsCache); |
156 | | }; |
157 | | |
158 | | namespace binding_detail { |
159 | | struct FastBase64URLEncodeOptions : public Base64URLEncodeOptions |
160 | | { |
161 | | inline FastBase64URLEncodeOptions() |
162 | | : Base64URLEncodeOptions(FastDictionaryInitializer()) |
163 | 0 | { |
164 | 0 | // Doesn't matter what int we pass to the parent constructor |
165 | 0 | } |
166 | | }; |
167 | | } // namespace binding_detail |
168 | | |
169 | | |
170 | | struct CategoryDispatchDictionary : public DictionaryBase |
171 | | { |
172 | | MOZ_INIT_OUTSIDE_CTOR uint16_t mCategory; |
173 | | MOZ_INIT_OUTSIDE_CTOR uint16_t mCount; |
174 | | |
175 | | CategoryDispatchDictionary(); |
176 | | |
177 | | explicit inline CategoryDispatchDictionary(const FastDictionaryInitializer& ) |
178 | 0 | { |
179 | 0 | // Do nothing here; this is used by our "Fast" subclass |
180 | 0 | } |
181 | | |
182 | | explicit inline CategoryDispatchDictionary(const CategoryDispatchDictionary& aOther) |
183 | 0 | { |
184 | 0 | *this = aOther; |
185 | 0 | } |
186 | | |
187 | | bool |
188 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
189 | | |
190 | | bool |
191 | | Init(const nsAString& aJSON); |
192 | | |
193 | | bool |
194 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
195 | | |
196 | | bool |
197 | | ToJSON(nsAString& aJSON) const; |
198 | | |
199 | | void |
200 | | TraceDictionary(JSTracer* trc); |
201 | | |
202 | | CategoryDispatchDictionary& |
203 | | operator=(const CategoryDispatchDictionary& aOther); |
204 | | |
205 | | private: |
206 | | static bool |
207 | | InitIds(JSContext* cx, CategoryDispatchDictionaryAtoms* atomsCache); |
208 | | }; |
209 | | |
210 | | namespace binding_detail { |
211 | | struct FastCategoryDispatchDictionary : public CategoryDispatchDictionary |
212 | | { |
213 | | inline FastCategoryDispatchDictionary() |
214 | | : CategoryDispatchDictionary(FastDictionaryInitializer()) |
215 | 0 | { |
216 | 0 | // Doesn't matter what int we pass to the parent constructor |
217 | 0 | } |
218 | | }; |
219 | | } // namespace binding_detail |
220 | | |
221 | | |
222 | | struct CompileScriptOptionsDictionary : public DictionaryBase |
223 | | { |
224 | | MOZ_INIT_OUTSIDE_CTOR nsString mCharset; |
225 | | MOZ_INIT_OUTSIDE_CTOR bool mHasReturnValue; |
226 | | MOZ_INIT_OUTSIDE_CTOR bool mLazilyParse; |
227 | | |
228 | | CompileScriptOptionsDictionary(); |
229 | | |
230 | | explicit inline CompileScriptOptionsDictionary(const FastDictionaryInitializer& ) |
231 | 0 | { |
232 | 0 | // Do nothing here; this is used by our "Fast" subclass |
233 | 0 | } |
234 | | |
235 | | explicit inline CompileScriptOptionsDictionary(const CompileScriptOptionsDictionary& aOther) |
236 | 0 | { |
237 | 0 | *this = aOther; |
238 | 0 | } |
239 | | |
240 | | bool |
241 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
242 | | |
243 | | bool |
244 | | Init(const nsAString& aJSON); |
245 | | |
246 | | bool |
247 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
248 | | |
249 | | bool |
250 | | ToJSON(nsAString& aJSON) const; |
251 | | |
252 | | void |
253 | | TraceDictionary(JSTracer* trc); |
254 | | |
255 | | CompileScriptOptionsDictionary& |
256 | | operator=(const CompileScriptOptionsDictionary& aOther); |
257 | | |
258 | | private: |
259 | | static bool |
260 | | InitIds(JSContext* cx, CompileScriptOptionsDictionaryAtoms* atomsCache); |
261 | | }; |
262 | | |
263 | | namespace binding_detail { |
264 | | struct FastCompileScriptOptionsDictionary : public CompileScriptOptionsDictionary |
265 | | { |
266 | | inline FastCompileScriptOptionsDictionary() |
267 | | : CompileScriptOptionsDictionary(FastDictionaryInitializer()) |
268 | 0 | { |
269 | 0 | // Doesn't matter what int we pass to the parent constructor |
270 | 0 | } |
271 | | }; |
272 | | } // namespace binding_detail |
273 | | |
274 | | |
275 | | struct HeapSnapshotBoundaries : public DictionaryBase |
276 | | { |
277 | | MOZ_INIT_OUTSIDE_CTOR Optional<JSObject*> mDebugger; |
278 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<JSObject*>> mGlobals; |
279 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mRuntime; |
280 | | |
281 | | HeapSnapshotBoundaries(); |
282 | | |
283 | | explicit inline HeapSnapshotBoundaries(const FastDictionaryInitializer& ) |
284 | 0 | { |
285 | 0 | // Do nothing here; this is used by our "Fast" subclass |
286 | 0 | } |
287 | | |
288 | | private: |
289 | | HeapSnapshotBoundaries(const HeapSnapshotBoundaries&) = delete; |
290 | | HeapSnapshotBoundaries& operator=(const HeapSnapshotBoundaries&) = delete; |
291 | | |
292 | | static bool |
293 | | InitIds(JSContext* cx, HeapSnapshotBoundariesAtoms* atomsCache); |
294 | | |
295 | | public: |
296 | | bool |
297 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
298 | | |
299 | | bool |
300 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
301 | | |
302 | | void |
303 | | TraceDictionary(JSTracer* trc); |
304 | | }; |
305 | | |
306 | | namespace binding_detail { |
307 | | struct FastHeapSnapshotBoundaries : public HeapSnapshotBoundaries |
308 | | { |
309 | | inline FastHeapSnapshotBoundaries() |
310 | | : HeapSnapshotBoundaries(FastDictionaryInitializer()) |
311 | 0 | { |
312 | 0 | // Doesn't matter what int we pass to the parent constructor |
313 | 0 | } |
314 | | }; |
315 | | } // namespace binding_detail |
316 | | |
317 | | |
318 | | struct IOActivityDataDictionary : public DictionaryBase |
319 | | { |
320 | | MOZ_INIT_OUTSIDE_CTOR nsCString mLocation; |
321 | | MOZ_INIT_OUTSIDE_CTOR uint64_t mRx; |
322 | | MOZ_INIT_OUTSIDE_CTOR uint64_t mTx; |
323 | | |
324 | | IOActivityDataDictionary(); |
325 | | |
326 | | explicit inline IOActivityDataDictionary(const FastDictionaryInitializer& ) |
327 | 0 | { |
328 | 0 | // Do nothing here; this is used by our "Fast" subclass |
329 | 0 | } |
330 | | |
331 | | explicit inline IOActivityDataDictionary(const IOActivityDataDictionary& aOther) |
332 | 0 | { |
333 | 0 | *this = aOther; |
334 | 0 | } |
335 | | |
336 | | bool |
337 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
338 | | |
339 | | bool |
340 | | Init(const nsAString& aJSON); |
341 | | |
342 | | bool |
343 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
344 | | |
345 | | bool |
346 | | ToJSON(nsAString& aJSON) const; |
347 | | |
348 | | void |
349 | | TraceDictionary(JSTracer* trc); |
350 | | |
351 | | IOActivityDataDictionary& |
352 | | operator=(const IOActivityDataDictionary& aOther); |
353 | | |
354 | | private: |
355 | | static bool |
356 | | InitIds(JSContext* cx, IOActivityDataDictionaryAtoms* atomsCache); |
357 | | }; |
358 | | |
359 | | namespace binding_detail { |
360 | | struct FastIOActivityDataDictionary : public IOActivityDataDictionary |
361 | | { |
362 | | inline FastIOActivityDataDictionary() |
363 | | : IOActivityDataDictionary(FastDictionaryInitializer()) |
364 | 0 | { |
365 | 0 | // Doesn't matter what int we pass to the parent constructor |
366 | 0 | } |
367 | | }; |
368 | | } // namespace binding_detail |
369 | | |
370 | | |
371 | | struct OriginAttributesDictionary : public DictionaryBase |
372 | | { |
373 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mAppId; |
374 | | MOZ_INIT_OUTSIDE_CTOR nsString mFirstPartyDomain; |
375 | | MOZ_INIT_OUTSIDE_CTOR bool mInIsolatedMozBrowser; |
376 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mPrivateBrowsingId; |
377 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mUserContextId; |
378 | | |
379 | | OriginAttributesDictionary(); |
380 | | |
381 | | explicit inline OriginAttributesDictionary(const FastDictionaryInitializer& ) |
382 | 0 | { |
383 | 0 | // Do nothing here; this is used by our "Fast" subclass |
384 | 0 | } |
385 | | |
386 | | explicit inline OriginAttributesDictionary(const OriginAttributesDictionary& aOther) |
387 | 0 | { |
388 | 0 | *this = aOther; |
389 | 0 | } |
390 | | |
391 | | bool |
392 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
393 | | |
394 | | bool |
395 | | Init(const nsAString& aJSON); |
396 | | |
397 | | bool |
398 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
399 | | |
400 | | bool |
401 | | ToJSON(nsAString& aJSON) const; |
402 | | |
403 | | void |
404 | | TraceDictionary(JSTracer* trc); |
405 | | |
406 | | OriginAttributesDictionary& |
407 | | operator=(const OriginAttributesDictionary& aOther); |
408 | | |
409 | | private: |
410 | | static bool |
411 | | InitIds(JSContext* cx, OriginAttributesDictionaryAtoms* atomsCache); |
412 | | }; |
413 | | |
414 | | namespace binding_detail { |
415 | | struct FastOriginAttributesDictionary : public OriginAttributesDictionary |
416 | | { |
417 | | inline FastOriginAttributesDictionary() |
418 | | : OriginAttributesDictionary(FastDictionaryInitializer()) |
419 | 0 | { |
420 | 0 | // Doesn't matter what int we pass to the parent constructor |
421 | 0 | } |
422 | | }; |
423 | | } // namespace binding_detail |
424 | | |
425 | | |
426 | | struct OriginAttributesPatternDictionary : public DictionaryBase |
427 | | { |
428 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mAppId; |
429 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mFirstPartyDomain; |
430 | | MOZ_INIT_OUTSIDE_CTOR Optional<bool> mInIsolatedMozBrowser; |
431 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mPrivateBrowsingId; |
432 | | MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mUserContextId; |
433 | | |
434 | | OriginAttributesPatternDictionary(); |
435 | | |
436 | | explicit inline OriginAttributesPatternDictionary(const FastDictionaryInitializer& ) |
437 | 0 | { |
438 | 0 | // Do nothing here; this is used by our "Fast" subclass |
439 | 0 | } |
440 | | |
441 | | explicit inline OriginAttributesPatternDictionary(const OriginAttributesPatternDictionary& aOther) |
442 | 0 | { |
443 | 0 | *this = aOther; |
444 | 0 | } |
445 | | |
446 | | bool |
447 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
448 | | |
449 | | bool |
450 | | Init(const nsAString& aJSON); |
451 | | |
452 | | bool |
453 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
454 | | |
455 | | bool |
456 | | ToJSON(nsAString& aJSON) const; |
457 | | |
458 | | void |
459 | | TraceDictionary(JSTracer* trc); |
460 | | |
461 | | OriginAttributesPatternDictionary& |
462 | | operator=(const OriginAttributesPatternDictionary& aOther); |
463 | | |
464 | | private: |
465 | | static bool |
466 | | InitIds(JSContext* cx, OriginAttributesPatternDictionaryAtoms* atomsCache); |
467 | | }; |
468 | | |
469 | | namespace binding_detail { |
470 | | struct FastOriginAttributesPatternDictionary : public OriginAttributesPatternDictionary |
471 | | { |
472 | | inline FastOriginAttributesPatternDictionary() |
473 | | : OriginAttributesPatternDictionary(FastDictionaryInitializer()) |
474 | 0 | { |
475 | 0 | // Doesn't matter what int we pass to the parent constructor |
476 | 0 | } |
477 | | }; |
478 | | } // namespace binding_detail |
479 | | |
480 | | |
481 | | class StringOrIID |
482 | | { |
483 | | friend class StringOrIIDArgument; |
484 | | enum Type |
485 | | { |
486 | | eUninitialized, |
487 | | eString, |
488 | | eIID |
489 | | }; |
490 | | |
491 | | union Value |
492 | | { |
493 | | UnionMember<binding_detail::FakeString > mString; |
494 | | UnionMember<nsIJSID* > mIID; |
495 | | |
496 | | }; |
497 | | |
498 | | Type mType; |
499 | | Value mValue; |
500 | | |
501 | | StringOrIID(const StringOrIID&) = delete; |
502 | | StringOrIID& operator=(const StringOrIID&) = delete; |
503 | | public: |
504 | | explicit inline StringOrIID() |
505 | | : mType(eUninitialized) |
506 | 0 | { |
507 | 0 | } |
508 | | |
509 | | inline ~StringOrIID() |
510 | 0 | { |
511 | 0 | Uninit(); |
512 | 0 | } |
513 | | |
514 | | inline binding_detail::FakeString& |
515 | | RawSetAsString() |
516 | 0 | { |
517 | 0 | if (mType == eString) { |
518 | 0 | return mValue.mString.Value(); |
519 | 0 | } |
520 | 0 | MOZ_ASSERT(mType == eUninitialized); |
521 | 0 | mType = eString; |
522 | 0 | return mValue.mString.SetValue(); |
523 | 0 | } |
524 | | |
525 | | inline binding_detail::FakeString& |
526 | | SetAsString() |
527 | 0 | { |
528 | 0 | if (mType == eString) { |
529 | 0 | return mValue.mString.Value(); |
530 | 0 | } |
531 | 0 | Uninit(); |
532 | 0 | mType = eString; |
533 | 0 | return mValue.mString.SetValue(); |
534 | 0 | } |
535 | | |
536 | | inline bool |
537 | | IsString() const |
538 | 0 | { |
539 | 0 | return mType == eString; |
540 | 0 | } |
541 | | |
542 | | inline binding_detail::FakeString& |
543 | | GetAsString() |
544 | 0 | { |
545 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
546 | 0 | return mValue.mString.Value(); |
547 | 0 | } |
548 | | |
549 | | inline const nsAString& |
550 | | GetAsString() const |
551 | 0 | { |
552 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
553 | 0 | return mValue.mString.Value(); |
554 | 0 | } |
555 | | |
556 | | inline nsIJSID*& |
557 | | RawSetAsIID() |
558 | 0 | { |
559 | 0 | if (mType == eIID) { |
560 | 0 | return mValue.mIID.Value(); |
561 | 0 | } |
562 | 0 | MOZ_ASSERT(mType == eUninitialized); |
563 | 0 | mType = eIID; |
564 | 0 | return mValue.mIID.SetValue(); |
565 | 0 | } |
566 | | |
567 | | inline nsIJSID*& |
568 | | SetAsIID() |
569 | 0 | { |
570 | 0 | if (mType == eIID) { |
571 | 0 | return mValue.mIID.Value(); |
572 | 0 | } |
573 | 0 | Uninit(); |
574 | 0 | mType = eIID; |
575 | 0 | return mValue.mIID.SetValue(); |
576 | 0 | } |
577 | | |
578 | | inline bool |
579 | | IsIID() const |
580 | 0 | { |
581 | 0 | return mType == eIID; |
582 | 0 | } |
583 | | |
584 | | inline nsIJSID*& |
585 | | GetAsIID() |
586 | 0 | { |
587 | 0 | MOZ_ASSERT(IsIID(), "Wrong type!"); |
588 | 0 | return mValue.mIID.Value(); |
589 | 0 | } |
590 | | |
591 | | inline nsIJSID* |
592 | | GetAsIID() const |
593 | 0 | { |
594 | 0 | MOZ_ASSERT(IsIID(), "Wrong type!"); |
595 | 0 | return mValue.mIID.Value(); |
596 | 0 | } |
597 | | |
598 | | inline void |
599 | | Uninit() |
600 | 0 | { |
601 | 0 | switch (mType) { |
602 | 0 | case eUninitialized: { |
603 | 0 | break; |
604 | 0 | } |
605 | 0 | case eString: { |
606 | 0 | DestroyString(); |
607 | 0 | break; |
608 | 0 | } |
609 | 0 | case eIID: { |
610 | 0 | DestroyIID(); |
611 | 0 | break; |
612 | 0 | } |
613 | 0 | } |
614 | 0 | } |
615 | | |
616 | | bool |
617 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
618 | | |
619 | | private: |
620 | | inline void |
621 | | DestroyString() |
622 | 0 | { |
623 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
624 | 0 | mValue.mString.Destroy(); |
625 | 0 | mType = eUninitialized; |
626 | 0 | } |
627 | | |
628 | | inline void |
629 | | DestroyIID() |
630 | 0 | { |
631 | 0 | MOZ_ASSERT(IsIID(), "Wrong type!"); |
632 | 0 | mValue.mIID.Destroy(); |
633 | 0 | mType = eUninitialized; |
634 | 0 | } |
635 | | }; |
636 | | |
637 | | |
638 | | class OwningStringOrIID : public AllOwningUnionBase |
639 | | { |
640 | | friend void ImplCycleCollectionUnlink(OwningStringOrIID& aUnion); |
641 | | enum Type |
642 | | { |
643 | | eUninitialized, |
644 | | eString, |
645 | | eIID |
646 | | }; |
647 | | |
648 | | union Value |
649 | | { |
650 | | UnionMember<nsString > mString; |
651 | | UnionMember<RefPtr<nsIJSID> > mIID; |
652 | | |
653 | | }; |
654 | | |
655 | | Type mType; |
656 | | Value mValue; |
657 | | |
658 | | public: |
659 | | explicit inline OwningStringOrIID() |
660 | | : mType(eUninitialized) |
661 | 4 | { |
662 | 4 | } |
663 | | |
664 | | explicit inline OwningStringOrIID(const OwningStringOrIID& aOther) |
665 | | : mType(eUninitialized) |
666 | 0 | { |
667 | 0 | *this = aOther; |
668 | 0 | } |
669 | | |
670 | | inline ~OwningStringOrIID() |
671 | 4 | { |
672 | 4 | Uninit(); |
673 | 4 | } |
674 | | |
675 | | nsString& |
676 | | RawSetAsString(); |
677 | | |
678 | | nsString& |
679 | | SetAsString(); |
680 | | |
681 | | bool |
682 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
683 | | |
684 | | inline void |
685 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
686 | 0 | { |
687 | 0 | RawSetAsString().Assign(aData, aLength); |
688 | 0 | } |
689 | | |
690 | | inline bool |
691 | | IsString() const |
692 | 0 | { |
693 | 0 | return mType == eString; |
694 | 0 | } |
695 | | |
696 | | inline nsString& |
697 | | GetAsString() |
698 | 0 | { |
699 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
700 | 0 | return mValue.mString.Value(); |
701 | 0 | } |
702 | | |
703 | | inline nsString const & |
704 | | GetAsString() const |
705 | 0 | { |
706 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
707 | 0 | return mValue.mString.Value(); |
708 | 0 | } |
709 | | |
710 | | RefPtr<nsIJSID>& |
711 | | RawSetAsIID(); |
712 | | |
713 | | RefPtr<nsIJSID>& |
714 | | SetAsIID(); |
715 | | |
716 | | bool |
717 | | TrySetToIID(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
718 | | |
719 | | inline bool |
720 | | IsIID() const |
721 | 4 | { |
722 | 4 | return mType == eIID; |
723 | 4 | } |
724 | | |
725 | | inline RefPtr<nsIJSID>& |
726 | | GetAsIID() |
727 | 0 | { |
728 | 0 | MOZ_ASSERT(IsIID(), "Wrong type!"); |
729 | 0 | return mValue.mIID.Value(); |
730 | 0 | } |
731 | | |
732 | | inline RefPtr<nsIJSID> const & |
733 | | GetAsIID() const |
734 | 4 | { |
735 | 4 | MOZ_ASSERT(IsIID(), "Wrong type!"); |
736 | 4 | return mValue.mIID.Value(); |
737 | 4 | } |
738 | | |
739 | | void |
740 | | Uninit(); |
741 | | |
742 | | bool |
743 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
744 | | |
745 | | void |
746 | | TraceUnion(JSTracer* trc); |
747 | | |
748 | | OwningStringOrIID& |
749 | | operator=(const OwningStringOrIID& aOther); |
750 | | |
751 | | private: |
752 | | void |
753 | | DestroyString(); |
754 | | |
755 | | void |
756 | | DestroyIID(); |
757 | | }; |
758 | | |
759 | | |
760 | | struct PerformanceInfoDictionary : public DictionaryBase |
761 | | { |
762 | | MOZ_INIT_OUTSIDE_CTOR uint64_t mCounterId; |
763 | | MOZ_INIT_OUTSIDE_CTOR uint64_t mDuration; |
764 | | MOZ_INIT_OUTSIDE_CTOR nsCString mHost; |
765 | | MOZ_INIT_OUTSIDE_CTOR bool mIsTopLevel; |
766 | | MOZ_INIT_OUTSIDE_CTOR bool mIsWorker; |
767 | | MOZ_INIT_OUTSIDE_CTOR Sequence<CategoryDispatchDictionary> mItems; |
768 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mPid; |
769 | | MOZ_INIT_OUTSIDE_CTOR uint64_t mWindowId; |
770 | | |
771 | | PerformanceInfoDictionary(); |
772 | | |
773 | | explicit inline PerformanceInfoDictionary(const FastDictionaryInitializer& ) |
774 | 0 | { |
775 | 0 | // Do nothing here; this is used by our "Fast" subclass |
776 | 0 | } |
777 | | |
778 | | explicit inline PerformanceInfoDictionary(const PerformanceInfoDictionary& aOther) |
779 | 0 | { |
780 | 0 | *this = aOther; |
781 | 0 | } |
782 | | |
783 | | bool |
784 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
785 | | |
786 | | bool |
787 | | Init(const nsAString& aJSON); |
788 | | |
789 | | bool |
790 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
791 | | |
792 | | bool |
793 | | ToJSON(nsAString& aJSON) const; |
794 | | |
795 | | void |
796 | | TraceDictionary(JSTracer* trc); |
797 | | |
798 | | PerformanceInfoDictionary& |
799 | | operator=(const PerformanceInfoDictionary& aOther); |
800 | | |
801 | | private: |
802 | | static bool |
803 | | InitIds(JSContext* cx, PerformanceInfoDictionaryAtoms* atomsCache); |
804 | | }; |
805 | | |
806 | | namespace binding_detail { |
807 | | struct FastPerformanceInfoDictionary : public PerformanceInfoDictionary |
808 | | { |
809 | | inline FastPerformanceInfoDictionary() |
810 | | : PerformanceInfoDictionary(FastDictionaryInitializer()) |
811 | 0 | { |
812 | 0 | // Doesn't matter what int we pass to the parent constructor |
813 | 0 | } |
814 | | }; |
815 | | } // namespace binding_detail |
816 | | |
817 | | |
818 | | namespace ChromeUtils_Binding { |
819 | | |
820 | | typedef mozilla::dom::ChromeUtils NativeType; |
821 | | |
822 | | bool |
823 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
824 | | |
825 | | // We declare this as an array so that retrieving a pointer to this |
826 | | // binding's property hooks only requires compile/link-time resolvable |
827 | | // address arithmetic. Declaring it as a pointer instead would require |
828 | | // doing a run-time load to fetch a pointer to this binding's property |
829 | | // hooks. And then structures which embedded a pointer to this structure |
830 | | // would require a run-time load for proper initialization, which would |
831 | | // then induce static constructors. Lots of static constructors. |
832 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
833 | | |
834 | | void |
835 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
836 | | |
837 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
838 | 1 | { |
839 | 1 | /* Get the interface object for this class. This will create the object as |
840 | 1 | needed. */ |
841 | 1 | |
842 | 1 | return GetPerInterfaceObjectHandle(aCx, constructors::id::ChromeUtils, |
843 | 1 | &CreateInterfaceObjects, |
844 | 1 | aDefineOnGlobal); |
845 | 1 | } |
846 | | |
847 | | JSObject* |
848 | | GetConstructorObject(JSContext* aCx); |
849 | | |
850 | | } // namespace ChromeUtils_Binding |
851 | | |
852 | | |
853 | | |
854 | | namespace MozQueryInterface_Binding { |
855 | | |
856 | | typedef mozilla::dom::MozQueryInterface NativeType; |
857 | | |
858 | | bool |
859 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
860 | | |
861 | | const JSClass* |
862 | | GetJSClass(); |
863 | | |
864 | | bool |
865 | | Wrap(JSContext* aCx, mozilla::dom::MozQueryInterface* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
866 | | |
867 | | // We declare this as an array so that retrieving a pointer to this |
868 | | // binding's property hooks only requires compile/link-time resolvable |
869 | | // address arithmetic. Declaring it as a pointer instead would require |
870 | | // doing a run-time load to fetch a pointer to this binding's property |
871 | | // hooks. And then structures which embedded a pointer to this structure |
872 | | // would require a run-time load for proper initialization, which would |
873 | | // then induce static constructors. Lots of static constructors. |
874 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
875 | | |
876 | | void |
877 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
878 | | |
879 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
880 | 3 | { |
881 | 3 | /* Get the interface prototype object for this class. This will create the |
882 | 3 | object as needed. */ |
883 | 3 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::MozQueryInterface, |
884 | 3 | &CreateInterfaceObjects, |
885 | 3 | /* aDefineOnGlobal = */ true); |
886 | 3 | |
887 | 3 | } |
888 | | |
889 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
890 | 0 | { |
891 | 0 | /* Get the interface object for this class. This will create the object as |
892 | 0 | needed. */ |
893 | 0 |
|
894 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::MozQueryInterface, |
895 | 0 | &CreateInterfaceObjects, |
896 | 0 | aDefineOnGlobal); |
897 | 0 | } |
898 | | |
899 | | JSObject* |
900 | | GetConstructorObject(JSContext* aCx); |
901 | | |
902 | | } // namespace MozQueryInterface_Binding |
903 | | |
904 | | |
905 | | |
906 | | } // namespace dom |
907 | | } // namespace mozilla |
908 | | |
909 | | #endif // mozilla_dom_ChromeUtilsBinding_h |