Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM Headers.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_HeadersBinding_h
4 : #define mozilla_dom_HeadersBinding_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/FakeString.h"
11 : #include "mozilla/dom/IterableIterator.h"
12 : #include "mozilla/dom/Nullable.h"
13 : #include "mozilla/dom/Record.h"
14 : #include "mozilla/dom/UnionMember.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class Headers;
20 : struct HeadersAtoms;
21 : struct NativePropertyHooks;
22 : class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord;
23 : class ProtoAndIfaceCache;
24 :
25 : } // namespace dom
26 : } // namespace mozilla
27 :
28 : namespace mozilla {
29 : namespace dom {
30 :
31 : enum class HeadersGuardEnum : uint8_t {
32 : None,
33 : Request,
34 : Request_no_cors,
35 : Response,
36 : Immutable,
37 : EndGuard_
38 : };
39 :
40 : namespace HeadersGuardEnumValues {
41 : extern const EnumEntry strings[6];
42 : } // namespace HeadersGuardEnumValues
43 :
44 : bool
45 : ToJSValue(JSContext* aCx, HeadersGuardEnum aArgument, JS::MutableHandle<JS::Value> aValue);
46 :
47 :
48 : void
49 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aUnion, const char* aName, uint32_t aFlags = 0);
50 :
51 :
52 : void
53 : ImplCycleCollectionUnlink(OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aUnion);
54 :
55 :
56 : class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord
57 : {
58 : friend class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecordArgument;
59 : enum Type
60 : {
61 : eUninitialized,
62 : eHeaders,
63 : eByteStringSequenceSequence,
64 : eByteStringByteStringRecord
65 : };
66 :
67 0 : union Value
68 : {
69 : UnionMember<NonNull<mozilla::dom::Headers> > mHeaders;
70 : UnionMember<binding_detail::AutoSequence<Sequence<nsCString>> > mByteStringSequenceSequence;
71 : UnionMember<Record<nsCString, nsCString> > mByteStringByteStringRecord;
72 :
73 : };
74 :
75 : Type mType;
76 : Value mValue;
77 :
78 : HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord(const HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
79 : HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& operator=(const HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
80 : public:
81 0 : explicit inline HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
82 0 : : mType(eUninitialized)
83 : {
84 0 : }
85 :
86 0 : inline ~HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
87 0 : {
88 0 : Uninit();
89 0 : }
90 :
91 : inline NonNull<mozilla::dom::Headers>&
92 : RawSetAsHeaders()
93 : {
94 : if (mType == eHeaders) {
95 : return mValue.mHeaders.Value();
96 : }
97 : MOZ_ASSERT(mType == eUninitialized);
98 : mType = eHeaders;
99 : return mValue.mHeaders.SetValue();
100 : }
101 :
102 : inline NonNull<mozilla::dom::Headers>&
103 : SetAsHeaders()
104 : {
105 : if (mType == eHeaders) {
106 : return mValue.mHeaders.Value();
107 : }
108 : Uninit();
109 : mType = eHeaders;
110 : return mValue.mHeaders.SetValue();
111 : }
112 :
113 : inline bool
114 0 : IsHeaders() const
115 : {
116 0 : return mType == eHeaders;
117 : }
118 :
119 : inline NonNull<mozilla::dom::Headers>&
120 : GetAsHeaders()
121 : {
122 : MOZ_ASSERT(IsHeaders(), "Wrong type!");
123 : return mValue.mHeaders.Value();
124 : }
125 :
126 : inline mozilla::dom::Headers&
127 0 : GetAsHeaders() const
128 : {
129 0 : MOZ_ASSERT(IsHeaders(), "Wrong type!");
130 0 : return mValue.mHeaders.Value();
131 : }
132 :
133 : inline binding_detail::AutoSequence<Sequence<nsCString>>&
134 : RawSetAsByteStringSequenceSequence()
135 : {
136 : if (mType == eByteStringSequenceSequence) {
137 : return mValue.mByteStringSequenceSequence.Value();
138 : }
139 : MOZ_ASSERT(mType == eUninitialized);
140 : mType = eByteStringSequenceSequence;
141 : return mValue.mByteStringSequenceSequence.SetValue();
142 : }
143 :
144 : inline binding_detail::AutoSequence<Sequence<nsCString>>&
145 : SetAsByteStringSequenceSequence()
146 : {
147 : if (mType == eByteStringSequenceSequence) {
148 : return mValue.mByteStringSequenceSequence.Value();
149 : }
150 : Uninit();
151 : mType = eByteStringSequenceSequence;
152 : return mValue.mByteStringSequenceSequence.SetValue();
153 : }
154 :
155 : inline bool
156 0 : IsByteStringSequenceSequence() const
157 : {
158 0 : return mType == eByteStringSequenceSequence;
159 : }
160 :
161 : inline binding_detail::AutoSequence<Sequence<nsCString>>&
162 : GetAsByteStringSequenceSequence()
163 : {
164 : MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
165 : return mValue.mByteStringSequenceSequence.Value();
166 : }
167 :
168 : inline const Sequence<Sequence<nsCString>>&
169 0 : GetAsByteStringSequenceSequence() const
170 : {
171 0 : MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
172 0 : return mValue.mByteStringSequenceSequence.Value();
173 : }
174 :
175 : inline Record<nsCString, nsCString>&
176 : RawSetAsByteStringByteStringRecord()
177 : {
178 : if (mType == eByteStringByteStringRecord) {
179 : return mValue.mByteStringByteStringRecord.Value();
180 : }
181 : MOZ_ASSERT(mType == eUninitialized);
182 : mType = eByteStringByteStringRecord;
183 : return mValue.mByteStringByteStringRecord.SetValue();
184 : }
185 :
186 : inline Record<nsCString, nsCString>&
187 : SetAsByteStringByteStringRecord()
188 : {
189 : if (mType == eByteStringByteStringRecord) {
190 : return mValue.mByteStringByteStringRecord.Value();
191 : }
192 : Uninit();
193 : mType = eByteStringByteStringRecord;
194 : return mValue.mByteStringByteStringRecord.SetValue();
195 : }
196 :
197 : inline bool
198 0 : IsByteStringByteStringRecord() const
199 : {
200 0 : return mType == eByteStringByteStringRecord;
201 : }
202 :
203 : inline Record<nsCString, nsCString>&
204 : GetAsByteStringByteStringRecord()
205 : {
206 : MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
207 : return mValue.mByteStringByteStringRecord.Value();
208 : }
209 :
210 : inline const Record<nsCString, nsCString>&
211 0 : GetAsByteStringByteStringRecord() const
212 : {
213 0 : MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
214 0 : return mValue.mByteStringByteStringRecord.Value();
215 : }
216 :
217 : inline void
218 0 : Uninit()
219 : {
220 0 : switch (mType) {
221 : case eUninitialized: {
222 0 : break;
223 : }
224 : case eHeaders: {
225 0 : DestroyHeaders();
226 0 : break;
227 : }
228 : case eByteStringSequenceSequence: {
229 0 : DestroyByteStringSequenceSequence();
230 0 : break;
231 : }
232 : case eByteStringByteStringRecord: {
233 0 : DestroyByteStringByteStringRecord();
234 0 : break;
235 : }
236 : }
237 0 : }
238 :
239 : bool
240 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
241 :
242 : private:
243 : inline void
244 0 : DestroyHeaders()
245 : {
246 0 : MOZ_ASSERT(IsHeaders(), "Wrong type!");
247 0 : mValue.mHeaders.Destroy();
248 0 : mType = eUninitialized;
249 0 : }
250 :
251 : inline void
252 0 : DestroyByteStringSequenceSequence()
253 : {
254 0 : MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
255 0 : mValue.mByteStringSequenceSequence.Destroy();
256 0 : mType = eUninitialized;
257 0 : }
258 :
259 : inline void
260 0 : DestroyByteStringByteStringRecord()
261 : {
262 0 : MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
263 0 : mValue.mByteStringByteStringRecord.Destroy();
264 0 : mType = eUninitialized;
265 0 : }
266 : };
267 :
268 :
269 : class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord : public AllOwningUnionBase
270 : {
271 : friend void ImplCycleCollectionUnlink(OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aUnion);
272 : enum Type
273 : {
274 : eUninitialized,
275 : eHeaders,
276 : eByteStringSequenceSequence,
277 : eByteStringByteStringRecord
278 : };
279 :
280 0 : union Value
281 : {
282 : UnionMember<OwningNonNull<mozilla::dom::Headers> > mHeaders;
283 : UnionMember<Sequence<Sequence<nsCString>> > mByteStringSequenceSequence;
284 : UnionMember<Record<nsCString, nsCString> > mByteStringByteStringRecord;
285 :
286 : };
287 :
288 : Type mType;
289 : Value mValue;
290 :
291 : OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord(const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
292 : OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& operator=(const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord&) = delete;
293 : public:
294 0 : explicit inline OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
295 0 : : mType(eUninitialized)
296 : {
297 0 : }
298 :
299 0 : inline ~OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord()
300 0 : {
301 0 : Uninit();
302 0 : }
303 :
304 : OwningNonNull<mozilla::dom::Headers>&
305 : RawSetAsHeaders();
306 :
307 : OwningNonNull<mozilla::dom::Headers>&
308 : SetAsHeaders();
309 :
310 : bool
311 : TrySetToHeaders(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
312 :
313 : inline bool
314 0 : IsHeaders() const
315 : {
316 0 : return mType == eHeaders;
317 : }
318 :
319 : inline OwningNonNull<mozilla::dom::Headers>&
320 0 : GetAsHeaders()
321 : {
322 0 : MOZ_ASSERT(IsHeaders(), "Wrong type!");
323 0 : return mValue.mHeaders.Value();
324 : }
325 :
326 : inline OwningNonNull<mozilla::dom::Headers> const &
327 0 : GetAsHeaders() const
328 : {
329 0 : MOZ_ASSERT(IsHeaders(), "Wrong type!");
330 0 : return mValue.mHeaders.Value();
331 : }
332 :
333 : Sequence<Sequence<nsCString>>&
334 : RawSetAsByteStringSequenceSequence();
335 :
336 : Sequence<Sequence<nsCString>>&
337 : SetAsByteStringSequenceSequence();
338 :
339 : bool
340 : TrySetToByteStringSequenceSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
341 :
342 : inline bool
343 0 : IsByteStringSequenceSequence() const
344 : {
345 0 : return mType == eByteStringSequenceSequence;
346 : }
347 :
348 : inline Sequence<Sequence<nsCString>>&
349 : GetAsByteStringSequenceSequence()
350 : {
351 : MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
352 : return mValue.mByteStringSequenceSequence.Value();
353 : }
354 :
355 : inline Sequence<Sequence<nsCString>> const &
356 0 : GetAsByteStringSequenceSequence() const
357 : {
358 0 : MOZ_ASSERT(IsByteStringSequenceSequence(), "Wrong type!");
359 0 : return mValue.mByteStringSequenceSequence.Value();
360 : }
361 :
362 : Record<nsCString, nsCString>&
363 : RawSetAsByteStringByteStringRecord();
364 :
365 : Record<nsCString, nsCString>&
366 : SetAsByteStringByteStringRecord();
367 :
368 : bool
369 : TrySetToByteStringByteStringRecord(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
370 :
371 : inline bool
372 0 : IsByteStringByteStringRecord() const
373 : {
374 0 : return mType == eByteStringByteStringRecord;
375 : }
376 :
377 : inline Record<nsCString, nsCString>&
378 : GetAsByteStringByteStringRecord()
379 : {
380 : MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
381 : return mValue.mByteStringByteStringRecord.Value();
382 : }
383 :
384 : inline Record<nsCString, nsCString> const &
385 0 : GetAsByteStringByteStringRecord() const
386 : {
387 0 : MOZ_ASSERT(IsByteStringByteStringRecord(), "Wrong type!");
388 0 : return mValue.mByteStringByteStringRecord.Value();
389 : }
390 :
391 : void
392 : Uninit();
393 :
394 : bool
395 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
396 :
397 : void
398 : TraceUnion(JSTracer* trc);
399 :
400 : private:
401 : void
402 : DestroyHeaders();
403 :
404 : void
405 : DestroyByteStringSequenceSequence();
406 :
407 : void
408 : DestroyByteStringByteStringRecord();
409 : };
410 :
411 :
412 : namespace HeadersBinding {
413 :
414 : typedef mozilla::dom::Headers NativeType;
415 :
416 : JSObject*
417 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
418 :
419 : const JSClass*
420 : GetJSClass();
421 :
422 : bool
423 : Wrap(JSContext* aCx, mozilla::dom::Headers* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
424 :
425 : template <class T>
426 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
427 : {
428 0 : JS::Rooted<JSObject*> reflector(aCx);
429 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
430 : }
431 :
432 : // We declare this as an array so that retrieving a pointer to this
433 : // binding's property hooks only requires compile/link-time resolvable
434 : // address arithmetic. Declaring it as a pointer instead would require
435 : // doing a run-time load to fetch a pointer to this binding's property
436 : // hooks. And then structures which embedded a pointer to this structure
437 : // would require a run-time load for proper initialization, which would
438 : // then induce static constructors. Lots of static constructors.
439 : extern const NativePropertyHooks sNativePropertyHooks[];
440 :
441 : void
442 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
443 :
444 : JS::Handle<JSObject*>
445 : GetProtoObjectHandle(JSContext* aCx);
446 :
447 : JS::Handle<JSObject*>
448 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
449 :
450 : JSObject*
451 : GetConstructorObject(JSContext* aCx);
452 :
453 : } // namespace HeadersBinding
454 :
455 :
456 :
457 : namespace HeadersIteratorBinding {
458 :
459 : typedef mozilla::dom::IterableIterator<mozilla::dom::Headers> NativeType;
460 :
461 : const JSClass*
462 : GetJSClass();
463 :
464 : bool
465 : Wrap(JSContext* aCx, mozilla::dom::IterableIterator<mozilla::dom::Headers>* aObject, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
466 :
467 : // We declare this as an array so that retrieving a pointer to this
468 : // binding's property hooks only requires compile/link-time resolvable
469 : // address arithmetic. Declaring it as a pointer instead would require
470 : // doing a run-time load to fetch a pointer to this binding's property
471 : // hooks. And then structures which embedded a pointer to this structure
472 : // would require a run-time load for proper initialization, which would
473 : // then induce static constructors. Lots of static constructors.
474 : extern const NativePropertyHooks sNativePropertyHooks[];
475 :
476 : void
477 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
478 :
479 : JS::Handle<JSObject*>
480 : GetProtoObjectHandle(JSContext* aCx);
481 :
482 : } // namespace HeadersIteratorBinding
483 :
484 :
485 :
486 : } // namespace dom
487 : } // namespace mozilla
488 :
489 : #endif // mozilla_dom_HeadersBinding_h
|