Skip to content

Commit

Permalink
Update fmt version to 9.1.0 (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
SSimco committed Sep 5, 2022
1 parent f2ec0b4 commit 0ed4fdc
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 33 deletions.
6 changes: 3 additions & 3 deletions dependencies/vcpkg_overlay_ports/fmt/portfile.cmake
@@ -1,10 +1,10 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO fmtlib/fmt
REF 7bdf0628b1276379886c7f6dda2cef2b3b374f0b # v7.1.3
SHA512 52ea8f9d2c0cb52ec3a740e38fcdfd6a0318566e3b599bd2e8d557168642d005c0a59bc213cff2641a88fed3bb771d15f46c39035ccd64809569af982aba47aa
REF a33701196adfad74917046096bf5a2aa0ab0bb50 # v9.1.0
SHA512 0faf00e99b332fcb3d9fc50cc9649ddc004ca9035f3652c1a001facee725dab09f67b65a9dfcce0aedb47e76c74c45a9262a1fd6e250a9e9a27c7d021c8ee6b8
HEAD_REF master
PATCHES fix-warning4189.patch
# PATCHES fix-warning4189.patch
)

vcpkg_cmake_configure(
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/IOSU/legacy/iosu_boss.cpp
Expand Up @@ -219,7 +219,7 @@ namespace iosu
template <typename ... TArgs>
curl_slist* append_header_param(struct curl_slist* list, const char* format, TArgs&& ... args)
{
return curl_slist_append(list, fmt::format(format, std::forward<TArgs>(args)...).c_str());
return curl_slist_append(list, fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...).c_str());
}

bool starts_with(const char* str, const char* pre)
Expand Down
2 changes: 1 addition & 1 deletion src/Cafe/IOSU/legacy/iosu_fpd.cpp
Expand Up @@ -84,7 +84,7 @@ namespace iosu
name = tmp;
}

