mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-11-22 00:59:18 +01:00
Compatibility with fmtlib 10.1.x
This commit is contained in:
parent
ff9d180154
commit
757d458161
@ -134,7 +134,7 @@ find_package(ZLIB REQUIRED)
|
||||
find_package(zstd MODULE REQUIRED) # MODULE so that zstd::zstd is available
|
||||
find_package(OpenSSL COMPONENTS Crypto SSL REQUIRED)
|
||||
find_package(glm REQUIRED)
|
||||
find_package(fmt 9.1.0...<10 REQUIRED)
|
||||
find_package(fmt 9 REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
|
||||
# glslang versions older than 11.11.0 define targets without a namespace
|
||||
|
@ -251,7 +251,7 @@ void InfoLog_PrintActiveSettings()
|
||||
if(!GetConfig().vk_accurate_barriers.GetValue())
|
||||
cemuLog_log(LogType::Force, "Accurate barriers are disabled!");
|
||||
}
|
||||
cemuLog_log(LogType::Force, "Console language: {}", config.console_language);
|
||||
cemuLog_log(LogType::Force, "Console language: {}", stdx::to_underlying(config.console_language.GetValue()));
|
||||
}
|
||||
|
||||
struct SharedDataEntry
|
||||
|
@ -908,6 +908,11 @@ void _emitOperandInputCode(LatteDecompilerShaderContext* shaderContext, LatteDec
|
||||
{
|
||||
char floatAsStr[32];
|
||||
size_t floatAsStrLen = fmt::format_to_n(floatAsStr, 32, "{:#}", *(float*)&constVal).size;
|
||||
if(floatAsStrLen > 0 && floatAsStr[floatAsStrLen-1] == '.')
|
||||
{
|
||||
floatAsStr[floatAsStrLen] = '0';
|
||||
floatAsStrLen++;
|
||||
}
|
||||
cemu_assert_debug(floatAsStrLen >= 3); // shortest possible form is "0.0"
|
||||
src->add(std::string_view(floatAsStr, floatAsStrLen));
|
||||
}
|
||||
|
@ -70,21 +70,6 @@ bool cemuLog_log(LogType type, std::string_view text);
|
||||
bool cemuLog_log(LogType type, std::u8string_view text);
|
||||
void cemuLog_waitForFlush(); // wait until all log lines are written
|
||||
|
||||
template <typename T>
|
||||
auto ForwardEnum(T t)
|
||||
{
|
||||
if constexpr (std::is_enum_v<T>)
|
||||
return fmt::underlying(t);
|
||||
else
|
||||
return std::forward<T>(t);
|
||||
}
|
||||
|
||||
template <typename... TArgs>
|
||||
auto ForwardEnum(std::tuple<TArgs...> t)
|
||||
{
|
||||
return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t);
|
||||
}
|
||||
|
||||
template<typename T, typename ... TArgs>
|
||||
bool cemuLog_log(LogType type, std::basic_string<T> formatStr, TArgs&&... args)
|
||||
{
|
||||
@ -98,7 +83,7 @@ bool cemuLog_log(LogType type, std::basic_string<T> formatStr, TArgs&&... args)
|
||||
else
|
||||
{
|
||||
const auto format_view = fmt::basic_string_view<T>(formatStr);
|
||||
const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffer_context<T>>(ForwardEnum(args)...));
|
||||
const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffer_context<T>>(args...));
|
||||
cemuLog_log(type, std::basic_string_view(text.data(), text.size()));
|
||||
}
|
||||
return true;
|
||||
|
@ -159,5 +159,5 @@ template <typename T>
|
||||
struct fmt::formatter<MEMPTR<T>> : formatter<string_view>
|
||||
{
|
||||
template <typename FormatContext>
|
||||
auto format(const MEMPTR<T>& v, FormatContext& ctx) { return formatter<string_view>::format(fmt::format("{:#x}", v.GetMPTR()), ctx); }
|
||||
auto format(const MEMPTR<T>& v, FormatContext& ctx) const -> format_context::iterator { return fmt::format_to(ctx.out(), "{:#x}", v.GetMPTR()); }
|
||||
};
|
||||
|
@ -552,6 +552,29 @@ inline uint32 GetTitleIdLow(uint64 titleId)
|
||||
#include "Cafe/HW/Espresso/PPCState.h"
|
||||
#include "Cafe/HW/Espresso/PPCCallback.h"
|
||||
|
||||
// generic formatter for enums (to underlying)
|
||||
template <typename Enum>
|
||||
requires std::is_enum_v<Enum>
|
||||
struct fmt::formatter<Enum> : fmt::formatter<underlying_t<Enum>>
|
||||
{
|
||||
auto format(const Enum& e, format_context& ctx) const
|
||||
{
|
||||
//return fmt::format_to(ctx.out(), "{}", fmt::underlying(e));
|
||||
|
||||
return formatter<underlying_t<Enum>>::format(fmt::underlying(e), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
// formatter for betype<T>
|
||||
template <typename T>
|
||||
struct fmt::formatter<betype<T>> : fmt::formatter<T>
|
||||
{
|
||||
auto format(const betype<T>& e, format_context& ctx) const
|
||||
{
|
||||
return formatter<T>::format(static_cast<T>(e), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
// useful C++23 stuff that isn't yet widely supported
|
||||
|
||||
// std::to_underlying
|
||||
@ -561,5 +584,4 @@ namespace stdx
|
||||
constexpr std::underlying_type_t<EnumT> to_underlying(EnumT e) noexcept {
|
||||
return static_cast<std::underlying_type_t<EnumT>>(e);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -232,19 +232,3 @@ private:
|
||||
const TType m_min_value;
|
||||
const TType m_max_value;
|
||||
};
|
||||
|
||||
template <typename TType>
|
||||
struct fmt::formatter< ConfigValue<TType> > : formatter<TType> {
|
||||
template <typename FormatContext>
|
||||
auto format(const ConfigValue<TType>& v, FormatContext& ctx) {
|
||||
return formatter<TType>::format(v.GetValue(), ctx);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TType>
|
||||
struct fmt::formatter< ConfigValueBounds<TType> > : formatter<TType> {
|
||||
template <typename FormatContext>
|
||||
auto format(const ConfigValueBounds<TType>& v, FormatContext& ctx) {
|
||||
return formatter<TType>::format(v.GetValue(), ctx);
|
||||
}
|
||||
};
|
@ -235,6 +235,12 @@ public:
|
||||
set(name, value.load());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void set(const char* name, const ConfigValue<T>& value)
|
||||
{
|
||||
set(name, value.GetValue());
|
||||
}
|
||||
|
||||
void set(const char* name, uint64 value)
|
||||
{
|
||||
set(name, (sint64)value);
|
||||
@ -462,4 +468,3 @@ public:
|
||||
private:
|
||||
T m_data;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user