| {{- /* | |
| -------------------------------------------------------------------------------- | |
| Template file for use with tools/src/cmd/gen to generate function.h | |
| To update the generated file, run: | |
| ./tools/run gen | |
| See: | |
| * tools/src/cmd/gen for structures used by this template | |
| * https://golang.org/pkg/text/template/ for documentation on the template syntax | |
| -------------------------------------------------------------------------------- | |
| */ -}} | |
| #ifndef SRC_TINT_BUILTIN_FUNCTION_H_ | |
| #define SRC_TINT_BUILTIN_FUNCTION_H_ | |
| #include <string> | |
| #include "src/tint/utils/string_stream.h" | |
| // \cond DO_NOT_DOCUMENT | |
| namespace tint::builtin { | |
| /// Enumerator of all builtin functions | |
| enum class Function { | |
| kNone = -1, | |
| {{- range Sem.Builtins }} | |
| k{{PascalCase .Name}}, | |
| {{- end }} | |
| }; | |
| /// Matches the Function by name | |
| /// @param name the builtin name to parse | |
| /// @returns the parsed Function, or Function::kNone if `name` did not | |
| /// match any builtin function. | |
| Function ParseFunction(std::string_view name); | |
| /// @returns the name of the builtin function type. The spelling, including | |
| /// case, matches the name in the WGSL spec. | |
| const char* str(Function i); | |
| /// Emits the name of the builtin function type. The spelling, including case, | |
| /// matches the name in the WGSL spec. | |
| utils::StringStream& operator<<(utils::StringStream& out, Function i); | |
| /// All builtin functions | |
| constexpr Function kFunctions[] = { | |
| {{- range Sem.Builtins }} | |
| Function::k{{PascalCase .Name}}, | |
| {{- end }} | |
| }; | |
| /// All builtin function names | |
| constexpr const char* kFunctionStrings[] = { | |
| {{- range Sem.Builtins }} | |
| "{{.Name}}", | |
| {{- end }} | |
| }; | |
| } // namespace tint::builtin | |
| // \endcond | |
| #endif // SRC_TINT_BUILTIN_FUNCTION_H_ |