g_friend_notifications.emplace_back(fmt::format(msg_format, name), 5000);
g_friend_notifications.emplace_back(fmt::format(fmt::runtime(msg_format), name), 5000);
}
}
}
Expand Down
33 changes: 28 additions & 5 deletions src/Cemu/Logging/CemuLogging.h
Expand Up @@ -36,7 +36,8 @@ enum class LogType : sint32
template <>
struct fmt::formatter<std::u8string_view> : formatter<string_view> {
template <typename FormatContext>
auto format(std::u8string_view v, FormatContext& ctx) {
auto format(std::u8string_view v, FormatContext& ctx)
{
string_view s((char*)v.data(), v.size());
return formatter<string_view>::format(s, ctx);
}
Expand All @@ -52,17 +53,39 @@ bool cemuLog_log(LogType type, std::u8string_view text);
bool cemuLog_log(LogType type, std::wstring_view text);
void cemuLog_waitForFlush(); // wait until all log lines are written

template<typename TFmt, typename ... TArgs>
bool cemuLog_log(LogType type, TFmt format, TArgs&&... args)
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> format, TArgs&&... args)
{
if (!cemuLog_isLoggingEnabled(type))
return false;

const auto format_view = fmt::to_string_view(format);
const auto text = fmt::vformat(format_view, fmt::make_args_checked<TArgs...>(format_view, args...));
const auto format_view = fmt::basic_string_view<T>(format);
const auto text = fmt::vformat(format_view, fmt::make_format_args<fmt::buffer_context<T>>(ForwardEnum(args)...));
cemuLog_log(type, std::basic_string_view(text.data(), text.size()));
return true;
}

template<typename T, typename ... TArgs>
bool cemuLog_log(LogType type, const T* format, TArgs&&... args)
{
auto format_str=std::basic_string<T>(format);
return cemuLog_log(type, format_str, std::forward<TArgs>(args)...);
}

// same as cemuLog_log, but only outputs in debug/release mode
template<typename TFmt, typename ... TArgs>
Expand Down
2 changes: 1 addition & 1 deletion src/Cemu/Tools/DownloadManager/DownloadManager.cpp
Expand Up @@ -242,7 +242,7 @@ bool DownloadManager::_connect_queryAccountStatusAndServiceURLs()
NAPI::NAPI_ECSGetAccountStatus_Result accountStatusResult = NAPI::ECS_GetAccountStatus(authInfo);
if (accountStatusResult.apiError != NAPI_RESULT::SUCCESS)
{
cemuLog_log(LogType::Force, fmt::format("ECS - Failed to query account status (error: {0} {1})", accountStatusResult.apiError, accountStatusResult.serviceError));
cemuLog_log(LogType::Force, "ECS - Failed to query account status (error: {0} {1})", accountStatusResult.apiError, accountStatusResult.serviceError);
return false;
}
if (accountStatusResult.accountStatus == NAPI::NAPI_ECSGetAccountStatus_Result::AccountStatus::UNREGISTERED)
Expand Down
6 changes: 3 additions & 3 deletions src/config/ActiveSettings.h
Expand Up @@ -30,7 +30,7 @@ class ActiveSettings
[[nodiscard]] static fs::path GetPath(std::string_view format, TArgs&&... args)
{
cemu_assert_debug(format.empty() || (format[0] != '/' && format[0] != '\\'));
std::string tmpPathStr = fmt::format(format, std::forward<TArgs>(args)...);
std::string tmpPathStr = fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
std::basic_string_view<char8_t> s((const char8_t*)tmpPathStr.data(), tmpPathStr.size());
return s_path / fs::path(s);
}
Expand All @@ -46,15 +46,15 @@ class ActiveSettings
[[nodiscard]] static fs::path GetMlcPath(std::string_view format, TArgs&&... args)
{
cemu_assert_debug(format.empty() || (format[0] != '/' && format[0] != '\\'));
auto tmp = fmt::format(format, std::forward<TArgs>(args)...);
auto tmp = fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
return GetMlcPath() / fs::path(_asUtf8(tmp));
}

template <typename ...TArgs>
[[nodiscard]] static fs::path GetMlcPath(std::wstring_view format, TArgs&&... args)
{
cemu_assert_debug(format.empty() || (format[0] != L'/' && format[0] != L'\\'));
return GetMlcPath() / fmt::format(format, std::forward<TArgs>(args)...);
return GetMlcPath() / fmt::format(fmt::runtime(format), std::forward<TArgs>(args)...);
}

// get mlc path to default cemu root dir/mlc01
Expand Down
6 changes: 3 additions & 3 deletions src/gui/CemuApp.cpp
Expand Up @@ -217,7 +217,7 @@ void CemuApp::CreateDefaultFiles(bool first_start)
// check for mlc01 folder missing if custom path has been set
if (!fs::exists(mlc) && !first_start)
{
const std::wstring message = fmt::format(_(L"Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?").ToStdWstring(), mlc);
const std::wstring message = fmt::format(fmt::runtime(_(L"Your mlc01 folder seems to be missing.\n\nThis is where Cemu stores save files, game updates and other Wii U files.\n\nThe expected path is:\n{}\n\nDo you want to create the folder at the expected path?").ToStdWstring()), mlc);

wxMessageDialog dialog(nullptr, message, "Error", wxCENTRE | wxYES_NO | wxCANCEL| wxICON_WARNING);
dialog.SetYesNoCancelLabels(_("Yes"), _("No"), _("Select a custom path"));
Expand Down Expand Up @@ -293,7 +293,7 @@ void CemuApp::CreateDefaultFiles(bool first_start)
catch (const std::exception& ex)
{
std::stringstream errorMsg;
errorMsg << fmt::format(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString(), ex.what(), boost::nowide::narrow(mlc));
errorMsg << fmt::format(fmt::runtime(_("Couldn't create a required mlc01 subfolder or file!\n\nError: {0}\nTarget path:\n{1}").ToStdString()), ex.what(), boost::nowide::narrow(mlc));

#if BOOST_OS_WINDOWS
const DWORD lastError = GetLastError();
Expand All @@ -319,7 +319,7 @@ void CemuApp::CreateDefaultFiles(bool first_start)
catch (const std::exception& ex)
{
std::stringstream errorMsg;
errorMsg << fmt::format(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString(), ex.what());
errorMsg << fmt::format(fmt::runtime(_("Couldn't create a required cemu directory or file!\n\nError: {0}").ToStdString()), ex.what());

#if BOOST_OS_WINDOWS
const DWORD lastError = GetLastError();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/GameUpdateWindow.cpp
Expand Up @@ -63,7 +63,7 @@ bool GameUpdateWindow::ParseUpdate(const fs::path& metaPath)
std::string typeStrCurrentlyInstalled = _GetTitleIdTypeStr(tmp.GetAppTitleId());

std::string wxMsg = wxHelper::MakeUTF8(_("It seems that there is already a title installed at the target location but it has a different type.\nCurrently installed: \'{}\' Installing: \'{}\'\n\nThis can happen for titles which were installed with very old Cemu versions.\nDo you still want to continue with the installation? It will replace the currently installed title."));
wxMessageDialog dialog(this, fmt::format(wxMsg, typeStrCurrentlyInstalled, typeStrToInstall), _("Warning"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION);
wxMessageDialog dialog(this, fmt::format(fmt::runtime(wxMsg), typeStrCurrentlyInstalled, typeStrToInstall), _("Warning"), wxCENTRE | wxYES_NO | wxICON_EXCLAMATION);
if (dialog.ShowModal() != wxID_YES)
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/GeneralSettings2.cpp
Expand Up @@ -1110,7 +1110,7 @@ void GeneralSettings2::OnAccountDelete(wxCommandEvent& event)
auto& account = obj->GetAccount();

const std::wstring format_str = _("Are you sure you want to delete the account {} with id {:x}?").ToStdWstring();
const std::wstring msg = fmt::format(format_str,
const std::wstring msg = fmt::format(fmt::runtime(format_str),
std::wstring{ account.GetMiiName() }, account.GetPersistentId());

const int answer = wxMessageBox(msg, _("Confirmation"), wxYES_NO | wxCENTRE | wxICON_QUESTION, this);
Expand Down
2 changes: 1 addition & 1 deletion src/gui/MainWindow.cpp
Expand Up @@ -1803,7 +1803,7 @@ class CemuAboutDialog : public wxDialog

void AddHeaderInfo(wxWindow* parent, wxSizer* sizer)
{
auto versionString = fmt::format(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}").ToStdString(), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov");
auto versionString = fmt::format(fmt::runtime(_("Cemu\nVersion {0}\nCompiled on {1}\nOriginal authors: {2}").ToStdString()), BUILD_VERSION_STRING, BUILD_DATE, "Exzap, Petergov");

sizer->Add(new wxStaticText(parent, wxID_ANY, versionString), wxSizerFlags().Border(wxALL, 3).Border(wxTOP, 10));
sizer->Add(new wxHyperlinkCtrl(parent, -1, "https://cemu.info", "https://cemu.info"), wxSizerFlags().Expand().Border(wxTOP | wxBOTTOM, 3));
Expand Down
2 changes: 1 addition & 1 deletion src/gui/canvas/VulkanCanvas.cpp
Expand Up @@ -27,7 +27,7 @@ VulkanCanvas::VulkanCanvas(wxWindow* parent, const wxSize& size, bool is_main_wi
}
catch(const std::exception& ex)
{
const auto msg = fmt::format(_("Error when initializing Vulkan renderer:\n{}").ToStdString(), ex.what());
const auto msg = fmt::format(fmt::runtime(_("Error when initializing Vulkan renderer:\n{}").ToStdString()), ex.what());
forceLog_printf(const_cast<char*>(msg.c_str()));
wxMessageDialog dialog(this, msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR);
dialog.ShowModal();
Expand Down
12 changes: 6 additions & 6 deletions src/gui/components/wxTitleManagerList.cpp
Expand Up @@ -293,23 +293,23 @@ void wxTitleManagerList::OnConvertToCompressedFormat(uint64 titleId)
std::string msg = wxHelper::MakeUTF8(_("The following content will be converted to a compressed Wii U archive file (.wua):\n \n"));

if (titleInfo_base.IsValid())
msg.append(fmt::format(wxHelper::MakeUTF8(_("Base game: {}")), _utf8Wrapper(titleInfo_base.GetPath())));
msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game: {}"))), _utf8Wrapper(titleInfo_base.GetPath())));
else
msg.append(fmt::format(wxHelper::MakeUTF8(_("Base game: Not installed"))));
msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Base game: Not installed")))));

msg.append("\n");

if (titleInfo_update.IsValid())
msg.append(fmt::format(wxHelper::MakeUTF8(_("Update: {}")), _utf8Wrapper(titleInfo_update.GetPath())));
msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update: {}"))), _utf8Wrapper(titleInfo_update.GetPath())));
else
msg.append(fmt::format(wxHelper::MakeUTF8(_("Update: Not installed"))));
msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("Update: Not installed")))));

msg.append("\n");

if (titleInfo_aoc.IsValid())
msg.append(fmt::format(wxHelper::MakeUTF8(_("DLC: {}")), _utf8Wrapper(titleInfo_aoc.GetPath())));
msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC: {}"))), _utf8Wrapper(titleInfo_aoc.GetPath())));
else
msg.append(fmt::format(wxHelper::MakeUTF8(_("DLC: Not installed"))));
msg.append(fmt::format(fmt::runtime(wxHelper::MakeUTF8(_("DLC: Not installed")))));

const int answer = wxMessageBox(wxString::FromUTF8(msg), _("Confirmation"), wxOK | wxCANCEL | wxCENTRE | wxICON_QUESTION, this);
if (answer != wxOK)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp
Expand Up @@ -71,15 +71,15 @@ void wxCreateAccountDialog::OnOK(wxCommandEvent& event)
const auto id = GetPersistentId();
if(id < Account::kMinPersistendId)
{
wxMessageBox(fmt::format(_("The persistent id must be greater than {:x}!").ToStdString(), Account::kMinPersistendId),
wxMessageBox(fmt::format(fmt::runtime(_("The persistent id must be greater than {:x}!").ToStdString()), Account::kMinPersistendId),
_("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
return;
}

const auto& account = Account::GetAccount(id);
if(account.GetPersistentId() == id)
{
const std::wstring msg = fmt::format(_("The persistent id {:x} is already in use by account {}!").ToStdWstring(),
const std::wstring msg = fmt::format(fmt::runtime(_("The persistent id {:x} is already in use by account {}!").ToStdWstring()),
account.GetPersistentId(), std::wstring{ account.GetMiiName() });
wxMessageBox(msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR, this);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/helpers/wxHelpers.h
Expand Up @@ -48,13 +48,13 @@ template<typename ...TArgs>
wxString wxStringFormat2(const wxString& format, TArgs&&...args)
{
// ignores locale?
return fmt::format(format.ToStdString(), std::forward<TArgs>(args)...);
return fmt::format(fmt::runtime(format.ToStdString()), std::forward<TArgs>(args)...);
}

template<typename ...TArgs>
wxString wxStringFormat2W(const wxString& format, TArgs&&...args)
{
return fmt::format(format.ToStdWstring(), std::forward<TArgs>(args)...);
return fmt::format(fmt::runtime(format.ToStdWstring()), std::forward<TArgs>(args)...);
}

// executes a function when destroying the obj
Expand Down
2 changes: 1 addition & 1 deletion src/util/Zir/EmitterGLSL/ZpIREmitGLSL.cpp
Expand Up @@ -35,7 +35,7 @@ class DualStringBuffer
void appendFmt(const char* format_str, Args... args)
{
char* buf = (char*)(m_strBuffer + m_offsetEnd);
char* r = fmt::format_to(buf, format_str, std::forward<Args>(args)...);
char* r = fmt::format_to(buf, fmt::runtime(format_str), std::forward<Args>(args)...);
cemu_assert_debug(r <= (char*)(m_strBuffer + N));
m_offsetEnd += (uint32)(r - buf);
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/helpers/StringBuf.h
Expand Up @@ -20,7 +20,7 @@ class StringBuf
template<typename TFmt, typename ... TArgs>
void addFmt(const TFmt& format, TArgs&&... args)
{
auto r = fmt::vformat_to_n((char*)(this->str + this->length), (size_t)(this->limit - this->length), fmt::to_string_view(format), fmt::make_args_checked<TArgs...>(format, args...));
auto r = fmt::vformat_to_n((char*)(this->str + this->length), (size_t)(this->limit - this->length), fmt::detail::to_string_view(format), fmt::make_format_args(args...));
this->length += (uint32)r.size;
}

Expand Down

0 comments on commit 0ed4fdc

Please sign in to comment.