From ddef95e2db52f107501da7fd641f9b352121618d Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Wed, 9 Apr 2025 23:35:32 -0400 Subject: [PATCH] deps/fmt: code compiles now (untested) --- common/formatter/formatter.cpp | 2 +- common/goos/Interpreter.cpp | 25 ++++++------------- common/log/log.h | 2 +- common/repl/repl_wrapper.cpp | 7 +++--- game/overlord/jak3/pagemanager.cpp | 3 ++- game/system/hid/sdl_util.cpp | 1 + .../build_level/common/color_quantization.cpp | 1 + goalc/build_level/jak1/build_level.cpp | 2 ++ 8 files changed, 20 insertions(+), 23 deletions(-) diff --git a/common/formatter/formatter.cpp b/common/formatter/formatter.cpp index dc98f4503c..8e10b92e59 100644 --- a/common/formatter/formatter.cpp +++ b/common/formatter/formatter.cpp @@ -6,12 +6,12 @@ #include "common/formatter/rules/rule_config.h" #include "common/log/log.h" #include "common/util/FileUtil.h" -#include "common/util/ast_util.h" #include "common/util/string_util.h" #include "tree_sitter/api.h" #include "fmt/format.h" +#include "fmt/ranges.h" // Declare the `tree_sitter_opengoal` function, which is // implemented by the `tree-sitter-opengoal` library. diff --git a/common/goos/Interpreter.cpp b/common/goos/Interpreter.cpp index cf24fdbbb0..abe5030bf8 100644 --- a/common/goos/Interpreter.cpp +++ b/common/goos/Interpreter.cpp @@ -16,6 +16,7 @@ #include "common/util/string_util.h" #include "common/util/unicode_util.h" +#include "fmt/args.h" #include "fmt/base.h" #include "fmt/format.h" @@ -1770,26 +1771,16 @@ Object Interpreter::eval_format(const Object& form, throw_eval_error(form, "format string must be a string"); } - std::vector strings; + fmt::dynamic_format_arg_store arg_store; for (size_t i = 2; i < args.unnamed.size(); i++) { - if (args.unnamed.at(i).is_string()) { - strings.push_back(args.unnamed.at(i).as_string()->data); - } else { - strings.push_back(args.unnamed.at(i).print()); - } + if (args.unnamed.at(i).is_string()) { + arg_store.push_back(args.unnamed.at(i).as_string()->data); + } else { + arg_store.push_back(args.unnamed.at(i).print()); + } } - // Create a vector of fmt::format_arg - std::vector> fmt_args; - for (auto& x : strings) { - fmt_args.push_back(fmt::make_format_args(x)); - } - - // Format the string using the public API - auto formatted = fmt::vformat( - format_str.as_string()->data, - fmt::basic_format_args(fmt_args.data(), static_cast(fmt_args.size())) - ); + auto formatted = fmt::vformat(format_str.as_string()->data, arg_store); if (truthy(dest)) { lg::print("{}", formatted.c_str()); } diff --git a/common/log/log.h b/common/log/log.h index 7ce37db5af..6d59c7db84 100644 --- a/common/log/log.h +++ b/common/log/log.h @@ -72,7 +72,7 @@ void print(const std::string& format, Args&&... args) { } template void print(const fmt::text_style& ts, const std::string& format, Args&&... args) { - std::string formatted_message = fmt::format(ts, format, std::forward(args)...); + std::string formatted_message = fmt::vformat(ts, format, fmt::make_format_args(args...)); internal::log_print(formatted_message.c_str()); } diff --git a/common/repl/repl_wrapper.cpp b/common/repl/repl_wrapper.cpp index 3370a3d9ee..5544f2ec00 100644 --- a/common/repl/repl_wrapper.cpp +++ b/common/repl/repl_wrapper.cpp @@ -7,6 +7,7 @@ #include "fmt/color.h" #include "fmt/format.h" +#include "fmt/ranges.h" #include "third-party/replxx/include/replxx.hxx" namespace REPL { @@ -41,7 +42,7 @@ void Wrapper::print_welcome_message(const std::vector& loaded_proje message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " . --- ."); message += fmt::format(" Project Path: {}\n", - fmt::format(fg(fmt::color::gray), file_util::get_jak_project_dir().string())); + fmt::styled(file_util::get_jak_project_dir().string(), fg(fmt::color::gray))); message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " - :===: -"); std::string effective_iso_path; if (repl_config.iso_path.empty()) { @@ -50,7 +51,7 @@ void Wrapper::print_welcome_message(const std::vector& loaded_proje effective_iso_path = repl_config.iso_path; } message += - fmt::format(" ISO Data Path: {}\n", fmt::format(fg(fmt::color::gray), effective_iso_path)); + fmt::format(" ISO Data Path: {}\n", fmt::styled(effective_iso_path, fg(fmt::color::gray))); message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " --. .--: :--. .--"); message += " nREPL:"; if (!nrepl_alive) { @@ -63,7 +64,7 @@ void Wrapper::print_welcome_message(const std::vector& loaded_proje message += " Source File Search Dirs: "; const auto search_dir_string = fmt::format("{}", fmt::join(repl_config.asm_file_search_dirs, ",")); - message += fmt::format("[{}]\n", fmt::format(fg(fmt::color::gray), search_dir_string)); + message += fmt::format("[{}]\n", fmt::styled(search_dir_string, fg(fmt::color::gray))); message += fmt::format(fmt::emphasis::bold | fg(fmt::color::orange), " .-=====-. .-=====-"); message += fmt::format(" {} or {} for basic help and usage\n", fmt::format(fg(fmt::color::cyan), "(repl-help)"), diff --git a/game/overlord/jak3/pagemanager.cpp b/game/overlord/jak3/pagemanager.cpp index 88d829f49a..b5153d4b63 100644 --- a/game/overlord/jak3/pagemanager.cpp +++ b/game/overlord/jak3/pagemanager.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "common/log/log.h" #include "common/util/Assert.h" @@ -849,4 +850,4 @@ void CPageManager::GarbageCollectPageList(jak3::CPageList* list) { } } -} // namespace jak3 \ No newline at end of file +} // namespace jak3 diff --git a/game/system/hid/sdl_util.cpp b/game/system/hid/sdl_util.cpp index 95d07a1f9b..591c6279b1 100644 --- a/game/system/hid/sdl_util.cpp +++ b/game/system/hid/sdl_util.cpp @@ -2,6 +2,7 @@ #include "common/log/log.h" +#include "fmt/ranges.h" #include "third-party/SDL/include/SDL3/SDL.h" namespace sdl_util { diff --git a/goalc/build_level/common/color_quantization.cpp b/goalc/build_level/common/color_quantization.cpp index e4750281cb..2525935c7d 100644 --- a/goalc/build_level/common/color_quantization.cpp +++ b/goalc/build_level/common/color_quantization.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "common/log/log.h" #include "common/util/Assert.h" diff --git a/goalc/build_level/jak1/build_level.cpp b/goalc/build_level/jak1/build_level.cpp index e3051f2b36..8714332429 100644 --- a/goalc/build_level/jak1/build_level.cpp +++ b/goalc/build_level/jak1/build_level.cpp @@ -14,6 +14,8 @@ #include "goalc/build_level/jak1/FileInfo.h" #include "goalc/build_level/jak1/LevelFile.h" +#include "fmt/ranges.h" + namespace jak1 { bool run_build_level(const std::string& input_file, const std::string& bsp_output_file,