/work/obj-fuzz/dist/include/mozilla/dom/ConsoleBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM Console.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_ConsoleBinding_h |
4 | | #define mozilla_dom_ConsoleBinding_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/FakeString.h" |
13 | | #include "mozilla/dom/Nullable.h" |
14 | | #include "mozilla/dom/PrototypeList.h" |
15 | | #include "mozilla/dom/ToJSValue.h" |
16 | | #include "mozilla/dom/UnionMember.h" |
17 | | |
18 | | namespace mozilla { |
19 | | namespace dom { |
20 | | |
21 | | class Console; |
22 | | struct ConsoleAtoms; |
23 | | struct ConsoleCounterAtoms; |
24 | | struct ConsoleCounterErrorAtoms; |
25 | | struct ConsoleEventAtoms; |
26 | | class ConsoleInstance; |
27 | | struct ConsoleInstanceAtoms; |
28 | | class ConsoleInstanceDumpCallback; |
29 | | struct ConsoleInstanceOptionsAtoms; |
30 | | struct ConsoleProfileEventAtoms; |
31 | | struct ConsoleStackEntryAtoms; |
32 | | struct ConsoleTimerErrorAtoms; |
33 | | struct ConsoleTimerLogOrEndAtoms; |
34 | | struct ConsoleTimerStartAtoms; |
35 | | struct NativePropertyHooks; |
36 | | class OwningUnsignedLongLongOrString; |
37 | | class ProtoAndIfaceCache; |
38 | | class UnsignedLongLongOrString; |
39 | | |
40 | | } // namespace dom |
41 | | } // namespace mozilla |
42 | | |
43 | | namespace mozilla { |
44 | | namespace dom { |
45 | | |
46 | | enum class ConsoleLogLevel : uint8_t { |
47 | | All, |
48 | | Debug, |
49 | | Log, |
50 | | Info, |
51 | | Clear, |
52 | | Trace, |
53 | | TimeLog, |
54 | | TimeEnd, |
55 | | Time, |
56 | | Group, |
57 | | GroupEnd, |
58 | | Profile, |
59 | | ProfileEnd, |
60 | | Dir, |
61 | | Dirxml, |
62 | | Warn, |
63 | | Error, |
64 | | Off, |
65 | | EndGuard_ |
66 | | }; |
67 | | |
68 | | namespace ConsoleLogLevelValues { |
69 | | extern const EnumEntry strings[19]; |
70 | | } // namespace ConsoleLogLevelValues |
71 | | |
72 | | bool |
73 | | ToJSValue(JSContext* aCx, ConsoleLogLevel aArgument, JS::MutableHandle<JS::Value> aValue); |
74 | | |
75 | | |
76 | | enum class ConsoleLevel : uint8_t { |
77 | | Log, |
78 | | Warning, |
79 | | Error, |
80 | | EndGuard_ |
81 | | }; |
82 | | |
83 | | namespace ConsoleLevelValues { |
84 | | extern const EnumEntry strings[4]; |
85 | | } // namespace ConsoleLevelValues |
86 | | |
87 | | bool |
88 | | ToJSValue(JSContext* aCx, ConsoleLevel aArgument, JS::MutableHandle<JS::Value> aValue); |
89 | | |
90 | | |
91 | | struct ConsoleCounter : public DictionaryBase |
92 | | { |
93 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mCount; |
94 | | MOZ_INIT_OUTSIDE_CTOR nsString mLabel; |
95 | | |
96 | | ConsoleCounter(); |
97 | | |
98 | | explicit inline ConsoleCounter(const FastDictionaryInitializer& ) |
99 | 0 | { |
100 | 0 | // Do nothing here; this is used by our "Fast" subclass |
101 | 0 | } |
102 | | |
103 | | explicit inline ConsoleCounter(const ConsoleCounter& aOther) |
104 | 0 | { |
105 | 0 | *this = aOther; |
106 | 0 | } |
107 | | |
108 | | bool |
109 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
110 | | |
111 | | bool |
112 | | Init(const nsAString& aJSON); |
113 | | |
114 | | bool |
115 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
116 | | |
117 | | bool |
118 | | ToJSON(nsAString& aJSON) const; |
119 | | |
120 | | void |
121 | | TraceDictionary(JSTracer* trc); |
122 | | |
123 | | ConsoleCounter& |
124 | | operator=(const ConsoleCounter& aOther); |
125 | | |
126 | | private: |
127 | | static bool |
128 | | InitIds(JSContext* cx, ConsoleCounterAtoms* atomsCache); |
129 | | }; |
130 | | |
131 | | namespace binding_detail { |
132 | | struct FastConsoleCounter : public ConsoleCounter |
133 | | { |
134 | | inline FastConsoleCounter() |
135 | | : ConsoleCounter(FastDictionaryInitializer()) |
136 | 0 | { |
137 | 0 | // Doesn't matter what int we pass to the parent constructor |
138 | 0 | } |
139 | | }; |
140 | | } // namespace binding_detail |
141 | | |
142 | | |
143 | | struct ConsoleCounterError : public DictionaryBase |
144 | | { |
145 | | MOZ_INIT_OUTSIDE_CTOR nsString mError; |
146 | | MOZ_INIT_OUTSIDE_CTOR nsString mLabel; |
147 | | |
148 | | ConsoleCounterError(); |
149 | | |
150 | | explicit inline ConsoleCounterError(const FastDictionaryInitializer& ) |
151 | 0 | { |
152 | 0 | // Do nothing here; this is used by our "Fast" subclass |
153 | 0 | } |
154 | | |
155 | | explicit inline ConsoleCounterError(const ConsoleCounterError& aOther) |
156 | 0 | { |
157 | 0 | *this = aOther; |
158 | 0 | } |
159 | | |
160 | | bool |
161 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
162 | | |
163 | | bool |
164 | | Init(const nsAString& aJSON); |
165 | | |
166 | | bool |
167 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
168 | | |
169 | | bool |
170 | | ToJSON(nsAString& aJSON) const; |
171 | | |
172 | | void |
173 | | TraceDictionary(JSTracer* trc); |
174 | | |
175 | | ConsoleCounterError& |
176 | | operator=(const ConsoleCounterError& aOther); |
177 | | |
178 | | private: |
179 | | static bool |
180 | | InitIds(JSContext* cx, ConsoleCounterErrorAtoms* atomsCache); |
181 | | }; |
182 | | |
183 | | namespace binding_detail { |
184 | | struct FastConsoleCounterError : public ConsoleCounterError |
185 | | { |
186 | | inline FastConsoleCounterError() |
187 | | : ConsoleCounterError(FastDictionaryInitializer()) |
188 | 0 | { |
189 | 0 | // Doesn't matter what int we pass to the parent constructor |
190 | 0 | } |
191 | | }; |
192 | | } // namespace binding_detail |
193 | | |
194 | | |
195 | | struct ConsoleInstanceOptions : public DictionaryBase |
196 | | { |
197 | | MOZ_INIT_OUTSIDE_CTOR nsString mConsoleID; |
198 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningNonNull<ConsoleInstanceDumpCallback>> mDump; |
199 | | MOZ_INIT_OUTSIDE_CTOR nsString mInnerID; |
200 | | MOZ_INIT_OUTSIDE_CTOR Optional<ConsoleLogLevel> mMaxLogLevel; |
201 | | MOZ_INIT_OUTSIDE_CTOR nsString mMaxLogLevelPref; |
202 | | MOZ_INIT_OUTSIDE_CTOR nsString mPrefix; |
203 | | |
204 | | ConsoleInstanceOptions(); |
205 | | |
206 | | explicit inline ConsoleInstanceOptions(const FastDictionaryInitializer& ) |
207 | 0 | { |
208 | 0 | // Do nothing here; this is used by our "Fast" subclass |
209 | 0 | } |
210 | | |
211 | | private: |
212 | | ConsoleInstanceOptions(const ConsoleInstanceOptions&) = delete; |
213 | | ConsoleInstanceOptions& operator=(const ConsoleInstanceOptions&) = delete; |
214 | | |
215 | | static bool |
216 | | InitIds(JSContext* cx, ConsoleInstanceOptionsAtoms* atomsCache); |
217 | | |
218 | | public: |
219 | | bool |
220 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
221 | | |
222 | | bool |
223 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
224 | | |
225 | | void |
226 | | TraceDictionary(JSTracer* trc); |
227 | | |
228 | | inline void |
229 | | TraverseForCC(nsCycleCollectionTraversalCallback& aCallback, uint32_t aFlags) |
230 | 0 | { |
231 | 0 | ImplCycleCollectionTraverse(aCallback, mDump, "mDump", aFlags); |
232 | 0 | } |
233 | | |
234 | | inline void |
235 | | UnlinkForCC() |
236 | 0 | { |
237 | 0 | ImplCycleCollectionUnlink(mDump); |
238 | 0 | } |
239 | | }; |
240 | | |
241 | | namespace binding_detail { |
242 | | struct FastConsoleInstanceOptions : public ConsoleInstanceOptions |
243 | | { |
244 | | inline FastConsoleInstanceOptions() |
245 | | : ConsoleInstanceOptions(FastDictionaryInitializer()) |
246 | 0 | { |
247 | 0 | // Doesn't matter what int we pass to the parent constructor |
248 | 0 | } |
249 | | }; |
250 | | } // namespace binding_detail |
251 | | |
252 | | |
253 | | struct ConsoleProfileEvent : public DictionaryBase |
254 | | { |
255 | | MOZ_INIT_OUTSIDE_CTOR nsString mAction; |
256 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<JS::Value>> mArguments; |
257 | | |
258 | | ConsoleProfileEvent(); |
259 | | |
260 | | explicit inline ConsoleProfileEvent(const FastDictionaryInitializer& ) |
261 | 0 | { |
262 | 0 | // Do nothing here; this is used by our "Fast" subclass |
263 | 0 | } |
264 | | |
265 | | private: |
266 | | ConsoleProfileEvent(const ConsoleProfileEvent&) = delete; |
267 | | ConsoleProfileEvent& operator=(const ConsoleProfileEvent&) = delete; |
268 | | |
269 | | static bool |
270 | | InitIds(JSContext* cx, ConsoleProfileEventAtoms* atomsCache); |
271 | | |
272 | | public: |
273 | | bool |
274 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
275 | | |
276 | | bool |
277 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
278 | | |
279 | | void |
280 | | TraceDictionary(JSTracer* trc); |
281 | | }; |
282 | | |
283 | | namespace binding_detail { |
284 | | struct FastConsoleProfileEvent : public ConsoleProfileEvent |
285 | | { |
286 | | inline FastConsoleProfileEvent() |
287 | | : ConsoleProfileEvent(FastDictionaryInitializer()) |
288 | 0 | { |
289 | 0 | // Doesn't matter what int we pass to the parent constructor |
290 | 0 | } |
291 | | }; |
292 | | } // namespace binding_detail |
293 | | |
294 | | |
295 | | struct ConsoleStackEntry : public DictionaryBase |
296 | | { |
297 | | MOZ_INIT_OUTSIDE_CTOR Optional<nsString> mAsyncCause; |
298 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mColumnNumber; |
299 | | MOZ_INIT_OUTSIDE_CTOR nsString mFilename; |
300 | | MOZ_INIT_OUTSIDE_CTOR nsString mFunctionName; |
301 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mLineNumber; |
302 | | |
303 | | ConsoleStackEntry(); |
304 | | |
305 | | explicit inline ConsoleStackEntry(const FastDictionaryInitializer& ) |
306 | 0 | { |
307 | 0 | // Do nothing here; this is used by our "Fast" subclass |
308 | 0 | } |
309 | | |
310 | | explicit inline ConsoleStackEntry(const ConsoleStackEntry& aOther) |
311 | 0 | { |
312 | 0 | *this = aOther; |
313 | 0 | } |
314 | | |
315 | | bool |
316 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
317 | | |
318 | | bool |
319 | | Init(const nsAString& aJSON); |
320 | | |
321 | | bool |
322 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
323 | | |
324 | | bool |
325 | | ToJSON(nsAString& aJSON) const; |
326 | | |
327 | | void |
328 | | TraceDictionary(JSTracer* trc); |
329 | | |
330 | | ConsoleStackEntry& |
331 | | operator=(const ConsoleStackEntry& aOther); |
332 | | |
333 | | private: |
334 | | static bool |
335 | | InitIds(JSContext* cx, ConsoleStackEntryAtoms* atomsCache); |
336 | | }; |
337 | | |
338 | | namespace binding_detail { |
339 | | struct FastConsoleStackEntry : public ConsoleStackEntry |
340 | | { |
341 | | inline FastConsoleStackEntry() |
342 | | : ConsoleStackEntry(FastDictionaryInitializer()) |
343 | 0 | { |
344 | 0 | // Doesn't matter what int we pass to the parent constructor |
345 | 0 | } |
346 | | }; |
347 | | } // namespace binding_detail |
348 | | |
349 | | |
350 | | struct ConsoleTimerError : public DictionaryBase |
351 | | { |
352 | | MOZ_INIT_OUTSIDE_CTOR nsString mError; |
353 | | MOZ_INIT_OUTSIDE_CTOR nsString mName; |
354 | | |
355 | | ConsoleTimerError(); |
356 | | |
357 | | explicit inline ConsoleTimerError(const FastDictionaryInitializer& ) |
358 | 0 | { |
359 | 0 | // Do nothing here; this is used by our "Fast" subclass |
360 | 0 | } |
361 | | |
362 | | explicit inline ConsoleTimerError(const ConsoleTimerError& aOther) |
363 | 0 | { |
364 | 0 | *this = aOther; |
365 | 0 | } |
366 | | |
367 | | bool |
368 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
369 | | |
370 | | bool |
371 | | Init(const nsAString& aJSON); |
372 | | |
373 | | bool |
374 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
375 | | |
376 | | bool |
377 | | ToJSON(nsAString& aJSON) const; |
378 | | |
379 | | void |
380 | | TraceDictionary(JSTracer* trc); |
381 | | |
382 | | ConsoleTimerError& |
383 | | operator=(const ConsoleTimerError& aOther); |
384 | | |
385 | | private: |
386 | | static bool |
387 | | InitIds(JSContext* cx, ConsoleTimerErrorAtoms* atomsCache); |
388 | | }; |
389 | | |
390 | | namespace binding_detail { |
391 | | struct FastConsoleTimerError : public ConsoleTimerError |
392 | | { |
393 | | inline FastConsoleTimerError() |
394 | | : ConsoleTimerError(FastDictionaryInitializer()) |
395 | 0 | { |
396 | 0 | // Doesn't matter what int we pass to the parent constructor |
397 | 0 | } |
398 | | }; |
399 | | } // namespace binding_detail |
400 | | |
401 | | |
402 | | struct ConsoleTimerLogOrEnd : public DictionaryBase |
403 | | { |
404 | | MOZ_INIT_OUTSIDE_CTOR double mDuration; |
405 | | MOZ_INIT_OUTSIDE_CTOR nsString mName; |
406 | | |
407 | | ConsoleTimerLogOrEnd(); |
408 | | |
409 | | explicit inline ConsoleTimerLogOrEnd(const FastDictionaryInitializer& ) |
410 | 0 | { |
411 | 0 | // Do nothing here; this is used by our "Fast" subclass |
412 | 0 | } |
413 | | |
414 | | explicit inline ConsoleTimerLogOrEnd(const ConsoleTimerLogOrEnd& aOther) |
415 | 0 | { |
416 | 0 | *this = aOther; |
417 | 0 | } |
418 | | |
419 | | bool |
420 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
421 | | |
422 | | bool |
423 | | Init(const nsAString& aJSON); |
424 | | |
425 | | bool |
426 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
427 | | |
428 | | bool |
429 | | ToJSON(nsAString& aJSON) const; |
430 | | |
431 | | void |
432 | | TraceDictionary(JSTracer* trc); |
433 | | |
434 | | ConsoleTimerLogOrEnd& |
435 | | operator=(const ConsoleTimerLogOrEnd& aOther); |
436 | | |
437 | | private: |
438 | | static bool |
439 | | InitIds(JSContext* cx, ConsoleTimerLogOrEndAtoms* atomsCache); |
440 | | }; |
441 | | |
442 | | namespace binding_detail { |
443 | | struct FastConsoleTimerLogOrEnd : public ConsoleTimerLogOrEnd |
444 | | { |
445 | | inline FastConsoleTimerLogOrEnd() |
446 | | : ConsoleTimerLogOrEnd(FastDictionaryInitializer()) |
447 | 0 | { |
448 | 0 | // Doesn't matter what int we pass to the parent constructor |
449 | 0 | } |
450 | | }; |
451 | | } // namespace binding_detail |
452 | | |
453 | | |
454 | | struct ConsoleTimerStart : public DictionaryBase |
455 | | { |
456 | | MOZ_INIT_OUTSIDE_CTOR nsString mName; |
457 | | |
458 | | ConsoleTimerStart(); |
459 | | |
460 | | explicit inline ConsoleTimerStart(const FastDictionaryInitializer& ) |
461 | 0 | { |
462 | 0 | // Do nothing here; this is used by our "Fast" subclass |
463 | 0 | } |
464 | | |
465 | | explicit inline ConsoleTimerStart(const ConsoleTimerStart& aOther) |
466 | 0 | { |
467 | 0 | *this = aOther; |
468 | 0 | } |
469 | | |
470 | | bool |
471 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
472 | | |
473 | | bool |
474 | | Init(const nsAString& aJSON); |
475 | | |
476 | | bool |
477 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
478 | | |
479 | | bool |
480 | | ToJSON(nsAString& aJSON) const; |
481 | | |
482 | | void |
483 | | TraceDictionary(JSTracer* trc); |
484 | | |
485 | | ConsoleTimerStart& |
486 | | operator=(const ConsoleTimerStart& aOther); |
487 | | |
488 | | private: |
489 | | static bool |
490 | | InitIds(JSContext* cx, ConsoleTimerStartAtoms* atomsCache); |
491 | | }; |
492 | | |
493 | | namespace binding_detail { |
494 | | struct FastConsoleTimerStart : public ConsoleTimerStart |
495 | | { |
496 | | inline FastConsoleTimerStart() |
497 | | : ConsoleTimerStart(FastDictionaryInitializer()) |
498 | 0 | { |
499 | 0 | // Doesn't matter what int we pass to the parent constructor |
500 | 0 | } |
501 | | }; |
502 | | } // namespace binding_detail |
503 | | |
504 | | |
505 | | class UnsignedLongLongOrString |
506 | | { |
507 | | friend class UnsignedLongLongOrStringArgument; |
508 | | enum Type |
509 | | { |
510 | | eUninitialized, |
511 | | eUnsignedLongLong, |
512 | | eString |
513 | | }; |
514 | | |
515 | | union Value |
516 | | { |
517 | | UnionMember<uint64_t > mUnsignedLongLong; |
518 | | UnionMember<binding_detail::FakeString > mString; |
519 | | |
520 | | }; |
521 | | |
522 | | Type mType; |
523 | | Value mValue; |
524 | | |
525 | | UnsignedLongLongOrString(const UnsignedLongLongOrString&) = delete; |
526 | | UnsignedLongLongOrString& operator=(const UnsignedLongLongOrString&) = delete; |
527 | | public: |
528 | | explicit inline UnsignedLongLongOrString() |
529 | | : mType(eUninitialized) |
530 | 0 | { |
531 | 0 | } |
532 | | |
533 | | inline ~UnsignedLongLongOrString() |
534 | 0 | { |
535 | 0 | Uninit(); |
536 | 0 | } |
537 | | |
538 | | inline uint64_t& |
539 | | RawSetAsUnsignedLongLong() |
540 | 0 | { |
541 | 0 | if (mType == eUnsignedLongLong) { |
542 | 0 | return mValue.mUnsignedLongLong.Value(); |
543 | 0 | } |
544 | 0 | MOZ_ASSERT(mType == eUninitialized); |
545 | 0 | mType = eUnsignedLongLong; |
546 | 0 | return mValue.mUnsignedLongLong.SetValue(); |
547 | 0 | } |
548 | | |
549 | | inline uint64_t& |
550 | | SetAsUnsignedLongLong() |
551 | 0 | { |
552 | 0 | if (mType == eUnsignedLongLong) { |
553 | 0 | return mValue.mUnsignedLongLong.Value(); |
554 | 0 | } |
555 | 0 | Uninit(); |
556 | 0 | mType = eUnsignedLongLong; |
557 | 0 | return mValue.mUnsignedLongLong.SetValue(); |
558 | 0 | } |
559 | | |
560 | | inline bool |
561 | | IsUnsignedLongLong() const |
562 | 0 | { |
563 | 0 | return mType == eUnsignedLongLong; |
564 | 0 | } |
565 | | |
566 | | inline uint64_t& |
567 | | GetAsUnsignedLongLong() |
568 | 0 | { |
569 | 0 | MOZ_ASSERT(IsUnsignedLongLong(), "Wrong type!"); |
570 | 0 | return mValue.mUnsignedLongLong.Value(); |
571 | 0 | } |
572 | | |
573 | | inline uint64_t |
574 | | GetAsUnsignedLongLong() const |
575 | 0 | { |
576 | 0 | MOZ_ASSERT(IsUnsignedLongLong(), "Wrong type!"); |
577 | 0 | return mValue.mUnsignedLongLong.Value(); |
578 | 0 | } |
579 | | |
580 | | inline binding_detail::FakeString& |
581 | | RawSetAsString() |
582 | 0 | { |
583 | 0 | if (mType == eString) { |
584 | 0 | return mValue.mString.Value(); |
585 | 0 | } |
586 | 0 | MOZ_ASSERT(mType == eUninitialized); |
587 | 0 | mType = eString; |
588 | 0 | return mValue.mString.SetValue(); |
589 | 0 | } |
590 | | |
591 | | inline binding_detail::FakeString& |
592 | | SetAsString() |
593 | 0 | { |
594 | 0 | if (mType == eString) { |
595 | 0 | return mValue.mString.Value(); |
596 | 0 | } |
597 | 0 | Uninit(); |
598 | 0 | mType = eString; |
599 | 0 | return mValue.mString.SetValue(); |
600 | 0 | } |
601 | | |
602 | | inline bool |
603 | | IsString() const |
604 | 0 | { |
605 | 0 | return mType == eString; |
606 | 0 | } |
607 | | |
608 | | inline binding_detail::FakeString& |
609 | | GetAsString() |
610 | 0 | { |
611 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
612 | 0 | return mValue.mString.Value(); |
613 | 0 | } |
614 | | |
615 | | inline const nsAString& |
616 | | GetAsString() const |
617 | 0 | { |
618 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
619 | 0 | return mValue.mString.Value(); |
620 | 0 | } |
621 | | |
622 | | inline void |
623 | | Uninit() |
624 | 0 | { |
625 | 0 | switch (mType) { |
626 | 0 | case eUninitialized: { |
627 | 0 | break; |
628 | 0 | } |
629 | 0 | case eUnsignedLongLong: { |
630 | 0 | DestroyUnsignedLongLong(); |
631 | 0 | break; |
632 | 0 | } |
633 | 0 | case eString: { |
634 | 0 | DestroyString(); |
635 | 0 | break; |
636 | 0 | } |
637 | 0 | } |
638 | 0 | } |
639 | | |
640 | | bool |
641 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
642 | | |
643 | | private: |
644 | | inline void |
645 | | DestroyUnsignedLongLong() |
646 | 0 | { |
647 | 0 | MOZ_ASSERT(IsUnsignedLongLong(), "Wrong type!"); |
648 | 0 | mValue.mUnsignedLongLong.Destroy(); |
649 | 0 | mType = eUninitialized; |
650 | 0 | } |
651 | | |
652 | | inline void |
653 | | DestroyString() |
654 | 0 | { |
655 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
656 | 0 | mValue.mString.Destroy(); |
657 | 0 | mType = eUninitialized; |
658 | 0 | } |
659 | | }; |
660 | | |
661 | | |
662 | | class OwningUnsignedLongLongOrString : public AllOwningUnionBase |
663 | | { |
664 | | friend void ImplCycleCollectionUnlink(OwningUnsignedLongLongOrString& aUnion); |
665 | | enum Type |
666 | | { |
667 | | eUninitialized, |
668 | | eUnsignedLongLong, |
669 | | eString |
670 | | }; |
671 | | |
672 | | union Value |
673 | | { |
674 | | UnionMember<uint64_t > mUnsignedLongLong; |
675 | | UnionMember<nsString > mString; |
676 | | |
677 | | }; |
678 | | |
679 | | Type mType; |
680 | | Value mValue; |
681 | | |
682 | | public: |
683 | | explicit inline OwningUnsignedLongLongOrString() |
684 | | : mType(eUninitialized) |
685 | 0 | { |
686 | 0 | } |
687 | | |
688 | | explicit inline OwningUnsignedLongLongOrString(const OwningUnsignedLongLongOrString& aOther) |
689 | | : mType(eUninitialized) |
690 | 0 | { |
691 | 0 | *this = aOther; |
692 | 0 | } |
693 | | |
694 | | inline ~OwningUnsignedLongLongOrString() |
695 | 0 | { |
696 | 0 | Uninit(); |
697 | 0 | } |
698 | | |
699 | | uint64_t& |
700 | | RawSetAsUnsignedLongLong(); |
701 | | |
702 | | uint64_t& |
703 | | SetAsUnsignedLongLong(); |
704 | | |
705 | | bool |
706 | | TrySetToUnsignedLongLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
707 | | |
708 | | inline bool |
709 | | IsUnsignedLongLong() const |
710 | 0 | { |
711 | 0 | return mType == eUnsignedLongLong; |
712 | 0 | } |
713 | | |
714 | | inline uint64_t& |
715 | | GetAsUnsignedLongLong() |
716 | 0 | { |
717 | 0 | MOZ_ASSERT(IsUnsignedLongLong(), "Wrong type!"); |
718 | 0 | return mValue.mUnsignedLongLong.Value(); |
719 | 0 | } |
720 | | |
721 | | inline uint64_t const & |
722 | | GetAsUnsignedLongLong() const |
723 | 0 | { |
724 | 0 | MOZ_ASSERT(IsUnsignedLongLong(), "Wrong type!"); |
725 | 0 | return mValue.mUnsignedLongLong.Value(); |
726 | 0 | } |
727 | | |
728 | | nsString& |
729 | | RawSetAsString(); |
730 | | |
731 | | nsString& |
732 | | SetAsString(); |
733 | | |
734 | | bool |
735 | | TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
736 | | |
737 | | inline void |
738 | | SetStringData(const nsString::char_type* aData, nsString::size_type aLength) |
739 | 0 | { |
740 | 0 | RawSetAsString().Assign(aData, aLength); |
741 | 0 | } |
742 | | |
743 | | inline bool |
744 | | IsString() const |
745 | 0 | { |
746 | 0 | return mType == eString; |
747 | 0 | } |
748 | | |
749 | | inline nsString& |
750 | | GetAsString() |
751 | 0 | { |
752 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
753 | 0 | return mValue.mString.Value(); |
754 | 0 | } |
755 | | |
756 | | inline nsString const & |
757 | | GetAsString() const |
758 | 0 | { |
759 | 0 | MOZ_ASSERT(IsString(), "Wrong type!"); |
760 | 0 | return mValue.mString.Value(); |
761 | 0 | } |
762 | | |
763 | | void |
764 | | Uninit(); |
765 | | |
766 | | bool |
767 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
768 | | |
769 | | void |
770 | | TraceUnion(JSTracer* trc); |
771 | | |
772 | | OwningUnsignedLongLongOrString& |
773 | | operator=(const OwningUnsignedLongLongOrString& aOther); |
774 | | |
775 | | private: |
776 | | void |
777 | | DestroyUnsignedLongLong(); |
778 | | |
779 | | void |
780 | | DestroyString(); |
781 | | }; |
782 | | |
783 | | |
784 | | struct ConsoleEvent : public DictionaryBase |
785 | | { |
786 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningUnsignedLongLongOrString> mID; |
787 | | MOZ_INIT_OUTSIDE_CTOR nsString mAddonId; |
788 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<JS::Value>> mArguments; |
789 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mColumnNumber; |
790 | | MOZ_INIT_OUTSIDE_CTOR nsString mConsoleID; |
791 | | MOZ_INIT_OUTSIDE_CTOR JS::Value mCounter; |
792 | | MOZ_INIT_OUTSIDE_CTOR nsString mFilename; |
793 | | MOZ_INIT_OUTSIDE_CTOR nsString mFunctionName; |
794 | | MOZ_INIT_OUTSIDE_CTOR nsString mGroupName; |
795 | | MOZ_INIT_OUTSIDE_CTOR Optional<OwningUnsignedLongLongOrString> mInnerID; |
796 | | MOZ_INIT_OUTSIDE_CTOR nsString mLevel; |
797 | | MOZ_INIT_OUTSIDE_CTOR uint32_t mLineNumber; |
798 | | MOZ_INIT_OUTSIDE_CTOR nsString mPrefix; |
799 | | MOZ_INIT_OUTSIDE_CTOR bool mPrivate; |
800 | | MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<nsString>> mStyles; |
801 | | MOZ_INIT_OUTSIDE_CTOR double mTimeStamp; |
802 | | MOZ_INIT_OUTSIDE_CTOR JS::Value mTimer; |
803 | | |
804 | | ConsoleEvent(); |
805 | | |
806 | | explicit inline ConsoleEvent(const FastDictionaryInitializer& ) |
807 | | : mCounter(JS::UndefinedValue()), |
808 | | mTimer(JS::UndefinedValue()) |
809 | 0 | { |
810 | 0 | // Do nothing here; this is used by our "Fast" subclass |
811 | 0 | } |
812 | | |
813 | | private: |
814 | | ConsoleEvent(const ConsoleEvent&) = delete; |
815 | | ConsoleEvent& operator=(const ConsoleEvent&) = delete; |
816 | | |
817 | | static bool |
818 | | InitIds(JSContext* cx, ConsoleEventAtoms* atomsCache); |
819 | | |
820 | | public: |
821 | | bool |
822 | | Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false); |
823 | | |
824 | | bool |
825 | | ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const; |
826 | | |
827 | | void |
828 | | TraceDictionary(JSTracer* trc); |
829 | | }; |
830 | | |
831 | | namespace binding_detail { |
832 | | struct FastConsoleEvent : public ConsoleEvent |
833 | | { |
834 | | inline FastConsoleEvent() |
835 | | : ConsoleEvent(FastDictionaryInitializer()) |
836 | 0 | { |
837 | 0 | // Doesn't matter what int we pass to the parent constructor |
838 | 0 | } |
839 | | }; |
840 | | } // namespace binding_detail |
841 | | |
842 | | |
843 | | class ConsoleInstanceDumpCallback : public CallbackFunction |
844 | | { |
845 | | public: |
846 | | explicit inline ConsoleInstanceDumpCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal) |
847 | | : CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal) |
848 | 0 | { |
849 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
850 | 0 | } |
851 | | |
852 | | explicit inline ConsoleInstanceDumpCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& ) |
853 | | : CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
854 | 0 | { |
855 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
856 | 0 | } |
857 | | |
858 | | explicit inline ConsoleInstanceDumpCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal) |
859 | | : CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal) |
860 | 0 | { |
861 | 0 | MOZ_ASSERT(JS::IsCallable(mCallback)); |
862 | 0 | } |
863 | | |
864 | | explicit inline ConsoleInstanceDumpCallback(CallbackFunction* aOther) |
865 | | : CallbackFunction(aOther) |
866 | 0 | { |
867 | 0 | } |
868 | | |
869 | | template <typename T> |
870 | | inline void |
871 | | Call(const T& thisVal, const nsAString& message, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
872 | | { |
873 | | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
874 | | if (!aExecutionReason) { |
875 | | aExecutionReason = "ConsoleInstanceDumpCallback"; |
876 | | } |
877 | | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
878 | | if (!s.GetContext()) { |
879 | | MOZ_ASSERT(aRv.Failed()); |
880 | | return; |
881 | | } |
882 | | JS::Rooted<JS::Value> thisValJS(s.GetContext()); |
883 | | if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) { |
884 | | aRv.Throw(NS_ERROR_FAILURE); |
885 | | return; |
886 | | } |
887 | | return Call(s.GetContext(), thisValJS, message, aRv); |
888 | | } |
889 | | |
890 | | inline void |
891 | | Call(const nsAString& message, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr) |
892 | 0 | { |
893 | 0 | MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!"); |
894 | 0 | if (!aExecutionReason) { |
895 | 0 | aExecutionReason = "ConsoleInstanceDumpCallback"; |
896 | 0 | } |
897 | 0 | CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm); |
898 | 0 | if (!s.GetContext()) { |
899 | 0 | MOZ_ASSERT(aRv.Failed()); |
900 | 0 | return; |
901 | 0 | } |
902 | 0 | return Call(s.GetContext(), JS::UndefinedHandleValue, message, aRv); |
903 | 0 | } |
904 | | |
905 | | template <typename T> |
906 | | inline void |
907 | | Call(const T& thisVal, const nsAString& message, const char* aExecutionReason = nullptr) |
908 | | { |
909 | | return Call(thisVal, message, IgnoreErrors(), aExecutionReason); |
910 | | } |
911 | | |
912 | | inline void |
913 | | Call(const nsAString& message, const char* aExecutionReason = nullptr) |
914 | 0 | { |
915 | 0 | return Call(message, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr); |
916 | 0 | } |
917 | | |
918 | | inline bool |
919 | | operator==(const ConsoleInstanceDumpCallback& aOther) const |
920 | 0 | { |
921 | 0 | return CallbackFunction::operator==(aOther); |
922 | 0 | } |
923 | | |
924 | | private: |
925 | | void Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, const nsAString& message, ErrorResult& aRv); |
926 | | }; |
927 | | |
928 | | |
929 | | namespace binding_detail { |
930 | | class FastConsoleInstanceDumpCallback : public ConsoleInstanceDumpCallback |
931 | | { |
932 | | public: |
933 | | explicit inline FastConsoleInstanceDumpCallback(JSObject* aCallback, JSObject* aCallbackGlobal) |
934 | | : ConsoleInstanceDumpCallback(aCallback, aCallbackGlobal, FastCallbackConstructor()) |
935 | 0 | { |
936 | 0 | } |
937 | | |
938 | | inline void |
939 | | Trace(JSTracer* aTracer) |
940 | 0 | { |
941 | 0 | ConsoleInstanceDumpCallback::Trace(aTracer); |
942 | 0 | } |
943 | | |
944 | | inline void |
945 | | FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx) |
946 | 0 | { |
947 | 0 | ConsoleInstanceDumpCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx); |
948 | 0 | } |
949 | | }; |
950 | | } // namespace binding_detail |
951 | | |
952 | | |
953 | | namespace ConsoleInstance_Binding { |
954 | | |
955 | | typedef mozilla::dom::ConsoleInstance NativeType; |
956 | | |
957 | | bool |
958 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj); |
959 | | |
960 | | const JSClass* |
961 | | GetJSClass(); |
962 | | |
963 | | bool |
964 | | Wrap(JSContext* aCx, mozilla::dom::ConsoleInstance* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
965 | | |
966 | | template <class T> |
967 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
968 | 0 | { |
969 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
970 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
971 | 0 | } |
972 | | |
973 | | // We declare this as an array so that retrieving a pointer to this |
974 | | // binding's property hooks only requires compile/link-time resolvable |
975 | | // address arithmetic. Declaring it as a pointer instead would require |
976 | | // doing a run-time load to fetch a pointer to this binding's property |
977 | | // hooks. And then structures which embedded a pointer to this structure |
978 | | // would require a run-time load for proper initialization, which would |
979 | | // then induce static constructors. Lots of static constructors. |
980 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
981 | | |
982 | | void |
983 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
984 | | |
985 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
986 | 0 | { |
987 | 0 | /* Get the interface prototype object for this class. This will create the |
988 | 0 | object as needed. */ |
989 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::ConsoleInstance, |
990 | 0 | &CreateInterfaceObjects, |
991 | 0 | /* aDefineOnGlobal = */ true); |
992 | 0 |
|
993 | 0 | } |
994 | | |
995 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
996 | 0 | { |
997 | 0 | /* Get the interface object for this class. This will create the object as |
998 | 0 | needed. */ |
999 | 0 |
|
1000 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::ConsoleInstance, |
1001 | 0 | &CreateInterfaceObjects, |
1002 | 0 | aDefineOnGlobal); |
1003 | 0 | } |
1004 | | |
1005 | | JSObject* |
1006 | | GetConstructorObject(JSContext* aCx); |
1007 | | |
1008 | | } // namespace ConsoleInstance_Binding |
1009 | | |
1010 | | |
1011 | | |
1012 | | namespace console_Binding { |
1013 | | |
1014 | | typedef mozilla::dom::Console NativeType; |
1015 | | |
1016 | | static const bool IS_NATIVE_CONSOLE = true; |
1017 | | // We declare this as an array so that retrieving a pointer to this |
1018 | | // binding's property hooks only requires compile/link-time resolvable |
1019 | | // address arithmetic. Declaring it as a pointer instead would require |
1020 | | // doing a run-time load to fetch a pointer to this binding's property |
1021 | | // hooks. And then structures which embedded a pointer to this structure |
1022 | | // would require a run-time load for proper initialization, which would |
1023 | | // then induce static constructors. Lots of static constructors. |
1024 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
1025 | | |
1026 | | void |
1027 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
1028 | | |
1029 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
1030 | 0 | { |
1031 | 0 | /* Get the interface object for this class. This will create the object as |
1032 | 0 | needed. */ |
1033 | 0 |
|
1034 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::console, |
1035 | 0 | &CreateInterfaceObjects, |
1036 | 0 | aDefineOnGlobal); |
1037 | 0 | } |
1038 | | |
1039 | | JSObject* |
1040 | | GetConstructorObject(JSContext* aCx); |
1041 | | |
1042 | | } // namespace console_Binding |
1043 | | |
1044 | | |
1045 | | |
1046 | | } // namespace dom |
1047 | | } // namespace mozilla |
1048 | | |
1049 | | #endif // mozilla_dom_ConsoleBinding_h |