Condense namespaces in tint/utils.

This PR condenses the namespaces in the tint/utils folder.

Change-Id: I6b541a6383386346a0b11ba46074a5981fe75f66
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86028
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
dan sinclair 2022-04-07 16:55:55 +00:00 committed by Dawn LUCI CQ
parent b5599d35f9
commit fe4bfd45fe
31 changed files with 62 additions and 124 deletions

View File

@ -19,8 +19,7 @@
#include "src/tint/utils/concat.h" #include "src/tint/utils/concat.h"
namespace tint { namespace tint::utils {
namespace utils {
/// Defer executes a function or function like object when it is destructed. /// Defer executes a function or function like object when it is destructed.
template <typename F> template <typename F>
@ -51,8 +50,7 @@ inline Defer<F> MakeDefer(F&& f) {
return Defer<F>(std::forward<F>(f)); return Defer<F>(std::forward<F>(f));
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
/// TINT_DEFER(S) executes the statement(s) `S` when exiting the current lexical /// TINT_DEFER(S) executes the statement(s) `S` when exiting the current lexical
/// scope. /// scope.

View File

@ -16,8 +16,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(DeferTest, Basic) { TEST(DeferTest, Basic) {
@ -40,5 +39,4 @@ TEST(DeferTest, DeferOrder) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -21,8 +21,7 @@
#include <type_traits> #include <type_traits>
#include <utility> #include <utility>
namespace tint { namespace tint::utils {
namespace utils {
/// EnumSet is a set of enum values. /// EnumSet is a set of enum values.
/// @note As the EnumSet is backed by a single uint64_t value, it can only hold /// @note As the EnumSet is backed by a single uint64_t value, it can only hold
@ -237,8 +236,7 @@ inline std::ostream& operator<<(std::ostream& out, EnumSet<ENUM> set) {
return out << "}"; return out << "}";
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
namespace std { namespace std {

View File

@ -19,8 +19,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
using ::testing::ElementsAre; using ::testing::ElementsAre;
@ -240,5 +239,4 @@ TEST(EnumSetTest, Ostream) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -20,8 +20,7 @@
#include <functional> #include <functional>
#include <vector> #include <vector>
namespace tint { namespace tint::utils {
namespace utils {
namespace detail { namespace detail {
/// Helper for obtaining a seed bias value for HashCombine with a bit-width /// Helper for obtaining a seed bias value for HashCombine with a bit-width
@ -77,7 +76,6 @@ size_t Hash(const ARGS&... args) {
return hash; return hash;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_HASH_H_ #endif // SRC_TINT_UTILS_HASH_H_

View File

@ -18,8 +18,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(HashTests, Basic) { TEST(HashTests, Basic) {
@ -45,5 +44,4 @@ TEST(HashTests, Vector) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -18,8 +18,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
namespace tint { namespace tint::utils {
namespace utils {
/// Command is a helper used by tests for executing a process with a number of /// Command is a helper used by tests for executing a process with a number of
/// arguments and an optional stdin string, and then collecting and returning /// arguments and an optional stdin string, and then collecting and returning
@ -78,7 +77,6 @@ class Command {
std::string input_; std::string input_;
}; };
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_IO_COMMAND_H_ #endif // SRC_TINT_UTILS_IO_COMMAND_H_

View File

@ -14,8 +14,7 @@
#include "src/tint/utils/io/command.h" #include "src/tint/utils/io/command.h"
namespace tint { namespace tint::utils {
namespace utils {
Command::Command(const std::string&) {} Command::Command(const std::string&) {}
@ -33,5 +32,4 @@ Command::Output Command::Exec(std::initializer_list<std::string>) const {
return out; return out;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -21,8 +21,7 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
@ -261,5 +260,4 @@ Command::Output Command::Exec(
} }
} }
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -16,8 +16,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
#ifdef _WIN32 #ifdef _WIN32
@ -88,5 +87,4 @@ TEST(CommandTest, False) {
#endif #endif
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -19,8 +19,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
@ -245,5 +244,4 @@ Command::Output Command::Exec(
return output; return output;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -18,8 +18,7 @@
#include <sstream> #include <sstream>
#include <string> #include <string>
namespace tint { namespace tint::utils {
namespace utils {
/// TmpFile constructs a temporary file that can be written to, and is /// TmpFile constructs a temporary file that can be written to, and is
/// automatically deleted on destruction. /// automatically deleted on destruction.
@ -70,7 +69,6 @@ class TmpFile {
std::string path_; std::string path_;
}; };
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_IO_TMPFILE_H_ #endif // SRC_TINT_UTILS_IO_TMPFILE_H_

View File

@ -14,8 +14,7 @@
#include "src/tint/utils/io/tmpfile.h" #include "src/tint/utils/io/tmpfile.h"
namespace tint { namespace tint::utils {
namespace utils {
TmpFile::TmpFile(std::string) {} TmpFile::TmpFile(std::string) {}
@ -25,5 +24,4 @@ bool TmpFile::Append(const void*, size_t) const {
return false; return false;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -19,8 +19,7 @@
#include "src/tint/debug.h" #include "src/tint/debug.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
@ -66,5 +65,4 @@ bool TmpFile::Append(const void* data, size_t size) const {
return false; return false;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -18,8 +18,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(TmpFileTest, WriteReadAppendDelete) { TEST(TmpFileTest, WriteReadAppendDelete) {
@ -86,5 +85,4 @@ TEST(TmpFileTest, FileExtension) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -17,8 +17,7 @@
#include <stdio.h> #include <stdio.h>
#include <cstdio> #include <cstdio>
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
@ -59,5 +58,4 @@ bool TmpFile::Append(const void* data, size_t size) const {
return true; return true;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -17,8 +17,7 @@
#include <unordered_map> #include <unordered_map>
namespace tint { namespace tint::utils {
namespace utils {
/// Lookup is a utility function for fetching a value from an unordered map if /// Lookup is a utility function for fetching a value from an unordered map if
/// it exists, otherwise returning the `if_missing` argument. /// it exists, otherwise returning the `if_missing` argument.
@ -56,7 +55,6 @@ V GetOrCreate(std::unordered_map<K, V, H, C>& map,
return value; return value;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_MAP_H_ #endif // SRC_TINT_UTILS_MAP_H_

View File

@ -18,8 +18,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(Lookup, Test) { TEST(Lookup, Test) {
@ -54,5 +53,4 @@ TEST(GetOrCreateTest, ExistingKey) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -19,8 +19,7 @@
#include <string> #include <string>
#include <type_traits> #include <type_traits>
namespace tint { namespace tint::utils {
namespace utils {
/// @param alignment the next multiple to round `value` to /// @param alignment the next multiple to round `value` to
/// @param value the value to round to the next multiple of `alignment` /// @param value the value to round to the next multiple of `alignment`
@ -51,7 +50,6 @@ inline std::enable_if_t<std::is_unsigned<T>::value, T> MaxAlignOf(T value) {
return pot; return pot;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_MATH_H_ #endif // SRC_TINT_UTILS_MATH_H_

View File

@ -16,8 +16,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(MathTests, RoundUp) { TEST(MathTests, RoundUp) {
@ -79,5 +78,4 @@ TEST(MathTests, MaxAlignOf) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -17,8 +17,7 @@
#include <iterator> #include <iterator>
namespace tint { namespace tint::utils {
namespace utils {
namespace detail { namespace detail {
/// Used by utils::Reverse to hold the underlying iterable. /// Used by utils::Reverse to hold the underlying iterable.
@ -58,7 +57,6 @@ detail::ReverseIterable<T> Reverse(T&& iterable) {
return {iterable}; return {iterable};
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_REVERSE_H_ #endif // SRC_TINT_UTILS_REVERSE_H_

View File

@ -18,8 +18,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(ReverseTest, Vector) { TEST(ReverseTest, Vector) {
@ -32,5 +31,4 @@ TEST(ReverseTest, Vector) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -20,8 +20,7 @@
#include "src/tint/utils/concat.h" #include "src/tint/utils/concat.h"
namespace tint { namespace tint::utils {
namespace utils {
/// Helper class that temporarily assigns a value to a variable for the lifetime /// Helper class that temporarily assigns a value to a variable for the lifetime
/// of the ScopedAssignment object. Once the ScopedAssignment is destructed, the /// of the ScopedAssignment object. Once the ScopedAssignment is destructed, the
@ -50,8 +49,7 @@ class ScopedAssignment {
T old_value_; T old_value_;
}; };
} // namespace utils } // namespace tint::utils
} // namespace tint
/// TINT_SCOPED_ASSIGNMENT(var, val) assigns `val` to `var`, and automatically /// TINT_SCOPED_ASSIGNMENT(var, val) assigns `val` to `var`, and automatically
/// restores the original value of `var` when exiting the current lexical scope. /// restores the original value of `var` when exiting the current lexical scope.

View File

@ -16,8 +16,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(ScopedAssignmentTest, Scopes) { TEST(ScopedAssignmentTest, Scopes) {
@ -43,5 +42,4 @@ TEST(ScopedAssignmentTest, Scopes) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -17,8 +17,7 @@
#include <string> #include <string>
namespace tint { namespace tint::utils {
namespace utils {
/// @param str the string to apply replacements to /// @param str the string to apply replacements to
/// @param substr the string to search for /// @param substr the string to search for
@ -35,7 +34,6 @@ inline std::string ReplaceAll(std::string str,
return str; return str;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_STRING_H_ #endif // SRC_TINT_UTILS_STRING_H_

View File

@ -16,8 +16,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(StringTest, ReplaceAll) { TEST(StringTest, ReplaceAll) {
@ -34,5 +33,4 @@ TEST(StringTest, ReplaceAll) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -18,8 +18,7 @@
#include <vector> #include <vector>
namespace tint { namespace tint::utils {
namespace utils {
/// @param in a vector of `T*` /// @param in a vector of `T*`
/// @returns a vector of `const T*` with the content of `in`. /// @returns a vector of `const T*` with the content of `in`.
@ -33,7 +32,6 @@ std::vector<const T*> ToConstPtrVec(const std::vector<T*>& in) {
return out; return out;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_TO_CONST_PTR_VEC_H_ #endif // SRC_TINT_UTILS_TO_CONST_PTR_VEC_H_

View File

@ -22,8 +22,7 @@
#include "src/tint/traits.h" #include "src/tint/traits.h"
namespace tint { namespace tint::utils {
namespace utils {
/// Transform performs an element-wise transformation of a vector. /// Transform performs an element-wise transformation of a vector.
/// @param in the input vector. /// @param in the input vector.
@ -56,7 +55,6 @@ auto Transform(const std::vector<IN>& in, TRANSFORMER&& transform)
return result; return result;
} }
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_TRANSFORM_H_ #endif // SRC_TINT_UTILS_TRANSFORM_H_

View File

@ -23,8 +23,7 @@
static_assert(std::is_same<decltype(vector)::value_type, expected>::value, \ static_assert(std::is_same<decltype(vector)::value_type, expected>::value, \
"unexpected result vector element type") "unexpected result vector element type")
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(TransformTest, Empty) { TEST(TransformTest, Empty) {
@ -90,5 +89,4 @@ TEST(TransformTest, TransformDifferentType) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint

View File

@ -21,8 +21,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace tint { namespace tint::utils {
namespace utils {
/// UniqueVector is an ordered container that only contains unique items. /// UniqueVector is an ordered container that only contains unique items.
/// Attempting to add a duplicate is a no-op. /// Attempting to add a duplicate is a no-op.
@ -107,7 +106,6 @@ struct UniqueVector {
std::unordered_set<T, HASH, EQUAL> set; std::unordered_set<T, HASH, EQUAL> set;
}; };
} // namespace utils } // namespace tint::utils
} // namespace tint
#endif // SRC_TINT_UTILS_UNIQUE_VECTOR_H_ #endif // SRC_TINT_UTILS_UNIQUE_VECTOR_H_

View File

@ -17,8 +17,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace tint { namespace tint::utils {
namespace utils {
namespace { namespace {
TEST(UniqueVectorTest, Empty) { TEST(UniqueVectorTest, Empty) {
@ -141,5 +140,4 @@ TEST(UniqueVectorTest, PopBack) {
} }
} // namespace } // namespace
} // namespace utils } // namespace tint::utils
} // namespace tint