diff options
author | Andrey Tuganov <andreyt@google.com> | 2017-03-15 17:28:24 -0400 |
---|---|---|
committer | David Neto <dneto@google.com> | 2017-03-16 15:29:17 -0400 |
commit | c804c125c568914aabf4d734cf85923611bdfd21 (patch) | |
tree | ca7452d1e51b861435eb8f0ee327d65b6b28d539 /source/enum_string_mapping.h | |
parent | b0116331718113de20af5b0a1cc869ccc95b13fa (diff) | |
download | spirv-tools-c804c125c568914aabf4d734cf85923611bdfd21.tar.gz |
Autogenererating enum-string mappings from grammar
Autogenerating the following code:
- extension enum
- extension-to-string
- string-to-extension
- capability-to-string
Capability mapping table will not compile if incomplete.
TODO: Use "spirv-latest-version.h" instead of 1.1.
Added function to generate capability tables for tests.
Diffstat (limited to 'source/enum_string_mapping.h')
-rw-r--r-- | source/enum_string_mapping.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/source/enum_string_mapping.h b/source/enum_string_mapping.h new file mode 100644 index 00000000..773d40c4 --- /dev/null +++ b/source/enum_string_mapping.h @@ -0,0 +1,37 @@ +// Copyright (c) 2017 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef LIBSPIRV_ENUM_STRING_MAPPING_H_ +#define LIBSPIRV_ENUM_STRING_MAPPING_H_ + +#include <string> + +#include "spirv/1.1/spirv.h" + +namespace libspirv { + +enum class Extension; + +// Finds Extension enum corresponding to |str|. Returns false if not found. +bool GetExtensionFromString(const std::string& str, Extension* extension); + +// Returns text string corresponding to |extension|. +std::string ExtensionToString(Extension extension); + +// Returns text string corresponding to |capability|. +std::string CapabilityToString(SpvCapability capability); + +} // namespace libspirv + +#endif // LIBSPIRV_ENUM_STRING_MAPPING_H_ |