From 0ed4fdcd789081f210d9587b24af7e5c050cfc55 Mon Sep 17 00:00:00 2001 From: SSimco <37044560+SSimco@users.noreply.github.com> Date: Mon, 5 Sep 2022 15:48:44 +0300 Subject: [PATCH] Update fmt version to 9.1.0 (#177) --- .../vcpkg_overlay_ports/fmt/portfile.cmake | 6 ++-- src/Cafe/IOSU/legacy/iosu_boss.cpp | 2 +- src/Cafe/IOSU/legacy/iosu_fpd.cpp | 2 +- src/Cemu/Logging/CemuLogging.h | 33 ++++++++++++++++--- .../Tools/DownloadManager/DownloadManager.cpp | 2 +- src/config/ActiveSettings.h | 6 ++-- src/gui/CemuApp.cpp | 6 ++-- src/gui/GameUpdateWindow.cpp | 2 +- src/gui/GeneralSettings2.cpp | 2 +- src/gui/MainWindow.cpp | 2 +- src/gui/canvas/VulkanCanvas.cpp | 2 +- src/gui/components/wxTitleManagerList.cpp | 12 +++---- .../CreateAccount/wxCreateAccountDialog.cpp | 4 +-- src/gui/helpers/wxHelpers.h | 4 +-- src/util/Zir/EmitterGLSL/ZpIREmitGLSL.cpp | 2 +- src/util/helpers/StringBuf.h | 2 +- 16 files changed, 56 insertions(+), 33 deletions(-) diff --git a/dependencies/vcpkg_overlay_ports/fmt/portfile.cmake b/dependencies/vcpkg_overlay_ports/fmt/portfile.cmake index aef43b47..e3edc0f6 100644 --- a/dependencies/vcpkg_overlay_ports/fmt/portfile.cmake +++ b/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( diff --git a/src/Cafe/IOSU/legacy/iosu_boss.cpp b/src/Cafe/IOSU/legacy/iosu_boss.cpp index 4c99f5df..22c11eba 100644 --- a/src/Cafe/IOSU/legacy/iosu_boss.cpp +++ b/src/Cafe/IOSU/legacy/iosu_boss.cpp @@ -219,7 +219,7 @@ namespace iosu template curl_slist* append_header_param(struct curl_slist* list, const char* format, TArgs&& ... args) { - return curl_slist_append(list, fmt::format(format, std::forward(args)...).c_str()); + return curl_slist_append(list, fmt::format(fmt::runtime(format), std::forward(args)...).c_str()); } bool starts_with(const char* str, const char* pre) diff --git a/src/Cafe/IOSU/legacy/iosu_fpd.cpp b/src/Cafe/IOSU/legacy/iosu_fpd.cpp index 678c187f..ec8733ab 100644 --- a/src/Cafe/IOSU/legacy/iosu_fpd.cpp +++ b/src/Cafe/IOSU/legacy/iosu_fpd.cpp @@ -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); } } } diff --git a/src/Cemu/Logging/CemuLogging.h b/src/Cemu/Logging/CemuLogging.h index 4238b638..d89d9cec 100644 --- a/src/Cemu/Logging/CemuLogging.h +++ b/src/Cemu/Logging/CemuLogging.h @@ -36,7 +36,8 @@ enum class LogType : sint32 template <> struct fmt::formatter : formatter { template - 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::format(s, ctx); } @@ -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 -bool cemuLog_log(LogType type, TFmt format, TArgs&&... args) +template +auto ForwardEnum(T t) +{ + if constexpr (std::is_enum_v) + return fmt::underlying(t); + else + return std::forward(t); +} + +template +auto ForwardEnum(std::tuple t) +{ + return std::apply([](auto... x) { return std::make_tuple(ForwardEnum(x)...); }, t); +} + +template +bool cemuLog_log(LogType type, std::basic_string 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(format_view, args...)); + const auto format_view = fmt::basic_string_view(format); + const auto text = fmt::vformat(format_view, fmt::make_format_args>(ForwardEnum(args)...)); cemuLog_log(type, std::basic_string_view(text.data(), text.size())); return true; } + +template +bool cemuLog_log(LogType type, const T* format, TArgs&&... args) +{ + auto format_str=std::basic_string(format); + return cemuLog_log(type, format_str, std::forward(args)...); +} // same as cemuLog_log, but only outputs in debug/release mode template diff --git a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp index 45b66eed..f953844a 100644 --- a/src/Cemu/Tools/DownloadManager/DownloadManager.cpp +++ b/src/Cemu/Tools/DownloadManager/DownloadManager.cpp @@ -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) diff --git a/src/config/ActiveSettings.h b/src/config/ActiveSettings.h index 44b5f509..95ceae16 100644 --- a/src/config/ActiveSettings.h +++ b/src/config/ActiveSettings.h @@ -30,7 +30,7 @@ public: [[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(args)...); + std::string tmpPathStr = fmt::format(fmt::runtime(format), std::forward(args)...); std::basic_string_view s((const char8_t*)tmpPathStr.data(), tmpPathStr.size()); return s_path / fs::path(s); } @@ -46,7 +46,7 @@ public: [[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(args)...); + auto tmp = fmt::format(fmt::runtime(format), std::forward(args)...); return GetMlcPath() / fs::path(_asUtf8(tmp)); } @@ -54,7 +54,7 @@ public: [[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(args)...); + return GetMlcPath() / fmt::format(fmt::runtime(format), std::forward(args)...); } // get mlc path to default cemu root dir/mlc01 diff --git a/src/gui/CemuApp.cpp b/src/gui/CemuApp.cpp index 17e31f7a..e78b30b3 100644 --- a/src/gui/CemuApp.cpp +++ b/src/gui/CemuApp.cpp @@ -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")); @@ -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(); @@ -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(); diff --git a/src/gui/GameUpdateWindow.cpp b/src/gui/GameUpdateWindow.cpp index a42d4087..c689dd6f 100644 --- a/src/gui/GameUpdateWindow.cpp +++ b/src/gui/GameUpdateWindow.cpp @@ -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; } diff --git a/src/gui/GeneralSettings2.cpp b/src/gui/GeneralSettings2.cpp index 012b8557..78e1feec 100644 --- a/src/gui/GeneralSettings2.cpp +++ b/src/gui/GeneralSettings2.cpp @@ -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); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index b23a5ca7..8f26f810 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -1803,7 +1803,7 @@ public: 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)); diff --git a/src/gui/canvas/VulkanCanvas.cpp b/src/gui/canvas/VulkanCanvas.cpp index dfad8c9a..b8faa8c7 100644 --- a/src/gui/canvas/VulkanCanvas.cpp +++ b/src/gui/canvas/VulkanCanvas.cpp @@ -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(msg.c_str())); wxMessageDialog dialog(this, msg, _("Error"), wxOK | wxCENTRE | wxICON_ERROR); dialog.ShowModal(); diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index 9ac31bce..c8c1d6e4 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -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) diff --git a/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp b/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp index 49e7f5ec..71b56637 100644 --- a/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp +++ b/src/gui/dialogs/CreateAccount/wxCreateAccountDialog.cpp @@ -71,7 +71,7 @@ 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; } @@ -79,7 +79,7 @@ void wxCreateAccountDialog::OnOK(wxCommandEvent& event) 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; diff --git a/src/gui/helpers/wxHelpers.h b/src/gui/helpers/wxHelpers.h index 96c8dcfa..8fd0f8a9 100644 --- a/src/gui/helpers/wxHelpers.h +++ b/src/gui/helpers/wxHelpers.h @@ -48,13 +48,13 @@ template wxString wxStringFormat2(const wxString& format, TArgs&&...args) { // ignores locale? - return fmt::format(format.ToStdString(), std::forward(args)...); + return fmt::format(fmt::runtime(format.ToStdString()), std::forward(args)...); } template wxString wxStringFormat2W(const wxString& format, TArgs&&...args) { - return fmt::format(format.ToStdWstring(), std::forward(args)...); + return fmt::format(fmt::runtime(format.ToStdWstring()), std::forward(args)...); } // executes a function when destroying the obj diff --git a/src/util/Zir/EmitterGLSL/ZpIREmitGLSL.cpp b/src/util/Zir/EmitterGLSL/ZpIREmitGLSL.cpp index aab2c49e..0b0c2dc5 100644 --- a/src/util/Zir/EmitterGLSL/ZpIREmitGLSL.cpp +++ b/src/util/Zir/EmitterGLSL/ZpIREmitGLSL.cpp @@ -35,7 +35,7 @@ public: 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)...); + char* r = fmt::format_to(buf, fmt::runtime(format_str), std::forward(args)...); cemu_assert_debug(r <= (char*)(m_strBuffer + N)); m_offsetEnd += (uint32)(r - buf); } diff --git a/src/util/helpers/StringBuf.h b/src/util/helpers/StringBuf.h index 3744caa4..8c7b1645 100644 --- a/src/util/helpers/StringBuf.h +++ b/src/util/helpers/StringBuf.h @@ -20,7 +20,7 @@ public: template 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(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; }