blob: 33a517166e79498fa979c0bfb3e8d1b4b04c4ef5 [file] [log] [blame]
// Copyright 2023 The Tint Authors.
//
// 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.
////////////////////////////////////////////////////////////////////////////////
// File generated by tools/src/cmd/gen
// using the template:
// src/tint/builtin/attribute.cc.tmpl
//
// Do not modify this file directly
////////////////////////////////////////////////////////////////////////////////
#include "src/tint/builtin/attribute.h"
namespace tint::builtin {
/// ParseAttribute parses a Attribute from a string.
/// @param str the string to parse
/// @returns the parsed enum, or Attribute::kUndefined if the string could not be parsed.
Attribute ParseAttribute(std::string_view str) {
if (str == "align") {
return Attribute::kAlign;
}
if (str == "binding") {
return Attribute::kBinding;
}
if (str == "builtin") {
return Attribute::kBuiltin;
}
if (str == "compute") {
return Attribute::kCompute;
}
if (str == "diagnostic") {
return Attribute::kDiagnostic;
}
if (str == "fragment") {
return Attribute::kFragment;
}
if (str == "group") {
return Attribute::kGroup;
}
if (str == "id") {
return Attribute::kId;
}
if (str == "interpolate") {
return Attribute::kInterpolate;
}
if (str == "invariant") {
return Attribute::kInvariant;
}
if (str == "location") {
return Attribute::kLocation;
}
if (str == "must_use") {
return Attribute::kMustUse;
}
if (str == "size") {
return Attribute::kSize;
}
if (str == "vertex") {
return Attribute::kVertex;
}
if (str == "workgroup_size") {
return Attribute::kWorkgroupSize;
}
return Attribute::kUndefined;
}
utils::StringStream& operator<<(utils::StringStream& out, Attribute value) {
switch (value) {
case Attribute::kUndefined:
return out << "undefined";
case Attribute::kAlign:
return out << "align";
case Attribute::kBinding:
return out << "binding";
case Attribute::kBuiltin:
return out << "builtin";
case Attribute::kCompute:
return out << "compute";
case Attribute::kDiagnostic:
return out << "diagnostic";
case Attribute::kFragment:
return out << "fragment";
case Attribute::kGroup:
return out << "group";
case Attribute::kId:
return out << "id";
case Attribute::kInterpolate:
return out << "interpolate";
case Attribute::kInvariant:
return out << "invariant";
case Attribute::kLocation:
return out << "location";
case Attribute::kMustUse:
return out << "must_use";
case Attribute::kSize:
return out << "size";
case Attribute::kVertex:
return out << "vertex";
case Attribute::kWorkgroupSize:
return out << "workgroup_size";
}
return out << "<unknown>";
}
} // namespace tint::builtin