// Copyright 2022 The Dawn & Tint Authors
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
//    list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
//    contributors may be used to endorse or promote products derived from
//    this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

////////////////////////////////////////////////////////////////////////////////
// File generated by 'tools/src/cmd/gen' using the template:
//   src/tint/lang/wgsl/extension.cc.tmpl
//
// To regenerate run: './tools/run gen'
//
//                       Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////

#include "src/tint/lang/wgsl/extension.h"

namespace tint::wgsl {

/// ParseExtension parses a Extension from a string.
/// @param str the string to parse
/// @returns the parsed enum, or Extension::kUndefined if the string could not be parsed.
Extension ParseExtension(std::string_view str) {
    if (str == "chromium_disable_uniformity_analysis") {
        return Extension::kChromiumDisableUniformityAnalysis;
    }
    if (str == "chromium_experimental_framebuffer_fetch") {
        return Extension::kChromiumExperimentalFramebufferFetch;
    }
    if (str == "chromium_experimental_pixel_local") {
        return Extension::kChromiumExperimentalPixelLocal;
    }
    if (str == "chromium_experimental_push_constant") {
        return Extension::kChromiumExperimentalPushConstant;
    }
    if (str == "chromium_experimental_subgroups") {
        return Extension::kChromiumExperimentalSubgroups;
    }
    if (str == "chromium_internal_graphite") {
        return Extension::kChromiumInternalGraphite;
    }
    if (str == "chromium_internal_input_attachments") {
        return Extension::kChromiumInternalInputAttachments;
    }
    if (str == "chromium_internal_relaxed_uniform_layout") {
        return Extension::kChromiumInternalRelaxedUniformLayout;
    }
    if (str == "dual_source_blending") {
        return Extension::kDualSourceBlending;
    }
    if (str == "f16") {
        return Extension::kF16;
    }
    if (str == "subgroups") {
        return Extension::kSubgroups;
    }
    if (str == "subgroups_f16") {
        return Extension::kSubgroupsF16;
    }
    return Extension::kUndefined;
}

std::string_view ToString(Extension value) {
    switch (value) {
        case Extension::kUndefined:
            return "undefined";
        case Extension::kChromiumDisableUniformityAnalysis:
            return "chromium_disable_uniformity_analysis";
        case Extension::kChromiumExperimentalFramebufferFetch:
            return "chromium_experimental_framebuffer_fetch";
        case Extension::kChromiumExperimentalPixelLocal:
            return "chromium_experimental_pixel_local";
        case Extension::kChromiumExperimentalPushConstant:
            return "chromium_experimental_push_constant";
        case Extension::kChromiumExperimentalSubgroups:
            return "chromium_experimental_subgroups";
        case Extension::kChromiumInternalGraphite:
            return "chromium_internal_graphite";
        case Extension::kChromiumInternalInputAttachments:
            return "chromium_internal_input_attachments";
        case Extension::kChromiumInternalRelaxedUniformLayout:
            return "chromium_internal_relaxed_uniform_layout";
        case Extension::kDualSourceBlending:
            return "dual_source_blending";
        case Extension::kF16:
            return "f16";
        case Extension::kSubgroups:
            return "subgroups";
        case Extension::kSubgroupsF16:
            return "subgroups_f16";
    }
    return "<unknown>";
}

}  // namespace tint::wgsl
