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 | |
23 | #if ENABLE(WEBGPU) |
24 | |
25 | #include "JSGPUCompareFunction.h" |
26 | |
27 | #include <JavaScriptCore/JSCInlines.h> |
28 | #include <JavaScriptCore/JSString.h> |
29 | #include <wtf/NeverDestroyed.h> |
30 | |
31 | |
32 | namespace WebCore { |
33 | using namespace JSC; |
34 | |
35 | String convertEnumerationToString(GPUCompareFunction enumerationValue) |
36 | { |
37 | static const NeverDestroyed<String> values[] = { |
38 | MAKE_STATIC_STRING_IMPL("never" ), |
39 | MAKE_STATIC_STRING_IMPL("less" ), |
40 | MAKE_STATIC_STRING_IMPL("equal" ), |
41 | MAKE_STATIC_STRING_IMPL("less-equal" ), |
42 | MAKE_STATIC_STRING_IMPL("greater" ), |
43 | MAKE_STATIC_STRING_IMPL("not-equal" ), |
44 | MAKE_STATIC_STRING_IMPL("greater-equal" ), |
45 | MAKE_STATIC_STRING_IMPL("always" ), |
46 | }; |
47 | static_assert(static_cast<size_t>(GPUCompareFunction::Never) == 0, "GPUCompareFunction::Never is not 0 as expected" ); |
48 | static_assert(static_cast<size_t>(GPUCompareFunction::Less) == 1, "GPUCompareFunction::Less is not 1 as expected" ); |
49 | static_assert(static_cast<size_t>(GPUCompareFunction::Equal) == 2, "GPUCompareFunction::Equal is not 2 as expected" ); |
50 | static_assert(static_cast<size_t>(GPUCompareFunction::LessEqual) == 3, "GPUCompareFunction::LessEqual is not 3 as expected" ); |
51 | static_assert(static_cast<size_t>(GPUCompareFunction::Greater) == 4, "GPUCompareFunction::Greater is not 4 as expected" ); |
52 | static_assert(static_cast<size_t>(GPUCompareFunction::NotEqual) == 5, "GPUCompareFunction::NotEqual is not 5 as expected" ); |
53 | static_assert(static_cast<size_t>(GPUCompareFunction::GreaterEqual) == 6, "GPUCompareFunction::GreaterEqual is not 6 as expected" ); |
54 | static_assert(static_cast<size_t>(GPUCompareFunction::Always) == 7, "GPUCompareFunction::Always is not 7 as expected" ); |
55 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
56 | return values[static_cast<size_t>(enumerationValue)]; |
57 | } |
58 | |
59 | template<> JSString* convertEnumerationToJS(ExecState& state, GPUCompareFunction enumerationValue) |
60 | { |
61 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
62 | } |
63 | |
64 | template<> Optional<GPUCompareFunction> parseEnumeration<GPUCompareFunction>(ExecState& state, JSValue value) |
65 | { |
66 | auto stringValue = value.toWTFString(&state); |
67 | if (stringValue == "never" ) |
68 | return GPUCompareFunction::Never; |
69 | if (stringValue == "less" ) |
70 | return GPUCompareFunction::Less; |
71 | if (stringValue == "equal" ) |
72 | return GPUCompareFunction::Equal; |
73 | if (stringValue == "less-equal" ) |
74 | return GPUCompareFunction::LessEqual; |
75 | if (stringValue == "greater" ) |
76 | return GPUCompareFunction::Greater; |
77 | if (stringValue == "not-equal" ) |
78 | return GPUCompareFunction::NotEqual; |
79 | if (stringValue == "greater-equal" ) |
80 | return GPUCompareFunction::GreaterEqual; |
81 | if (stringValue == "always" ) |
82 | return GPUCompareFunction::Always; |
83 | return WTF::nullopt; |
84 | } |
85 | |
86 | template<> const char* expectedEnumerationValues<GPUCompareFunction>() |
87 | { |
88 | return "\"never\", \"less\", \"equal\", \"less-equal\", \"greater\", \"not-equal\", \"greater-equal\", \"always\"" ; |
89 | } |
90 | |
91 | } // namespace WebCore |
92 | |
93 | #endif // ENABLE(WEBGPU) |
94 | |