Butcher narrow cast a little (don't print value).

Also remove some forward declarations from util/types.hpp
If they don't work properly, it's easier to remove them.
This commit is contained in:
Nekotekina 2020-12-22 14:05:05 +03:00
parent b7bf316c1a
commit 43a58df8a0
8 changed files with 15 additions and 29 deletions

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "util/types.hpp" #include "util/types.hpp"
#include "Utilities/StrFmt.h"
template<typename T, uint N> template<typename T, uint N>
struct bf_base struct bf_base

View file

@ -294,29 +294,21 @@ void fmt_class_string<src_loc>::format(std::string& out, u64 arg)
namespace fmt namespace fmt
{ {
void raw_verify_error(const src_loc& loc) [[noreturn]] void raw_verify_error(const src_loc& loc)
{ {
std::string out{"Verification failed"}; std::string out{"Verification failed"};
fmt::append(out, "%s", loc); fmt::append(out, "%s", loc);
thread_ctrl::emergency_exit(out); thread_ctrl::emergency_exit(out);
} }
void raw_narrow_error(const src_loc& loc, const fmt_type_info* sup, u64 arg) [[noreturn]] void raw_narrow_error(const src_loc& loc)
{ {
std::string out{"Narrowing error"}; std::string out{"Narrowing error"};
if (sup)
{
out += " (";
sup->fmt_string(out, arg); // Print value
out += ")";
}
fmt::append(out, "%s", loc); fmt::append(out, "%s", loc);
thread_ctrl::emergency_exit(out); thread_ctrl::emergency_exit(out);
} }
void raw_throw_exception(const src_loc& loc, const char* fmt, const fmt_type_info* sup, const u64* args) [[noreturn]] void raw_throw_exception(const src_loc& loc, const char* fmt, const fmt_type_info* sup, const u64* args)
{ {
std::string out; std::string out;
raw_append(out, fmt, sup, args); raw_append(out, fmt, sup, args);

View file

@ -10,7 +10,7 @@ namespace fmt
static std::string format(const CharT(&)[N], const Args&...); static std::string format(const CharT(&)[N], const Args&...);
} }
template <typename T, typename> template <typename T, typename = void>
struct fmt_unveil struct fmt_unveil
{ {
static_assert(sizeof(T) > 0, "fmt_unveil<> error: incomplete type"); static_assert(sizeof(T) > 0, "fmt_unveil<> error: incomplete type");
@ -245,6 +245,9 @@ struct fmt_type_info
template <typename... Args> template <typename... Args>
using fmt_args_t = const u64(&&)[sizeof...(Args) + 1]; using fmt_args_t = const u64(&&)[sizeof...(Args) + 1];
template <typename Arg>
using fmt_unveil_t = typename fmt_unveil<Arg>::type;
namespace fmt namespace fmt
{ {
// Base-57 format helper // Base-57 format helper

View file

@ -23,6 +23,7 @@ Intersection (&) and symmetric difference (^) is also available.
#include "util/types.hpp" #include "util/types.hpp"
#include "util/atomic.hpp" #include "util/atomic.hpp"
#include "Utilities/StrFmt.h"
template <typename T> template <typename T>
class atomic_bs_t; class atomic_bs_t;

View file

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "util/types.hpp" #include "util/types.hpp"
#include "Utilities/StrFmt.h"
// Error code type (return type), implements error reporting. // Error code type (return type), implements error reporting.
class error_code class error_code

View file

@ -2,6 +2,7 @@
#include "util/types.hpp" #include "util/types.hpp"
#include "util/to_endian.hpp" #include "util/to_endian.hpp"
#include "Utilities/StrFmt.h"
#include "vm.h" #include "vm.h"
class ppu_thread; class ppu_thread;

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#ifdef _WIN32
#include "util/types.hpp" #include "util/types.hpp"
#include "Emu/Io/PadHandler.h" #include "Emu/Io/PadHandler.h"
#ifndef NOMINMAX #ifndef NOMINMAX
@ -137,3 +138,4 @@ private:
PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override; PadHandlerBase::connection update_connection(const std::shared_ptr<PadDevice>& device) override;
std::unordered_map<u64, u16> get_button_values(const std::shared_ptr<PadDevice>& device) override; std::unordered_map<u64, u16> get_button_values(const std::shared_ptr<PadDevice>& device) override;
}; };
#endif

View file

@ -188,21 +188,6 @@ std::remove_cvref_t<T> as_rvalue(T&& obj)
return std::forward<T>(obj); return std::forward<T>(obj);
} }
// Formatting helper, type-specific preprocessing for improving safety and functionality
template <typename T, typename = void>
struct fmt_unveil;
template <typename Arg>
using fmt_unveil_t = typename fmt_unveil<Arg>::type;
struct fmt_type_info;
namespace fmt
{
template <typename... Args>
const fmt_type_info* get_type_info();
}
template <typename T, usz Align> template <typename T, usz Align>
class atomic_t; class atomic_t;
@ -744,7 +729,7 @@ struct src_loc
namespace fmt namespace fmt
{ {
[[noreturn]] void raw_verify_error(const src_loc& loc); [[noreturn]] void raw_verify_error(const src_loc& loc);
[[noreturn]] void raw_narrow_error(const src_loc& loc, const fmt_type_info* sup, u64 arg); [[noreturn]] void raw_narrow_error(const src_loc& loc);
} }
template <typename T> template <typename T>
@ -845,7 +830,7 @@ template <typename To = void, typename From, typename = decltype(static_cast<To>
if (narrow_impl<From, To>::test(value)) [[unlikely]] if (narrow_impl<From, To>::test(value)) [[unlikely]]
{ {
// Pack value as formatting argument // Pack value as formatting argument
fmt::raw_narrow_error({line, col, file, func}, fmt::get_type_info<fmt_unveil_t<From>>(), fmt_unveil<From>::get(value)); fmt::raw_narrow_error({line, col, file, func});
} }
return static_cast<To>(value); return static_cast<To>(value);