mirror of
https://git.uzuy-edge.org/Uzuy-Mali/Uzuy.git
synced 2024-11-26 23:40:28 +00:00
feat: Add custom formatters for Shader::IR::Inst in formatters.h
- Created a new header file `formatters.h` under `shader_recompiler/frontend/ir/`. - Added a custom `fmt::formatter` specialization for the `Shader::IR::Inst` type. - This allows `Shader::IR::Inst` objects to be formatted using `fmt::format`, `fmt::print`, and similar functions from the `fmt` library. - The formatter uses the `ToString` method of `Shader::IR::Inst` to generate a formatted string representation.
This commit is contained in:
parent
4b35c8c259
commit
c56306393b
20
src/shader_recompiler/frontend/ir/formatters.h
Normal file
20
src/shader_recompiler/frontend/ir/formatters.h
Normal file
@ -0,0 +1,20 @@
|
||||
// shader_recompiler/frontend/ir/formatters.h
|
||||
|
||||
#pragma once
|
||||
#include <fmt/format.h>
|
||||
#include "shader_recompiler/frontend/ir/value.h"
|
||||
|
||||
namespace Shader::IR {
|
||||
// Custom formatter for Shader::IR::Inst
|
||||
template <>
|
||||
struct fmt::formatter<Shader::IR::Inst> {
|
||||
constexpr auto parse(fmt::format_parse_context& ctx) {
|
||||
return ctx.begin();
|
||||
}
|
||||
|
||||
template <typename FormatContext>
|
||||
auto format(const Shader::IR::Inst& inst, FormatContext& ctx) {
|
||||
return fmt::format_to(ctx.out(), "{}", inst.ToString());
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user