mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-25 16:03:38 +00:00
dawn_node: Add message support to UNIMPLEMENTED()
Have UNIMPLEMENTED() take a variadic set of message arguments which are printed with the fatal error message. Bug: dawn:1123 Change-Id: Idfa7ca71a8c59565434651a310d9e049349bb227 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/65400 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
7ed0624337
commit
7c9294584e
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <sstream>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -101,12 +102,22 @@ namespace wgpu { namespace utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unimplemented() prints an 'UNIMPLEMENTED' message to stdout with the given
|
// Unimplemented() prints an 'UNIMPLEMENTED' message to stdout with the given
|
||||||
// file, line and function, then calls abort().
|
// file, line, function and optional message, then calls abort().
|
||||||
// Unimplemented() is usually not called directly, but by the UNIMPLEMENTED()
|
// Unimplemented() is usually not called directly, but by the UNIMPLEMENTED()
|
||||||
// macro below.
|
// macro below.
|
||||||
[[noreturn]] inline void Unimplemented(const char* file, int line, const char* function) {
|
template <typename... MSG_ARGS>
|
||||||
std::cout << file << ":" << line << ": "
|
[[noreturn]] inline void Unimplemented(const char* file,
|
||||||
<< "UNIMPLEMENTED : " << function << std::endl;
|
int line,
|
||||||
|
const char* function,
|
||||||
|
MSG_ARGS&&... msg_args) {
|
||||||
|
std::stringstream msg;
|
||||||
|
msg << file << ":" << line << ": "
|
||||||
|
<< "UNIMPLEMENTED: " << function << "()";
|
||||||
|
if constexpr (sizeof...(msg_args)) {
|
||||||
|
msg << " ";
|
||||||
|
Write(msg, std::forward<MSG_ARGS>(msg_args)...);
|
||||||
|
}
|
||||||
|
std::cout << msg.str() << std::endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,10 +129,11 @@ namespace wgpu { namespace utils {
|
|||||||
<< std::endl
|
<< std::endl
|
||||||
|
|
||||||
// UNIMPLEMENTED() prints 'UNIMPLEMENTED' with the current file, line and
|
// UNIMPLEMENTED() prints 'UNIMPLEMENTED' with the current file, line and
|
||||||
// function to stdout, then calls abort().
|
// function to stdout, along with the optional message, then calls abort().
|
||||||
// The macro calls Unimplemented(), which is annotated with [[noreturn]].
|
// The macro calls Unimplemented(), which is annotated with [[noreturn]].
|
||||||
// Used to stub code that has not yet been implemented.
|
// Used to stub code that has not yet been implemented.
|
||||||
#define UNIMPLEMENTED() ::wgpu::utils::Unimplemented(__FILE__, __LINE__, __FUNCTION__)
|
#define UNIMPLEMENTED(...) \
|
||||||
|
::wgpu::utils::Unimplemented(__FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)
|
||||||
|
|
||||||
}} // namespace wgpu::utils
|
}} // namespace wgpu::utils
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user