1 | /* |
2 | This file is part of the WebKit open source project. |
3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #include "config.h" |
22 | #include "JSFetchReferrerPolicy.h" |
23 | |
24 | #include <JavaScriptCore/JSCInlines.h> |
25 | #include <JavaScriptCore/JSString.h> |
26 | #include <wtf/NeverDestroyed.h> |
27 | |
28 | |
29 | namespace WebCore { |
30 | using namespace JSC; |
31 | |
32 | String convertEnumerationToString(FetchReferrerPolicy enumerationValue) |
33 | { |
34 | static const NeverDestroyed<String> values[] = { |
35 | emptyString(), |
36 | MAKE_STATIC_STRING_IMPL("no-referrer" ), |
37 | MAKE_STATIC_STRING_IMPL("no-referrer-when-downgrade" ), |
38 | MAKE_STATIC_STRING_IMPL("same-origin" ), |
39 | MAKE_STATIC_STRING_IMPL("origin" ), |
40 | MAKE_STATIC_STRING_IMPL("strict-origin" ), |
41 | MAKE_STATIC_STRING_IMPL("origin-when-cross-origin" ), |
42 | MAKE_STATIC_STRING_IMPL("strict-origin-when-cross-origin" ), |
43 | MAKE_STATIC_STRING_IMPL("unsafe-url" ), |
44 | }; |
45 | static_assert(static_cast<size_t>(FetchReferrerPolicy::EmptyString) == 0, "FetchReferrerPolicy::EmptyString is not 0 as expected" ); |
46 | static_assert(static_cast<size_t>(FetchReferrerPolicy::NoReferrer) == 1, "FetchReferrerPolicy::NoReferrer is not 1 as expected" ); |
47 | static_assert(static_cast<size_t>(FetchReferrerPolicy::NoReferrerWhenDowngrade) == 2, "FetchReferrerPolicy::NoReferrerWhenDowngrade is not 2 as expected" ); |
48 | static_assert(static_cast<size_t>(FetchReferrerPolicy::SameOrigin) == 3, "FetchReferrerPolicy::SameOrigin is not 3 as expected" ); |
49 | static_assert(static_cast<size_t>(FetchReferrerPolicy::Origin) == 4, "FetchReferrerPolicy::Origin is not 4 as expected" ); |
50 | static_assert(static_cast<size_t>(FetchReferrerPolicy::StrictOrigin) == 5, "FetchReferrerPolicy::StrictOrigin is not 5 as expected" ); |
51 | static_assert(static_cast<size_t>(FetchReferrerPolicy::OriginWhenCrossOrigin) == 6, "FetchReferrerPolicy::OriginWhenCrossOrigin is not 6 as expected" ); |
52 | static_assert(static_cast<size_t>(FetchReferrerPolicy::StrictOriginWhenCrossOrigin) == 7, "FetchReferrerPolicy::StrictOriginWhenCrossOrigin is not 7 as expected" ); |
53 | static_assert(static_cast<size_t>(FetchReferrerPolicy::UnsafeUrl) == 8, "FetchReferrerPolicy::UnsafeUrl is not 8 as expected" ); |
54 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
55 | return values[static_cast<size_t>(enumerationValue)]; |
56 | } |
57 | |
58 | template<> JSString* convertEnumerationToJS(ExecState& state, FetchReferrerPolicy enumerationValue) |
59 | { |
60 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
61 | } |
62 | |
63 | template<> Optional<FetchReferrerPolicy> parseEnumeration<FetchReferrerPolicy>(ExecState& state, JSValue value) |
64 | { |
65 | auto stringValue = value.toWTFString(&state); |
66 | if (stringValue.isEmpty()) |
67 | return FetchReferrerPolicy::EmptyString; |
68 | if (stringValue == "no-referrer" ) |
69 | return FetchReferrerPolicy::NoReferrer; |
70 | if (stringValue == "no-referrer-when-downgrade" ) |
71 | return FetchReferrerPolicy::NoReferrerWhenDowngrade; |
72 | if (stringValue == "same-origin" ) |
73 | return FetchReferrerPolicy::SameOrigin; |
74 | if (stringValue == "origin" ) |
75 | return FetchReferrerPolicy::Origin; |
76 | if (stringValue == "strict-origin" ) |
77 | return FetchReferrerPolicy::StrictOrigin; |
78 | if (stringValue == "origin-when-cross-origin" ) |
79 | return FetchReferrerPolicy::OriginWhenCrossOrigin; |
80 | if (stringValue == "strict-origin-when-cross-origin" ) |
81 | return FetchReferrerPolicy::StrictOriginWhenCrossOrigin; |
82 | if (stringValue == "unsafe-url" ) |
83 | return FetchReferrerPolicy::UnsafeUrl; |
84 | return WTF::nullopt; |
85 | } |
86 | |
87 | template<> const char* expectedEnumerationValues<FetchReferrerPolicy>() |
88 | { |
89 | return "\"\", \"no-referrer\", \"no-referrer-when-downgrade\", \"same-origin\", \"origin\", \"strict-origin\", \"origin-when-cross-origin\", \"strict-origin-when-cross-origin\", \"unsafe-url\"" ; |
90 | } |
91 | |
92 | } // namespace WebCore |
93 | |