From 057ae361bf53854d2f79707533b1f752f40a7a33 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sun, 21 May 2023 16:24:23 -0500 Subject: [PATCH] LSP: OpenGOAL Feature Support - Part 1 (#2668) --- .vscode/extensions.json | 2 +- common/log/log.cpp | 8 +- common/log/log.h | 4 +- common/util/FileUtil.cpp | 21 +- common/util/FileUtil.h | 1 + common/util/json_util.h | 22 + common/util/string_util.cpp | 20 + common/util/string_util.h | 3 +- decompiler/config/jak2/all-types.gc | 74 +- goal_src/jak2/engine/camera/cam-layout.gc | 2 +- .../jak2/engine/collide/collide-edge-grab.gc | 2 +- goal_src/jak2/engine/debug/debug.gc | 4 +- goal_src/jak2/engine/debug/editable.gc | 14 +- goal_src/jak2/engine/debug/menu.gc | 28 +- goal_src/jak2/engine/draw/drawable.gc | 2 +- goal_src/jak2/engine/entity/entity.gc | 10 +- goal_src/jak2/engine/game/game-info.gc | 4 +- .../jak2/engine/game/task/task-control.gc | 2 +- goal_src/jak2/engine/geometry/path.gc | 4 +- goal_src/jak2/engine/gfx/font-h.gc | 74 +- goal_src/jak2/engine/level/region.gc | 8 +- goal_src/jak2/engine/math/math.gc | 3 +- goal_src/jak2/engine/nav/nav-control.gc | 2 +- goal_src/jak2/engine/nav/nav-mesh.gc | 10 +- .../process-drawable/process-drawable.gc | 2 +- goal_src/jak2/engine/scene/scene.gc | 4 +- goal_src/jak2/engine/ui/hud-classes.gc | 4 +- goal_src/jak2/engine/ui/hud.gc | 2 +- .../jak2/engine/ui/progress/progress-draw.gc | 148 +- goal_src/jak2/engine/ui/progress/progress.gc | 2 +- .../jak2/levels/city/common/ctywide-obs.gc | 4 +- .../jak2/levels/city/common/height-map.gc | 2 +- goal_src/jak2/levels/city/common/nav-graph.gc | 2 +- .../jak2/levels/city/common/traffic-engine.gc | 2 +- goal_src/jak2/levels/city/common/trail.gc | 4 +- goal_src/jak2/levels/common/ai/bot.gc | 2 +- goal_src/jak2/levels/common/battle.gc | 4 +- .../common/enemy/hover/hover-nav-control.gc | 2 +- goal_src/jak2/levels/common/races/race-hud.gc | 16 +- .../jak2/levels/common/races/race-manager.gc | 4 +- .../jak2/levels/common/races/race-mesh.gc | 2 +- goal_src/jak2/levels/demo/demo-obs.gc | 4 +- goal_src/jak2/levels/gungame/gungame-obs.gc | 2 +- goal_src/jak2/levels/title/title-obs.gc | 4 +- goal_src/jak2/pc/debug/anim-tester-x.gc | 6 +- goal_src/jak2/pc/features/speedruns.gc | 2 +- goalc/compiler/Compiler.h | 5 +- .../compiler/compilation/CompilerControl.cpp | 7 + goalc/compiler/docs/DocTypes.cpp | 47 +- lsp/CMakeLists.txt | 17 +- lsp/handlers/initialize.h | 2 + lsp/handlers/lsp_router.cpp | 13 + lsp/handlers/lsp_router.h | 6 +- lsp/handlers/text_document/completion.h | 5 +- lsp/handlers/text_document/document_color.h | 77 + lsp/handlers/text_document/document_symbol.h | 2 + .../text_document/document_synchronization.h | 42 +- lsp/handlers/text_document/go_to.h | 82 +- lsp/handlers/text_document/hover.h | 144 +- lsp/main.cpp | 10 +- lsp/protocol/common_types.cpp | 23 + lsp/protocol/common_types.h | 52 +- lsp/protocol/completion.cpp | 4 + lsp/protocol/completion.h | 95 + lsp/protocol/document_color.cpp | 19 + lsp/protocol/document_color.h | 24 + lsp/protocol/hover.cpp | 9 - lsp/protocol/hover.h | 34 - lsp/protocol/initialize_result.h | 3 +- lsp/protocol/progress_report.cpp | 79 + lsp/protocol/progress_report.h | 105 + lsp/state/app.h | 2 +- lsp/state/lsp_requester.cpp | 76 + lsp/state/lsp_requester.h | 19 + lsp/state/workspace.cpp | 204 +- lsp/state/workspace.h | 52 +- .../jak2/engine/camera/cam-layout_REF.gc | 2 +- .../engine/collide/collide-edge-grab_REF.gc | 2 +- .../reference/jak2/engine/debug/debug_REF.gc | 14 +- .../jak2/engine/debug/editable_REF.gc | 21 +- .../reference/jak2/engine/debug/menu_REF.gc | 37 +- .../jak2/engine/draw/drawable_REF.gc | 8 +- .../jak2/engine/entity/entity_REF.gc | 10 +- .../jak2/engine/game/game-info_REF.gc | 4 +- .../jak2/engine/game/task/task-control_REF.gc | 18 +- .../jak2/engine/geometry/path_REF.gc | 4 +- .../reference/jak2/engine/level/region_REF.gc | 8 +- .../jak2/engine/nav/nav-control_REF.gc | 2 +- .../reference/jak2/engine/nav/nav-mesh_REF.gc | 10 +- .../process-drawable/process-drawable_REF.gc | 2 +- .../reference/jak2/engine/scene/scene_REF.gc | 4 +- .../jak2/engine/ui/hud-classes_REF.gc | 8 +- .../engine/ui/progress/progress-draw_REF.gc | 148 +- .../jak2/engine/ui/progress/progress_REF.gc | 2 +- .../levels/city/common/ctywide-obs_REF.gc | 4 +- .../jak2/levels/city/common/height-map_REF.gc | 6 +- .../jak2/levels/city/common/nav-graph_REF.gc | 2 +- .../levels/city/common/traffic-engine_REF.gc | 2 +- .../jak2/levels/city/common/trail_REF.gc | 4 +- .../jak2/levels/common/ai/bot_REF.gc | 2 +- .../jak2/levels/common/battle_REF.gc | 4 +- .../enemy/hover/hover-nav-control_REF.gc | 2 +- .../jak2/levels/common/races/race-hud_REF.gc | 16 +- .../levels/common/races/race-manager_REF.gc | 28 +- .../jak2/levels/common/races/race-mesh_REF.gc | 2 +- .../jak2/levels/demo/demo-obs_REF.gc | 4 +- .../jak2/levels/gungame/gungame-obs_REF.gc | 2 +- .../jak2/levels/title/title-obs_REF.gc | 4 +- third-party/json.hpp | 13795 ++++++++-------- 109 files changed, 8032 insertions(+), 7956 deletions(-) create mode 100644 lsp/handlers/text_document/document_color.h create mode 100644 lsp/protocol/document_color.cpp create mode 100644 lsp/protocol/document_color.h create mode 100644 lsp/protocol/progress_report.cpp create mode 100644 lsp/protocol/progress_report.h create mode 100644 lsp/state/lsp_requester.cpp create mode 100644 lsp/state/lsp_requester.h diff --git a/.vscode/extensions.json b/.vscode/extensions.json index cadc99d8a..ecce19d95 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,7 +3,7 @@ // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp // List of extensions which should be recommended for users of this workspace. - "recommendations": ["opengoal.opengoal", "naumovs.color-highlight"], + "recommendations": ["opengoal.opengoal"], // List of extensions recommended by VS Code that should not be recommended for users of this workspace. "unwantedRecommendations": [] } diff --git a/common/log/log.cpp b/common/log/log.cpp index 8ec3fcc74..29d972edd 100644 --- a/common/log/log.cpp +++ b/common/log/log.cpp @@ -111,7 +111,7 @@ void log_print(const char* message) { // how many extra log files for a single program should be kept? constexpr int LOG_ROTATE_MAX = 5; -void set_file(const std::string& filename, const bool should_rotate) { +void set_file(const std::string& filename, const bool should_rotate, const bool append) { ASSERT(!gLogger.fp); file_util::create_dir_if_needed_for_file(filename); @@ -133,7 +133,11 @@ void set_file(const std::string& filename, const bool should_rotate) { } } - gLogger.fp = file_util::open_file(filename.c_str(), "w"); + if (append) { + gLogger.fp = file_util::open_file(filename.c_str(), "a"); + } else { + gLogger.fp = file_util::open_file(filename.c_str(), "w"); + } ASSERT(gLogger.fp); } diff --git a/common/log/log.h b/common/log/log.h index e41651579..a0b85f763 100644 --- a/common/log/log.h +++ b/common/log/log.h @@ -40,7 +40,9 @@ void log_message(level log_level, LogTime& now, const char* message); void log_print(const char* message); } // namespace internal -void set_file(const std::string& filename, const bool should_rotate = true); +void set_file(const std::string& filename, + const bool should_rotate = true, + const bool append = false); void set_flush_level(level log_level); void set_file_level(level log_level); void set_stdout_level(level log_level); diff --git a/common/util/FileUtil.cpp b/common/util/FileUtil.cpp index f5aaf6ecd..05e950c22 100644 --- a/common/util/FileUtil.cpp +++ b/common/util/FileUtil.cpp @@ -111,20 +111,21 @@ std::string get_current_executable_path() { #endif } +std::optional try_get_project_path_from_path(const std::string& path) { + std::string::size_type pos = + std::string(path).rfind("jak-project"); // Strip file path down to /jak-project/ directory + if (pos == std::string::npos) { + return {}; + } + return std::string(path).substr( + 0, pos + 11); // + 12 to include "/jak-project" in the returned filepath +} + /*! * See if the current executable is somewhere in jak-project/. If so, return the path to jak-project */ std::optional try_get_jak_project_path() { - std::string my_path = get_current_executable_path(); - - std::string::size_type pos = - std::string(my_path).rfind("jak-project"); // Strip file path down to /jak-project/ directory - if (pos == std::string::npos) { - return {}; - } - - return std::make_optional(std::string(my_path).substr( - 0, pos + 11)); // + 12 to include "/jak-project" in the returned filepath + return try_get_project_path_from_path(get_current_executable_path()); } std::optional try_get_data_dir() { diff --git a/common/util/FileUtil.h b/common/util/FileUtil.h index 5c5337a5b..14ce1bf3c 100644 --- a/common/util/FileUtil.h +++ b/common/util/FileUtil.h @@ -37,6 +37,7 @@ fs::path get_jak_project_dir(); bool create_dir_if_needed(const fs::path& path); bool create_dir_if_needed_for_file(const std::string& path); bool create_dir_if_needed_for_file(const fs::path& path); +std::optional try_get_project_path_from_path(const std::string& path); bool setup_project_path(std::optional project_path_override); std::string get_file_path(const std::vector& path); void write_binary_file(const std::string& name, const void* data, size_t size); diff --git a/common/util/json_util.h b/common/util/json_util.h index c5e7948d1..fb0d667f9 100644 --- a/common/util/json_util.h +++ b/common/util/json_util.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "common/util/Range.h" @@ -12,7 +13,28 @@ std::string strip_cpp_style_comments(const std::string& input); nlohmann::json parse_commented_json(const std::string& input, const std::string& source_name); Range parse_json_optional_integer_range(const nlohmann::json& json); +#define json_serialize(field_name) j[#field_name] = obj.field_name; + +#define json_serialize_optional(field_name) \ + if (obj.field_name) { \ + j[#field_name] = obj.field_name.value(); \ + } + #define json_deserialize_if_exists(field_name) \ if (j.contains(#field_name)) { \ j.at(#field_name).get_to(obj.field_name); \ } + +template +void json_get_optional(const nlohmann::json& json, + const std::string& key, + std::optional& optionalValue) { + if (json.contains(key) && !json[key].is_null()) { + optionalValue = json[key].get(); + } +} + +#define json_deserialize_optional_if_exists(field_name) \ + if (j.contains(#field_name)) { \ + json_get_optional(j, #field_name, obj.field_name); \ + } diff --git a/common/util/string_util.cpp b/common/util/string_util.cpp index 1d3826ba5..a3f343871 100644 --- a/common/util/string_util.cpp +++ b/common/util/string_util.cpp @@ -1,5 +1,6 @@ #include "string_util.h" +#include #include #include "common/util/diff.h" @@ -101,4 +102,23 @@ bool replace(std::string& str, const std::string& from, const std::string& to) { str.replace(start_pos, from.length(), to); return true; } + +std::string uuid() { + static std::random_device dev; + static std::mt19937 rng(dev()); + + std::uniform_int_distribution dist(0, 15); + + const char* v = "0123456789abcdef"; + const bool dash[] = {0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0}; + + std::string res; + for (int i = 0; i < 16; i++) { + if (dash[i]) + res += "-"; + res += v[dist(rng)]; + res += v[dist(rng)]; + } + return res; +} } // namespace str_util diff --git a/common/util/string_util.h b/common/util/string_util.h index 8306fc59f..c06642f9a 100644 --- a/common/util/string_util.h +++ b/common/util/string_util.h @@ -6,7 +6,7 @@ namespace str_util { bool contains(const std::string& s, const std::string& substr); bool starts_with(const std::string& s, const std::string& prefix); -bool ends_with(const std::string& s, const std::string& prefix); +bool ends_with(const std::string& s, const std::string& suffix); std::string ltrim(const std::string& s); std::string rtrim(const std::string& s); std::string trim(const std::string& s); @@ -21,4 +21,5 @@ std::vector split(const ::std::string& str, char delimiter = '\n'); std::string join(const std::vector& strs, const std::string& join_with); std::vector regex_get_capture_groups(const std::string& str, const std::string& regex); bool replace(std::string& str, const std::string& from, const std::string& to); +std::string uuid(); } // namespace str_util diff --git a/decompiler/config/jak2/all-types.gc b/decompiler/config/jak2/all-types.gc index 009ea83d3..93c8ae017 100644 --- a/decompiler/config/jak2/all-types.gc +++ b/decompiler/config/jak2/all-types.gc @@ -6311,45 +6311,45 @@ (defenum font-color :type uint32 (default 0) - (#dadada 1) - (#ededed 2) + (font-color-1 1) + (font-color-2 2) (red 3) - (gold-#ba9200 4) - (yellow-#f3f300 5) - (green-#3df23d 6) - (blue-#003cf1 7) - (cyan-#00fefe 8) - (magenta-#f87df8 9) - (#a0d5d5 10) - (#7cbaba 11) - (white-#ffffff 12) - (#959595 13) - (#f9a400 14) - (#daf95e 15) - (#8aa81f 16) - (#a6b5a6 17) - (#757f75 18) - (#5e3f5e 19) + (gold 4) + (yellow 5) + (green 6) + (blue 7) + (cyan 8) + (magenta 9) + (font-color-10 10) + (font-color-11 11) + (white 12) + (font-color-13 13) + (font-color-14 14) + (font-color-15 15) + (font-color-16 16) + (font-color-17 17) + (font-color-18 18) + (font-color-19 19) (flat-yellow 20) - (#3fbaed 21) - (#3a3a3a 22) - (#5c5c5c 23) - (#f298c8 24) - (#f46868 25) - (#20ca98 26) - (#8289de 27) - (#a8f3f6 28) - (#fef666 29) - (#f1f104 30) - (#8ed0f4 31) - (#7efbfb 32) - (#7ffcfc 33) - (#f9f9f9 34) - (#408080 35) - (#e0f0e0 36) - (#c00000 37) - (#ffc040 38) - (#000000 39) + (font-color-21 21) + (font-color-22 22) + (font-color-23 23) + (font-color-24 24) + (font-color-25 25) + (font-color-26 26) + (font-color-27 27) + (font-color-28 28) + (font-color-29 29) + (font-color-30 30) + (font-color-31 31) + (font-color-32 32) + (font-color-33 33) + (font-color-34 34) + (font-color-35 35) + (font-color-36 36) + (font-color-37 37) + (font-color-38 38) + (font-color-39 39) ) ;; ---font-h:font-color diff --git a/goal_src/jak2/engine/camera/cam-layout.gc b/goal_src/jak2/engine/camera/cam-layout.gc index 0d9d80604..156266f32 100644 --- a/goal_src/jak2/engine/camera/cam-layout.gc +++ b/goal_src/jak2/engine/camera/cam-layout.gc @@ -167,7 +167,7 @@ (with-dma-buffer-add-bucket ((s5-0 (-> *display* frames (-> *display* on-screen) debug-buf)) (bucket-id debug2) ) - (draw-string-xy arg2 s5-0 arg0 arg1 (font-color #dadada) (font-flags shadow kerning)) + (draw-string-xy arg2 s5-0 arg0 arg1 (font-color font-color-1) (font-flags shadow kerning)) ) ) diff --git a/goal_src/jak2/engine/collide/collide-edge-grab.gc b/goal_src/jak2/engine/collide/collide-edge-grab.gc index fe34340c4..0d2eddb9f 100644 --- a/goal_src/jak2/engine/collide/collide-edge-grab.gc +++ b/goal_src/jak2/engine/collide/collide-edge-grab.gc @@ -589,7 +589,7 @@ ) (sv-32 a0-10 a1-4 a2-2) ) - (s2-0 s1-0 (the-as bucket-id s0-0) *temp-string* s3-0 (font-color #dadada) (the-as vector2h #f)) + (s2-0 s1-0 (the-as bucket-id s0-0) *temp-string* s3-0 (font-color font-color-1) (the-as vector2h #f)) ) ) ) diff --git a/goal_src/jak2/engine/debug/debug.gc b/goal_src/jak2/engine/debug/debug.gc index c8731b088..64deec7de 100644 --- a/goal_src/jak2/engine/debug/debug.gc +++ b/goal_src/jak2/engine/debug/debug.gc @@ -1598,10 +1598,10 @@ Most functions take a boolean as their first argument. If the boolean is set to (font-color red) ) ((= v1-7 2) - (font-color yellow-#f3f300) + (font-color yellow) ) ((= v1-7 4) - (font-color green-#3df23d) + (font-color green) ) (else (font-color default) diff --git a/goal_src/jak2/engine/debug/editable.gc b/goal_src/jak2/engine/debug/editable.gc index 1eca4e22b..2384f80a7 100644 --- a/goal_src/jak2/engine/debug/editable.gc +++ b/goal_src/jak2/engine/debug/editable.gc @@ -123,7 +123,7 @@ (s1-0 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "region-~D~%" (-> obj id)) - (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* arg0 (font-color #dadada) sv-32) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) (when (>= arg1 1) @@ -134,7 +134,7 @@ (s1-1 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "(on-enter ~S)" s4-1) - (s3-1 s2-1 (the-as bucket-id s1-1) *temp-string* arg0 (font-color #dadada) sv-32) + (s3-1 s2-1 (the-as bucket-id s1-1) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -146,7 +146,7 @@ (s1-2 318) ) (format (clear *temp-string*) "(on-inside ~S)" s4-2) - (s3-2 s2-2 (the-as bucket-id s1-2) *temp-string* arg0 (font-color #dadada) sv-32) + (s3-2 s2-2 (the-as bucket-id s1-2) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -158,7 +158,7 @@ (s2-3 318) ) (format (clear *temp-string*) "(on-exit ~S)" s5-1) - (s4-3 s3-3 (the-as bucket-id s2-3) *temp-string* arg0 (font-color #dadada) sv-32) + (s4-3 s3-3 (the-as bucket-id s2-3) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -951,7 +951,7 @@ (s3-1 318) ) (format (clear *temp-string*) "~S~%" (-> obj name)) - (s5-1 s4-1 (the-as bucket-id s3-1) *temp-string* (-> obj trans) (font-color #dadada) (the-as vector2h #f)) + (s5-1 s4-1 (the-as bucket-id s3-1) *temp-string* (-> obj trans) (font-color font-color-1) (the-as vector2h #f)) ) ) ((method-of-type editable-sphere editable-method-10) obj) @@ -1185,8 +1185,8 @@ *temp-string* (-> gp-0 s4-1) (if (logtest? (-> obj flags) (editable-flag orient)) - (font-color yellow-#f3f300) - (font-color #dadada) + (font-color yellow) + (font-color font-color-1) ) (the-as vector2h #f) ) diff --git a/goal_src/jak2/engine/debug/menu.gc b/goal_src/jak2/engine/debug/menu.gc index 78c1358f4..7406b0bc7 100644 --- a/goal_src/jak2/engine/debug/menu.gc +++ b/goal_src/jak2/engine/debug/menu.gc @@ -740,13 +740,13 @@ ) (set! (-> s5-0 color) (cond ((zero? arg3) - (font-color white-#ffffff) + (font-color white) ) (arg4 - (font-color #7cbaba) + (font-color font-color-11) ) (else - (font-color #959595) + (font-color font-color-13) ) ) ) @@ -807,19 +807,19 @@ ) (set! (-> v1-2 color) (cond ((= (-> arg0 is-on) 'invalid) - (font-color #5e3f5e) + (font-color font-color-19) ) ((-> arg0 is-on) (if (zero? arg3) - (font-color #daf95e) - (font-color #8aa81f) + (font-color font-color-15) + (font-color font-color-16) ) ) ((zero? arg3) - (font-color #a6b5a6) + (font-color font-color-17) ) (else - (font-color #757f75) + (font-color font-color-18) ) ) ) @@ -844,15 +844,15 @@ (set! (-> s5-0 color) (cond ((zero? arg3) (if (-> arg0 grabbed-joypad-p) - (font-color #a0d5d5) - (font-color white-#ffffff) + (font-color font-color-10) + (font-color white) ) ) (arg4 - (font-color #7cbaba) + (font-color font-color-11) ) (else - (font-color #959595) + (font-color font-color-13) ) ) ) @@ -949,8 +949,8 @@ (while (not (null? s1-1)) (when (= s0-1 arg3) (set! (-> arg0 context font color) (if (nonzero? arg4) - (font-color #959595) - (font-color white-#ffffff) + (font-color font-color-13) + (font-color white) ) ) (let ((v1-20 (-> arg0 context font)) diff --git a/goal_src/jak2/engine/draw/drawable.gc b/goal_src/jak2/engine/draw/drawable.gc index bc63f0aed..89120edee 100644 --- a/goal_src/jak2/engine/draw/drawable.gc +++ b/goal_src/jak2/engine/draw/drawable.gc @@ -213,7 +213,7 @@ (bucket-id debug-no-zbuf1) arg1 (-> arg0 bsphere) - (font-color #dadada) + (font-color font-color-1) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/engine/entity/entity.gc b/goal_src/jak2/engine/entity/entity.gc index 15e4e0a75..caeee7d37 100644 --- a/goal_src/jak2/engine/entity/entity.gc +++ b/goal_src/jak2/engine/entity/entity.gc @@ -1107,7 +1107,7 @@ (-> (the-as process-drawable arg0) root trans) (if (logtest? (-> sv-16 extra perm status) (entity-perm-status bit-0 bit-1)) (font-color red) - (font-color #dadada) + (font-color font-color-1) ) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) @@ -1123,7 +1123,7 @@ (the-as bucket-id s3-1) *temp-string* (-> (the-as process-drawable arg0) root trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 24)) ) ) @@ -1135,7 +1135,7 @@ (bucket-id debug-no-zbuf1) (symbol->string v1-49) (-> (the-as process-drawable arg0) root trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 24)) ) ) @@ -1170,7 +1170,7 @@ (the-as bucket-id s3-3) *temp-string* (-> (the-as process-drawable arg0) root trans) - (font-color green-#3df23d) + (font-color green) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) ) @@ -1184,7 +1184,7 @@ "#f" ) (-> (the-as process-drawable arg0) root trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) ) (label cfg-51) diff --git a/goal_src/jak2/engine/game/game-info.gc b/goal_src/jak2/engine/game/game-info.gc index 0e04bd76e..600a4d60c 100644 --- a/goal_src/jak2/engine/game/game-info.gc +++ b/goal_src/jak2/engine/game/game-info.gc @@ -892,7 +892,7 @@ (+ (the int (/ (the float (+ (/ (-> s3-0 x) 16) -1792)) (-> *video-params* relative-x-scale))) -48) (+ (/ (-> s3-0 y) 16) -1855) 0.0 - (font-color gold-#ba9200) + (font-color gold) (font-flags shadow kerning) ) ) @@ -1186,7 +1186,7 @@ (bucket-id debug-no-zbuf1) (-> obj name) (-> obj trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) (let ((a3-2 (vector-z-quaternion! (new-stack-vector0) (the-as quaternion (-> obj quat))))) diff --git a/goal_src/jak2/engine/game/task/task-control.gc b/goal_src/jak2/engine/game/task/task-control.gc index d2c58dd40..75947fbc7 100644 --- a/goal_src/jak2/engine/game/task/task-control.gc +++ b/goal_src/jak2/engine/game/task/task-control.gc @@ -1413,7 +1413,7 @@ 70 20 0.0 - (font-color gold-#ba9200) + (font-color gold) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/engine/geometry/path.gc b/goal_src/jak2/engine/geometry/path.gc index 5bed8e661..415b15023 100644 --- a/goal_src/jak2/engine/geometry/path.gc +++ b/goal_src/jak2/engine/geometry/path.gc @@ -52,7 +52,7 @@ (s1-0 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "~D" s5-1) - (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold-#ba9200) (the-as vector2h #f)) + (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold) (the-as vector2h #f)) ) ) ) @@ -430,7 +430,7 @@ using the fractional component of `idx` as the interpolant, return this result (s1-0 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "~D" s5-1) - (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold-#ba9200) (the-as vector2h #f)) + (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold) (the-as vector2h #f)) ) ) ) diff --git a/goal_src/jak2/engine/gfx/font-h.gc b/goal_src/jak2/engine/gfx/font-h.gc index a5758e2c8..b2692b0df 100644 --- a/goal_src/jak2/engine/gfx/font-h.gc +++ b/goal_src/jak2/engine/gfx/font-h.gc @@ -11,45 +11,45 @@ (defenum font-color :type uint32 (default 0) - (#dadada 1) - (#ededed 2) + (font-color-1 1) + (font-color-2 2) (red 3) - (gold-#ba9200 4) - (yellow-#f3f300 5) - (green-#3df23d 6) - (blue-#003cf1 7) - (cyan-#00fefe 8) - (magenta-#f87df8 9) - (#a0d5d5 10) - (#7cbaba 11) - (white-#ffffff 12) - (#959595 13) - (#f9a400 14) - (#daf95e 15) - (#8aa81f 16) - (#a6b5a6 17) - (#757f75 18) - (#5e3f5e 19) + (gold 4) + (yellow 5) + (green 6) + (blue 7) + (cyan 8) + (magenta 9) + (font-color-10 10) + (font-color-11 11) + (white 12) + (font-color-13 13) + (font-color-14 14) + (font-color-15 15) + (font-color-16 16) + (font-color-17 17) + (font-color-18 18) + (font-color-19 19) (flat-yellow 20) - (#3fbaed 21) - (#3a3a3a 22) - (#5c5c5c 23) - (#f298c8 24) - (#f46868 25) - (#20ca98 26) - (#8289de 27) - (#a8f3f6 28) - (#fef666 29) - (#f1f104 30) - (#8ed0f4 31) - (#7efbfb 32) - (#7ffcfc 33) - (#f9f9f9 34) - (#408080 35) - (#e0f0e0 36) - (#c00000 37) - (#ffc040 38) - (#000000 39) + (font-color-21 21) + (font-color-22 22) + (font-color-23 23) + (font-color-24 24) + (font-color-25 25) + (font-color-26 26) + (font-color-27 27) + (font-color-28 28) + (font-color-29 29) + (font-color-30 30) + (font-color-31 31) + (font-color-32 32) + (font-color-33 33) + (font-color-34 34) + (font-color-35 35) + (font-color-36 36) + (font-color-37 37) + (font-color-38 38) + (font-color-39 39) ) ;; ---font-color diff --git a/goal_src/jak2/engine/level/region.gc b/goal_src/jak2/engine/level/region.gc index 89f42eac6..4bc05dc90 100644 --- a/goal_src/jak2/engine/level/region.gc +++ b/goal_src/jak2/engine/level/region.gc @@ -94,7 +94,7 @@ (s3-0 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "region-~D~%" (-> obj region id)) - (s5-0 s4-0 (the-as bucket-id s3-0) *temp-string* sv-36 (font-color #dadada) sv-32) + (s5-0 s4-0 (the-as bucket-id s3-0) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) (let ((s5-1 (-> obj region on-enter))) @@ -104,7 +104,7 @@ (s2-1 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "(on-enter ~S)" s5-1) - (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* sv-36 (font-color #dadada) sv-32) + (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -116,7 +116,7 @@ (s2-2 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "(on-inside ~S)" s5-2) - (s4-2 s3-2 (the-as bucket-id s2-2) *temp-string* sv-36 (font-color #dadada) sv-32) + (s4-2 s3-2 (the-as bucket-id s2-2) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -128,7 +128,7 @@ (s3-3 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "(on-exit ~S)" gp-1) - (s5-3 s4-3 (the-as bucket-id s3-3) *temp-string* sv-36 (font-color #dadada) sv-32) + (s5-3 s4-3 (the-as bucket-id s3-3) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) diff --git a/goal_src/jak2/engine/math/math.gc b/goal_src/jak2/engine/math/math.gc index 3ee8c2743..ce9373bf7 100644 --- a/goal_src/jak2/engine/math/math.gc +++ b/goal_src/jak2/engine/math/math.gc @@ -17,7 +17,8 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun truncate ((arg0 float)) - "Round (toward zero) to an integer." + "Round (toward zero) to an integer. + @param arg0 float to truncate" (the float (the int arg0)) ) diff --git a/goal_src/jak2/engine/nav/nav-control.gc b/goal_src/jak2/engine/nav/nav-control.gc index f8a3602de..c870db2b9 100644 --- a/goal_src/jak2/engine/nav/nav-control.gc +++ b/goal_src/jak2/engine/nav/nav-control.gc @@ -281,7 +281,7 @@ Note that this doesn't actually return the nav-control, but instead adds this pr (s1-0 (bucket-id debug-no-zbuf1)) ) (format (clear *temp-string*) "~D" s5-1) - (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color cyan-#00fefe) (the-as vector2h #f)) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color cyan) (the-as vector2h #f)) ) ) ) diff --git a/goal_src/jak2/engine/nav/nav-mesh.gc b/goal_src/jak2/engine/nav/nav-mesh.gc index 033b3f1ab..a4167379e 100644 --- a/goal_src/jak2/engine/nav/nav-mesh.gc +++ b/goal_src/jak2/engine/nav/nav-mesh.gc @@ -389,7 +389,7 @@ (bucket-id debug-no-zbuf1) (res-lump-struct obj 'name string) s5-0 - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) (let ((s4-1 add-debug-text-3d) @@ -402,7 +402,7 @@ (the-as bucket-id s2-1) *temp-string* s5-0 - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) ) ) @@ -548,7 +548,7 @@ (the-as bucket-id s2-1) *temp-string* (-> gp-0 1) - (font-color magenta-#f87df8) + (font-color magenta) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) ) @@ -1474,7 +1474,7 @@ (the-as bucket-id s2-0) *temp-string* (-> obj static-sphere s5-0) - (font-color cyan-#00fefe) + (font-color cyan) (the-as vector2h #f) ) ) @@ -1510,7 +1510,7 @@ (the-as bucket-id s1-1) *temp-string* (poly-centroid obj s4-1 sv-32) - (font-color cyan-#00fefe) + (font-color cyan) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/engine/process-drawable/process-drawable.gc b/goal_src/jak2/engine/process-drawable/process-drawable.gc index 50a3b1221..4bae6bc3f 100644 --- a/goal_src/jak2/engine/process-drawable/process-drawable.gc +++ b/goal_src/jak2/engine/process-drawable/process-drawable.gc @@ -537,7 +537,7 @@ ) (format (clear *temp-string*) "~d" (+ s2-0 -1)) (let ((a2-3 *temp-string*)) - (add-debug-text-3d #t (bucket-id debug-no-zbuf1) a2-3 s3-0 (font-color blue-#003cf1) s5-0) + (add-debug-text-3d #t (bucket-id debug-no-zbuf1) a2-3 s3-0 (font-color blue) s5-0) ) (+! (-> s5-0 x) 10) ) diff --git a/goal_src/jak2/engine/scene/scene.gc b/goal_src/jak2/engine/scene/scene.gc index dd8a86237..a13000cfe 100644 --- a/goal_src/jak2/engine/scene/scene.gc +++ b/goal_src/jak2/engine/scene/scene.gc @@ -711,7 +711,7 @@ (set! (-> s2-0 flags) (font-flags kerning middle left large)) (set! (-> s2-0 origin x) (+ -1.0 (-> s2-0 origin x))) (set! (-> s2-0 origin y) (+ -1.0 (-> s2-0 origin y))) - (set! (-> s2-0 color) (font-color #000000)) + (set! (-> s2-0 color) (font-color font-color-39)) (set! (-> s2-0 origin x) (+ 1.0 (-> s2-0 origin x))) (set! (-> s2-0 origin y) (+ 1.0 (-> s2-0 origin y))) (set! (-> s2-0 color) (font-color default)) @@ -1312,7 +1312,7 @@ (bucket-id debug-no-zbuf1) (-> v1-94 name) (-> v1-94 draw origin) - (font-color yellow-#f3f300) + (font-color yellow) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) ) diff --git a/goal_src/jak2/engine/ui/hud-classes.gc b/goal_src/jak2/engine/ui/hud-classes.gc index bafad67cb..80b15ad92 100644 --- a/goal_src/jak2/engine/ui/hud-classes.gc +++ b/goal_src/jak2/engine/ui/hud-classes.gc @@ -653,7 +653,7 @@ (alloc-string-if-needed obj s5-0) (set! (-> obj strings s5-0 scale) 0.8) (set! (-> obj strings s5-0 flags) (font-flags kerning middle large)) - (set! (-> obj strings s5-0 color) (font-color green-#3df23d)) + (set! (-> obj strings s5-0 color) (font-color green)) ) (set! (-> obj values 2 target) (-> obj values 1 target)) 0 @@ -692,7 +692,7 @@ (alloc-string-if-needed obj 0) (set! (-> obj strings 0 scale) 0.8) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color green-#3df23d)) + (set! (-> obj strings 0 color) (font-color green)) 0 (none) ) diff --git a/goal_src/jak2/engine/ui/hud.gc b/goal_src/jak2/engine/ui/hud.gc index 751554e77..7f6c7e210 100644 --- a/goal_src/jak2/engine/ui/hud.gc +++ b/goal_src/jak2/engine/ui/hud.gc @@ -1177,7 +1177,7 @@ (dotimes (v1-9 14) (set! (-> self strings v1-9 text) #f) (set! (-> self strings v1-9 scale) 1.0) - (set! (-> self strings v1-9 color) (font-color #dadada)) + (set! (-> self strings v1-9 color) (font-color font-color-1)) (set! (-> self strings v1-9 flags) (font-flags shadow kerning large)) (set! (-> self strings v1-9 pos 0) 0) (set! (-> self strings v1-9 pos 2) #xfffffff) diff --git a/goal_src/jak2/engine/ui/progress/progress-draw.gc b/goal_src/jak2/engine/ui/progress/progress-draw.gc index 10aa51c6f..10331c764 100644 --- a/goal_src/jak2/engine/ui/progress/progress-draw.gc +++ b/goal_src/jak2/engine/ui/progress/progress-draw.gc @@ -9,7 +9,7 @@ ;; WARN: Return type mismatch int vs font-color. (defbehavior progress-selected progress ((arg0 int)) - (let ((color (font-color #7ffcfc))) + (let ((color (font-color font-color-33))) (cond ((< 4 (the-as int (logand (-> self clock integral-frame-counter) 7))) (set! (-> *progress-state* color-flash-counter) 1) @@ -458,7 +458,7 @@ ) (set! (-> arg1 origin x) (- (-> arg1 origin x) (the float s5-0))) ) - (set! (-> arg1 color) (font-color #7efbfb)) + (set! (-> arg1 color) (font-color font-color-32)) 0 (none) ) @@ -625,7 +625,7 @@ (arg3 (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #f9f9f9)) + (set! (-> a0-1 color) (font-color font-color-34)) ) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) (set! (-> arg1 origin y) (+ 18.0 (-> arg1 origin y))) @@ -684,7 +684,7 @@ (arg3 (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #f9f9f9)) + (set! (-> a0-1 color) (font-color font-color-34)) ) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) (set! (-> arg1 origin y) (+ 18.0 (-> arg1 origin y))) @@ -749,7 +749,7 @@ ) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-6 arg1)) - (set! (-> a0-6 color) (font-color #f9f9f9)) + (set! (-> a0-6 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 44 f28-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -789,7 +789,7 @@ ) (else (let ((a0-23 arg1)) - (set! (-> a0-23 color) (font-color #7efbfb)) + (set! (-> a0-23 color) (font-color font-color-32)) ) ) ) @@ -1024,7 +1024,7 @@ (set! (-> v1-7 scale) 0.75) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-3 arg1)) @@ -1599,7 +1599,7 @@ (set! (-> arg1 origin y) (the float sv-48)) (set! (-> arg1 height) 50.0) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((a0-2 arg1)) (set! (-> a0-2 flags) (font-flags kerning middle large)) @@ -1682,7 +1682,7 @@ (set! (-> sv-48 height) 50.0) (set! (-> sv-48 origin y) (the float sv-16)) (let ((a0-2 sv-48)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! sv-32 print-game-text) (let ((a0-4 (lookup-text! *common-text* s0-0 #f)) @@ -1757,7 +1757,7 @@ (set! (-> sv-16 origin y) (the float sv-32)) (set! (-> sv-16 height) 50.0) (let ((a0-2 sv-16)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! (-> sv-16 origin x) 80.0) (let ((a0-3 sv-16)) @@ -1844,7 +1844,7 @@ (set! (-> sv-48 origin y) (the float sv-16)) (set! (-> sv-48 height) 50.0) (let ((a0-2 sv-48)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! sv-32 print-game-text) (let ((a0-4 (lookup-text! *common-text* s0-0 #f)) @@ -1937,7 +1937,7 @@ (set! (-> a0-6 flags) (font-flags kerning middle large)) ) (let ((a0-7 sv-80)) - (set! (-> a0-7 color) (font-color #7efbfb)) + (set! (-> a0-7 color) (font-color font-color-32)) ) (set! sv-48 print-game-text) (let* ((a0-8 *common-text*) @@ -2034,7 +2034,7 @@ (let ((s2-3 arg1)) (set! (-> s2-3 color) (if (= arg2 sv-20) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) @@ -2220,7 +2220,7 @@ (s2-7 *temp-string* arg1 #f 44 (bucket-id progress)) ) (let ((a0-45 arg1)) - (set! (-> a0-45 color) (font-color #7efbfb)) + (set! (-> a0-45 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) 250.0) (set! (-> arg1 origin y) 110.0) @@ -2457,7 +2457,7 @@ (set! (-> v1-25 height) (the float 160)) ) (let ((a0-16 arg1)) - (set! (-> a0-16 color) (font-color #7efbfb)) + (set! (-> a0-16 color) (font-color font-color-32)) ) (let ((s5-2 print-game-text)) (format (clear *temp-string*) (lookup-text! *common-text* (text-id progress-memcard-dont-remove) #f) 1) @@ -2474,7 +2474,7 @@ (set! (-> v1-3 scale) 0.5) ) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #7efbfb)) + (set! (-> a0-3 color) (font-color font-color-32)) ) (let ((a0-4 arg1)) (set! (-> a0-4 flags) (font-flags kerning middle left large)) @@ -2564,7 +2564,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2609,7 +2609,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2655,7 +2655,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2722,7 +2722,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2797,7 +2797,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2855,7 +2855,7 @@ (defmethod draw-option menu-error-disc-removed-option ((obj menu-error-disc-removed-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -2913,7 +2913,7 @@ (defmethod draw-option menu-error-reading-option ((obj menu-error-reading-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -2969,7 +2969,7 @@ (defmethod draw-option menu-icon-info-option ((obj menu-icon-info-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3043,7 +3043,7 @@ (defmethod draw-option menu-format-card-option ((obj menu-format-card-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3095,7 +3095,7 @@ (defmethod draw-option menu-already-exists-option ((obj menu-already-exists-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3139,7 +3139,7 @@ (defmethod draw-option menu-create-game-option ((obj menu-create-game-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3180,7 +3180,7 @@ (defmethod draw-option menu-video-mode-warning-option ((obj menu-video-mode-warning-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3246,7 +3246,7 @@ (defmethod draw-option menu-video-mode-ok-option ((obj menu-video-mode-ok-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3290,7 +3290,7 @@ (defmethod draw-option menu-progressive-mode-warning-option ((obj menu-progressive-mode-warning-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3356,7 +3356,7 @@ (defmethod draw-option menu-progressive-mode-ok-option ((obj menu-progressive-mode-ok-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.55) @@ -3400,7 +3400,7 @@ (defmethod draw-option menu-quit-option ((obj menu-quit-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.55) @@ -3459,7 +3459,7 @@ (set! (-> a0-3 flags) (font-flags kerning middle large)) ) (let ((a0-4 arg1)) - (set! (-> a0-4 color) (font-color #7efbfb)) + (set! (-> a0-4 color) (font-color font-color-32)) ) (set! (-> arg1 origin y) 100.0) (let ((v1-9 arg1)) @@ -3553,7 +3553,7 @@ ) (else (let ((a0-35 arg1)) - (set! (-> a0-35 color) (font-color #7efbfb)) + (set! (-> a0-35 color) (font-color font-color-32)) ) ) ) @@ -3654,7 +3654,7 @@ (set! (-> v1-15 height) (the float 210)) ) (let ((a1-9 arg1)) - (set! (-> a1-9 color) (font-color #7efbfb)) + (set! (-> a1-9 color) (font-color font-color-32)) ) (if (or (= (-> *setting-control* user-default language) (language-enum french)) (= (-> *setting-control* user-default language) (language-enum spanish)) @@ -3748,7 +3748,7 @@ ) (else (let ((a0-21 arg1)) - (set! (-> a0-21 color) (font-color #7efbfb)) + (set! (-> a0-21 color) (font-color font-color-32)) ) ) ) @@ -3988,7 +3988,7 @@ (set! (-> arg1 origin x) 60.0) (set! (-> arg1 origin y) 80.0) (let ((a0-21 arg1)) - (set! (-> a0-21 color) (font-color #7efbfb)) + (set! (-> a0-21 color) (font-color font-color-32)) ) (let ((v1-40 (-> obj page-index))) (cond @@ -4210,7 +4210,7 @@ (let ((s3-1 arg2)) (set! (-> s3-1 color) (if (= arg3 1) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) @@ -4236,7 +4236,7 @@ ) (set! (-> arg2 origin x) 360.0) (let ((a0-35 arg2)) - (set! (-> a0-35 color) (font-color #7efbfb)) + (set! (-> a0-35 color) (font-color font-color-32)) ) ) ) @@ -4382,7 +4382,7 @@ (set! (-> a0-21 flags) (font-flags kerning middle large)) ) (let ((a0-22 arg1)) - (set! (-> a0-22 color) (font-color #7efbfb)) + (set! (-> a0-22 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) 59.0) (let ((v1-54 arg1)) @@ -5382,7 +5382,7 @@ (set! (-> a0-4 flags) (font-flags kerning middle large)) ) (let ((a0-5 sv-140)) - (set! (-> a0-5 color) (font-color #7efbfb)) + (set! (-> a0-5 color) (font-color font-color-32)) ) (set! (-> sv-140 origin x) 59.0) (set! (-> sv-140 origin y) 78.0) @@ -5424,7 +5424,7 @@ (set! (-> a0-23 flags) (font-flags kerning large)) ) (let ((a0-24 sv-140)) - (set! (-> a0-24 color) (font-color #f9f9f9)) + (set! (-> a0-24 color) (font-color font-color-34)) ) (set! (-> sv-140 origin x) (+ 20.0 sv-120 (-> sv-140 origin x))) (let ((v1-53 sv-140)) @@ -5483,7 +5483,7 @@ ) (set! sv-108 (-> sv-140 origin x)) (let ((a0-54 sv-140)) - (set! (-> a0-54 color) (font-color #7efbfb)) + (set! (-> a0-54 color) (font-color font-color-32)) ) (+! (-> sv-140 origin x) sv-120) (let ((v1-96 sv-140)) @@ -5538,7 +5538,7 @@ (set! (-> a0-74 flags) (font-flags kerning large)) ) (let ((a0-75 sv-140)) - (set! (-> a0-75 color) (font-color #f9f9f9)) + (set! (-> a0-75 color) (font-color font-color-34)) ) (set! (-> sv-140 origin x) (+ 20.0 sv-124 (-> sv-140 origin x))) (let ((v1-142 sv-140)) @@ -5597,7 +5597,7 @@ ) (set! sv-108 (-> sv-140 origin x)) (let ((a0-105 sv-140)) - (set! (-> a0-105 color) (font-color #7efbfb)) + (set! (-> a0-105 color) (font-color font-color-32)) ) (+! (-> sv-140 origin x) sv-124) (let ((v1-185 sv-140)) @@ -5656,7 +5656,7 @@ ((and (zero? (-> *progress-state* game-options-item-selected)) (-> *progress-state* game-options-item-picked)) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #f9f9f9)) + (set! (-> a0-2 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -1.0 (-> arg1 origin y))) 41 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -5693,7 +5693,7 @@ ) (else (let ((a0-17 arg1)) - (set! (-> a0-17 color) (font-color #7efbfb)) + (set! (-> a0-17 color) (font-color font-color-32)) ) ) ) @@ -5744,7 +5744,7 @@ ((and (= (-> *progress-state* game-options-item-selected) 1) (-> *progress-state* game-options-item-picked)) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -1.0 (-> arg1 origin y))) 41 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -5781,7 +5781,7 @@ ) (else (let ((a0-20 arg1)) - (set! (-> a0-20 color) (font-color #7efbfb)) + (set! (-> a0-20 color) (font-color font-color-32)) ) ) ) @@ -5841,7 +5841,7 @@ (cond ((and (= (-> *progress-state* game-options-item-selected) 2) (-> *progress-state* game-options-item-picked)) (let ((a0-7 arg1)) - (set! (-> a0-7 color) (font-color #f9f9f9)) + (set! (-> a0-7 color) (font-color font-color-34)) ) (draw-highlight (the int (-> arg1 origin y)) 44 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -5860,13 +5860,13 @@ ) ) (let ((a0-12 arg1)) - (set! (-> a0-12 color) (font-color #7efbfb)) + (set! (-> a0-12 color) (font-color font-color-32)) ) (let ((v1-33 arg1)) (set! (-> v1-33 scale) 0.5) ) (let ((a0-14 arg1)) - (set! (-> a0-14 color) (font-color #7efbfb)) + (set! (-> a0-14 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) (+ -70.0 (-> arg1 origin x))) (let ((s5-1 print-game-text)) @@ -5908,7 +5908,7 @@ ) (else (let ((a0-31 arg1)) - (set! (-> a0-31 color) (font-color #7efbfb)) + (set! (-> a0-31 color) (font-color font-color-32)) ) ) ) @@ -5920,7 +5920,7 @@ (set! (-> v1-54 scale) 0.5) ) (let ((a0-36 arg1)) - (set! (-> a0-36 color) (font-color #7efbfb)) + (set! (-> a0-36 color) (font-color font-color-32)) ) (set! (-> arg1 origin y) (+ 24.0 (-> arg1 origin y))) (let ((a0-37 arg1)) @@ -5974,7 +5974,7 @@ (cond ((and (= (-> *progress-state* game-options-item-selected) 3) (-> *progress-state* game-options-item-picked)) (let ((a0-7 arg1)) - (set! (-> a0-7 color) (font-color #f9f9f9)) + (set! (-> a0-7 color) (font-color font-color-34)) ) (draw-highlight (the int (-> arg1 origin y)) 44 f30-0) (let ((s3-0 print-game-text)) @@ -5996,13 +5996,13 @@ ) ) (let ((a0-14 arg1)) - (set! (-> a0-14 color) (font-color #7efbfb)) + (set! (-> a0-14 color) (font-color font-color-32)) ) (let ((v1-33 arg1)) (set! (-> v1-33 scale) 0.5) ) (let ((a0-16 arg1)) - (set! (-> a0-16 color) (font-color #7efbfb)) + (set! (-> a0-16 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) (+ -70.0 (-> arg1 origin x))) (let ((s5-1 print-game-text)) @@ -6044,7 +6044,7 @@ ) (else (let ((a0-33 arg1)) - (set! (-> a0-33 color) (font-color #7efbfb)) + (set! (-> a0-33 color) (font-color font-color-32)) ) ) ) @@ -6059,7 +6059,7 @@ (set! (-> v1-54 scale) 0.5) ) (let ((a0-40 arg1)) - (set! (-> a0-40 color) (font-color #7efbfb)) + (set! (-> a0-40 color) (font-color font-color-32)) ) (format (clear *temp-string*) "~S" (lookup-text! *common-text* (-> *language-name-remap* (-> s4-0 0)) #f)) *temp-string* @@ -6133,7 +6133,7 @@ ) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-4 arg1)) - (set! (-> a0-4 color) (font-color #f9f9f9)) + (set! (-> a0-4 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 42 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6174,7 +6174,7 @@ ) (else (let ((a0-21 arg1)) - (set! (-> a0-21 color) (font-color #7efbfb)) + (set! (-> a0-21 color) (font-color font-color-32)) ) ) ) @@ -6240,7 +6240,7 @@ ) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 42 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6281,7 +6281,7 @@ ) (else (let ((a0-20 arg1)) - (set! (-> a0-20 color) (font-color #7efbfb)) + (set! (-> a0-20 color) (font-color font-color-32)) ) ) ) @@ -6340,7 +6340,7 @@ (set! (-> v1-10 scale) 0.6) ) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (set! (-> arg1 width) 350.0) (set! (-> arg1 height) 60.0) @@ -6415,7 +6415,7 @@ ) (else (let ((a0-31 arg1)) - (set! (-> a0-31 color) (font-color #7efbfb)) + (set! (-> a0-31 color) (font-color font-color-32)) ) ) ) @@ -6444,7 +6444,7 @@ (cond ((and (zero? (-> *progress-state* qr-options-item-selected)) (-> *progress-state* qr-options-item-picked)) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #f9f9f9)) + (set! (-> a0-2 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 50 f0-1) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6507,7 +6507,7 @@ (cond ((and (= (-> *progress-state* qr-options-item-selected) 1) (-> *progress-state* qr-options-item-picked)) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 50 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6669,7 +6669,7 @@ (set! sv-128 (-> obj value-to-modify)) (set! (-> s5-0 origin y) (+ -8.0 (-> s5-0 origin y))) (let ((a0-12 s5-0)) - (set! (-> a0-12 color) (font-color #f9f9f9)) + (set! (-> a0-12 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> s5-0 origin y))) 52 f30-0) (set! sv-144 print-game-text) @@ -6965,7 +6965,7 @@ arg3 ) (let ((a0-7 arg1)) - (set! (-> a0-7 color) (font-color #f9f9f9)) + (set! (-> a0-7 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -1.0 (-> arg1 origin y))) 42 f30-0) (let ((s3-1 print-game-text)) @@ -6974,13 +6974,13 @@ ) (set! (-> arg1 origin y) (+ 22.0 (-> arg1 origin y))) (let ((a0-13 arg1)) - (set! (-> a0-13 color) (font-color #7efbfb)) + (set! (-> a0-13 color) (font-color font-color-32)) ) (let ((v1-22 arg1)) (set! (-> v1-22 scale) 0.5) ) (let ((a0-15 arg1)) - (set! (-> a0-15 color) (font-color #7efbfb)) + (set! (-> a0-15 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) (+ -70.0 (-> arg1 origin x))) (let ((s4-1 print-game-text)) @@ -7023,7 +7023,7 @@ (set! (-> v1-39 scale) 0.5) ) (let ((a0-33 arg1)) - (set! (-> a0-33 color) (font-color #7efbfb)) + (set! (-> a0-33 color) (font-color font-color-32)) ) (format (clear *temp-string*) "~S" (lookup-text! *common-text* (-> *stereo-mode-name-remap* s5-0) #f)) (let ((a0-37 *temp-string*)) @@ -7085,7 +7085,7 @@ (let ((s0-0 arg1)) (set! (-> s0-0 color) (if (= arg2 (-> arg0 option-index)) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) @@ -7097,7 +7097,7 @@ ) (else (let ((a0-9 arg1)) - (set! (-> a0-9 color) (font-color #7efbfb)) + (set! (-> a0-9 color) (font-color font-color-32)) ) ) ) diff --git a/goal_src/jak2/engine/ui/progress/progress.gc b/goal_src/jak2/engine/ui/progress/progress.gc index 8c01c0c55..22b7cfc12 100644 --- a/goal_src/jak2/engine/ui/progress/progress.gc +++ b/goal_src/jak2/engine/ui/progress/progress.gc @@ -1341,7 +1341,7 @@ (let ((s3-0 sv-144)) (set! (-> s3-0 color) (if (and (= s4-1 (-> self option-index)) (= (-> self menu-transition) 0.0)) (progress-selected 0) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) diff --git a/goal_src/jak2/levels/city/common/ctywide-obs.gc b/goal_src/jak2/levels/city/common/ctywide-obs.gc index 3381fa50e..b67fe644b 100644 --- a/goal_src/jak2/levels/city/common/ctywide-obs.gc +++ b/goal_src/jak2/levels/city/common/ctywide-obs.gc @@ -3540,7 +3540,7 @@ This commonly includes things such as: (set! (-> v1-51 origin y) (the float a0-59)) ) (let ((a0-60 s1-0)) - (set! (-> a0-60 color) (font-color #fef666)) + (set! (-> a0-60 color) (font-color font-color-29)) ) (let ((s0-0 print-game-text)) (set! sv-352 format) @@ -3570,7 +3570,7 @@ This commonly includes things such as: ) (let ((a0-68 s1-0)) (set! (-> a0-68 color) (if (= s0-1 s5-0) - (font-color #f1f104) + (font-color font-color-30) (font-color default) ) ) diff --git a/goal_src/jak2/levels/city/common/height-map.gc b/goal_src/jak2/levels/city/common/height-map.gc index 6fdcccbf6..134783363 100644 --- a/goal_src/jak2/levels/city/common/height-map.gc +++ b/goal_src/jak2/levels/city/common/height-map.gc @@ -80,7 +80,7 @@ (the-as bucket-id s2-0) *temp-string* s5-0 - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) ) ) diff --git a/goal_src/jak2/levels/city/common/nav-graph.gc b/goal_src/jak2/levels/city/common/nav-graph.gc index 39d33f64c..e75a3a9ea 100644 --- a/goal_src/jak2/levels/city/common/nav-graph.gc +++ b/goal_src/jak2/levels/city/common/nav-graph.gc @@ -118,7 +118,7 @@ gp-0 (if (logtest? (-> obj flags) (nav-node-flag-byte blocked)) (font-color red) - (font-color cyan-#00fefe) + (font-color cyan) ) (the-as vector2h #f) ) diff --git a/goal_src/jak2/levels/city/common/traffic-engine.gc b/goal_src/jak2/levels/city/common/traffic-engine.gc index b897d2fd8..83af50ddf 100644 --- a/goal_src/jak2/levels/city/common/traffic-engine.gc +++ b/goal_src/jak2/levels/city/common/traffic-engine.gc @@ -1139,7 +1139,7 @@ Process is recycled and moved to reserved, if it deactivates." *temp-string* sv-84 (if (< (-> sv-20 user-count) (-> sv-20 max-user-count)) - (font-color yellow-#f3f300) + (font-color yellow) (font-color red) ) (the-as vector2h #f) diff --git a/goal_src/jak2/levels/city/common/trail.gc b/goal_src/jak2/levels/city/common/trail.gc index 7b95ee7f9..43fdb5832 100644 --- a/goal_src/jak2/levels/city/common/trail.gc +++ b/goal_src/jak2/levels/city/common/trail.gc @@ -40,7 +40,7 @@ (s2-1 324) ) (format (clear *temp-string*) "~D" arg1) - (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color yellow-#f3f300) (the-as vector2h #f)) + (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color yellow) (the-as vector2h #f)) ) ) ) @@ -66,7 +66,7 @@ (s2-1 324) ) (format (clear *temp-string*) "~D" arg0) - (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color cyan-#00fefe) (the-as vector2h #f)) + (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color cyan) (the-as vector2h #f)) ) ) ) diff --git a/goal_src/jak2/levels/common/ai/bot.gc b/goal_src/jak2/levels/common/ai/bot.gc index cb36457d2..30b8251b8 100644 --- a/goal_src/jak2/levels/common/ai/bot.gc +++ b/goal_src/jak2/levels/common/ai/bot.gc @@ -56,7 +56,7 @@ (bucket-id debug-no-zbuf1) spot-id (-> spot center) - (font-color #dadada) + (font-color font-color-1) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/levels/common/battle.gc b/goal_src/jak2/levels/common/battle.gc index 9bfc6aa24..5f9f20b8a 100644 --- a/goal_src/jak2/levels/common/battle.gc +++ b/goal_src/jak2/levels/common/battle.gc @@ -830,7 +830,7 @@ (-> obj stat-child-count) (-> obj allies length) ) - (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color gold-#ba9200) (the-as vector2h #f)) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color gold) (the-as vector2h #f)) ) ) (dotimes (s5-1 (-> obj spawners length)) @@ -862,7 +862,7 @@ (the-as bucket-id s1-1) *temp-string* (-> s4-1 entity extra trans) - (font-color yellow-#f3f300) + (font-color yellow) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/levels/common/enemy/hover/hover-nav-control.gc b/goal_src/jak2/levels/common/enemy/hover/hover-nav-control.gc index 4fb5e4f54..8ad360690 100644 --- a/goal_src/jak2/levels/common/enemy/hover/hover-nav-control.gc +++ b/goal_src/jak2/levels/common/enemy/hover/hover-nav-control.gc @@ -242,7 +242,7 @@ (add-debug-x #t (bucket-id debug2) (-> s4-0 pos) *color-white*) (format (clear *temp-string*) "~d" s5-0) (let ((a2-2 *temp-string*)) - (add-debug-text-3d #t (bucket-id debug2) a2-2 (-> s4-0 pos) (font-color #dadada) (the-as vector2h #f)) + (add-debug-text-3d #t (bucket-id debug2) a2-2 (-> s4-0 pos) (font-color font-color-1) (the-as vector2h #f)) ) (dotimes (s3-1 (-> s4-0 count)) (let ((a2-3 (new 'stack-no-clear 'vector))) diff --git a/goal_src/jak2/levels/common/races/race-hud.gc b/goal_src/jak2/levels/common/races/race-hud.gc index 84e78a94f..51447bad0 100644 --- a/goal_src/jak2/levels/common/races/race-hud.gc +++ b/goal_src/jak2/levels/common/races/race-hud.gc @@ -41,15 +41,15 @@ (alloc-string-if-needed obj 0) (set! (-> obj strings 0 scale) 0.55) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color green-#3df23d)) + (set! (-> obj strings 0 color) (font-color green)) (alloc-string-if-needed obj 1) (set! (-> obj strings 1 scale) 0.55) (set! (-> obj strings 1 flags) (font-flags kerning middle large)) - (set! (-> obj strings 1 color) (font-color green-#3df23d)) + (set! (-> obj strings 1 color) (font-color green)) (alloc-string-if-needed obj 2) (set! (-> obj strings 2 scale) 0.55) (set! (-> obj strings 2 flags) (font-flags kerning middle large)) - (set! (-> obj strings 2 color) (font-color green-#3df23d)) + (set! (-> obj strings 2 color) (font-color green)) (set! (-> obj sprites 1 tex) (lookup-texture-by-id (new 'static 'texture-id :index #x23 :page #x679))) 0 (none) @@ -89,7 +89,7 @@ (set! (-> obj sprites 0 tex) (lookup-texture-by-id (new 'static 'texture-id :index #xe :page #x679))) (alloc-string-if-needed obj 0) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color green-#3df23d)) + (set! (-> obj strings 0 color) (font-color green)) (set! (-> obj sprites 1 tex) (lookup-texture-by-id (new 'static 'texture-id :index #xd :page #x679))) (set! (-> obj sprites 2 tex) (lookup-texture-by-id (new 'static 'texture-id :index #xc :page #x679))) 0 @@ -381,7 +381,7 @@ (let ((s2-1 (-> s5-0 lap-time-array (+ (- -1 s4-0) (-> s5-0 lap-count))))) (set! (-> obj strings s3-0 scale) 0.5) (set! (-> obj strings s3-0 flags) (font-flags kerning large)) - (set! (-> obj strings s3-0 color) (font-color #dadada)) + (set! (-> obj strings s3-0 color) (font-color font-color-1)) (set-as-offset-from! (the-as hud-sprite (&+ (-> obj strings 0 pos) (* 48 s3-0))) (the-as vector4w (-> obj strings 1 pos)) @@ -401,7 +401,7 @@ (let ((s3-1 (+ s3-0 1))) (set! (-> obj strings s3-1 scale) 0.5) (set! (-> obj strings s3-1 flags) (font-flags kerning right large)) - (set! (-> obj strings s3-1 color) (font-color #dadada)) + (set! (-> obj strings s3-1 color) (font-color font-color-1)) (set-as-offset-from! (the-as hud-sprite (&+ (-> obj strings 0 pos) (* 48 s3-1))) (the-as vector4w (-> obj strings 2 pos)) @@ -441,9 +441,9 @@ (set! (-> obj strings 0 flags) (font-flags kerning middle large)) (set! (-> obj strings 0 color) (font-color red)) (set! (-> obj strings 1 flags) (font-flags kerning large)) - (set! (-> obj strings 1 color) (font-color #dadada)) + (set! (-> obj strings 1 color) (font-color font-color-1)) (set! (-> obj strings 2 flags) (font-flags kerning large)) - (set! (-> obj strings 2 color) (font-color #dadada)) + (set! (-> obj strings 2 color) (font-color font-color-1)) 0 (none) ) diff --git a/goal_src/jak2/levels/common/races/race-manager.gc b/goal_src/jak2/levels/common/races/race-manager.gc index f9ab582e2..25b06ed93 100644 --- a/goal_src/jak2/levels/common/races/race-manager.gc +++ b/goal_src/jak2/levels/common/races/race-manager.gc @@ -1256,7 +1256,7 @@ 70 20 0.0 - (font-color gold-#ba9200) + (font-color gold) (font-flags shadow kerning) ) ) @@ -1292,7 +1292,7 @@ 70 20 0.0 - (font-color gold-#ba9200) + (font-color gold) (font-flags shadow kerning) ) ) diff --git a/goal_src/jak2/levels/common/races/race-mesh.gc b/goal_src/jak2/levels/common/races/race-mesh.gc index 4c6e85a80..dba0b182e 100644 --- a/goal_src/jak2/levels/common/races/race-mesh.gc +++ b/goal_src/jak2/levels/common/races/race-mesh.gc @@ -413,7 +413,7 @@ (s2-0 318) ) (format (clear *temp-string*) "~D" arg0) - (s4-1 s3-1 (the-as bucket-id s2-0) *temp-string* s5-0 (font-color #dadada) (the-as vector2h #f)) + (s4-1 s3-1 (the-as bucket-id s2-0) *temp-string* s5-0 (font-color font-color-1) (the-as vector2h #f)) ) ) ) diff --git a/goal_src/jak2/levels/demo/demo-obs.gc b/goal_src/jak2/levels/demo/demo-obs.gc index 79523598e..d39601f24 100644 --- a/goal_src/jak2/levels/demo/demo-obs.gc +++ b/goal_src/jak2/levels/demo/demo-obs.gc @@ -533,8 +533,8 @@ (set! (-> sv-112 scale) 0.7) (dotimes (s5-4 (-> gp-1 length)) (if (= (-> self selected) s5-4) - (set! (-> sv-112 color) (font-color #f1f104)) - (set! (-> sv-112 color) (font-color #dadada)) + (set! (-> sv-112 color) (font-color font-color-30)) + (set! (-> sv-112 color) (font-color font-color-1)) ) (print-game-text (lookup-text! *common-text* (the-as text-id (-> gp-1 s5-4)) #f) diff --git a/goal_src/jak2/levels/gungame/gungame-obs.gc b/goal_src/jak2/levels/gungame/gungame-obs.gc index 07a5af56f..3d14601f8 100644 --- a/goal_src/jak2/levels/gungame/gungame-obs.gc +++ b/goal_src/jak2/levels/gungame/gungame-obs.gc @@ -135,7 +135,7 @@ (the-as bucket-id s4-0) *temp-string* (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 0.0 'interp) - (font-color green-#3df23d) + (font-color green) (the-as vector2h #f) ) ) diff --git a/goal_src/jak2/levels/title/title-obs.gc b/goal_src/jak2/levels/title/title-obs.gc index fc4a44b80..635a3d254 100644 --- a/goal_src/jak2/levels/title/title-obs.gc +++ b/goal_src/jak2/levels/title/title-obs.gc @@ -539,8 +539,8 @@ (set! (-> sv-112 scale) 0.7) (dotimes (s5-4 (-> gp-1 length)) (if (= (-> self selected) s5-4) - (set! (-> sv-112 color) (font-color #f1f104)) - (set! (-> sv-112 color) (font-color #dadada)) + (set! (-> sv-112 color) (font-color font-color-30)) + (set! (-> sv-112 color) (font-color font-color-1)) ) (print-game-text (lookup-text! *common-text* (the-as text-id (-> gp-1 s5-4)) #f) diff --git a/goal_src/jak2/pc/debug/anim-tester-x.gc b/goal_src/jak2/pc/debug/anim-tester-x.gc index 5b58b054a..d8c5cb189 100644 --- a/goal_src/jak2/pc/debug/anim-tester-x.gc +++ b/goal_src/jak2/pc/debug/anim-tester-x.gc @@ -245,21 +245,21 @@ (let ((items-drawn (-> lst offset)) (i 0) - (color (font-color white-#ffffff)) + (color (font-color white)) (text-len (the draw-string-result 0))) (with-dma-buffer-add-bucket ((buf (-> (current-frame) debug-buf)) (bucket-id debug-no-zbuf1)) (when (nonzero? (length title)) - (set! text-len (draw-string-xy title buf 9 (+ 28 4 (* items-drawn 14)) (font-color white-#ffffff) (font-flags shadow kerning))) + (set! text-len (draw-string-xy title buf 9 (+ 28 4 (* items-drawn 14)) (font-color white) (font-flags shadow kerning))) (1+! items-drawn) ) (do-atx-list (item lst) (let ((selected? (= i (-> lst selection)))) - (set! color (if (= (-> item extra) sel-obj) (font-color green-#3df23d) (font-color white-#ffffff))) + (set! color (if (= (-> item extra) sel-obj) (font-color green) (font-color white))) (let ((this-len (draw-string-xy (-> item group name) buf 21 (+ 28 4 (* items-drawn 14)) color (font-flags shadow kerning)))) (if (> this-len text-len) diff --git a/goal_src/jak2/pc/features/speedruns.gc b/goal_src/jak2/pc/features/speedruns.gc index 0ac753045..69061f64c 100644 --- a/goal_src/jak2/pc/features/speedruns.gc +++ b/goal_src/jak2/pc/features/speedruns.gc @@ -82,5 +82,5 @@ (-> *pc-settings* speedrunner-mode?) (enum->string speedrun-category (-> *speedrun-info* category)) (-> *autosplit-info-jak2* res-fortress-escape)) - buf 0 (- 220 (* 8 4)) (font-color #fef666) (font-flags shadow kerning)))) + buf 0 (- 220 (* 8 4)) (font-color font-color-29) (font-flags shadow kerning)))) (none)) diff --git a/goalc/compiler/Compiler.h b/goalc/compiler/Compiler.h index 269d4327a..cea624254 100644 --- a/goalc/compiler/Compiler.h +++ b/goalc/compiler/Compiler.h @@ -95,6 +95,9 @@ class Compiler { std::vector> const& user_data); bool knows_object_file(const std::string& name); MakeSystem& make_system() { return m_make; } + std::set lookup_symbol_infos_starting_with(const std::string& prefix) const; + std::vector* lookup_exact_name_info(const std::string& name) const; + std::optional lookup_typespec(const std::string& symbol_name) const; private: GameVersion m_version; @@ -126,8 +129,6 @@ class Compiler { } m_debug_stats; void setup_goos_forms(); - std::set lookup_symbol_infos_starting_with(const std::string& prefix) const; - std::vector* lookup_exact_name_info(const std::string& name) const; bool get_true_or_false(const goos::Object& form, const goos::Object& boolean); bool try_getting_macro_from_goos(const goos::Object& macro_name, goos::Object* dest); bool expand_macro_once(const goos::Object& src, goos::Object* out, Env* env); diff --git a/goalc/compiler/compilation/CompilerControl.cpp b/goalc/compiler/compilation/CompilerControl.cpp index 58a7c2ba6..f4f4ba23e 100644 --- a/goalc/compiler/compilation/CompilerControl.cpp +++ b/goalc/compiler/compilation/CompilerControl.cpp @@ -599,6 +599,13 @@ std::vector* Compiler::lookup_exact_name_info(const std::string& nam } } +std::optional Compiler::lookup_typespec(const std::string& symbol_name) const { + if (m_symbol_types.find(symbol_name) != m_symbol_types.end()) { + return m_symbol_types.at(symbol_name); + } + return {}; +} + Val* Compiler::compile_load_project(const goos::Object& form, const goos::Object& rest, Env*) { auto args = get_va(form, rest); va_check(form, args, {goos::ObjectType::STRING}, {}); diff --git a/goalc/compiler/docs/DocTypes.cpp b/goalc/compiler/docs/DocTypes.cpp index 419a25448..4c1cb0246 100644 --- a/goalc/compiler/docs/DocTypes.cpp +++ b/goalc/compiler/docs/DocTypes.cpp @@ -138,44 +138,37 @@ std::vector get_args_from_docstring(std::vector } auto lines = str_util::split(docstring); for (const auto& line : lines) { - if (str_util::starts_with(line, "@param")) { + const auto trimmed_line = str_util::ltrim(line); + if (str_util::starts_with(trimmed_line, "@param")) { // Get the info from the @param line const auto& tokens = - str_util::regex_get_capture_groups(line, "(@param.)\\s?([^\\s]*)\\s(.*)"); + str_util::regex_get_capture_groups(trimmed_line, "(@param.)\\s?([^\\s]*)\\s(.*)"); if (tokens.size() != 3) { - lg::warn("invalid docstring line - {}, skipping", line); + lg::warn("invalid docstring line - {}, skipping", trimmed_line); continue; } const auto& param_type = str_util::trim(tokens[0]); const auto& param_name = str_util::trim(tokens[1]); const auto& param_description = str_util::trim(tokens[2]); - // First, let's find the appropriate arg_doc -- if we can't, skip it as well! - std::optional find_arg_doc; - for (const auto& arg : arg_docs) { + // Locate the appropriate arg based on the name + for (auto& arg : arg_docs) { if (arg.name == param_name) { - find_arg_doc = arg; + arg.description = param_description; + if (param_type == "@param") { + // a normal arg, nothing fancy + } else if (param_type == "@param_") { + // it's unused + arg.is_unused = true; + } else if (param_type == "@param!") { + // the params value is mutated within the function body + arg.is_mutated = true; + } else if (param_type == "@param?") { + // the param is optional -- there are checks to see if it was provided or not so its + // safe to pass "nothing" + arg.is_optional = true; + } } } - if (!find_arg_doc) { - lg::warn("@param name '{}', doesn't correspond with an arg name in line '{}', skipping", - param_name, line); - continue; - } - auto& arg_doc = find_arg_doc.value(); - arg_doc.description = param_description; - if (param_type == "@param") { - // a normal arg, nothing fancy - } else if (param_type == "@param_") { - // it's unused - arg_doc.is_unused = true; - } else if (param_type == "@param!") { - // the params value is mutated within the function body - arg_doc.is_mutated = true; - } else if (param_type == "@param?") { - // the param is optional -- there are checks to see if it was provided or not so its safe to - // pass "nothing" - arg_doc.is_optional = true; - } } } return arg_docs; diff --git a/lsp/CMakeLists.txt b/lsp/CMakeLists.txt index 02b3d9fd2..b4a3fe95c 100644 --- a/lsp/CMakeLists.txt +++ b/lsp/CMakeLists.txt @@ -1,15 +1,20 @@ add_executable(lsp - main.cpp - transport/stdio.cpp - state/workspace.cpp handlers/lsp_router.cpp + main.cpp protocol/common_types.cpp protocol/completion.cpp + protocol/document_color.cpp + protocol/document_diagnostics.cpp protocol/document_symbols.cpp protocol/document_synchronization.cpp - protocol/document_diagnostics.cpp protocol/hover.cpp - state/data/mips_instruction.cpp) + protocol/progress_report.cpp + state/data/mips_instruction.cpp + state/lsp_requester.cpp + state/workspace.cpp + transport/stdio.cpp +) -target_link_libraries(lsp common decomp tree-sitter) +target_compile_definitions(lsp PRIVATE -DJSON_DIAGNOSTICS=1) +target_link_libraries(lsp common decomp compiler tree-sitter) diff --git a/lsp/handlers/initialize.h b/lsp/handlers/initialize.h index d48c51f62..622f4b4dd 100644 --- a/lsp/handlers/initialize.h +++ b/lsp/handlers/initialize.h @@ -1,3 +1,5 @@ +#pragma once + #include "common/log/log.h" #include "lsp/protocol/initialize_result.h" diff --git a/lsp/handlers/lsp_router.cpp b/lsp/handlers/lsp_router.cpp index 33bb7c1a1..174c6d6fa 100644 --- a/lsp/handlers/lsp_router.cpp +++ b/lsp/handlers/lsp_router.cpp @@ -5,6 +5,7 @@ #include "lsp/handlers/initialize.h" #include "lsp/protocol/error_codes.h" #include "text_document/completion.h" +#include "text_document/document_color.h" #include "text_document/document_symbol.h" #include "text_document/document_synchronization.h" #include "text_document/go_to.h" @@ -27,6 +28,11 @@ LSPRoute::LSPRoute(std::function(Workspace&, int, json)> req : m_route_type(LSPRouteType::REQUEST_RESPONSE), m_request_handler(request_handler) {} void LSPRouter::init_routes() { + m_routes["shutdown"] = + LSPRoute([](Workspace& workspace, int id, nlohmann::json params) -> std::optional { + lg::info("Shutting down LSP due to explicit request"); + exit(0); + }); m_routes["initialize"] = LSPRoute(initialize_handler); m_routes["initialize"].m_generic_post_action = [](Workspace& workspace) { workspace.set_initialized(true); @@ -39,6 +45,13 @@ void LSPRouter::init_routes() { m_routes["textDocument/hover"] = LSPRoute(hover_handler); m_routes["textDocument/definition"] = LSPRoute(go_to_definition_handler); m_routes["textDocument/completion"] = LSPRoute(get_completions_handler); + m_routes["textDocument/documentColor"] = LSPRoute(document_color_handler); + // TODO - m_routes["textDocument/signatureHelp"] = LSPRoute(get_completions_handler); + // Not Yet Supported Routes, noops + m_routes["$/cancelRequest"] = LSPRoute(); + m_routes["textDocument/documentLink"] = LSPRoute(); + m_routes["textDocument/codeLens"] = LSPRoute(); + m_routes["textDocument/colorPresentation"] = LSPRoute(); } json error_resp(ErrorCodes error_code, const std::string& error_message) { diff --git a/lsp/handlers/lsp_router.h b/lsp/handlers/lsp_router.h index 6625a0b96..9da8c6a00 100644 --- a/lsp/handlers/lsp_router.h +++ b/lsp/handlers/lsp_router.h @@ -3,14 +3,12 @@ #include #include +#include "common/util/json_util.h" + #include "lsp/state/app.h" #include "lsp/state/workspace.h" #include "lsp/transport/stdio.h" -#include "third-party/json.hpp" - -using json = nlohmann::json; - enum class LSPRouteType { NOOP = 0, NOTIFICATION = 1, REQUEST_RESPONSE = 2 }; class LSPRoute { diff --git a/lsp/handlers/text_document/completion.h b/lsp/handlers/text_document/completion.h index 91a5f3904..70540ec4b 100644 --- a/lsp/handlers/text_document/completion.h +++ b/lsp/handlers/text_document/completion.h @@ -1,3 +1,5 @@ +#pragma once + #include #include "lsp/protocol/common_types.h" @@ -8,8 +10,9 @@ std::optional get_completions_handler(Workspace& workspace, int id, json params) { auto converted_params = params.get(); + // TODO - these need to be cached, + // TODO - implement response object return json::array(); - ; } diff --git a/lsp/handlers/text_document/document_color.h b/lsp/handlers/text_document/document_color.h new file mode 100644 index 000000000..e88e2f4b3 --- /dev/null +++ b/lsp/handlers/text_document/document_color.h @@ -0,0 +1,77 @@ +#pragma once + +#include + +#include "common/util/string_util.h" + +#include "lsp/protocol/common_types.h" +#include "lsp/protocol/document_color.h" + +float hexToFloat(const std::string& hex) { + int value = std::stoi(hex, nullptr, 16); + return static_cast(value) / 255.0f; +} + +std::optional color_hexstring_to_lsp_color(const std::string& color_name) { + if (!str_util::contains(color_name, "#")) { + return {}; + } + const auto color_tokens = str_util::split(color_name, '#'); + const auto hexstring = color_tokens.at(1); + std::string red_hex = hexstring.substr(0, 2); + std::string green_hex = hexstring.substr(2, 2); + std::string blue_hex = hexstring.substr(4, 2); + + float red = hexToFloat(red_hex); + float green = hexToFloat(green_hex); + float blue = hexToFloat(blue_hex); + + return LSPSpec::Color{red, green, blue, 1.0}; +} + +std::optional document_color_handler(Workspace& workspace, int id, json raw_params) { + auto params = raw_params.get(); + json colors = json::array(); + + // TODO - hex strings aren't desirable in the `font-color` enum + // this could be used for the `new 'static 'rgba` instances but that requires proper + // AST support as it cannot (and should not) be assumed that all 4 components will be on the same + // line + return colors; + + //// Iterate through document, mark text colors ourselves + // auto file_type = workspace.determine_filetype_from_uri(params.textDocument.m_uri); + + // if (file_type == Workspace::FileType::OpenGOAL) { + // auto tracked_file = workspace.get_tracked_og_file(params.textDocument.m_uri); + // if (!tracked_file) { + // return {}; + // } + + // // This is something that is ok to be a regex, because it's very niche + // for (int i = 0; i < tracked_file->m_lines.size(); i++) { + // const auto& line = tracked_file->m_lines.at(i); + // std::smatch matches; + // std::regex regex("\\(font-color ([^)]*)\\)"); + + // std::sregex_iterator iter(line.begin(), line.end(), regex); + // std::sregex_iterator end; + + // for (; iter != end; iter++) { + // std::smatch match = *iter; + // std::string capture_group = match.str(1); + // LSPSpec::ColorInformation color_info; + // color_info.range = {{i, match.position(1)}, {i, match.position(1) + match.size()}}; + // const auto color = color_hexstring_to_lsp_color(capture_group); + // if (!color) { + // continue; + // } + // color_info.color = color.value(); + // colors.push_back(color_info); + // lg::debug("color - {}", capture_group); + // } + // } + //} + + // return colors; +} diff --git a/lsp/handlers/text_document/document_symbol.h b/lsp/handlers/text_document/document_symbol.h index 8e0757744..01dbe6539 100644 --- a/lsp/handlers/text_document/document_symbol.h +++ b/lsp/handlers/text_document/document_symbol.h @@ -1,3 +1,5 @@ +#pragma once + #include #include "lsp/protocol/common_types.h" diff --git a/lsp/handlers/text_document/document_synchronization.h b/lsp/handlers/text_document/document_synchronization.h index b0c7e6756..579bbde5b 100644 --- a/lsp/handlers/text_document/document_synchronization.h +++ b/lsp/handlers/text_document/document_synchronization.h @@ -1,3 +1,5 @@ +#pragma once + #include #include "lsp/protocol/document_diagnostics.h" @@ -26,18 +28,22 @@ void did_close_handler(Workspace& workspace, json raw_params) { workspace.stop_tracking_file(params.m_textDocument.m_uri); } -std::optional did_open_push_diagnostics(Workspace& workspace, json params) { - auto converted_params = params.get(); - auto tracked_file = workspace.get_tracked_ir_file(converted_params.m_textDocument.m_uri); - - if (!tracked_file) { - return {}; - } +std::optional did_open_push_diagnostics(Workspace& workspace, json raw_params) { + auto params = raw_params.get(); + const auto file_type = + workspace.determine_filetype_from_languageid(params.m_textDocument.m_languageId); LSPSpec::PublishDiagnosticParams publish_params; - publish_params.m_uri = converted_params.m_textDocument.m_uri; - publish_params.m_diagnostics = tracked_file.value().m_diagnostics; - publish_params.m_version = converted_params.m_textDocument.m_version; + publish_params.m_uri = params.m_textDocument.m_uri; + publish_params.m_version = params.m_textDocument.m_version; + + if (file_type == Workspace::FileType::OpenGOALIR) { + auto tracked_file = workspace.get_tracked_ir_file(params.m_textDocument.m_uri); + if (!tracked_file) { + return {}; + } + publish_params.m_diagnostics = tracked_file.value().m_diagnostics; + } json response; response["method"] = "textDocument/publishDiagnostics"; @@ -48,17 +54,21 @@ std::optional did_open_push_diagnostics(Workspace& workspace, json params) std::optional did_change_push_diagnostics(Workspace& workspace, json raw_params) { auto params = raw_params.get(); - auto tracked_file = workspace.get_tracked_ir_file(params.m_textDocument.m_uri); - - if (!tracked_file) { - return {}; - } + const auto file_type = workspace.determine_filetype_from_uri(params.m_textDocument.m_uri); LSPSpec::PublishDiagnosticParams publish_params; publish_params.m_uri = params.m_textDocument.m_uri; - publish_params.m_diagnostics = tracked_file.value().m_diagnostics; publish_params.m_version = params.m_textDocument.m_version; + if (file_type == Workspace::FileType::OpenGOALIR) { + auto tracked_file = workspace.get_tracked_ir_file(params.m_textDocument.m_uri); + + if (!tracked_file) { + return {}; + } + publish_params.m_diagnostics = tracked_file.value().m_diagnostics; + } + json response; response["method"] = "textDocument/publishDiagnostics"; response["params"] = publish_params; diff --git a/lsp/handlers/text_document/go_to.h b/lsp/handlers/text_document/go_to.h index c57825393..015cc56cb 100644 --- a/lsp/handlers/text_document/go_to.h +++ b/lsp/handlers/text_document/go_to.h @@ -1,3 +1,5 @@ +#pragma once + #include #include "lsp/protocol/common_types.h" @@ -5,40 +7,60 @@ #include "lsp/state/data/mips_instructions.h" #include "lsp/state/workspace.h" -std::optional go_to_definition_handler(Workspace& workspace, int id, json params) { - auto converted_params = params.get(); - auto tracked_file = workspace.get_tracked_ir_file(converted_params.m_textDocument.m_uri); - - if (!tracked_file) { - lg::debug("GOTODEF - no file"); - return {}; - } +std::optional go_to_definition_handler(Workspace& workspace, int id, json raw_params) { + auto params = raw_params.get(); + const auto file_type = workspace.determine_filetype_from_uri(params.m_textDocument.m_uri); json locations = json::array(); - auto symbol_name = tracked_file->get_symbol_at_position(converted_params.m_position); - if (!symbol_name) { - lg::debug("GOTODEF - no symbol"); - return {}; - } - - lg::debug("GOTODEF - symbol - {}", symbol_name.value()); - - auto symbol_info = workspace.get_definition_info_from_all_types(symbol_name.value(), - tracked_file->m_all_types_uri); - - if (!symbol_info) { - lg::debug("GOTODEF - no symbol info"); - return {}; - } - - LSPSpec::Location location; - location.m_uri = tracked_file->m_all_types_uri; - location.m_range.m_start = {(uint32_t)symbol_info.value().definition_info->line_idx_to_display, + if (file_type == Workspace::FileType::OpenGOALIR) { + auto tracked_file = workspace.get_tracked_ir_file(params.m_textDocument.m_uri); + if (!tracked_file) { + return {}; + } + auto symbol_name = tracked_file->get_symbol_at_position(params.m_position); + if (!symbol_name) { + return {}; + } + auto symbol_info = workspace.get_definition_info_from_all_types(symbol_name.value(), + tracked_file->m_all_types_uri); + if (!symbol_info) { + return {}; + } + LSPSpec::Location location; + location.m_uri = tracked_file->m_all_types_uri; + location.m_range.m_start = {(uint32_t)symbol_info.value().definition_info->line_idx_to_display, + (uint32_t)symbol_info.value().definition_info->pos_in_line}; + location.m_range.m_end = {(uint32_t)symbol_info.value().definition_info->line_idx_to_display, (uint32_t)symbol_info.value().definition_info->pos_in_line}; - location.m_range.m_end = {(uint32_t)symbol_info.value().definition_info->line_idx_to_display, - (uint32_t)symbol_info.value().definition_info->pos_in_line}; - locations.push_back(location); + locations.push_back(location); + } else if (file_type == Workspace::FileType::OpenGOAL) { + auto tracked_file = workspace.get_tracked_og_file(params.m_textDocument.m_uri); + if (!tracked_file) { + return {}; + } + const auto symbol = tracked_file->get_symbol_at_position(params.m_position); + if (!symbol) { + return {}; + } + const auto& symbol_info = + workspace.get_global_symbol_info(tracked_file.value(), symbol.value()); + if (!symbol_info) { + return {}; + } + + const auto& def_loc = + workspace.get_symbol_def_location(tracked_file.value(), symbol_info.value()); + if (!def_loc) { + return {}; + } + + LSPSpec::Location location; + location.m_uri = def_loc->filename; + location.m_range.m_start = {(uint32_t)def_loc->line_idx, (uint32_t)def_loc->char_idx}; + location.m_range.m_end = {(uint32_t)def_loc->line_idx, (uint32_t)def_loc->char_idx}; + locations.push_back(location); + } return locations; } diff --git a/lsp/handlers/text_document/hover.h b/lsp/handlers/text_document/hover.h index f38f88d89..6ba2f6b3d 100644 --- a/lsp/handlers/text_document/hover.h +++ b/lsp/handlers/text_document/hover.h @@ -1,6 +1,9 @@ +#pragma once + #include #include +#include "goalc/compiler/docs/DocTypes.h" #include "lsp/protocol/common_types.h" #include "lsp/protocol/hover.h" #include "lsp/state/data/mips_instructions.h" @@ -14,31 +17,25 @@ bool is_number(const std::string& s) { std::vector og_method_names = {"new", "delete", "print", "inspect", "length", "asize-of", "copy", "relocate", "mem-usage"}; -std::optional hover_handler(Workspace& workspace, int id, json params) { - auto converted_params = params.get(); - auto tracked_file = workspace.get_tracked_ir_file(converted_params.m_textDocument.m_uri); - - if (!tracked_file) { - return {}; - } - +std::optional hover_handler_ir(Workspace& workspace, + const LSPSpec::TextDocumentPositionParams& params, + const WorkspaceIRFile& tracked_file) { // See if it's an OpenGOAL symbol or a MIPS mnemonic - auto symbol_name = tracked_file->get_symbol_at_position(converted_params.m_position); - auto token_at_pos = tracked_file->get_mips_instruction_at_position(converted_params.m_position); + auto symbol_name = tracked_file.get_symbol_at_position(params.m_position); + auto token_at_pos = tracked_file.get_mips_instruction_at_position(params.m_position); if (!symbol_name && !token_at_pos) { return {}; } - // TODO - try specifying the range so it highlights everything, ie. `c.lt.s` - LSPSpec::MarkupContent markup; markup.m_kind = "markdown"; + // TODO - try specifying the range so it highlights everything, ie. `c.lt.s` // Prefer symbols if (symbol_name) { lg::debug("hover - symbol match - {}", symbol_name.value()); auto symbol_info = workspace.get_definition_info_from_all_types(symbol_name.value(), - tracked_file->m_all_types_uri); + tracked_file.m_all_types_uri); if (symbol_info && symbol_info.value().docstring.has_value()) { std::string docstring = symbol_info.value().docstring.value(); lg::debug("hover - symbol has docstring - {}", docstring); @@ -58,13 +55,13 @@ std::optional hover_handler(Workspace& workspace, int id, json params) { } // Get this symbols info auto symbol_info = - workspace.get_definition_info_from_all_types(name, tracked_file->m_all_types_uri); + workspace.get_definition_info_from_all_types(name, tracked_file.m_all_types_uri); if (!symbol_info) { symbol_replacements[name] = fmt::format("_{}_", name); } else { // Construct path auto symbol_uri = - fmt::format("{}#L{}%2C{}", tracked_file->m_all_types_uri, + fmt::format("{}#L{}%2C{}", tracked_file.m_all_types_uri, symbol_info.value().definition_info->line_idx_to_display + 1, symbol_info.value().definition_info->pos_in_line); symbol_replacements[name] = fmt::format("[{}]({})", name, symbol_uri); @@ -159,6 +156,123 @@ std::optional hover_handler(Workspace& workspace, int id, json params) { hover_resp.m_contents = markup; return hover_resp; } +} + +std::string truncate_docstring(const std::string& docstring) { + std::string truncated = ""; + const auto lines = str_util::split(docstring); + for (const auto& line : lines) { + const auto trimmed_line = str_util::ltrim(line); + if (str_util::starts_with(trimmed_line, "@")) { + break; + } + truncated += trimmed_line + "\n"; + } + return truncated; +} + +std::optional hover_handler(Workspace& workspace, int id, json raw_params) { + auto params = raw_params.get(); + auto file_type = workspace.determine_filetype_from_uri(params.m_textDocument.m_uri); + + if (file_type == Workspace::FileType::OpenGOALIR) { + auto tracked_file = workspace.get_tracked_ir_file(params.m_textDocument.m_uri); + if (!tracked_file) { + return {}; + } + return hover_handler_ir(workspace, params, tracked_file.value()); + } else if (file_type == Workspace::FileType::OpenGOAL) { + auto tracked_file = workspace.get_tracked_og_file(params.m_textDocument.m_uri); + if (!tracked_file) { + return {}; + } + // TODO - replace with AST usage instead of figuring out the symbol ourselves + const auto symbol = tracked_file->get_symbol_at_position(params.m_position); + if (!symbol) { + lg::debug("hover - no symbol"); + return {}; + } + // TODO - there is an issue with docstrings and overridden methods + const auto& symbol_info = + workspace.get_global_symbol_info(tracked_file.value(), symbol.value()); + if (!symbol_info) { + lg::debug("hover - no symbol info - {}", symbol.value()); + return {}; + } + LSPSpec::MarkupContent markup; + markup.m_kind = "markdown"; + + const auto args = + Docs::get_args_from_docstring(symbol_info->args(), symbol_info->meta().docstring); + std::string signature = ""; + bool takes_args = true; + if (symbol_info->kind() == SymbolInfo::Kind::FUNCTION) { + signature += "function "; + } else if (symbol_info->kind() == SymbolInfo::Kind::METHOD) { + signature += "method "; + } else if (symbol_info->kind() == SymbolInfo::Kind::MACRO) { + signature += "macro "; + } else { + takes_args = false; + } + // TODO - others useful, probably states? + signature += symbol.value(); + if (takes_args) { + signature += "("; + for (int i = 0; i < args.size(); i++) { + const auto& arg = args.at(i); + if (i == args.size() - 1) { + signature += fmt::format("{}: {}", arg.name, arg.type); + } else { + signature += fmt::format("{}: {}, ", arg.name, arg.type); + } + } + signature += ")"; + if (symbol_info->kind() == SymbolInfo::Kind::FUNCTION && + workspace.get_symbol_typespec(tracked_file.value(), symbol.value())) { + signature += + fmt::format(": {}", workspace.get_symbol_typespec(tracked_file.value(), symbol.value()) + ->last_arg() + .base_type()); + } else if (symbol_info->kind() == SymbolInfo::Kind::METHOD) { + signature += fmt::format(": {}", symbol_info->method_info().type.last_arg().base_type()); + } + } else if (workspace.get_symbol_typespec(tracked_file.value(), symbol.value())) { + signature += fmt::format( + ": {}", workspace.get_symbol_typespec(tracked_file.value(), symbol.value())->base_type()); + } + + std::string body = fmt::format("```opengoal\n{}\n```\n\n", signature); + body += "___\n\n"; + if (!symbol_info->meta().docstring.empty()) { + body += truncate_docstring(symbol_info->meta().docstring) + "\n\n"; + } + + // TODO - support @see/@returns/[[reference]] + for (const auto& arg : args) { + std::string param_line = ""; + if (arg.is_mutated) { + param_line += fmt::format("*@param!* `{}: {}`", arg.name, arg.type); + } else if (arg.is_optional) { + param_line += fmt::format("*@param?* `{}: {}`", arg.name, arg.type); + } else if (arg.is_unused) { + param_line += fmt::format("*@param_* `{}: {}`", arg.name, arg.type); + } else { + param_line += fmt::format("*@param* `{}: {}`", arg.name, arg.type); + } + if (!arg.description.empty()) { + param_line += fmt::format(" - {}\n\n", arg.description); + } else { + param_line += "\n\n"; + } + body += param_line; + } + + markup.m_value = body; + LSPSpec::Hover hover_resp; + hover_resp.m_contents = markup; + return hover_resp; + } return {}; } diff --git a/lsp/main.cpp b/lsp/main.cpp index 057721feb..de38b6c8c 100644 --- a/lsp/main.cpp +++ b/lsp/main.cpp @@ -35,7 +35,7 @@ void setup_logging(bool verbose, std::string log_file) { if (!log_file.empty()) { - lg::set_file(log_file, false); + lg::set_file(log_file, false, true); } if (verbose) { lg::set_file_level(lg::level::debug); @@ -91,6 +91,14 @@ int main(int argc, char** argv) { if (message_buffer.message_completed()) { json body = message_buffer.body(); + // If the request doesn't have a 'method', then it's not a request + // skip it, but log it. We don't depend on any requests from the client yet + // currently they are mostly just notifications + if (!body.contains("method")) { + lg::warn("Response received from client - {}", body.dump()); + message_buffer.clear(); + continue; + } auto method_name = body["method"].get(); lg::info(">>> Received message of method '{}'", method_name); auto responses = lsp_router.route_message(message_buffer, appstate); diff --git a/lsp/protocol/common_types.cpp b/lsp/protocol/common_types.cpp index 6f521c056..3c4aded8e 100644 --- a/lsp/protocol/common_types.cpp +++ b/lsp/protocol/common_types.cpp @@ -67,3 +67,26 @@ void LSPSpec::from_json(const json& j, TextDocumentPositionParams& obj) { j.at("textDocument").get_to(obj.m_textDocument); j.at("position").get_to(obj.m_position); } + +void LSPSpec::to_json(json& j, const MarkupContent& obj) { + j = json{{"kind", obj.m_kind}, {"value", obj.m_value}}; +} + +void LSPSpec::from_json(const json& j, MarkupContent& obj) { + j.at("kind").get_to(obj.m_kind); + j.at("value").get_to(obj.m_value); +} + +void LSPSpec::to_json(json& j, const Color& obj) { + json_serialize(red); + json_serialize(green); + json_serialize(blue); + json_serialize(alpha); +} + +void LSPSpec::from_json(const json& j, Color& obj) { + json_deserialize_if_exists(red); + json_deserialize_if_exists(green); + json_deserialize_if_exists(blue); + json_deserialize_if_exists(alpha); +} diff --git a/lsp/protocol/common_types.h b/lsp/protocol/common_types.h index ed9fa393c..6d1e670f5 100644 --- a/lsp/protocol/common_types.h +++ b/lsp/protocol/common_types.h @@ -5,12 +5,10 @@ #include #include -#include "third-party/json.hpp" - -using json = nlohmann::json; +#include "common/util/json_util.h" namespace LSPSpec { -// TODO - eventually parse this + typedef std::string URI; typedef std::string DocumentUri; @@ -78,4 +76,50 @@ struct TextDocumentPositionParams { void to_json(json& j, const TextDocumentPositionParams& obj); void from_json(const json& j, TextDocumentPositionParams& obj); + +// A `MarkupContent` literal represents a string value which content is +// interpreted base on its kind flag. Currently the protocol supports +// `plaintext` and `markdown` as markup kinds. +// +// If the kind is `markdown` then the value can contain fenced code blocks like +// in GitHub issues. +// +// Here is an example how such a string can be constructed using +// JavaScript / TypeScript: +// ```typescript +// let markdown: MarkdownContent = { +// kind: MarkupKind.Markdown, +// value: [ +// '# Header', +// 'Some text', +// '```typescript', +// 'someCode();', +// '```' +// ].join('\n') +// }; +// ``` +// +// *Please Note* that clients might sanitize the return markdown. A client could +// decide to remove HTML from the markdown to avoid script execution. +struct MarkupContent { + std::string m_kind; // Actually a MarkupKind which is either 'plaintext' or 'markdown' + std::string m_value; +}; + +void to_json(json& j, const MarkupContent& obj); +void from_json(const json& j, MarkupContent& obj); + +// Represents a color in RGBA space. +struct Color { + // The red component of this color in the range [0-1]. + float red; + // The green component of this color in the range [0-1]. + float green; + // The blue component of this color in the range [0-1]. + float blue; + // The alpha component of this color in the range [0-1]. + float alpha; +}; +void to_json(json& j, const Color& obj); +void from_json(const json& j, Color& obj); } // namespace LSPSpec diff --git a/lsp/protocol/completion.cpp b/lsp/protocol/completion.cpp index b71ff427e..de58fae8e 100644 --- a/lsp/protocol/completion.cpp +++ b/lsp/protocol/completion.cpp @@ -8,3 +8,7 @@ void LSPSpec::from_json(const json& j, CompletionParams& obj) { j.at("textDocument").get_to(obj.m_textDocument); j.at("position").get_to(obj.m_position); } + +void LSPSpec::to_json(json& j, const CompletionList& obj) {} + +void LSPSpec::from_json(const json& j, CompletionList& obj) {} diff --git a/lsp/protocol/completion.h b/lsp/protocol/completion.h index 80e8fc4ca..9d4dafb04 100644 --- a/lsp/protocol/completion.h +++ b/lsp/protocol/completion.h @@ -29,4 +29,99 @@ struct CompletionParams { void to_json(json& j, const CompletionParams& obj); void from_json(const json& j, CompletionParams& obj); +/// @brief Additional details for a completion item label. +struct CompletionItemLabelDetails { + /// An optional string which is rendered less prominently directly after {@link + /// CompletionItem.label label}, without any spacing. Should be used for function signatures or + /// type annotations. + std::optional detail; + /// An optional string which is rendered less prominently after {@link + /// CompletionItemLabelDetails.detail}. Should be used for fully qualified names or file path. + std::optional description; +}; + +/// @brief The kind of a completion entry. +enum class CompletionItemKind { + Text = 1, + Method = 2, + Function = 3, + Constructor = 4, + Field = 5, + Variable = 6, + Class = 7, + Interface = 8, + Module = 9, + Property = 10, + Unit = 11, + Value = 12, + Enum = 13, + Keyword = 14, + Snippet = 15, + Color = 16, + File = 17, + Reference = 18, + Folder = 19, + EnumMember = 20, + Constant = 21, + Struct = 22, + Event = 23, + Operator = 24, + TypeParameter = 25 +}; + +/// Completion item tags are extra annotations that tweak the rendering of a completion item. +enum class CompletionItemTag { + /// Render a completion as obsolete, usually using a strike-out. + Deprecated = 1 +}; + +struct CompletionItem { + /// The label of this completion item. + /// + /// The label property is also by default the text that is inserted when selecting this + /// completion. + /// + /// If label details are provided the label itself should be an unqualified name of the completion + /// item. + std::string label; + /// Additional details for the label + std::optional labelDetails; + /// The kind of this completion item. Based of the kind an icon is chosen by the editor. The + /// standardized set of available values is defined in `CompletionItemKind`. + std::optional kind; + /// Tags for this completion item. + std::optional> tags; + /// A human-readable string with additional information about this item, like type or symbol + /// information. + std::optional detail; + /// A human-readable string that represents a doc-comment. + std::optional documentation; + // NOTE - skipped deprecated + /// Select this item when showing. + /// + /// *Note* that only one completion item can be selected and that the tool / client decides which + /// item that is. The rule is that the *first* item of those that match best is selected. + std::optional preselect; + /// A string that should be used when comparing this item with other items. When omitted the label + /// is used as the sort text for this item. + std::optional sortText; + /// A string that should be used when filtering a set of completion items. When omitted the label + /// is used as the filter text for this item. + std::optional filterText; + // TODO - a lot of other fields... +}; + +struct CompletionList { + /// This list is not complete. Further typing should result in recomputing this list. + /// + /// Recomputed lists have all their items replaced (not appended) in the incomplete completion + /// sessions. + bool m_isIncomplete; + /// The completion items. + std::vector m_items; +}; + +void to_json(json& j, const CompletionList& obj); +void from_json(const json& j, CompletionList& obj); + } // namespace LSPSpec diff --git a/lsp/protocol/document_color.cpp b/lsp/protocol/document_color.cpp new file mode 100644 index 000000000..5a64ff47e --- /dev/null +++ b/lsp/protocol/document_color.cpp @@ -0,0 +1,19 @@ +#include "document_color.h" + +void LSPSpec::to_json(json& j, const DocumentColorParams& obj) { + json_serialize(textDocument); +} + +void LSPSpec::from_json(const json& j, DocumentColorParams& obj) { + json_deserialize_if_exists(textDocument); +} + +void LSPSpec::to_json(json& j, const ColorInformation& obj) { + json_serialize(range); + json_serialize(color); +} + +void LSPSpec::from_json(const json& j, ColorInformation& obj) { + json_deserialize_if_exists(range); + json_deserialize_if_exists(color); +} diff --git a/lsp/protocol/document_color.h b/lsp/protocol/document_color.h new file mode 100644 index 000000000..5e3a1fca4 --- /dev/null +++ b/lsp/protocol/document_color.h @@ -0,0 +1,24 @@ +#pragma once + +#include "common_types.h" + +namespace LSPSpec { +struct DocumentColorParams { + // The text document. + TextDocumentIdentifier textDocument; +}; + +void to_json(json& j, const DocumentColorParams& obj); +void from_json(const json& j, DocumentColorParams& obj); + +struct ColorInformation { + // The range in the document where this color appears. + Range range; + // The actual color value for this color range. + Color color; +}; + +void to_json(json& j, const ColorInformation& obj); +void from_json(const json& j, ColorInformation& obj); + +} // namespace LSPSpec diff --git a/lsp/protocol/hover.cpp b/lsp/protocol/hover.cpp index 576f94a3c..b3868512a 100644 --- a/lsp/protocol/hover.cpp +++ b/lsp/protocol/hover.cpp @@ -1,14 +1,5 @@ #include "hover.h" -void LSPSpec::to_json(json& j, const MarkupContent& obj) { - j = json{{"kind", obj.m_kind}, {"value", obj.m_value}}; -} - -void LSPSpec::from_json(const json& j, MarkupContent& obj) { - j.at("kind").get_to(obj.m_kind); - j.at("value").get_to(obj.m_value); -} - void LSPSpec::to_json(json& j, const Hover& obj) { j = json{{"contents", obj.m_contents}}; if (obj.m_range) { diff --git a/lsp/protocol/hover.h b/lsp/protocol/hover.h index ad35b5e33..6494b18f3 100644 --- a/lsp/protocol/hover.h +++ b/lsp/protocol/hover.h @@ -3,40 +3,6 @@ #include "common_types.h" namespace LSPSpec { -/** - * A `MarkupContent` literal represents a string value which content is - * interpreted base on its kind flag. Currently the protocol supports - * `plaintext` and `markdown` as markup kinds. - * - * If the kind is `markdown` then the value can contain fenced code blocks like - * in GitHub issues. - * - * Here is an example how such a string can be constructed using - * JavaScript / TypeScript: - * ```typescript - * let markdown: MarkdownContent = { - * kind: MarkupKind.Markdown, - * value: [ - * '# Header', - * 'Some text', - * '```typescript', - * 'someCode();', - * '```' - * ].join('\n') - * }; - * ``` - * - * *Please Note* that clients might sanitize the return markdown. A client could - * decide to remove HTML from the markdown to avoid script execution. - */ -struct MarkupContent { - std::string m_kind; // Actually a MarkupKind which is either 'plaintext' or 'markdown' - std::string m_value; -}; - -void to_json(json& j, const MarkupContent& obj); -void from_json(const json& j, MarkupContent& obj); - struct Hover { /// @brief The hover's content MarkupContent m_contents; diff --git a/lsp/protocol/initialize_result.h b/lsp/protocol/initialize_result.h index c468d1123..8355fd686 100644 --- a/lsp/protocol/initialize_result.h +++ b/lsp/protocol/initialize_result.h @@ -1,4 +1,4 @@ -// TODO - convert this a proper class +// TODO - convert this to a proper class #include "third-party/json.hpp" @@ -40,6 +40,7 @@ class InitializeResult { {"completionProvider", completion_provider}, {"signatureHelpProvider", signature_help_provider}, {"definitionProvider", true}, + {"colorProvider", true}, {"referencesProvider", false}, {"documentHighlightProvider", false}, {"documentSymbolProvider", diff --git a/lsp/protocol/progress_report.cpp b/lsp/protocol/progress_report.cpp new file mode 100644 index 000000000..dcc315880 --- /dev/null +++ b/lsp/protocol/progress_report.cpp @@ -0,0 +1,79 @@ +#include "progress_report.h" + +void LSPSpec::to_json(json& j, const WorkDoneProgressCreateParams& obj) { + json_serialize(token); +} + +void LSPSpec::from_json(const json& j, WorkDoneProgressCreateParams& obj) { + json_deserialize_if_exists(token); +} + +void LSPSpec::to_json(json& j, const ProgressPayloadBegin& obj) { + json_serialize(kind); + json_serialize(title); + json_serialize(cancellable); + json_serialize_optional(message); + json_serialize_optional(percentage); +} + +void LSPSpec::from_json(const json& j, ProgressPayloadBegin& obj) { + json_deserialize_if_exists(kind); + json_deserialize_if_exists(title); + json_deserialize_if_exists(cancellable); + json_deserialize_optional_if_exists(message); + json_deserialize_optional_if_exists(percentage); +} + +void LSPSpec::to_json(json& j, const ProgressParamsBegin& obj) { + json_serialize(token); + json_serialize(value); +} + +void LSPSpec::from_json(const json& j, ProgressParamsBegin& obj) { + json_deserialize_if_exists(token); + json_deserialize_if_exists(value); +} + +void LSPSpec::to_json(json& j, const ProgressPayloadReport& obj) { + json_serialize(kind); + json_serialize(cancellable); + json_serialize_optional(message); + json_serialize_optional(percentage); +} + +void LSPSpec::from_json(const json& j, ProgressPayloadReport& obj) { + json_deserialize_if_exists(kind); + json_deserialize_if_exists(cancellable); + json_deserialize_optional_if_exists(message); + json_deserialize_optional_if_exists(percentage); +} + +void LSPSpec::to_json(json& j, const ProgressParamsReport& obj) { + json_serialize(token); + json_serialize(value); +} + +void LSPSpec::from_json(const json& j, ProgressParamsReport& obj) { + json_deserialize_if_exists(token); + json_deserialize_if_exists(value); +} + +void LSPSpec::to_json(json& j, const ProgressPayloadEnd& obj) { + json_serialize(kind); + json_serialize_optional(message); +} + +void LSPSpec::from_json(const json& j, ProgressPayloadEnd& obj) { + json_deserialize_if_exists(kind); + json_deserialize_optional_if_exists(message); +} + +void LSPSpec::to_json(json& j, const ProgressParamsEnd& obj) { + json_serialize(token); + json_serialize(value); +} + +void LSPSpec::from_json(const json& j, ProgressParamsEnd& obj) { + json_deserialize_if_exists(token); + json_deserialize_if_exists(value); +} diff --git a/lsp/protocol/progress_report.h b/lsp/protocol/progress_report.h new file mode 100644 index 000000000..0e254c34a --- /dev/null +++ b/lsp/protocol/progress_report.h @@ -0,0 +1,105 @@ +#pragma once + +#include "common_types.h" + +namespace LSPSpec { +struct WorkDoneProgressCreateParams { + // The token to be used to report progress. (can also be an integer) + std::string token; +}; + +void to_json(json& j, const WorkDoneProgressCreateParams& obj); +void from_json(const json& j, WorkDoneProgressCreateParams& obj); + +struct ProgressPayloadBegin { + std::string kind = "begin"; + // Mandatory title of the progress operation. Used to briefly inform about + // the kind of operation being performed. + // + // Examples: "Indexing" or "Linking dependencies". + std::string title; + // Controls if a cancel button should show to allow the user to cancel the + // long running operation. Clients that don't support cancellation are + // allowed to ignore the setting. + bool cancellable = false; + // Optional, more detailed associated progress message. Contains + // complementary information to the `title`. + // + // Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". + // If unset, the previous progress message (if any) is still valid. + std::optional message; + // Optional progress percentage to display (value 100 is considered 100%). + // If not provided infinite progress is assumed and clients are allowed + // to ignore the `percentage` value in subsequent in report notifications. + // + // The value should be steadily rising. Clients are free to ignore values + // that are not following this rule. The value range is [0, 100] + std::optional percentage; +}; +void to_json(json& j, const ProgressPayloadBegin& obj); +void from_json(const json& j, ProgressPayloadBegin& obj); + +struct ProgressParamsBegin { + // The progress token provided by the client or server. + std::string token; + // Payload + ProgressPayloadBegin value; +}; + +void to_json(json& j, const ProgressParamsBegin& obj); +void from_json(const json& j, ProgressParamsBegin& obj); + +struct ProgressPayloadReport { + std::string kind = "report"; + // Controls enablement state of a cancel button. This property is only valid + // if a cancel button got requested in the `WorkDoneProgressBegin` payload. + // + // Clients that don't support cancellation or don't support control the + // button's enablement state are allowed to ignore the setting. + bool cancellable = false; + // Optional, more detailed associated progress message. Contains + // complementary information to the `title`. + // + // Examples: "3/25 files", "project/src/module2", "node_modules/some_dep". + // If unset, the previous progress message (if any) is still valid. + std::optional message; + // Optional progress percentage to display (value 100 is considered 100%). + // If not provided infinite progress is assumed and clients are allowed + // to ignore the `percentage` value in subsequent in report notifications. + // + // The value should be steadily rising. Clients are free to ignore values + // that are not following this rule. The value range is [0, 100] + std::optional percentage; +}; +void to_json(json& j, const ProgressPayloadReport& obj); +void from_json(const json& j, ProgressPayloadReport& obj); + +struct ProgressParamsReport { + // The progress token provided by the client or server. + std::string token; + // Payload + ProgressPayloadReport value; +}; + +void to_json(json& j, const ProgressParamsReport& obj); +void from_json(const json& j, ProgressParamsReport& obj); + +struct ProgressPayloadEnd { + std::string kind = "end"; + // Optional, a final message indicating to for example indicate the outcome + // of the operation. + std::optional message; +}; +void to_json(json& j, const ProgressPayloadEnd& obj); +void from_json(const json& j, ProgressPayloadEnd& obj); + +struct ProgressParamsEnd { + // The progress token provided by the client or server. + std::string token; + // Payload + ProgressPayloadEnd value; +}; + +void to_json(json& j, const ProgressParamsEnd& obj); +void from_json(const json& j, ProgressParamsEnd& obj); +} // namespace LSPSpec diff --git a/lsp/state/app.h b/lsp/state/app.h index 9d3c31734..62ae4604b 100644 --- a/lsp/state/app.h +++ b/lsp/state/app.h @@ -1,6 +1,6 @@ #pragma once -#include "workspace.h" +#include "lsp/state/workspace.h" struct AppState { Workspace workspace; diff --git a/lsp/state/lsp_requester.cpp b/lsp/state/lsp_requester.cpp new file mode 100644 index 000000000..4b95ed580 --- /dev/null +++ b/lsp/state/lsp_requester.cpp @@ -0,0 +1,76 @@ +#include "lsp_requester.h" + +#include + +#include "common/log/log.h" +#include "common/util/string_util.h" + +#include "lsp/protocol/progress_report.h" + +void LSPRequester::send_request(const json& params, const std::string& method) { + json req; + req["id"] = str_util::uuid(); + req["method"] = method; + req["params"] = params; + req["jsonrpc"] = "2.0"; + + std::string request; + request.append("Content-Length: " + std::to_string(req.dump().size()) + "\r\n"); + request.append("Content-Type: application/vscode-jsonrpc;charset=utf-8\r\n"); + request.append("\r\n"); + request += req.dump(); + + // Send requests immediately, as they may be done during the handling of a client request + lg::info("Sending Request {}", method); + std::cout << request.c_str() << std::flush; +} + +void LSPRequester::send_notification(const json& params, const std::string& method) { + json notification; + notification["method"] = method; + notification["params"] = params; + notification["jsonrpc"] = "2.0"; + + std::string request; + request.append("Content-Length: " + std::to_string(notification.dump().size()) + "\r\n"); + request.append("Content-Type: application/vscode-jsonrpc;charset=utf-8\r\n"); + request.append("\r\n"); + request += notification.dump(); + + // Send requests immediately, as they may be done during the handling of a client request + lg::info("Sending Notification {}", method); + std::cout << request.c_str() << std::flush; +} + +void LSPRequester::send_progress_create_request(const std::string& token, + const std::string& title) { + LSPSpec::WorkDoneProgressCreateParams params; + params.token = token; + send_request(params, "window/workDoneProgress/create"); + LSPSpec::ProgressPayloadBegin beginPayload; + beginPayload.title = title; + LSPSpec::ProgressParamsBegin beginParams; + beginParams.token = token; + beginParams.value = beginPayload; + send_notification(beginParams, "$/progress"); +} + +void LSPRequester::send_progress_update_request(const std::string& token, + const std::string& message) { + LSPSpec::ProgressPayloadReport reportPayload; + reportPayload.message = message; + LSPSpec::ProgressParamsReport reportParams; + reportParams.token = token; + reportParams.value = reportPayload; + send_notification(reportParams, "$/progress"); +} + +void LSPRequester::send_progress_finish_request(const std::string& token, + const std::string& message) { + LSPSpec::ProgressPayloadEnd endPayload; + endPayload.message = message; + LSPSpec::ProgressParamsEnd endParams; + endParams.token = token; + endParams.value = endPayload; + send_notification(endParams, "$/progress"); +} diff --git a/lsp/state/lsp_requester.h b/lsp/state/lsp_requester.h new file mode 100644 index 000000000..479865046 --- /dev/null +++ b/lsp/state/lsp_requester.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include + +#include "common/util/json_util.h" + +#include "lsp/transport/stdio.h" + +class LSPRequester { + public: + void send_progress_create_request(const std::string& token, const std::string& title); + void send_progress_update_request(const std::string& token, const std::string& message); + void send_progress_finish_request(const std::string& token, const std::string& message); + + private: + void send_request(const json& payload, const std::string& method); + void send_notification(const json& payload, const std::string& method); +}; diff --git a/lsp/state/workspace.cpp b/lsp/state/workspace.cpp index 1d18e6160..da1d452b3 100644 --- a/lsp/state/workspace.cpp +++ b/lsp/state/workspace.cpp @@ -5,6 +5,7 @@ #include #include "common/log/log.h" +#include "common/util/string_util.h" #include "lsp/protocol/common_types.h" @@ -31,18 +32,52 @@ std::string url_encode(const std::string& value) { return escaped.str(); } +std::string url_decode(const std::string& input) { + std::ostringstream decoded; + + for (std::size_t i = 0; i < input.length(); ++i) { + if (input[i] == '%') { + // Check if there are enough characters remaining + if (i + 2 < input.length()) { + // Convert the next two characters after '%' into an integer value + std::istringstream hexStream(input.substr(i + 1, 2)); + int hexValue = 0; + hexStream >> std::hex >> hexValue; + + // Append the decoded character to the result + decoded << static_cast(hexValue); + + // Skip the next two characters + i += 2; + } + } else if (input[i] == '+') { + // Replace '+' with space character ' ' + decoded << ' '; + } else { + // Append the character as is + decoded << input[i]; + } + } + + return decoded.str(); +} + LSPSpec::DocumentUri uri_from_path(fs::path path) { - std::string path_str = path.string(); - // Replace slash type on windows -#ifdef _WIN32 - std::replace(path_str.begin(), path_str.end(), '\\', '/'); -#endif + auto path_str = file_util::convert_to_unix_path_separators(path.string()); // vscode works with proper URL encoded URIs for file paths // which means we have to roll our own... path_str = url_encode(path_str); return fmt::format("file:///{}", path_str); } +std::string uri_to_path(LSPSpec::DocumentUri uri) { + auto decoded_uri = url_decode(uri); + if (str_util::starts_with(decoded_uri, "file:///")) { + decoded_uri = decoded_uri.substr(8); + } + return decoded_uri; +} + Workspace::Workspace(){}; Workspace::~Workspace(){}; @@ -54,6 +89,31 @@ void Workspace::set_initialized(bool new_value) { m_initialized = new_value; } +Workspace::FileType Workspace::determine_filetype_from_languageid(const std::string& language_id) { + if (language_id == "opengoal") { + return FileType::OpenGOAL; + } else if (language_id == "opengoal-ir") { + return FileType::OpenGOALIR; + } + return FileType::Unsupported; +} + +Workspace::FileType Workspace::determine_filetype_from_uri(const LSPSpec::DocumentUri& file_uri) { + if (str_util::ends_with(file_uri, ".gc")) { + return FileType::OpenGOAL; + } else if (str_util::ends_with(file_uri, "ir2.asm")) { + return FileType::OpenGOALIR; + } + return FileType::Unsupported; +} + +std::optional Workspace::get_tracked_og_file(const LSPSpec::URI& file_uri) { + if (m_tracked_og_files.find(file_uri) == m_tracked_og_files.end()) { + return {}; + } + return m_tracked_og_files[file_uri]; +} + std::optional Workspace::get_tracked_ir_file(const LSPSpec::URI& file_uri) { if (m_tracked_ir_files.count(file_uri) == 0) { return {}; @@ -74,6 +134,77 @@ std::optional Workspace::get_definition_info_from_all_types( return dts.symbol_metadata_map.at(symbol_name); } +// TODO - a gross hack that should go away when the language isn't so tightly coupled to the jak +// games +// +// This is bad because jak 2 now uses some code from the jak1 folder, and also wouldn't be able to +// be determined (jak1 or jak2?) if we had a proper 'common' folder(s). +std::optional determine_game_version_from_uri(const LSPSpec::DocumentUri& uri) { + const auto path = uri_to_path(uri); + if (str_util::contains(path, "goal_src/jak1")) { + return GameVersion::Jak1; + } else if (str_util::contains(path, "goal_src/jak2")) { + return GameVersion::Jak2; + } + return {}; +} + +std::optional Workspace::get_global_symbol_info(const WorkspaceOGFile& file, + const std::string& symbol_name) { + if (m_compiler_instances.find(file.m_game_version) == m_compiler_instances.end()) { + lg::debug("Compiler not instantiated for game version - {}", + version_to_game_name(file.m_game_version)); + return {}; + } + const auto& compiler = m_compiler_instances[file.m_game_version].get(); + const auto symbol_infos = compiler->lookup_exact_name_info(symbol_name); + if (!symbol_infos || symbol_infos->empty()) { + return {}; + } else if (symbol_infos->size() > 1) { + // TODO - handle this (overriden methods is the main issue here) + lg::debug("Found symbol info, but found multiple infos - {}", symbol_infos->size()); + return {}; + } + const auto& symbol = symbol_infos->at(0); + return symbol; +} + +std::optional Workspace::get_symbol_typespec(const WorkspaceOGFile& file, + const std::string& symbol_name) { + if (m_compiler_instances.find(file.m_game_version) == m_compiler_instances.end()) { + lg::debug("Compiler not instantiated for game version - {}", + version_to_game_name(file.m_game_version)); + return {}; + } + const auto& compiler = m_compiler_instances[file.m_game_version].get(); + const auto typespec = compiler->lookup_typespec(symbol_name); + if (typespec) { + return typespec; + } + return {}; +} + +std::optional Workspace::get_symbol_def_location( + const WorkspaceOGFile& file, + const SymbolInfo& symbol_info) { + if (m_compiler_instances.find(file.m_game_version) == m_compiler_instances.end()) { + lg::debug("Compiler not instantiated for game version - {}", + version_to_game_name(file.m_game_version)); + return {}; + } + const auto& compiler = m_compiler_instances[file.m_game_version].get(); + std::optional def_loc; + const auto& goos_info = compiler->get_goos().reader.db.get_short_info_for(symbol_info.src_form()); + if (goos_info) { + Docs::DefinitionLocation new_def_loc; + new_def_loc.filename = uri_from_path(goos_info->filename); + new_def_loc.line_idx = goos_info->line_idx_to_display; + new_def_loc.char_idx = goos_info->pos_in_line; + def_loc = new_def_loc; + } + return def_loc; +} + void Workspace::start_tracking_file(const LSPSpec::DocumentUri& file_uri, const std::string& language_id, const std::string& content) { @@ -89,8 +220,35 @@ void Workspace::start_tracking_file(const LSPSpec::DocumentUri& file_uri, m_tracked_all_types_files[file.m_all_types_uri].parse_type_system(); } } + } else if (language_id == "opengoal") { + auto game_version = determine_game_version_from_uri(file_uri); + if (!game_version) { + lg::debug("Could not determine game version from path - {}", file_uri); + return; + } + // TODO - this should happen on a separate thread so the LSP is not blocking during this lengthy + // step + if (m_compiler_instances.find(*game_version) == m_compiler_instances.end()) { + lg::debug( + "first time encountering a OpenGOAL file for game version - {}, initializing a compiler", + version_to_game_name(*game_version)); + const auto project_path = file_util::try_get_project_path_from_path(uri_to_path(file_uri)); + lg::debug("Detected project path - {}", project_path.value()); + if (!file_util::setup_project_path(project_path)) { + lg::debug("unable to setup project path, not initializing a compiler"); + return; + } + m_requester.send_progress_create_request("indexing-jak2", "Indexing - Jak 2"); + m_compiler_instances.emplace(game_version.value(), + std::make_unique(game_version.value())); + // TODO - if this fails, annotate some errors, adjust progress + m_compiler_instances.at(*game_version)->run_front_end_on_string("(make-group \"all-code\")"); + m_requester.send_progress_finish_request("indexing-jak2", "Indexed - Jak 2"); + } + // TODO - otherwise, just `ml` the file instead of rebuilding the entire thing + // TODO - if the file fails to `ml`, annotate some errors + m_tracked_og_files[file_uri] = WorkspaceOGFile(content, *game_version); } - // TODO - only supporting IR files currently! } void Workspace::update_tracked_file(const LSPSpec::DocumentUri& file_uri, @@ -131,6 +289,34 @@ void Workspace::stop_tracking_file(const LSPSpec::DocumentUri& file_uri) { } } +WorkspaceOGFile::WorkspaceOGFile(const std::string& content, const GameVersion& game_version) + : m_game_version(game_version) { + m_lines = str_util::split(content); + lg::info("Added new OG file. {} lines with {} symbols and {} diagnostics", m_lines.size(), + m_symbols.size(), m_diagnostics.size()); +} + +std::optional WorkspaceOGFile::get_symbol_at_position( + const LSPSpec::Position position) const { + // Split the line on typical word boundaries + std::string line = m_lines.at(position.m_line); + std::smatch matches; + std::regex regex("[\\w\\.\\-_!<>*?]+"); + std::regex_token_iterator rend; + + std::regex_token_iterator match(line.begin(), line.end(), regex); + while (match != rend) { + auto match_start = std::distance(line.begin(), match->first); + auto match_end = match_start + match->length(); + if (position.m_character >= match_start && position.m_character <= match_end) { + return match->str(); + } + match++; + } + + return {}; +} + WorkspaceIRFile::WorkspaceIRFile(const std::string& content) { // Get all lines of file std::string::size_type pos = 0; @@ -151,7 +337,7 @@ WorkspaceIRFile::WorkspaceIRFile(const std::string& content) { find_function_symbol(m_lines.size() - 1, line); identify_diagnostics(m_lines.size() - 1, line); - lg::info("Added new file. {} lines with {} symbols and {} diagnostics", m_lines.size(), + lg::info("Added new IR file. {} lines with {} symbols and {} diagnostics", m_lines.size(), m_symbols.size(), m_diagnostics.size()); } @@ -273,7 +459,7 @@ void WorkspaceIRFile::identify_diagnostics(const uint32_t line_num_zero_based, } std::optional WorkspaceIRFile::get_mips_instruction_at_position( - const LSPSpec::Position position) { + const LSPSpec::Position position) const { // Split the line on typical word boundaries std::string line = m_lines.at(position.m_line); std::smatch matches; @@ -292,7 +478,7 @@ std::optional WorkspaceIRFile::get_mips_instruction_at_position( } std::optional WorkspaceIRFile::get_symbol_at_position( - const LSPSpec::Position position) { + const LSPSpec::Position position) const { // Split the line on typical word boundaries std::string line = m_lines.at(position.m_line); std::smatch matches; diff --git a/lsp/state/workspace.h b/lsp/state/workspace.h index 2d7c18404..ec39e4b67 100644 --- a/lsp/state/workspace.h +++ b/lsp/state/workspace.h @@ -7,9 +7,27 @@ #include "common/util/FileUtil.h" #include "decompiler/util/DecompilerTypeSystem.h" +#include "goalc/compiler/Compiler.h" +#include "goalc/compiler/docs/DocTypes.h" #include "lsp/protocol/common_types.h" #include "lsp/protocol/document_diagnostics.h" #include "lsp/protocol/document_symbols.h" +#include "lsp/state/lsp_requester.h" + +class WorkspaceOGFile { + public: + WorkspaceOGFile(){}; + WorkspaceOGFile(const std::string& content, const GameVersion& game_version); + // TODO - make private + int32_t version; + // TODO - keep an AST of the file instead + std::vector m_lines; + std::vector m_symbols; + std::vector m_diagnostics; + GameVersion m_game_version; + + std::optional get_symbol_at_position(const LSPSpec::Position position) const; +}; class WorkspaceIRFile { public: @@ -24,17 +42,16 @@ class WorkspaceIRFile { LSPSpec::DocumentUri m_all_types_uri = ""; fs::path m_all_types_file_path; - std::optional get_mips_instruction_at_position(const LSPSpec::Position position); - std::optional get_symbol_at_position(const LSPSpec::Position position); + std::optional get_mips_instruction_at_position( + const LSPSpec::Position position) const; + std::optional get_symbol_at_position(const LSPSpec::Position position) const; private: void find_all_types_path(const std::string& line); void find_function_symbol(const uint32_t line_num_zero_based, const std::string& line); - /// @brief Make any relevant diagnostics on the IR line. + /// Make any relevant diagnostics on the IR line. /// It's assumed each line in an IR can have atmost one diagnostic, and they are contained to just /// that line! - /// @param line_num_zero_based - /// @param line void identify_diagnostics(const uint32_t line_num_zero_based, const std::string& line); }; @@ -57,24 +74,49 @@ class WorkspaceAllTypesFile { class Workspace { public: + enum class FileType { OpenGOAL, OpenGOALIR, Unsupported }; Workspace(); virtual ~Workspace(); bool is_initialized(); void set_initialized(bool new_value); + // Even though when a file is initially opened it has the language id + // many subsequent requests only provide a uri to the file + // and it's a lot faster to check the end of a string, then multiple tracked file maps + FileType determine_filetype_from_languageid(const std::string& language_id); + FileType determine_filetype_from_uri(const LSPSpec::DocumentUri& file_uri); + void start_tracking_file(const LSPSpec::DocumentUri& file_uri, const std::string& language_id, const std::string& content); void update_tracked_file(const LSPSpec::DocumentUri& file_uri, const std::string& content); void stop_tracking_file(const LSPSpec::DocumentUri& file_uri); + std::optional get_tracked_og_file(const LSPSpec::URI& file_uri); std::optional get_tracked_ir_file(const LSPSpec::URI& file_uri); std::optional get_definition_info_from_all_types( const std::string& symbol_name, const LSPSpec::DocumentUri& all_types_uri); + std::optional get_global_symbol_info(const WorkspaceOGFile& file, + const std::string& symbol_name); + std::optional get_symbol_typespec(const WorkspaceOGFile& file, + const std::string& symbol_name); + std::optional get_symbol_def_location(const WorkspaceOGFile& file, + const SymbolInfo& symbol_info); private: + LSPRequester m_requester; bool m_initialized = false; + std::unordered_map m_tracked_og_files = {}; std::unordered_map m_tracked_ir_files = {}; std::unordered_map m_tracked_all_types_files = {}; + + // TODO: + // OpenGOAL is still incredibly tightly coupled to the jak projects as a language + // + // In the future, information like GameVersion should just be within the project file + // and then we can track projects instead of games + // + // Until that decoupling happens, things like this will remain fairly clunky. + std::unordered_map> m_compiler_instances; }; diff --git a/test/decompiler/reference/jak2/engine/camera/cam-layout_REF.gc b/test/decompiler/reference/jak2/engine/camera/cam-layout_REF.gc index 0021a73f8..f922f0715 100644 --- a/test/decompiler/reference/jak2/engine/camera/cam-layout_REF.gc +++ b/test/decompiler/reference/jak2/engine/camera/cam-layout_REF.gc @@ -300,7 +300,7 @@ (with-dma-buffer-add-bucket ((s5-0 (-> *display* frames (-> *display* on-screen) debug-buf)) (bucket-id debug2) ) - (draw-string-xy arg2 s5-0 arg0 arg1 (font-color #dadada) (font-flags shadow kerning)) + (draw-string-xy arg2 s5-0 arg0 arg1 (font-color font-color-1) (font-flags shadow kerning)) ) ) diff --git a/test/decompiler/reference/jak2/engine/collide/collide-edge-grab_REF.gc b/test/decompiler/reference/jak2/engine/collide/collide-edge-grab_REF.gc index 288bce926..e325dd75c 100644 --- a/test/decompiler/reference/jak2/engine/collide/collide-edge-grab_REF.gc +++ b/test/decompiler/reference/jak2/engine/collide/collide-edge-grab_REF.gc @@ -649,7 +649,7 @@ ) (sv-32 a0-10 a1-4 a2-2) ) - (s2-0 s1-0 (the-as bucket-id s0-0) *temp-string* s3-0 (font-color #dadada) (the-as vector2h #f)) + (s2-0 s1-0 (the-as bucket-id s0-0) *temp-string* s3-0 (font-color font-color-1) (the-as vector2h #f)) ) ) ) diff --git a/test/decompiler/reference/jak2/engine/debug/debug_REF.gc b/test/decompiler/reference/jak2/engine/debug/debug_REF.gc index 4623df9f2..56ad4cac0 100644 --- a/test/decompiler/reference/jak2/engine/debug/debug_REF.gc +++ b/test/decompiler/reference/jak2/engine/debug/debug_REF.gc @@ -42,7 +42,6 @@ ;; definition (debug) for function add-debug-point ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ a0-6 8) 0) at op 152 (defun-debug add-debug-point ((enable-draw symbol) (bucket bucket-id) (pt vector)) (if (not enable-draw) (return #f) @@ -156,7 +155,6 @@ ;; definition (debug) for function internal-draw-debug-line ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ a0-29 8) 0) at op 271 (defun-debug internal-draw-debug-line ((bucket bucket-id) (start vector) (end vector) (start-color rgba) (mode symbol) (end-color rgba)) (local-vars (var-end vector) (sv-128 vector) (sv-144 vector)) (set! var-end end) @@ -290,7 +288,6 @@ ;; definition (debug) for function internal-draw-debug-text-3d ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ v1-12 8) 0) at op 54 (defun-debug internal-draw-debug-text-3d ((bucket bucket-id) (text string) (position vector) (color font-color) (screen-offset vector2h)) (let ((screen-pos (new 'stack-no-clear 'vector4w))) (set! (-> screen-pos quad) (the-as uint128 0)) @@ -349,7 +346,6 @@ ;; definition (debug) for function add-debug-flat-triangle ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ a0-13 8) 0) at op 153 (defun-debug add-debug-flat-triangle ((enable symbol) (bucket bucket-id) (p0 vector) (p1 vector) (p2 vector) (color rgba)) (local-vars (sv-160 vector) (sv-176 vector)) (set! sv-160 p0) @@ -656,7 +652,6 @@ ;; definition (debug) for function add-debug-line2d ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ v1-12 8) 0) at op 115 (defun-debug add-debug-line2d ((enable symbol) (bucket bucket-id) (start vector4w) (end vector4w) (color vector4w)) (if (not enable) (return #f) @@ -1438,7 +1433,6 @@ ;; INFO: Used lq/sq ;; WARN: Stack slot offset 32 signed mismatch ;; WARN: Stack slot offset 32 signed mismatch -;; ERROR: Failed store: (s.w! (+ v1-9 8) 0) at op 47 (defun-debug debug-percent-bar ((enable symbol) (bucket bucket-id) (x int) (y int) (percentage float) (color rgba) (width int) (height int)) (local-vars (sv-16 int) (sv-32 float)) (set! sv-16 y) @@ -1462,7 +1456,6 @@ ;; definition (debug) for function debug-pad-display ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ v1-16 8) 0) at op 75 (defun-debug debug-pad-display ((pad cpad-info)) (let ((stick-history (new 'static 'inline-array vector 32 (new 'static 'vector) @@ -1612,7 +1605,6 @@ ) ;; definition for method 3 of type debug-vertex-stats -;; INFO: this function exists in multiple non-identical object files (defmethod inspect debug-vertex-stats ((obj debug-vertex-stats)) (format #t "[~8x] ~A~%" obj (-> obj type)) (format #t "~Tlength: ~D~%" (-> obj length)) @@ -1735,7 +1727,6 @@ ;; definition (debug) for function add-debug-cursor ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -;; ERROR: Failed store: (s.w! (+ v1-9 8) 0) at op 38 (defun-debug add-debug-cursor ((enable symbol) (bucket bucket-id) (x int) (y int) (arg4 int)) (when enable (with-dma-buffer-add-bucket ((buf (-> *display* frames (-> *display* on-screen) global-buf)) @@ -1753,10 +1744,10 @@ (font-color red) ) ((= v1-7 2) - (font-color yellow-#f3f300) + (font-color yellow) ) ((= v1-7 4) - (font-color green-#3df23d) + (font-color green) ) (else (font-color default) @@ -1894,7 +1885,6 @@ ;; definition (debug) for function add-debug-bound ;; INFO: Used lq/sq ;; WARN: Return type mismatch int vs none. -;; ERROR: Failed store: (s.w! (+ a0-3 8) 0) at op 36 ;; WARN: Function add-debug-bound has a return type of none, but the expression builder found a return statement. (defun-debug add-debug-bound ((buf bucket-id) (pts (inline-array vector)) (c0 int) (c1 rgba) (flash rgba) (arg5 int)) (local-vars (sv-16 pointer) (sv-32 int)) diff --git a/test/decompiler/reference/jak2/engine/debug/editable_REF.gc b/test/decompiler/reference/jak2/engine/debug/editable_REF.gc index 84d68641c..79095f3a1 100644 --- a/test/decompiler/reference/jak2/engine/debug/editable_REF.gc +++ b/test/decompiler/reference/jak2/engine/debug/editable_REF.gc @@ -124,7 +124,7 @@ (s1-0 318) ) (format (clear *temp-string*) "region-~D~%" (-> obj id)) - (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* arg0 (font-color #dadada) sv-32) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) (when (>= arg1 1) @@ -135,7 +135,7 @@ (s1-1 318) ) (format (clear *temp-string*) "(on-enter ~S)" s4-1) - (s3-1 s2-1 (the-as bucket-id s1-1) *temp-string* arg0 (font-color #dadada) sv-32) + (s3-1 s2-1 (the-as bucket-id s1-1) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -147,7 +147,7 @@ (s1-2 318) ) (format (clear *temp-string*) "(on-inside ~S)" s4-2) - (s3-2 s2-2 (the-as bucket-id s1-2) *temp-string* arg0 (font-color #dadada) sv-32) + (s3-2 s2-2 (the-as bucket-id s1-2) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -159,7 +159,7 @@ (s2-3 318) ) (format (clear *temp-string*) "(on-exit ~S)" s5-1) - (s4-3 s3-3 (the-as bucket-id s2-3) *temp-string* arg0 (font-color #dadada) sv-32) + (s4-3 s3-3 (the-as bucket-id s2-3) *temp-string* arg0 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -1022,7 +1022,14 @@ (s3-1 318) ) (format (clear *temp-string*) "~S~%" (-> obj name)) - (s5-1 s4-1 (the-as bucket-id s3-1) *temp-string* (-> obj trans) (font-color #dadada) (the-as vector2h #f)) + (s5-1 + s4-1 + (the-as bucket-id s3-1) + *temp-string* + (-> obj trans) + (font-color font-color-1) + (the-as vector2h #f) + ) ) ) ((method-of-type editable-sphere editable-method-10) obj) @@ -1274,8 +1281,8 @@ *temp-string* (-> gp-0 s4-1) (if (logtest? (-> obj flags) (editable-flag orient)) - (font-color yellow-#f3f300) - (font-color #dadada) + (font-color yellow) + (font-color font-color-1) ) (the-as vector2h #f) ) diff --git a/test/decompiler/reference/jak2/engine/debug/menu_REF.gc b/test/decompiler/reference/jak2/engine/debug/menu_REF.gc index 9aaf7e6fc..59a26635e 100644 --- a/test/decompiler/reference/jak2/engine/debug/menu_REF.gc +++ b/test/decompiler/reference/jak2/engine/debug/menu_REF.gc @@ -912,7 +912,6 @@ ) ;; definition for function debug-menu-item-submenu-render -;; ERROR: Failed store: (s.w! (+ v1-9 8) 0) at op 42 (defun debug-menu-item-submenu-render ((arg0 debug-menu-item-submenu) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol)) (let ((s5-0 (-> arg0 parent context font))) (let ((v1-2 s5-0) @@ -923,13 +922,13 @@ ) (set! (-> s5-0 color) (cond ((zero? arg3) - (font-color white-#ffffff) + (font-color white) ) (arg4 - (font-color #7cbaba) + (font-color font-color-11) ) (else - (font-color #959595) + (font-color font-color-13) ) ) ) @@ -944,7 +943,6 @@ ) ;; definition for function debug-menu-item-function-render -;; ERROR: Failed store: (s.w! (+ v1-3 8) 0) at op 49 (defun debug-menu-item-function-render ((arg0 debug-menu-item-function) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol)) (let ((v1-2 (-> arg0 parent context font))) (let ((a0-1 v1-2) @@ -981,7 +979,6 @@ ) ;; definition for function debug-menu-item-flag-render -;; ERROR: Failed store: (s.w! (+ v1-3 8) 0) at op 47 (defun debug-menu-item-flag-render ((arg0 debug-menu-item-flag) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol)) (let ((v1-2 (-> arg0 parent context font))) (let ((a0-1 v1-2) @@ -992,19 +989,19 @@ ) (set! (-> v1-2 color) (cond ((= (-> arg0 is-on) 'invalid) - (font-color #5e3f5e) + (font-color font-color-19) ) ((-> arg0 is-on) (if (zero? arg3) - (font-color #daf95e) - (font-color #8aa81f) + (font-color font-color-15) + (font-color font-color-16) ) ) ((zero? arg3) - (font-color #a6b5a6) + (font-color font-color-17) ) (else - (font-color #757f75) + (font-color font-color-18) ) ) ) @@ -1018,7 +1015,6 @@ ) ;; definition for function debug-menu-item-var-render -;; ERROR: Failed store: (s.w! (+ v1-16 8) 0) at op 95 (defun debug-menu-item-var-render ((arg0 debug-menu-item-var) (arg1 int) (arg2 int) (arg3 int) (arg4 symbol)) (let ((s5-0 (-> arg0 parent context font))) (let ((v1-2 s5-0) @@ -1030,15 +1026,15 @@ (set! (-> s5-0 color) (cond ((zero? arg3) (if (-> arg0 grabbed-joypad-p) - (font-color #a0d5d5) - (font-color white-#ffffff) + (font-color font-color-10) + (font-color white) ) ) (arg4 - (font-color #7cbaba) + (font-color font-color-11) ) (else - (font-color #959595) + (font-color font-color-13) ) ) ) @@ -1104,7 +1100,6 @@ ;; definition for function debug-menu-render ;; INFO: Used lq/sq -;; ERROR: Failed store: (s.w! (+ v1-9 8) 0) at op 47 (defun debug-menu-render ((arg0 debug-menu) (arg1 int) (arg2 int) (arg3 debug-menu-node) (arg4 int)) (local-vars (sv-16 dma-buffer) (sv-32 pointer)) (let ((v1-0 0)) @@ -1138,8 +1133,8 @@ (while (not (null? s1-1)) (when (= s0-1 arg3) (set! (-> arg0 context font color) (if (nonzero? arg4) - (font-color #959595) - (font-color white-#ffffff) + (font-color font-color-13) + (font-color white) ) ) (let ((v1-20 (-> arg0 context font)) @@ -1695,7 +1690,3 @@ ;; failed to figure out what this is: 0 - - - - diff --git a/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc b/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc index a614dcfe3..e9a3979f8 100644 --- a/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc +++ b/test/decompiler/reference/jak2/engine/draw/drawable_REF.gc @@ -181,7 +181,7 @@ (bucket-id debug-no-zbuf1) arg1 (-> arg0 bsphere) - (font-color #dadada) + (font-color font-color-1) (the-as vector2h #f) ) ) @@ -1717,7 +1717,6 @@ ;; definition for function default-init-buffer ;; WARN: Return type mismatch symbol vs none. -;; ERROR: Failed store: (s.w! (+ t1-0 8) t2-1) at op 24 (defun default-init-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) (let ((v1-6 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) (when (!= v1-6 (-> v1-6 last)) @@ -1750,7 +1749,6 @@ ;; definition for function default-end-buffer ;; WARN: Return type mismatch symbol vs none. -;; ERROR: Failed store: (s.w! (+ t1-0 8) t2-1) at op 24 (defun default-end-buffer ((arg0 bucket-id) (arg1 gs-zbuf) (arg2 gs-test)) (let ((v1-6 (-> *display* frames (-> *display* on-screen) bucket-group arg0))) (when (!= v1-6 (-> v1-6 last)) @@ -2176,7 +2174,3 @@ (display-sync arg0) (none) ) - - - - diff --git a/test/decompiler/reference/jak2/engine/entity/entity_REF.gc b/test/decompiler/reference/jak2/engine/entity/entity_REF.gc index 9384553ff..252b8ae54 100644 --- a/test/decompiler/reference/jak2/engine/entity/entity_REF.gc +++ b/test/decompiler/reference/jak2/engine/entity/entity_REF.gc @@ -1308,7 +1308,7 @@ (-> (the-as process-drawable arg0) root trans) (if (logtest? (-> sv-16 extra perm status) (entity-perm-status bit-0 bit-1)) (font-color red) - (font-color #dadada) + (font-color font-color-1) ) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) @@ -1324,7 +1324,7 @@ (the-as bucket-id s3-1) *temp-string* (-> (the-as process-drawable arg0) root trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 24)) ) ) @@ -1336,7 +1336,7 @@ (bucket-id debug-no-zbuf1) (symbol->string v1-49) (-> (the-as process-drawable arg0) root trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 24)) ) ) @@ -1371,7 +1371,7 @@ (the-as bucket-id s3-3) *temp-string* (-> (the-as process-drawable arg0) root trans) - (font-color green-#3df23d) + (font-color green) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) ) @@ -1385,7 +1385,7 @@ "#f" ) (-> (the-as process-drawable arg0) root trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) ) (label cfg-51) diff --git a/test/decompiler/reference/jak2/engine/game/game-info_REF.gc b/test/decompiler/reference/jak2/engine/game/game-info_REF.gc index 06510085b..c0132345e 100644 --- a/test/decompiler/reference/jak2/engine/game/game-info_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/game-info_REF.gc @@ -780,7 +780,7 @@ (+ (the int (/ (the float (+ (/ (-> s3-0 x) 16) -1792)) (-> *video-params* relative-x-scale))) -48) (+ (/ (-> s3-0 y) 16) -1855) 0.0 - (font-color gold-#ba9200) + (font-color gold) (font-flags shadow kerning) ) ) @@ -1082,7 +1082,7 @@ (bucket-id debug-no-zbuf1) (-> obj name) (-> obj trans) - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) (let ((a3-2 (vector-z-quaternion! (new-stack-vector0) (the-as quaternion (-> obj quat))))) diff --git a/test/decompiler/reference/jak2/engine/game/task/task-control_REF.gc b/test/decompiler/reference/jak2/engine/game/task/task-control_REF.gc index 57877c799..3d8b7c81f 100644 --- a/test/decompiler/reference/jak2/engine/game/task/task-control_REF.gc +++ b/test/decompiler/reference/jak2/engine/game/task/task-control_REF.gc @@ -1458,17 +1458,9 @@ (when (and (not (logtest? (-> obj flags) (fail-mission-flags famflags-6))) (= (get-status *gui-control* (-> obj message-id)) (gui-status active)) ) - (let ((gp-0 (new - 'stack - 'font-context - *font-default-matrix* - 70 - 20 - 0.0 - (font-color gold-#ba9200) - (font-flags shadow kerning) - ) - ) + (let ((gp-0 + (new 'stack 'font-context *font-default-matrix* 70 20 0.0 (font-color gold) (font-flags shadow kerning)) + ) ) (set! (-> gp-0 origin x) 120.0) (let ((v1-7 gp-0)) @@ -2387,7 +2379,3 @@ (none) ) ) - - - - diff --git a/test/decompiler/reference/jak2/engine/geometry/path_REF.gc b/test/decompiler/reference/jak2/engine/geometry/path_REF.gc index 9b1816888..245c26559 100644 --- a/test/decompiler/reference/jak2/engine/geometry/path_REF.gc +++ b/test/decompiler/reference/jak2/engine/geometry/path_REF.gc @@ -48,7 +48,7 @@ (s1-0 318) ) (format (clear *temp-string*) "~D" s5-1) - (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold-#ba9200) (the-as vector2h #f)) + (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold) (the-as vector2h #f)) ) ) ) @@ -447,7 +447,7 @@ using the fractional component of `idx` as the interpolant, return this result (s1-0 318) ) (format (clear *temp-string*) "~D" s5-1) - (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold-#ba9200) (the-as vector2h #f)) + (s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold) (the-as vector2h #f)) ) ) ) diff --git a/test/decompiler/reference/jak2/engine/level/region_REF.gc b/test/decompiler/reference/jak2/engine/level/region_REF.gc index 14b774878..4ec536ad0 100644 --- a/test/decompiler/reference/jak2/engine/level/region_REF.gc +++ b/test/decompiler/reference/jak2/engine/level/region_REF.gc @@ -101,7 +101,7 @@ (s3-0 318) ) (format (clear *temp-string*) "region-~D~%" (-> obj region id)) - (s5-0 s4-0 (the-as bucket-id s3-0) *temp-string* sv-36 (font-color #dadada) sv-32) + (s5-0 s4-0 (the-as bucket-id s3-0) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) (let ((s5-1 (-> obj region on-enter))) @@ -111,7 +111,7 @@ (s2-1 318) ) (format (clear *temp-string*) "(on-enter ~S)" s5-1) - (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* sv-36 (font-color #dadada) sv-32) + (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -123,7 +123,7 @@ (s2-2 318) ) (format (clear *temp-string*) "(on-inside ~S)" s5-2) - (s4-2 s3-2 (the-as bucket-id s2-2) *temp-string* sv-36 (font-color #dadada) sv-32) + (s4-2 s3-2 (the-as bucket-id s2-2) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) @@ -135,7 +135,7 @@ (s3-3 318) ) (format (clear *temp-string*) "(on-exit ~S)" gp-1) - (s5-3 s4-3 (the-as bucket-id s3-3) *temp-string* sv-36 (font-color #dadada) sv-32) + (s5-3 s4-3 (the-as bucket-id s3-3) *temp-string* sv-36 (font-color font-color-1) sv-32) ) (+! (-> sv-32 y) 8) ) diff --git a/test/decompiler/reference/jak2/engine/nav/nav-control_REF.gc b/test/decompiler/reference/jak2/engine/nav/nav-control_REF.gc index 3733a5200..f465d040f 100644 --- a/test/decompiler/reference/jak2/engine/nav/nav-control_REF.gc +++ b/test/decompiler/reference/jak2/engine/nav/nav-control_REF.gc @@ -324,7 +324,7 @@ Note that this doesn't actually return the nav-control, but instead adds this pr (s1-0 318) ) (format (clear *temp-string*) "~D" s5-1) - (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color cyan-#00fefe) (the-as vector2h #f)) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color cyan) (the-as vector2h #f)) ) ) ) diff --git a/test/decompiler/reference/jak2/engine/nav/nav-mesh_REF.gc b/test/decompiler/reference/jak2/engine/nav/nav-mesh_REF.gc index 1433a62dc..59e939dfa 100644 --- a/test/decompiler/reference/jak2/engine/nav/nav-mesh_REF.gc +++ b/test/decompiler/reference/jak2/engine/nav/nav-mesh_REF.gc @@ -409,7 +409,7 @@ (bucket-id debug-no-zbuf1) (res-lump-struct obj 'name string) s5-0 - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) (let ((s4-1 add-debug-text-3d) @@ -422,7 +422,7 @@ (the-as bucket-id s2-1) *temp-string* s5-0 - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) ) ) @@ -576,7 +576,7 @@ (the-as bucket-id s2-1) *temp-string* (-> gp-0 1) - (font-color magenta-#f87df8) + (font-color magenta) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) ) @@ -1565,7 +1565,7 @@ (the-as bucket-id s2-0) *temp-string* (-> obj static-sphere s5-0) - (font-color cyan-#00fefe) + (font-color cyan) (the-as vector2h #f) ) ) @@ -1601,7 +1601,7 @@ (the-as bucket-id s1-1) *temp-string* (poly-centroid obj s4-1 sv-32) - (font-color cyan-#00fefe) + (font-color cyan) (the-as vector2h #f) ) ) diff --git a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc index 2d43617bc..defe7aa01 100644 --- a/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc +++ b/test/decompiler/reference/jak2/engine/process-drawable/process-drawable_REF.gc @@ -510,7 +510,7 @@ ) (format (clear *temp-string*) "~d" (+ s2-0 -1)) (let ((a2-3 *temp-string*)) - (add-debug-text-3d #t (bucket-id debug-no-zbuf1) a2-3 s3-0 (font-color blue-#003cf1) s5-0) + (add-debug-text-3d #t (bucket-id debug-no-zbuf1) a2-3 s3-0 (font-color blue) s5-0) ) (+! (-> s5-0 x) 10) ) diff --git a/test/decompiler/reference/jak2/engine/scene/scene_REF.gc b/test/decompiler/reference/jak2/engine/scene/scene_REF.gc index 3cec138a1..83f15812a 100644 --- a/test/decompiler/reference/jak2/engine/scene/scene_REF.gc +++ b/test/decompiler/reference/jak2/engine/scene/scene_REF.gc @@ -875,7 +875,7 @@ (set! (-> s2-0 flags) (font-flags kerning middle left large)) (set! (-> s2-0 origin x) (+ -1.0 (-> s2-0 origin x))) (set! (-> s2-0 origin y) (+ -1.0 (-> s2-0 origin y))) - (set! (-> s2-0 color) (font-color #000000)) + (set! (-> s2-0 color) (font-color font-color-39)) (set! (-> s2-0 origin x) (+ 1.0 (-> s2-0 origin x))) (set! (-> s2-0 origin y) (+ 1.0 (-> s2-0 origin y))) (set! (-> s2-0 color) (font-color default)) @@ -1479,7 +1479,7 @@ (bucket-id debug-no-zbuf1) (-> v1-94 name) (-> v1-94 draw origin) - (font-color yellow-#f3f300) + (font-color yellow) (new 'static 'vector2h :data (new 'static 'array int16 2 0 8)) ) ) diff --git a/test/decompiler/reference/jak2/engine/ui/hud-classes_REF.gc b/test/decompiler/reference/jak2/engine/ui/hud-classes_REF.gc index cfad10313..f17575be2 100644 --- a/test/decompiler/reference/jak2/engine/ui/hud-classes_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/hud-classes_REF.gc @@ -687,7 +687,7 @@ (alloc-string-if-needed obj s5-0) (set! (-> obj strings s5-0 scale) 0.8) (set! (-> obj strings s5-0 flags) (font-flags kerning middle large)) - (set! (-> obj strings s5-0 color) (font-color green-#3df23d)) + (set! (-> obj strings s5-0 color) (font-color green)) ) (set! (-> obj values 2 target) (-> obj values 1 target)) 0 @@ -732,7 +732,7 @@ (alloc-string-if-needed obj 0) (set! (-> obj strings 0 scale) 0.8) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color green-#3df23d)) + (set! (-> obj strings 0 color) (font-color green)) 0 (none) ) @@ -1200,7 +1200,3 @@ 0 (none) ) - - - - diff --git a/test/decompiler/reference/jak2/engine/ui/progress/progress-draw_REF.gc b/test/decompiler/reference/jak2/engine/ui/progress/progress-draw_REF.gc index f066f674e..363ff6875 100644 --- a/test/decompiler/reference/jak2/engine/ui/progress/progress-draw_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/progress/progress-draw_REF.gc @@ -4,7 +4,7 @@ ;; definition for function progress-selected ;; WARN: Return type mismatch int vs font-color. (defbehavior progress-selected progress ((arg0 int)) - (let ((color (font-color #7ffcfc))) + (let ((color (font-color font-color-33))) (cond ((< 4 (the-as int (logand (-> self clock integral-frame-counter) 7))) (set! (-> *progress-state* color-flash-counter) 1) @@ -475,7 +475,7 @@ ) (set! (-> arg1 origin x) (- (-> arg1 origin x) (the float s5-0))) ) - (set! (-> arg1 color) (font-color #7efbfb)) + (set! (-> arg1 color) (font-color font-color-32)) 0 (none) ) @@ -654,7 +654,7 @@ (arg3 (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #f9f9f9)) + (set! (-> a0-1 color) (font-color font-color-34)) ) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) (set! (-> arg1 origin y) (+ 18.0 (-> arg1 origin y))) @@ -715,7 +715,7 @@ (arg3 (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #f9f9f9)) + (set! (-> a0-1 color) (font-color font-color-34)) ) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) (set! (-> arg1 origin y) (+ 18.0 (-> arg1 origin y))) @@ -782,7 +782,7 @@ ) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-6 arg1)) - (set! (-> a0-6 color) (font-color #f9f9f9)) + (set! (-> a0-6 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 44 f28-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -822,7 +822,7 @@ ) (else (let ((a0-23 arg1)) - (set! (-> a0-23 color) (font-color #7efbfb)) + (set! (-> a0-23 color) (font-color font-color-32)) ) ) ) @@ -1061,7 +1061,7 @@ (set! (-> v1-7 scale) 0.75) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-3 arg1)) @@ -1643,7 +1643,7 @@ (set! (-> arg1 origin y) (the float sv-48)) (set! (-> arg1 height) 50.0) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((a0-2 arg1)) (set! (-> a0-2 flags) (font-flags kerning middle large)) @@ -1728,7 +1728,7 @@ (set! (-> sv-48 height) 50.0) (set! (-> sv-48 origin y) (the float sv-16)) (let ((a0-2 sv-48)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! sv-32 print-game-text) (let ((a0-4 (lookup-text! *common-text* s0-0 #f)) @@ -1805,7 +1805,7 @@ (set! (-> sv-16 origin y) (the float sv-32)) (set! (-> sv-16 height) 50.0) (let ((a0-2 sv-16)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! (-> sv-16 origin x) 80.0) (let ((a0-3 sv-16)) @@ -1894,7 +1894,7 @@ (set! (-> sv-48 origin y) (the float sv-16)) (set! (-> sv-48 height) 50.0) (let ((a0-2 sv-48)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (set! sv-32 print-game-text) (let ((a0-4 (lookup-text! *common-text* s0-0 #f)) @@ -1989,7 +1989,7 @@ (set! (-> a0-6 flags) (font-flags kerning middle large)) ) (let ((a0-7 sv-80)) - (set! (-> a0-7 color) (font-color #7efbfb)) + (set! (-> a0-7 color) (font-color font-color-32)) ) (set! sv-48 print-game-text) (let* ((a0-8 *common-text*) @@ -2179,7 +2179,7 @@ (let ((s2-3 arg1)) (set! (-> s2-3 color) (if (= arg2 sv-20) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) @@ -2365,7 +2365,7 @@ (s2-7 *temp-string* arg1 #f 44 (bucket-id progress)) ) (let ((a0-45 arg1)) - (set! (-> a0-45 color) (font-color #7efbfb)) + (set! (-> a0-45 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) 250.0) (set! (-> arg1 origin y) 110.0) @@ -2604,7 +2604,7 @@ (set! (-> v1-25 height) (the float 160)) ) (let ((a0-16 arg1)) - (set! (-> a0-16 color) (font-color #7efbfb)) + (set! (-> a0-16 color) (font-color font-color-32)) ) (let ((s5-2 print-game-text)) (format (clear *temp-string*) (lookup-text! *common-text* (text-id progress-memcard-dont-remove) #f) 1) @@ -2623,7 +2623,7 @@ (set! (-> v1-3 scale) 0.5) ) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #7efbfb)) + (set! (-> a0-3 color) (font-color font-color-32)) ) (let ((a0-4 arg1)) (set! (-> a0-4 flags) (font-flags kerning middle left large)) @@ -2715,7 +2715,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2762,7 +2762,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2810,7 +2810,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2879,7 +2879,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -2956,7 +2956,7 @@ (set! (-> v1-1 scale) 0.5) ) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #7efbfb)) + (set! (-> a0-2 color) (font-color font-color-32)) ) (let ((a0-3 arg1)) (set! (-> a0-3 flags) (font-flags kerning middle left large)) @@ -3016,7 +3016,7 @@ (defmethod draw-option menu-error-disc-removed-option ((obj menu-error-disc-removed-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3076,7 +3076,7 @@ (defmethod draw-option menu-error-reading-option ((obj menu-error-reading-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3134,7 +3134,7 @@ (defmethod draw-option menu-icon-info-option ((obj menu-icon-info-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3210,7 +3210,7 @@ (defmethod draw-option menu-format-card-option ((obj menu-format-card-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3264,7 +3264,7 @@ (defmethod draw-option menu-already-exists-option ((obj menu-already-exists-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3310,7 +3310,7 @@ (defmethod draw-option menu-create-game-option ((obj menu-create-game-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3353,7 +3353,7 @@ (defmethod draw-option menu-video-mode-warning-option ((obj menu-video-mode-warning-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3421,7 +3421,7 @@ (defmethod draw-option menu-video-mode-ok-option ((obj menu-video-mode-ok-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3467,7 +3467,7 @@ (defmethod draw-option menu-progressive-mode-warning-option ((obj menu-progressive-mode-warning-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.5) @@ -3535,7 +3535,7 @@ (defmethod draw-option menu-progressive-mode-ok-option ((obj menu-progressive-mode-ok-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.55) @@ -3581,7 +3581,7 @@ (defmethod draw-option menu-quit-option ((obj menu-quit-option) (arg0 progress) (arg1 font-context) (arg2 int) (arg3 symbol)) (set! (-> arg1 alpha) (- 1.0 (-> arg0 menu-transition))) (let ((a0-1 arg1)) - (set! (-> a0-1 color) (font-color #7efbfb)) + (set! (-> a0-1 color) (font-color font-color-32)) ) (let ((v1-2 arg1)) (set! (-> v1-2 scale) 0.55) @@ -3643,7 +3643,7 @@ (set! (-> a0-3 flags) (font-flags kerning middle large)) ) (let ((a0-4 arg1)) - (set! (-> a0-4 color) (font-color #7efbfb)) + (set! (-> a0-4 color) (font-color font-color-32)) ) (set! (-> arg1 origin y) 100.0) (let ((v1-9 arg1)) @@ -3735,7 +3735,7 @@ ) (else (let ((a0-35 arg1)) - (set! (-> a0-35 color) (font-color #7efbfb)) + (set! (-> a0-35 color) (font-color font-color-32)) ) ) ) @@ -3839,7 +3839,7 @@ (set! (-> v1-15 height) (the float 210)) ) (let ((a1-9 arg1)) - (set! (-> a1-9 color) (font-color #7efbfb)) + (set! (-> a1-9 color) (font-color font-color-32)) ) (if (or (= (-> *setting-control* user-default language) (language-enum french)) (= (-> *setting-control* user-default language) (language-enum spanish)) @@ -3933,7 +3933,7 @@ ) (else (let ((a0-21 arg1)) - (set! (-> a0-21 color) (font-color #7efbfb)) + (set! (-> a0-21 color) (font-color font-color-32)) ) ) ) @@ -4254,7 +4254,7 @@ (set! (-> arg1 origin x) 60.0) (set! (-> arg1 origin y) 80.0) (let ((a0-21 arg1)) - (set! (-> a0-21 color) (font-color #7efbfb)) + (set! (-> a0-21 color) (font-color font-color-32)) ) (let ((v1-40 (-> obj page-index))) (cond @@ -4477,7 +4477,7 @@ (let ((s3-1 arg2)) (set! (-> s3-1 color) (if (= arg3 1) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) @@ -4503,7 +4503,7 @@ ) (set! (-> arg2 origin x) 360.0) (let ((a0-35 arg2)) - (set! (-> a0-35 color) (font-color #7efbfb)) + (set! (-> a0-35 color) (font-color font-color-32)) ) ) ) @@ -4951,7 +4951,7 @@ (set! (-> a0-21 flags) (font-flags kerning middle large)) ) (let ((a0-22 arg1)) - (set! (-> a0-22 color) (font-color #7efbfb)) + (set! (-> a0-22 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) 59.0) (let ((v1-54 arg1)) @@ -6100,7 +6100,7 @@ (set! (-> a0-4 flags) (font-flags kerning middle large)) ) (let ((a0-5 sv-140)) - (set! (-> a0-5 color) (font-color #7efbfb)) + (set! (-> a0-5 color) (font-color font-color-32)) ) (set! (-> sv-140 origin x) 59.0) (set! (-> sv-140 origin y) 78.0) @@ -6142,7 +6142,7 @@ (set! (-> a0-23 flags) (font-flags kerning large)) ) (let ((a0-24 sv-140)) - (set! (-> a0-24 color) (font-color #f9f9f9)) + (set! (-> a0-24 color) (font-color font-color-34)) ) (set! (-> sv-140 origin x) (+ 20.0 sv-120 (-> sv-140 origin x))) (let ((v1-53 sv-140)) @@ -6201,7 +6201,7 @@ ) (set! sv-108 (-> sv-140 origin x)) (let ((a0-54 sv-140)) - (set! (-> a0-54 color) (font-color #7efbfb)) + (set! (-> a0-54 color) (font-color font-color-32)) ) (+! (-> sv-140 origin x) sv-120) (let ((v1-96 sv-140)) @@ -6256,7 +6256,7 @@ (set! (-> a0-74 flags) (font-flags kerning large)) ) (let ((a0-75 sv-140)) - (set! (-> a0-75 color) (font-color #f9f9f9)) + (set! (-> a0-75 color) (font-color font-color-34)) ) (set! (-> sv-140 origin x) (+ 20.0 sv-124 (-> sv-140 origin x))) (let ((v1-142 sv-140)) @@ -6315,7 +6315,7 @@ ) (set! sv-108 (-> sv-140 origin x)) (let ((a0-105 sv-140)) - (set! (-> a0-105 color) (font-color #7efbfb)) + (set! (-> a0-105 color) (font-color font-color-32)) ) (+! (-> sv-140 origin x) sv-124) (let ((v1-185 sv-140)) @@ -6376,7 +6376,7 @@ ((and (zero? (-> *progress-state* game-options-item-selected)) (-> *progress-state* game-options-item-picked)) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #f9f9f9)) + (set! (-> a0-2 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -1.0 (-> arg1 origin y))) 41 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6413,7 +6413,7 @@ ) (else (let ((a0-17 arg1)) - (set! (-> a0-17 color) (font-color #7efbfb)) + (set! (-> a0-17 color) (font-color font-color-32)) ) ) ) @@ -6466,7 +6466,7 @@ ((and (= (-> *progress-state* game-options-item-selected) 1) (-> *progress-state* game-options-item-picked)) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -1.0 (-> arg1 origin y))) 41 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6503,7 +6503,7 @@ ) (else (let ((a0-20 arg1)) - (set! (-> a0-20 color) (font-color #7efbfb)) + (set! (-> a0-20 color) (font-color font-color-32)) ) ) ) @@ -6565,7 +6565,7 @@ (cond ((and (= (-> *progress-state* game-options-item-selected) 2) (-> *progress-state* game-options-item-picked)) (let ((a0-7 arg1)) - (set! (-> a0-7 color) (font-color #f9f9f9)) + (set! (-> a0-7 color) (font-color font-color-34)) ) (draw-highlight (the int (-> arg1 origin y)) 44 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6584,13 +6584,13 @@ ) ) (let ((a0-12 arg1)) - (set! (-> a0-12 color) (font-color #7efbfb)) + (set! (-> a0-12 color) (font-color font-color-32)) ) (let ((v1-33 arg1)) (set! (-> v1-33 scale) 0.5) ) (let ((a0-14 arg1)) - (set! (-> a0-14 color) (font-color #7efbfb)) + (set! (-> a0-14 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) (+ -70.0 (-> arg1 origin x))) (let ((s5-1 print-game-text)) @@ -6632,7 +6632,7 @@ ) (else (let ((a0-31 arg1)) - (set! (-> a0-31 color) (font-color #7efbfb)) + (set! (-> a0-31 color) (font-color font-color-32)) ) ) ) @@ -6644,7 +6644,7 @@ (set! (-> v1-54 scale) 0.5) ) (let ((a0-36 arg1)) - (set! (-> a0-36 color) (font-color #7efbfb)) + (set! (-> a0-36 color) (font-color font-color-32)) ) (set! (-> arg1 origin y) (+ 24.0 (-> arg1 origin y))) (let ((a0-37 arg1)) @@ -6700,7 +6700,7 @@ (cond ((and (= (-> *progress-state* game-options-item-selected) 3) (-> *progress-state* game-options-item-picked)) (let ((a0-7 arg1)) - (set! (-> a0-7 color) (font-color #f9f9f9)) + (set! (-> a0-7 color) (font-color font-color-34)) ) (draw-highlight (the int (-> arg1 origin y)) 44 f30-0) (let ((s3-0 print-game-text)) @@ -6722,13 +6722,13 @@ ) ) (let ((a0-14 arg1)) - (set! (-> a0-14 color) (font-color #7efbfb)) + (set! (-> a0-14 color) (font-color font-color-32)) ) (let ((v1-33 arg1)) (set! (-> v1-33 scale) 0.5) ) (let ((a0-16 arg1)) - (set! (-> a0-16 color) (font-color #7efbfb)) + (set! (-> a0-16 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) (+ -70.0 (-> arg1 origin x))) (let ((s5-1 print-game-text)) @@ -6770,7 +6770,7 @@ ) (else (let ((a0-33 arg1)) - (set! (-> a0-33 color) (font-color #7efbfb)) + (set! (-> a0-33 color) (font-color font-color-32)) ) ) ) @@ -6785,7 +6785,7 @@ (set! (-> v1-54 scale) 0.5) ) (let ((a0-40 arg1)) - (set! (-> a0-40 color) (font-color #7efbfb)) + (set! (-> a0-40 color) (font-color font-color-32)) ) (format (clear *temp-string*) "~S" (lookup-text! *common-text* (-> *language-name-remap* (-> s4-0 0)) #f)) *temp-string* @@ -6863,7 +6863,7 @@ ) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-4 arg1)) - (set! (-> a0-4 color) (font-color #f9f9f9)) + (set! (-> a0-4 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 42 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -6904,7 +6904,7 @@ ) (else (let ((a0-21 arg1)) - (set! (-> a0-21 color) (font-color #7efbfb)) + (set! (-> a0-21 color) (font-color font-color-32)) ) ) ) @@ -6972,7 +6972,7 @@ ) (set! (-> arg1 origin y) (+ -8.0 (-> arg1 origin y))) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 42 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -7013,7 +7013,7 @@ ) (else (let ((a0-20 arg1)) - (set! (-> a0-20 color) (font-color #7efbfb)) + (set! (-> a0-20 color) (font-color font-color-32)) ) ) ) @@ -7074,7 +7074,7 @@ (set! (-> v1-10 scale) 0.6) ) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (set! (-> arg1 width) 350.0) (set! (-> arg1 height) 60.0) @@ -7149,7 +7149,7 @@ ) (else (let ((a0-31 arg1)) - (set! (-> a0-31 color) (font-color #7efbfb)) + (set! (-> a0-31 color) (font-color font-color-32)) ) ) ) @@ -7180,7 +7180,7 @@ (cond ((and (zero? (-> *progress-state* qr-options-item-selected)) (-> *progress-state* qr-options-item-picked)) (let ((a0-2 arg1)) - (set! (-> a0-2 color) (font-color #f9f9f9)) + (set! (-> a0-2 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 50 f0-1) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -7245,7 +7245,7 @@ (cond ((and (= (-> *progress-state* qr-options-item-selected) 1) (-> *progress-state* qr-options-item-picked)) (let ((a0-3 arg1)) - (set! (-> a0-3 color) (font-color #f9f9f9)) + (set! (-> a0-3 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> arg1 origin y))) 50 f30-0) (print-game-text (lookup-text! *common-text* (-> obj name) #f) arg1 #f 44 (bucket-id progress)) @@ -7410,7 +7410,7 @@ (set! sv-128 (-> obj value-to-modify)) (set! (-> s5-0 origin y) (+ -8.0 (-> s5-0 origin y))) (let ((a0-12 s5-0)) - (set! (-> a0-12 color) (font-color #f9f9f9)) + (set! (-> a0-12 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -2.0 (-> s5-0 origin y))) 52 f30-0) (set! sv-144 print-game-text) @@ -7708,7 +7708,7 @@ arg3 ) (let ((a0-7 arg1)) - (set! (-> a0-7 color) (font-color #f9f9f9)) + (set! (-> a0-7 color) (font-color font-color-34)) ) (draw-highlight (the int (+ -1.0 (-> arg1 origin y))) 42 f30-0) (let ((s3-1 print-game-text)) @@ -7717,13 +7717,13 @@ ) (set! (-> arg1 origin y) (+ 22.0 (-> arg1 origin y))) (let ((a0-13 arg1)) - (set! (-> a0-13 color) (font-color #7efbfb)) + (set! (-> a0-13 color) (font-color font-color-32)) ) (let ((v1-22 arg1)) (set! (-> v1-22 scale) 0.5) ) (let ((a0-15 arg1)) - (set! (-> a0-15 color) (font-color #7efbfb)) + (set! (-> a0-15 color) (font-color font-color-32)) ) (set! (-> arg1 origin x) (+ -70.0 (-> arg1 origin x))) (let ((s4-1 print-game-text)) @@ -7766,7 +7766,7 @@ (set! (-> v1-39 scale) 0.5) ) (let ((a0-33 arg1)) - (set! (-> a0-33 color) (font-color #7efbfb)) + (set! (-> a0-33 color) (font-color font-color-32)) ) (format (clear *temp-string*) "~S" (lookup-text! *common-text* (-> *stereo-mode-name-remap* s5-0) #f)) (let ((a0-37 *temp-string*)) @@ -7831,7 +7831,7 @@ (let ((s0-0 arg1)) (set! (-> s0-0 color) (if (= arg2 (-> arg0 option-index)) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) @@ -7843,7 +7843,7 @@ ) (else (let ((a0-9 arg1)) - (set! (-> a0-9 color) (font-color #7efbfb)) + (set! (-> a0-9 color) (font-color font-color-32)) ) ) ) diff --git a/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc b/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc index 569c14302..f683bc948 100644 --- a/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc +++ b/test/decompiler/reference/jak2/engine/ui/progress/progress_REF.gc @@ -1462,7 +1462,7 @@ (let ((s3-0 sv-144)) (set! (-> s3-0 color) (if (and (= s4-1 (-> self option-index)) (= (-> self menu-transition) 0.0)) (the-as font-color (the-as int (progress-selected 0))) - (font-color #7efbfb) + (font-color font-color-32) ) ) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/ctywide-obs_REF.gc b/test/decompiler/reference/jak2/levels/city/common/ctywide-obs_REF.gc index a02986875..b567f225c 100644 --- a/test/decompiler/reference/jak2/levels/city/common/ctywide-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/ctywide-obs_REF.gc @@ -3684,7 +3684,7 @@ This commonly includes things such as: (set! (-> v1-51 origin y) (the float a0-59)) ) (let ((a0-60 s1-0)) - (set! (-> a0-60 color) (font-color #fef666)) + (set! (-> a0-60 color) (font-color font-color-29)) ) (let ((s0-0 print-game-text)) (set! sv-352 format) @@ -3714,7 +3714,7 @@ This commonly includes things such as: ) (let ((a0-68 s1-0)) (set! (-> a0-68 color) (if (= s0-1 s5-0) - (font-color #f1f104) + (font-color font-color-30) (font-color default) ) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc b/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc index 044ac996c..ca0d19bce 100644 --- a/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/height-map_REF.gc @@ -80,7 +80,7 @@ (the-as bucket-id s2-0) *temp-string* s5-0 - (font-color #dadada) + (font-color font-color-1) (new 'static 'vector2h :data (new 'static 'array int16 2 0 16)) ) ) @@ -258,7 +258,3 @@ (none) ) ) - - - - diff --git a/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc b/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc index a0c7edb64..ef6b5994f 100644 --- a/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/nav-graph_REF.gc @@ -127,7 +127,7 @@ gp-0 (if (logtest? (-> obj flags) (nav-node-flag-byte blocked)) (font-color red) - (font-color cyan-#00fefe) + (font-color cyan) ) (the-as vector2h #f) ) diff --git a/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc b/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc index e7d391617..a1d78a2dd 100644 --- a/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/traffic-engine_REF.gc @@ -1223,7 +1223,7 @@ Process is recycled and moved to reserved, if it deactivates." *temp-string* sv-84 (if (< (-> sv-20 user-count) (-> sv-20 max-user-count)) - (font-color yellow-#f3f300) + (font-color yellow) (font-color red) ) (the-as vector2h #f) diff --git a/test/decompiler/reference/jak2/levels/city/common/trail_REF.gc b/test/decompiler/reference/jak2/levels/city/common/trail_REF.gc index ecf640172..b798c7957 100644 --- a/test/decompiler/reference/jak2/levels/city/common/trail_REF.gc +++ b/test/decompiler/reference/jak2/levels/city/common/trail_REF.gc @@ -35,7 +35,7 @@ (s2-1 324) ) (format (clear *temp-string*) "~D" arg1) - (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color yellow-#f3f300) (the-as vector2h #f)) + (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color yellow) (the-as vector2h #f)) ) ) ) @@ -63,7 +63,7 @@ (s2-1 324) ) (format (clear *temp-string*) "~D" arg0) - (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color cyan-#00fefe) (the-as vector2h #f)) + (s4-1 s3-1 (the-as bucket-id s2-1) *temp-string* s5-0 (font-color cyan) (the-as vector2h #f)) ) ) ) diff --git a/test/decompiler/reference/jak2/levels/common/ai/bot_REF.gc b/test/decompiler/reference/jak2/levels/common/ai/bot_REF.gc index 61cf3bfe2..d69a927cc 100644 --- a/test/decompiler/reference/jak2/levels/common/ai/bot_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/ai/bot_REF.gc @@ -54,7 +54,7 @@ (bucket-id debug-no-zbuf1) spot-id (-> spot center) - (font-color #dadada) + (font-color font-color-1) (the-as vector2h #f) ) ) diff --git a/test/decompiler/reference/jak2/levels/common/battle_REF.gc b/test/decompiler/reference/jak2/levels/common/battle_REF.gc index fde1794b2..b7cad2684 100644 --- a/test/decompiler/reference/jak2/levels/common/battle_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/battle_REF.gc @@ -978,7 +978,7 @@ (-> obj stat-child-count) (-> obj allies length) ) - (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color gold-#ba9200) (the-as vector2h #f)) + (s3-0 s2-0 (the-as bucket-id s1-0) *temp-string* s4-0 (font-color gold) (the-as vector2h #f)) ) ) (dotimes (s5-1 (-> obj spawners length)) @@ -1010,7 +1010,7 @@ (the-as bucket-id s1-1) *temp-string* (-> s4-1 entity extra trans) - (font-color yellow-#f3f300) + (font-color yellow) (the-as vector2h #f) ) ) diff --git a/test/decompiler/reference/jak2/levels/common/enemy/hover/hover-nav-control_REF.gc b/test/decompiler/reference/jak2/levels/common/enemy/hover/hover-nav-control_REF.gc index e1a1fdc44..0dec4172c 100644 --- a/test/decompiler/reference/jak2/levels/common/enemy/hover/hover-nav-control_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/enemy/hover/hover-nav-control_REF.gc @@ -266,7 +266,7 @@ (add-debug-x #t (bucket-id debug2) (-> s4-0 pos) *color-white*) (format (clear *temp-string*) "~d" s5-0) (let ((a2-2 *temp-string*)) - (add-debug-text-3d #t (bucket-id debug2) a2-2 (-> s4-0 pos) (font-color #dadada) (the-as vector2h #f)) + (add-debug-text-3d #t (bucket-id debug2) a2-2 (-> s4-0 pos) (font-color font-color-1) (the-as vector2h #f)) ) (dotimes (s3-1 (-> s4-0 count)) (let ((a2-3 (new 'stack-no-clear 'vector))) diff --git a/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc b/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc index 237ae4716..481a3d084 100644 --- a/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/races/race-hud_REF.gc @@ -41,15 +41,15 @@ (alloc-string-if-needed obj 0) (set! (-> obj strings 0 scale) 0.55) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color green-#3df23d)) + (set! (-> obj strings 0 color) (font-color green)) (alloc-string-if-needed obj 1) (set! (-> obj strings 1 scale) 0.55) (set! (-> obj strings 1 flags) (font-flags kerning middle large)) - (set! (-> obj strings 1 color) (font-color green-#3df23d)) + (set! (-> obj strings 1 color) (font-color green)) (alloc-string-if-needed obj 2) (set! (-> obj strings 2 scale) 0.55) (set! (-> obj strings 2 flags) (font-flags kerning middle large)) - (set! (-> obj strings 2 color) (font-color green-#3df23d)) + (set! (-> obj strings 2 color) (font-color green)) (set! (-> obj sprites 1 tex) (lookup-texture-by-id (new 'static 'texture-id :index #x23 :page #x679))) 0 (none) @@ -95,7 +95,7 @@ (set! (-> obj sprites 0 tex) (lookup-texture-by-id (new 'static 'texture-id :index #xe :page #x679))) (alloc-string-if-needed obj 0) (set! (-> obj strings 0 flags) (font-flags kerning middle large)) - (set! (-> obj strings 0 color) (font-color green-#3df23d)) + (set! (-> obj strings 0 color) (font-color green)) (set! (-> obj sprites 1 tex) (lookup-texture-by-id (new 'static 'texture-id :index #xd :page #x679))) (set! (-> obj sprites 2 tex) (lookup-texture-by-id (new 'static 'texture-id :index #xc :page #x679))) 0 @@ -405,7 +405,7 @@ (let ((s2-1 (-> s5-0 lap-time-array (+ (- -1 s4-0) (-> s5-0 lap-count))))) (set! (-> obj strings s3-0 scale) 0.5) (set! (-> obj strings s3-0 flags) (font-flags kerning large)) - (set! (-> obj strings s3-0 color) (font-color #dadada)) + (set! (-> obj strings s3-0 color) (font-color font-color-1)) (set-as-offset-from! (the-as hud-sprite (&+ (-> obj strings 0 pos) (* 48 s3-0))) (the-as vector4w (-> obj strings 1 pos)) @@ -425,7 +425,7 @@ (let ((s3-1 (+ s3-0 1))) (set! (-> obj strings s3-1 scale) 0.5) (set! (-> obj strings s3-1 flags) (font-flags kerning right large)) - (set! (-> obj strings s3-1 color) (font-color #dadada)) + (set! (-> obj strings s3-1 color) (font-color font-color-1)) (set-as-offset-from! (the-as hud-sprite (&+ (-> obj strings 0 pos) (* 48 s3-1))) (the-as vector4w (-> obj strings 2 pos)) @@ -469,9 +469,9 @@ (set! (-> obj strings 0 flags) (font-flags kerning middle large)) (set! (-> obj strings 0 color) (font-color red)) (set! (-> obj strings 1 flags) (font-flags kerning large)) - (set! (-> obj strings 1 color) (font-color #dadada)) + (set! (-> obj strings 1 color) (font-color font-color-1)) (set! (-> obj strings 2 flags) (font-flags kerning large)) - (set! (-> obj strings 2 color) (font-color #dadada)) + (set! (-> obj strings 2 color) (font-color font-color-1)) 0 (none) ) diff --git a/test/decompiler/reference/jak2/levels/common/races/race-manager_REF.gc b/test/decompiler/reference/jak2/levels/common/races/race-manager_REF.gc index 0638ae109..e8135fb78 100644 --- a/test/decompiler/reference/jak2/levels/common/races/race-manager_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/races/race-manager_REF.gc @@ -1288,17 +1288,9 @@ ;; WARN: Return type mismatch int vs none. (defmethod race-manager-method-24 race-manager ((obj race-manager)) (when (= (get-status *gui-control* (-> obj message-id)) (gui-status active)) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 70 - 20 - 0.0 - (font-color gold-#ba9200) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 70 20 0.0 (font-color gold) (font-flags shadow kerning)) + ) ) (let ((v1-4 gp-1)) (set! (-> v1-4 scale) 0.7) @@ -1326,17 +1318,9 @@ ;; WARN: Return type mismatch int vs none. (defmethod race-manager-method-25 race-manager ((obj race-manager)) (when (= (get-status *gui-control* (-> obj message-id)) (gui-status active)) - (let ((gp-1 (new - 'stack - 'font-context - *font-default-matrix* - 70 - 20 - 0.0 - (font-color gold-#ba9200) - (font-flags shadow kerning) - ) - ) + (let ((gp-1 + (new 'stack 'font-context *font-default-matrix* 70 20 0.0 (font-color gold) (font-flags shadow kerning)) + ) ) (let ((v1-4 gp-1)) (set! (-> v1-4 scale) 0.7) diff --git a/test/decompiler/reference/jak2/levels/common/races/race-mesh_REF.gc b/test/decompiler/reference/jak2/levels/common/races/race-mesh_REF.gc index 9489972ae..b801880ce 100644 --- a/test/decompiler/reference/jak2/levels/common/races/race-mesh_REF.gc +++ b/test/decompiler/reference/jak2/levels/common/races/race-mesh_REF.gc @@ -595,7 +595,7 @@ (s2-0 318) ) (format (clear *temp-string*) "~D" arg0) - (s4-1 s3-1 (the-as bucket-id s2-0) *temp-string* s5-0 (font-color #dadada) (the-as vector2h #f)) + (s4-1 s3-1 (the-as bucket-id s2-0) *temp-string* s5-0 (font-color font-color-1) (the-as vector2h #f)) ) ) ) diff --git a/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc b/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc index 767852171..d0c7b5925 100644 --- a/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/demo/demo-obs_REF.gc @@ -562,8 +562,8 @@ (set! (-> sv-112 scale) 0.7) (dotimes (s5-4 (-> gp-1 length)) (if (= (-> self selected) s5-4) - (set! (-> sv-112 color) (font-color #f1f104)) - (set! (-> sv-112 color) (font-color #dadada)) + (set! (-> sv-112 color) (font-color font-color-30)) + (set! (-> sv-112 color) (font-color font-color-1)) ) (print-game-text (lookup-text! *common-text* (the-as text-id (-> gp-1 s5-4)) #f) diff --git a/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc b/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc index 18eb4ed41..28c5d608f 100644 --- a/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/gungame/gungame-obs_REF.gc @@ -194,7 +194,7 @@ (the-as bucket-id s4-0) *temp-string* (get-point-in-path! (-> self path) (new 'stack-no-clear 'vector) 0.0 'interp) - (font-color green-#3df23d) + (font-color green) (the-as vector2h #f) ) ) diff --git a/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc b/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc index c3f920f6c..ae2bf0012 100644 --- a/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc +++ b/test/decompiler/reference/jak2/levels/title/title-obs_REF.gc @@ -570,8 +570,8 @@ (set! (-> sv-112 scale) 0.7) (dotimes (s5-4 (-> gp-1 length)) (if (= (-> self selected) s5-4) - (set! (-> sv-112 color) (font-color #f1f104)) - (set! (-> sv-112 color) (font-color #dadada)) + (set! (-> sv-112 color) (font-color font-color-30)) + (set! (-> sv-112 color) (font-color font-color-1)) ) (print-game-text (lookup-text! *common-text* (the-as text-id (-> gp-1 s5-4)) #f) diff --git a/third-party/json.hpp b/third-party/json.hpp index 9c66a8457..4d1a37ad7 100644 --- a/third-party/json.hpp +++ b/third-party/json.hpp @@ -1,44 +1,30 @@ -/* - __ _____ _____ _____ - __| | __| | | | JSON for Modern C++ -| | |__ | | | | | | version 3.9.0 -|_____|_____|_____|_|___| https://github.com/nlohmann/json +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT -Licensed under the MIT License . -SPDX-License-Identifier: MIT -Copyright (c) 2013-2019 Niels Lohmann . - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ +/****************************************************************************\ + * Note on documentation: The source files contain links to the online * + * documentation of the public API at https://json.nlohmann.me. This URL * + * contains the most recent documentation and should also be applicable to * + * previous versions; documentation for deprecated functions is not * + * removed, but marked deprecated. See "Generate documentation" section in * + * file docs/README.md. * +\****************************************************************************/ #ifndef INCLUDE_NLOHMANN_JSON_HPP_ #define INCLUDE_NLOHMANN_JSON_HPP_ -#define NLOHMANN_JSON_VERSION_MAJOR 3 -#define NLOHMANN_JSON_VERSION_MINOR 9 -#define NLOHMANN_JSON_VERSION_PATCH 0 - #include // all_of, find, for_each #include // nullptr_t, ptrdiff_t, size_t #include // hash, less #include // initializer_list -#include // istream, ostream +#ifndef JSON_NO_IO + #include // istream, ostream +#endif // JSON_NO_IO #include // random_access_iterator_tag #include // unique_ptr #include // accumulate @@ -47,11 +33,129 @@ SOFTWARE. #include // vector // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// This file contains all macro definitions affecting or depending on the ABI + +#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK + #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) + #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 + #warning "Already included a different version of the library!" + #endif + #endif +#endif + +#define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) +#define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) + +#ifndef JSON_DIAGNOSTICS + #define JSON_DIAGNOSTICS 0 +#endif + +#ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 +#endif + +#if JSON_DIAGNOSTICS + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag +#else + #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS +#endif + +#if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp +#else + #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION + #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 +#endif + +// Construct the namespace ABI tags component +#define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b +#define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ + NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) + +#define NLOHMANN_JSON_ABI_TAGS \ + NLOHMANN_JSON_ABI_TAGS_CONCAT( \ + NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ + NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) + +// Construct the namespace version component +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ + _v ## major ## _ ## minor ## _ ## patch +#define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) + +#if NLOHMANN_JSON_NAMESPACE_NO_VERSION +#define NLOHMANN_JSON_NAMESPACE_VERSION +#else +#define NLOHMANN_JSON_NAMESPACE_VERSION \ + NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ + NLOHMANN_JSON_VERSION_MINOR, \ + NLOHMANN_JSON_VERSION_PATCH) +#endif + +// Combine namespace components +#define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b +#define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ + NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) + +#ifndef NLOHMANN_JSON_NAMESPACE +#define NLOHMANN_JSON_NAMESPACE \ + nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_BEGIN +#define NLOHMANN_JSON_NAMESPACE_BEGIN \ + namespace nlohmann \ + { \ + inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ + NLOHMANN_JSON_ABI_TAGS, \ + NLOHMANN_JSON_NAMESPACE_VERSION) \ + { +#endif + +#ifndef NLOHMANN_JSON_NAMESPACE_END +#define NLOHMANN_JSON_NAMESPACE_END \ + } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ + } // namespace nlohmann +#endif + // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include // transform @@ -67,63 +171,169 @@ SOFTWARE. #include // valarray // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + +#include // nullptr_t #include // exception #include // runtime_error #include // to_string +#include // vector -// #include +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + +#include // array #include // size_t - -namespace nlohmann -{ -namespace detail -{ -/// struct to capture the start position of the current token -struct position_t -{ - /// the total number of characters read - std::size_t chars_read_total = 0; - /// the number of characters read in the current line - std::size_t chars_read_current_line = 0; - /// the number of lines read - std::size_t lines_read = 0; - - /// conversion to size_t to preserve SAX interface - constexpr operator size_t() const - { - return chars_read_total; - } -}; - -} // namespace detail -} // namespace nlohmann +#include // uint8_t +#include // string // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT -#include // pair + +#include // declval, pair +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +template struct make_void +{ + using type = void; +}; +template using void_t = typename make_void::type; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +// https://en.cppreference.com/w/cpp/experimental/is_detected +struct nonesuch +{ + nonesuch() = delete; + ~nonesuch() = delete; + nonesuch(nonesuch const&) = delete; + nonesuch(nonesuch const&&) = delete; + void operator=(nonesuch const&) = delete; + void operator=(nonesuch&&) = delete; +}; + +template class Op, + class... Args> +struct detector +{ + using value_t = std::false_type; + using type = Default; +}; + +template class Op, class... Args> +struct detector>, Op, Args...> +{ + using value_t = std::true_type; + using type = Op; +}; + +template class Op, class... Args> +using is_detected = typename detector::value_t; + +template class Op, class... Args> +struct is_detected_lazy : is_detected { }; + +template class Op, class... Args> +using detected_t = typename detector::type; + +template class Op, class... Args> +using detected_or = detector; + +template class Op, class... Args> +using detected_or_t = typename detected_or::type; + +template class Op, class... Args> +using is_detected_exact = std::is_same>; + +template class Op, class... Args> +using is_detected_convertible = + std::is_convertible, To>; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + // #include + + +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-FileCopyrightText: 2016-2021 Evan Nemerson +// SPDX-License-Identifier: MIT + /* Hedley - https://nemequ.github.io/hedley * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 */ -#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 13) +#if !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < 15) #if defined(JSON_HEDLEY_VERSION) #undef JSON_HEDLEY_VERSION #endif -#define JSON_HEDLEY_VERSION 13 +#define JSON_HEDLEY_VERSION 15 #if defined(JSON_HEDLEY_STRINGIFY_EX) #undef JSON_HEDLEY_STRINGIFY_EX @@ -196,18 +406,18 @@ struct position_t #if defined(JSON_HEDLEY_MSVC_VERSION) #undef JSON_HEDLEY_MSVC_VERSION #endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) +#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, (_MSC_FULL_VER % 10000000) / 100000, (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) +#elif defined(_MSC_FULL_VER) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, (_MSC_FULL_VER % 1000000) / 10000, (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && !defined(__ICL) #define JSON_HEDLEY_MSVC_VERSION JSON_HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) #endif #if defined(JSON_HEDLEY_MSVC_VERSION_CHECK) #undef JSON_HEDLEY_MSVC_VERSION_CHECK #endif -#if !defined(_MSC_VER) +#if !defined(JSON_HEDLEY_MSVC_VERSION) #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (0) #elif defined(_MSC_VER) && (_MSC_VER >= 1400) #define JSON_HEDLEY_MSVC_VERSION_CHECK(major,minor,patch) (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) @@ -220,9 +430,9 @@ struct position_t #if defined(JSON_HEDLEY_INTEL_VERSION) #undef JSON_HEDLEY_INTEL_VERSION #endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && !defined(__ICL) #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) +#elif defined(__INTEL_COMPILER) && !defined(__ICL) #define JSON_HEDLEY_INTEL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) #endif @@ -235,6 +445,22 @@ struct position_t #define JSON_HEDLEY_INTEL_VERSION_CHECK(major,minor,patch) (0) #endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #undef JSON_HEDLEY_INTEL_CL_VERSION +#endif +#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) && defined(__ICL) + #define JSON_HEDLEY_INTEL_CL_VERSION JSON_HEDLEY_VERSION_ENCODE(__INTEL_COMPILER, __INTEL_COMPILER_UPDATE, 0) +#endif + +#if defined(JSON_HEDLEY_INTEL_CL_VERSION_CHECK) + #undef JSON_HEDLEY_INTEL_CL_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_INTEL_CL_VERSION) + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_INTEL_CL_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_INTEL_CL_VERSION_CHECK(major,minor,patch) (0) +#endif + #if defined(JSON_HEDLEY_PGI_VERSION) #undef JSON_HEDLEY_PGI_VERSION #endif @@ -474,7 +700,7 @@ struct position_t #if __VER__ > 1000 #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), (__VER__ % 1000)) #else - #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) + #define JSON_HEDLEY_IAR_VERSION JSON_HEDLEY_VERSION_ENCODE(__VER__ / 100, __VER__ % 100, 0) #endif #endif @@ -551,6 +777,22 @@ struct position_t #define JSON_HEDLEY_PELLES_VERSION_CHECK(major,minor,patch) (0) #endif +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #undef JSON_HEDLEY_MCST_LCC_VERSION +#endif +#if defined(__LCC__) && defined(__LCC_MINOR__) + #define JSON_HEDLEY_MCST_LCC_VERSION JSON_HEDLEY_VERSION_ENCODE(__LCC__ / 100, __LCC__ % 100, __LCC_MINOR__) +#endif + +#if defined(JSON_HEDLEY_MCST_LCC_VERSION_CHECK) + #undef JSON_HEDLEY_MCST_LCC_VERSION_CHECK +#endif +#if defined(JSON_HEDLEY_MCST_LCC_VERSION) + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (JSON_HEDLEY_MCST_LCC_VERSION >= JSON_HEDLEY_VERSION_ENCODE(major, minor, patch)) +#else + #define JSON_HEDLEY_MCST_LCC_VERSION_CHECK(major,minor,patch) (0) +#endif + #if defined(JSON_HEDLEY_GCC_VERSION) #undef JSON_HEDLEY_GCC_VERSION #endif @@ -560,6 +802,7 @@ struct position_t !defined(JSON_HEDLEY_INTEL_VERSION) && \ !defined(JSON_HEDLEY_PGI_VERSION) && \ !defined(JSON_HEDLEY_ARM_VERSION) && \ + !defined(JSON_HEDLEY_CRAY_VERSION) && \ !defined(JSON_HEDLEY_TI_VERSION) && \ !defined(JSON_HEDLEY_TI_ARMCL_VERSION) && \ !defined(JSON_HEDLEY_TI_CL430_VERSION) && \ @@ -567,7 +810,8 @@ struct position_t !defined(JSON_HEDLEY_TI_CL6X_VERSION) && \ !defined(JSON_HEDLEY_TI_CL7X_VERSION) && \ !defined(JSON_HEDLEY_TI_CLPRU_VERSION) && \ - !defined(__COMPCERT__) + !defined(__COMPCERT__) && \ + !defined(JSON_HEDLEY_MCST_LCC_VERSION) #define JSON_HEDLEY_GCC_VERSION JSON_HEDLEY_GNUC_VERSION #endif @@ -583,17 +827,21 @@ struct position_t #if defined(JSON_HEDLEY_HAS_ATTRIBUTE) #undef JSON_HEDLEY_HAS_ATTRIBUTE #endif -#if defined(__has_attribute) - #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) +#if \ + defined(__has_attribute) && \ + ( \ + (!defined(JSON_HEDLEY_IAR_VERSION) || JSON_HEDLEY_IAR_VERSION_CHECK(8,5,9)) \ + ) +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) #else - #define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) +# define JSON_HEDLEY_HAS_ATTRIBUTE(attribute) (0) #endif #if defined(JSON_HEDLEY_GNUC_HAS_ATTRIBUTE) #undef JSON_HEDLEY_GNUC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) #else #define JSON_HEDLEY_GNUC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GNUC_VERSION_CHECK(major,minor,patch) #endif @@ -602,7 +850,7 @@ struct position_t #undef JSON_HEDLEY_GCC_HAS_ATTRIBUTE #endif #if defined(__has_attribute) - #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) __has_attribute(attribute) + #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_HAS_ATTRIBUTE(attribute) #else #define JSON_HEDLEY_GCC_HAS_ATTRIBUTE(attribute,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif @@ -787,6 +1035,72 @@ struct position_t #define JSON_HEDLEY_GCC_HAS_WARNING(warning,major,minor,patch) JSON_HEDLEY_GCC_VERSION_CHECK(major,minor,patch) #endif +#if \ + (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ + defined(__clang__) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ + JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ + JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ + JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ + JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ + JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ + (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) + #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) + #define JSON_HEDLEY_PRAGMA(value) __pragma(value) +#else + #define JSON_HEDLEY_PRAGMA(value) +#endif + +#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) + #undef JSON_HEDLEY_DIAGNOSTIC_PUSH +#endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) + #undef JSON_HEDLEY_DIAGNOSTIC_POP +#endif +#if defined(__clang__) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") +#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) + #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) +#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") +#elif \ + JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ + JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ + JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ + JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") +#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) + #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") + #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") +#else + #define JSON_HEDLEY_DIAGNOSTIC_PUSH + #define JSON_HEDLEY_DIAGNOSTIC_POP +#endif + /* JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_ is for HEDLEY INTERNAL USE ONLY. API subject to change without notice. */ #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_) @@ -795,12 +1109,22 @@ struct position_t #if defined(__cplusplus) # if JSON_HEDLEY_HAS_WARNING("-Wc++98-compat") # if JSON_HEDLEY_HAS_WARNING("-Wc++17-extensions") -# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ +# if JSON_HEDLEY_HAS_WARNING("-Wc++1z-extensions") +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ + JSON_HEDLEY_DIAGNOSTIC_PUSH \ + _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ + _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ + _Pragma("clang diagnostic ignored \"-Wc++1z-extensions\"") \ + xpr \ + JSON_HEDLEY_DIAGNOSTIC_POP +# else +# define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("clang diagnostic ignored \"-Wc++98-compat\"") \ _Pragma("clang diagnostic ignored \"-Wc++17-extensions\"") \ xpr \ JSON_HEDLEY_DIAGNOSTIC_POP +# endif # else # define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(xpr) \ JSON_HEDLEY_DIAGNOSTIC_PUSH \ @@ -865,7 +1189,7 @@ struct position_t # define JSON_HEDLEY_CPP_CAST(T, expr) \ JSON_HEDLEY_DIAGNOSTIC_PUSH \ _Pragma("diag_suppress=Pe137") \ - JSON_HEDLEY_DIAGNOSTIC_POP \ + JSON_HEDLEY_DIAGNOSTIC_POP # else # define JSON_HEDLEY_CPP_CAST(T, expr) ((T) (expr)) # endif @@ -873,70 +1197,6 @@ struct position_t # define JSON_HEDLEY_CPP_CAST(T, expr) (expr) #endif -#if \ - (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,7,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(2,0,1) || \ - JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,1,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,0,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(5,0,0) || \ - JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,17) || \ - JSON_HEDLEY_SUNPRO_VERSION_CHECK(8,0,0) || \ - (JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) && defined(__C99_PRAGMA_OPERATOR)) - #define JSON_HEDLEY_PRAGMA(value) _Pragma(#value) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_PRAGMA(value) __pragma(value) -#else - #define JSON_HEDLEY_PRAGMA(value) -#endif - -#if defined(JSON_HEDLEY_DIAGNOSTIC_PUSH) - #undef JSON_HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(JSON_HEDLEY_DIAGNOSTIC_POP) - #undef JSON_HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif JSON_HEDLEY_GCC_VERSION_CHECK(4,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) - #define JSON_HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif \ - JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ - JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,2,0) || \ - JSON_HEDLEY_TI_CL430_VERSION_CHECK(4,4,0) || \ - JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,1,0) || \ - JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif JSON_HEDLEY_PELLES_VERSION_CHECK(2,90,0) - #define JSON_HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") - #define JSON_HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else - #define JSON_HEDLEY_DIAGNOSTIC_PUSH - #define JSON_HEDLEY_DIAGNOSTIC_POP -#endif - #if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED #endif @@ -944,12 +1204,18 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warning(disable:1478 1786)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:1478 1786)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1216,1444,1445") #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable:4996)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") #elif \ JSON_HEDLEY_TI_VERSION_CHECK(15,12,0) || \ (JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(4,8,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ @@ -982,6 +1248,8 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") #elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("warning(disable:161)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS __pragma(warning(disable:161)) #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") #elif JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) @@ -998,6 +1266,8 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 161") #else #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS #endif @@ -1011,8 +1281,12 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #elif JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("warning(disable:1292)") +#elif JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:1292)) #elif JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES __pragma(warning(disable:5030)) +#elif JSON_HEDLEY_PGI_VERSION_CHECK(20,7,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097,1098") #elif JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus) @@ -1024,6 +1298,8 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1173") #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress=Pe1097") +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES _Pragma("diag_suppress 1097") #else #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_CPP_ATTRIBUTES #endif @@ -1041,20 +1317,34 @@ struct position_t #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL #endif +#if defined(JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION) + #undef JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif +#if JSON_HEDLEY_HAS_WARNING("-Wunused-function") + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("clang diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("GCC diagnostic ignored \"-Wunused-function\"") +#elif JSON_HEDLEY_MSVC_VERSION_CHECK(1,0,0) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION __pragma(warning(disable:4505)) +#elif JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION _Pragma("diag_suppress 3142") +#else + #define JSON_HEDLEY_DIAGNOSTIC_DISABLE_UNUSED_FUNCTION +#endif + #if defined(JSON_HEDLEY_DEPRECATED) #undef JSON_HEDLEY_DEPRECATED #endif #if defined(JSON_HEDLEY_DEPRECATED_FOR) #undef JSON_HEDLEY_DEPRECATED_FOR #endif -#if JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) +#if \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " # since)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement)) -#elif defined(__cplusplus) && (__cplusplus >= 201402L) - #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) - #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) #elif \ - JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ + (JSON_HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(5,6,0) || \ @@ -1064,9 +1354,13 @@ struct position_t JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(18,1,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,3,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,3,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__("Since " #since))) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__("Since " #since "; use " #replacement))) +#elif defined(__cplusplus) && (__cplusplus >= 201402L) + #define JSON_HEDLEY_DEPRECATED(since) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since)]]) + #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[deprecated("Since " #since "; use " #replacement)]]) #elif \ JSON_HEDLEY_HAS_ATTRIBUTE(deprecated) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ @@ -1081,12 +1375,15 @@ struct position_t (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) #define JSON_HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__)) #elif \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) + JSON_HEDLEY_PELLES_VERSION_CHECK(6,50,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_DEPRECATED(since) __declspec(deprecated) #define JSON_HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) #elif JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) @@ -1103,7 +1400,8 @@ struct position_t #if \ JSON_HEDLEY_HAS_ATTRIBUTE(warning) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_UNAVAILABLE(available_since) __attribute__((__warning__("Not available until " #available_since))) #else #define JSON_HEDLEY_UNAVAILABLE(available_since) @@ -1115,13 +1413,7 @@ struct position_t #if defined(JSON_HEDLEY_WARN_UNUSED_RESULT_MSG) #undef JSON_HEDLEY_WARN_UNUSED_RESULT_MSG #endif -#if (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) -#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) - #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) - #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) -#elif \ +#if \ JSON_HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,4,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ @@ -1137,9 +1429,16 @@ struct position_t JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) __attribute__((__warn_unused_result__)) +#elif (JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard(msg)]]) +#elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE(nodiscard) + #define JSON_HEDLEY_WARN_UNUSED_RESULT JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) + #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[nodiscard]]) #elif defined(_Check_return_) /* SAL */ #define JSON_HEDLEY_WARN_UNUSED_RESULT _Check_return_ #define JSON_HEDLEY_WARN_UNUSED_RESULT_MSG(msg) _Check_return_ @@ -1155,7 +1454,8 @@ struct position_t JSON_HEDLEY_HAS_ATTRIBUTE(sentinel) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) + JSON_HEDLEY_ARM_VERSION_CHECK(5,4,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) #else #define JSON_HEDLEY_SENTINEL(position) @@ -1166,7 +1466,9 @@ struct position_t #endif #if JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) #define JSON_HEDLEY_NO_RETURN __noreturn -#elif JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) +#elif \ + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define JSON_HEDLEY_NO_RETURN _Noreturn @@ -1188,11 +1490,14 @@ struct position_t (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) #define JSON_HEDLEY_NO_RETURN __attribute__((__noreturn__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #define JSON_HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_NO_RETURN __declspec(noreturn) #elif JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,0,0) && defined(__cplusplus) #define JSON_HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") @@ -1224,7 +1529,8 @@ struct position_t #endif #if \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_ASSUME(expr) __assume(expr) #elif JSON_HEDLEY_HAS_BUILTIN(__builtin_assume) #define JSON_HEDLEY_ASSUME(expr) __builtin_assume(expr) @@ -1242,7 +1548,9 @@ struct position_t JSON_HEDLEY_GCC_VERSION_CHECK(4,5,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(18,10,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ - JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) + JSON_HEDLEY_IBM_VERSION_CHECK(13,1,5) || \ + JSON_HEDLEY_CRAY_VERSION_CHECK(10,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_UNREACHABLE() __builtin_unreachable() #elif defined(JSON_HEDLEY_ASSUME) #define JSON_HEDLEY_UNREACHABLE() JSON_HEDLEY_ASSUME(0) @@ -1320,7 +1628,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __attribute__((__format__(__printf__, string_idx, first_to_check))) #elif JSON_HEDLEY_PELLES_VERSION_CHECK(6,0,0) #define JSON_HEDLEY_PRINTF_FORMAT(string_idx,first_to_check) __declspec(vaformat(printf,string_idx,first_to_check)) @@ -1356,15 +1665,16 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable((expr)) #endif #if \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) && !defined(JSON_HEDLEY_PGI_VERSION)) || \ + JSON_HEDLEY_GCC_VERSION_CHECK(9,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PREDICT(expr, value, probability) __builtin_expect_with_probability( (expr), (value), (probability)) # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) __builtin_expect_with_probability(!!(expr), 1 , (probability)) # define JSON_HEDLEY_PREDICT_FALSE(expr, probability) __builtin_expect_with_probability(!!(expr), 0 , (probability)) # define JSON_HEDLEY_LIKELY(expr) __builtin_expect (!!(expr), 1 ) # define JSON_HEDLEY_UNLIKELY(expr) __builtin_expect (!!(expr), 0 ) #elif \ - JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) || \ + (JSON_HEDLEY_HAS_BUILTIN(__builtin_expect) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,15,0) && defined(__cplusplus)) || \ @@ -1378,7 +1688,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ JSON_HEDLEY_TINYC_VERSION_CHECK(0,9,27) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PREDICT(expr, expected, probability) \ (((probability) >= 0.9) ? __builtin_expect((expr), (expected)) : (JSON_HEDLEY_STATIC_CAST(void, expected), (expr))) # define JSON_HEDLEY_PREDICT_TRUE(expr, probability) \ @@ -1424,11 +1735,14 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_MALLOC __attribute__((__malloc__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) #define JSON_HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_MALLOC __declspec(restrict) #else #define JSON_HEDLEY_MALLOC @@ -1455,7 +1769,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PURE __attribute__((__pure__)) #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) # define JSON_HEDLEY_PURE _Pragma("does_not_write_global_data") @@ -1491,7 +1806,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ - JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) + JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_CONST __attribute__((__const__)) #elif \ JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) @@ -1509,6 +1825,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_GCC_VERSION_CHECK(3,1,0) || \ JSON_HEDLEY_MSVC_VERSION_CHECK(14,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(10,1,0) || \ JSON_HEDLEY_PGI_VERSION_CHECK(17,10,0) || \ @@ -1518,7 +1835,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,14,0) && defined(__cplusplus)) || \ JSON_HEDLEY_IAR_VERSION_CHECK(8,0,0) || \ - defined(__clang__) + defined(__clang__) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_RESTRICT __restrict #elif JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,3,0) && !defined(__cplusplus) #define JSON_HEDLEY_RESTRICT _Restrict @@ -1539,13 +1857,15 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_HEDLEY_INLINE __inline__ #elif \ JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) || \ JSON_HEDLEY_TI_ARMCL_VERSION_CHECK(5,1,0) || \ JSON_HEDLEY_TI_CL430_VERSION_CHECK(3,1,0) || \ JSON_HEDLEY_TI_CL2000_VERSION_CHECK(6,2,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(8,0,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_INLINE __inline #else #define JSON_HEDLEY_INLINE @@ -1571,9 +1891,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) # define JSON_HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) JSON_HEDLEY_INLINE -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(12,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) # define JSON_HEDLEY_ALWAYS_INLINE __forceinline #elif defined(__cplusplus) && \ ( \ @@ -1611,9 +1935,13 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) || \ JSON_HEDLEY_TI_CL7X_VERSION_CHECK(1,2,0) || \ - JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) + JSON_HEDLEY_TI_CLPRU_VERSION_CHECK(2,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) || \ + JSON_HEDLEY_IAR_VERSION_CHECK(8,10,0) #define JSON_HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(13,10,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_NEVER_INLINE __declspec(noinline) #elif JSON_HEDLEY_PGI_VERSION_CHECK(10,2,0) #define JSON_HEDLEY_NEVER_INLINE _Pragma("noinline") @@ -1656,7 +1984,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP (JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,2,0) && defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(7,5,0) \ ) \ - ) + ) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define JSON_HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) # define JSON_HEDLEY_PUBLIC __attribute__((__visibility__("default"))) # else @@ -1672,10 +2001,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if \ JSON_HEDLEY_HAS_ATTRIBUTE(nothrow) || \ JSON_HEDLEY_GCC_VERSION_CHECK(3,3,0) || \ - JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) + JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_NO_THROW __attribute__((__nothrow__)) #elif \ JSON_HEDLEY_MSVC_VERSION_CHECK(13,1,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) || \ JSON_HEDLEY_ARM_VERSION_CHECK(4,1,0) #define JSON_HEDLEY_NO_THROW __declspec(nothrow) #else @@ -1687,7 +2018,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if \ JSON_HEDLEY_HAS_ATTRIBUTE(fallthrough) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) + JSON_HEDLEY_GCC_VERSION_CHECK(7,0,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) #elif JSON_HEDLEY_HAS_CPP_ATTRIBUTE_NS(clang,fallthrough) #define JSON_HEDLEY_FALL_THROUGH JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_([[clang::fallthrough]]) @@ -1704,7 +2036,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif #if \ JSON_HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || \ - JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) + JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) #elif defined(_Ret_notnull_) /* SAL */ #define JSON_HEDLEY_RETURNS_NON_NULL _Ret_notnull_ @@ -1746,7 +2079,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_IBM_VERSION_CHECK(13,1,0) || \ JSON_HEDLEY_TI_CL6X_VERSION_CHECK(6,1,0) || \ (JSON_HEDLEY_SUNPRO_VERSION_CHECK(5,10,0) && !defined(__cplusplus)) || \ - JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) + JSON_HEDLEY_CRAY_VERSION_CHECK(8,1,0) || \ + JSON_HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) #define JSON_HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) #endif #if !defined(__cplusplus) @@ -1770,7 +2104,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP !defined(JSON_HEDLEY_SUNPRO_VERSION) && \ !defined(JSON_HEDLEY_PGI_VERSION) && \ !defined(JSON_HEDLEY_IAR_VERSION)) || \ - JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) || \ + (JSON_HEDLEY_HAS_EXTENSION(c_generic_selections) && !defined(JSON_HEDLEY_IAR_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(4,9,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(17,0,0) || \ JSON_HEDLEY_IBM_VERSION_CHECK(12,1,0) || \ @@ -1840,7 +2174,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if \ !defined(__cplusplus) && ( \ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - JSON_HEDLEY_HAS_FEATURE(c_static_assert) || \ + (JSON_HEDLEY_HAS_FEATURE(c_static_assert) && !defined(JSON_HEDLEY_INTEL_CL_VERSION)) || \ JSON_HEDLEY_GCC_VERSION_CHECK(6,0,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \ @@ -1848,7 +2182,8 @@ JSON_HEDLEY_DIAGNOSTIC_POP # define JSON_HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #elif \ (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) + JSON_HEDLEY_MSVC_VERSION_CHECK(16,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) # define JSON_HEDLEY_STATIC_ASSERT(expr, message) JSON_HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) #else # define JSON_HEDLEY_STATIC_ASSERT(expr, message) @@ -1908,7 +2243,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP JSON_HEDLEY_PGI_VERSION_CHECK(18,4,0) || \ JSON_HEDLEY_INTEL_VERSION_CHECK(13,0,0) # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(GCC warning msg) -#elif JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) +#elif \ + JSON_HEDLEY_MSVC_VERSION_CHECK(15,0,0) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_PRAGMA(message(msg)) #else # define JSON_HEDLEY_WARNING(msg) JSON_HEDLEY_MESSAGE(msg) @@ -1944,8 +2281,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_FLAGS) #undef JSON_HEDLEY_FLAGS #endif -#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) +#if JSON_HEDLEY_HAS_ATTRIBUTE(flag_enum) && (!defined(__cplusplus) || JSON_HEDLEY_HAS_WARNING("-Wbitfield-enum-conversion")) #define JSON_HEDLEY_FLAGS __attribute__((__flag_enum__)) +#else + #define JSON_HEDLEY_FLAGS #endif #if defined(JSON_HEDLEY_FLAGS_CAST) @@ -1965,7 +2304,9 @@ JSON_HEDLEY_DIAGNOSTIC_POP #if defined(JSON_HEDLEY_EMPTY_BASES) #undef JSON_HEDLEY_EMPTY_BASES #endif -#if JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0) +#if \ + (JSON_HEDLEY_MSVC_VERSION_CHECK(19,0,23918) && !JSON_HEDLEY_MSVC_VERSION_CHECK(20,0,0)) || \ + JSON_HEDLEY_INTEL_CL_VERSION_CHECK(2021,1,0) #define JSON_HEDLEY_EMPTY_BASES __declspec(empty_bases) #else #define JSON_HEDLEY_EMPTY_BASES @@ -2020,9 +2361,12 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif /* !defined(JSON_HEDLEY_VERSION) || (JSON_HEDLEY_VERSION < X) */ -// This file contains all internal macro definitions +// This file contains all internal macro definitions (except those affecting ABI) // You MUST include macro_unscope.hpp at the end of json.hpp to undef all of them +// #include + + // exclude unsupported compilers #if !defined(JSON_SKIP_UNSUPPORTED_COMPILER_CHECK) #if defined(__clang__) @@ -2037,30 +2381,128 @@ JSON_HEDLEY_DIAGNOSTIC_POP #endif // C++ language standard detection -#if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) - #define JSON_HAS_CPP_20 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 - #define JSON_HAS_CPP_17 - #define JSON_HAS_CPP_14 -#elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) - #define JSON_HAS_CPP_14 +// if the user manually specified the used c++ version this is skipped +#if !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11) + #if (defined(__cplusplus) && __cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) + #define JSON_HAS_CPP_20 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201703L) || (defined(_HAS_CXX17) && _HAS_CXX17 == 1) // fix for issue #464 + #define JSON_HAS_CPP_17 + #define JSON_HAS_CPP_14 + #elif (defined(__cplusplus) && __cplusplus >= 201402L) || (defined(_HAS_CXX14) && _HAS_CXX14 == 1) + #define JSON_HAS_CPP_14 + #endif + // the cpp 11 flag is always specified because it is the minimal required version + #define JSON_HAS_CPP_11 #endif -// disable float-equal warnings on GCC/clang -#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wfloat-equal" +#ifdef __has_include + #if __has_include() + #include + #endif +#endif + +#if !defined(JSON_HAS_FILESYSTEM) && !defined(JSON_HAS_EXPERIMENTAL_FILESYSTEM) + #ifdef JSON_HAS_CPP_17 + #if defined(__cpp_lib_filesystem) + #define JSON_HAS_FILESYSTEM 1 + #elif defined(__cpp_lib_experimental_filesystem) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif !defined(__has_include) + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_FILESYSTEM 1 + #elif __has_include() + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 1 + #endif + + // std::filesystem does not work on MinGW GCC 8: https://sourceforge.net/p/mingw-w64/bugs/737/ + #if defined(__MINGW32__) && defined(__GNUC__) && __GNUC__ == 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before GCC 8: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 8 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before Clang 7: https://en.cppreference.com/w/cpp/compiler_support + #if defined(__clang_major__) && __clang_major__ < 7 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before MSVC 19.14: https://en.cppreference.com/w/cpp/compiler_support + #if defined(_MSC_VER) && _MSC_VER < 1914 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before iOS 13 + #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED < 130000 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + + // no filesystem support before macOS Catalina + #if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500 + #undef JSON_HAS_FILESYSTEM + #undef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #endif + #endif +#endif + +#ifndef JSON_HAS_EXPERIMENTAL_FILESYSTEM + #define JSON_HAS_EXPERIMENTAL_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_FILESYSTEM + #define JSON_HAS_FILESYSTEM 0 +#endif + +#ifndef JSON_HAS_THREE_WAY_COMPARISON + #if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L \ + && defined(__cpp_lib_three_way_comparison) && __cpp_lib_three_way_comparison >= 201907L + #define JSON_HAS_THREE_WAY_COMPARISON 1 + #else + #define JSON_HAS_THREE_WAY_COMPARISON 0 + #endif +#endif + +#ifndef JSON_HAS_RANGES + // ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error + #if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427 + #define JSON_HAS_RANGES 0 + #elif defined(__cpp_lib_ranges) + #define JSON_HAS_RANGES 1 + #else + #define JSON_HAS_RANGES 0 + #endif +#endif + +#ifdef JSON_HAS_CPP_17 + #define JSON_INLINE_VARIABLE inline +#else + #define JSON_INLINE_VARIABLE +#endif + +#if JSON_HEDLEY_HAS_ATTRIBUTE(no_unique_address) + #define JSON_NO_UNIQUE_ADDRESS [[no_unique_address]] +#else + #define JSON_NO_UNIQUE_ADDRESS #endif // disable documentation warnings on clang #if defined(__clang__) - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wdocumentation" + #pragma clang diagnostic ignored "-Wdocumentation-unknown-command" #endif -// allow to disable exceptions +// allow disabling exceptions #if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) #define JSON_THROW(exception) throw exception #define JSON_TRY try @@ -2094,12 +2536,19 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_INTERNAL_CATCH JSON_INTERNAL_CATCH_USER #endif -// allow to override assert +// allow overriding assert #if !defined(JSON_ASSERT) #include // assert #define JSON_ASSERT(x) assert(x) #endif +// allow to access some private functions (needed by the test suite) +#if defined(JSON_TESTS_PRIVATE) + #define JSON_PRIVATE_UNLESS_TESTED public +#else + #define JSON_PRIVATE_UNLESS_TESTED private +#endif + /*! @brief macro to briefly define a mapping between an enum and JSON @def NLOHMANN_JSON_SERIALIZE_ENUM @@ -2283,6 +2732,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define NLOHMANN_JSON_TO(v1) nlohmann_json_j[#v1] = nlohmann_json_t.v1; #define NLOHMANN_JSON_FROM(v1) nlohmann_json_j.at(#v1).get_to(nlohmann_json_t.v1); +#define NLOHMANN_JSON_FROM_WITH_DEFAULT(v1) nlohmann_json_t.v1 = nlohmann_json_j.value(#v1, nlohmann_json_default_obj.v1); /*! @brief macro @@ -2293,6 +2743,10 @@ JSON_HEDLEY_DIAGNOSTIC_POP friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + friend void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + friend void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + /*! @brief macro @def NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE @@ -2302,6 +2756,49 @@ JSON_HEDLEY_DIAGNOSTIC_POP inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM, __VA_ARGS__)) } +#define NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(Type, ...) \ + inline void to_json(nlohmann::json& nlohmann_json_j, const Type& nlohmann_json_t) { NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_TO, __VA_ARGS__)) } \ + inline void from_json(const nlohmann::json& nlohmann_json_j, Type& nlohmann_json_t) { Type nlohmann_json_default_obj; NLOHMANN_JSON_EXPAND(NLOHMANN_JSON_PASTE(NLOHMANN_JSON_FROM_WITH_DEFAULT, __VA_ARGS__)) } + + +// inspired from https://stackoverflow.com/a/26745591 +// allows to call any std function as if (e.g. with begin): +// using std::begin; begin(x); +// +// it allows using the detected idiom to retrieve the return type +// of such an expression +#define NLOHMANN_CAN_CALL_STD_FUNC_IMPL(std_name) \ + namespace detail { \ + using std::std_name; \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + } \ + \ + namespace detail2 { \ + struct std_name##_tag \ + { \ + }; \ + \ + template \ + std_name##_tag std_name(T&&...); \ + \ + template \ + using result_of_##std_name = decltype(std_name(std::declval()...)); \ + \ + template \ + struct would_call_std_##std_name \ + { \ + static constexpr auto const value = ::nlohmann::detail:: \ + is_detected_exact::value; \ + }; \ + } /* namespace detail2 */ \ + \ + template \ + struct would_call_std_##std_name : detail2::would_call_std_##std_name \ + { \ + } + #ifndef JSON_USE_IMPLICIT_CONVERSIONS #define JSON_USE_IMPLICIT_CONVERSIONS 1 #endif @@ -2312,406 +2809,383 @@ JSON_HEDLEY_DIAGNOSTIC_POP #define JSON_EXPLICIT explicit #endif +#ifndef JSON_DISABLE_ENUM_SERIALIZATION + #define JSON_DISABLE_ENUM_SERIALIZATION 0 +#endif -namespace nlohmann -{ +#ifndef JSON_USE_GLOBAL_UDLS + #define JSON_USE_GLOBAL_UDLS 1 +#endif + +#if JSON_HAS_THREE_WAY_COMPARISON + #include // partial_ordering +#endif + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { -//////////////// -// exceptions // -//////////////// + +/////////////////////////// +// JSON type enumeration // +/////////////////////////// /*! -@brief general exception of the @ref basic_json class +@brief the JSON type enumeration -This class is an extension of `std::exception` objects with a member @a id for -exception ids. It is used as the base class for all exceptions thrown by the -@ref basic_json class. This class can hence be used as "wildcard" to catch -exceptions. +This enumeration collects the different JSON types. It is internally used to +distinguish the stored values, and the functions @ref basic_json::is_null(), +@ref basic_json::is_object(), @ref basic_json::is_array(), +@ref basic_json::is_string(), @ref basic_json::is_boolean(), +@ref basic_json::is_number() (with @ref basic_json::is_number_integer(), +@ref basic_json::is_number_unsigned(), and @ref basic_json::is_number_float()), +@ref basic_json::is_discarded(), @ref basic_json::is_primitive(), and +@ref basic_json::is_structured() rely on it. -Subclasses: -- @ref parse_error for exceptions indicating a parse error -- @ref invalid_iterator for exceptions indicating errors with iterators -- @ref type_error for exceptions indicating executing a member function with - a wrong type -- @ref out_of_range for exceptions indicating access out of the defined range -- @ref other_error for exceptions indicating other library errors +@note There are three enumeration entries (number_integer, number_unsigned, and +number_float), because the library distinguishes these three types for numbers: +@ref basic_json::number_unsigned_t is used for unsigned integers, +@ref basic_json::number_integer_t is used for signed integers, and +@ref basic_json::number_float_t is used for floating-point numbers or to +approximate integers which do not fit in the limits of their respective type. -@internal -@note To have nothrow-copy-constructible exceptions, we internally use - `std::runtime_error` which can cope with arbitrary-length error messages. - Intermediate strings are built with static functions and then passed to - the actual constructor. -@endinternal +@sa see @ref basic_json::basic_json(const value_t value_type) -- create a JSON +value with the default value for a given type -@liveexample{The following code shows how arbitrary library exceptions can be -caught.,exception} - -@since version 3.0.0 +@since version 1.0.0 */ -class exception : public std::exception +enum class value_t : std::uint8_t { - public: - /// returns the explanatory string - JSON_HEDLEY_RETURNS_NON_NULL - const char* what() const noexcept override - { - return m.what(); - } - - /// the id of the exception - const int id; - - protected: - JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} - - static std::string name(const std::string& ename, int id_) - { - return "[json.exception." + ename + "." + std::to_string(id_) + "] "; - } - - private: - /// an exception object as storage for error messages - std::runtime_error m; + null, ///< null value + object, ///< object (unordered set of name/value pairs) + array, ///< array (ordered collection of values) + string, ///< string value + boolean, ///< boolean value + number_integer, ///< number value (signed integer) + number_unsigned, ///< number value (unsigned integer) + number_float, ///< number value (floating-point) + binary, ///< binary array (ordered collection of bytes) + discarded ///< discarded by the parser callback function }; /*! -@brief exception indicating a parse error +@brief comparison operator for JSON types -This exception is thrown by the library when a parse error occurs. Parse errors -can occur during the deserialization of JSON text, CBOR, MessagePack, as well -as when using JSON Patch. +Returns an ordering that is similar to Python: +- order: null < boolean < number < object < array < string < binary +- furthermore, each type is not smaller than itself +- discarded values are not comparable +- binary is represented as a b"" string in python and directly comparable to a + string; however, making a binary array directly comparable with a string would + be surprising behavior in a JSON file. -Member @a byte holds the byte index of the last read character in the input -file. - -Exceptions have ids 1xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.parse_error.101 | parse error at 2: unexpected end of input; expected string literal | This error indicates a syntax error while deserializing a JSON text. The error message describes that an unexpected token (character) was encountered, and the member @a byte indicates the error position. -json.exception.parse_error.102 | parse error at 14: missing or wrong low surrogate | JSON uses the `\uxxxx` format to describe Unicode characters. Code points above above 0xFFFF are split into two `\uxxxx` entries ("surrogate pairs"). This error indicates that the surrogate pair is incomplete or contains an invalid code point. -json.exception.parse_error.103 | parse error: code points above 0x10FFFF are invalid | Unicode supports code points up to 0x10FFFF. Code points above 0x10FFFF are invalid. -json.exception.parse_error.104 | parse error: JSON patch must be an array of objects | [RFC 6902](https://tools.ietf.org/html/rfc6902) requires a JSON Patch document to be a JSON document that represents an array of objects. -json.exception.parse_error.105 | parse error: operation must have string member 'op' | An operation of a JSON Patch document must contain exactly one "op" member, whose value indicates the operation to perform. Its value must be one of "add", "remove", "replace", "move", "copy", or "test"; other values are errors. -json.exception.parse_error.106 | parse error: array index '01' must not begin with '0' | An array index in a JSON Pointer ([RFC 6901](https://tools.ietf.org/html/rfc6901)) may be `0` or any number without a leading `0`. -json.exception.parse_error.107 | parse error: JSON pointer must be empty or begin with '/' - was: 'foo' | A JSON Pointer must be a Unicode string containing a sequence of zero or more reference tokens, each prefixed by a `/` character. -json.exception.parse_error.108 | parse error: escape character '~' must be followed with '0' or '1' | In a JSON Pointer, only `~0` and `~1` are valid escape sequences. -json.exception.parse_error.109 | parse error: array index 'one' is not a number | A JSON Pointer array index must be a number. -json.exception.parse_error.110 | parse error at 1: cannot read 2 bytes from vector | When parsing CBOR or MessagePack, the byte vector ends before the complete value has been read. -json.exception.parse_error.112 | parse error at 1: error reading CBOR; last byte: 0xF8 | Not all types of CBOR or MessagePack are supported. This exception occurs if an unsupported byte was read. -json.exception.parse_error.113 | parse error at 2: expected a CBOR string; last byte: 0x98 | While parsing a map key, a value that is not a string has been read. -json.exception.parse_error.114 | parse error: Unsupported BSON record type 0x0F | The parsing of the corresponding BSON record type is not implemented (yet). -json.exception.parse_error.115 | parse error at byte 5: syntax error while parsing UBJSON high-precision number: invalid number text: 1A | A UBJSON high-precision number could not be parsed. - -@note For an input with n bytes, 1 is the index of the first character and n+1 - is the index of the terminating null byte or the end of file. This also - holds true when reading a byte vector (CBOR or MessagePack). - -@liveexample{The following code shows how a `parse_error` exception can be -caught.,parse_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 +@since version 1.0.0 */ -class parse_error : public exception +#if JSON_HAS_THREE_WAY_COMPARISON + inline std::partial_ordering operator<=>(const value_t lhs, const value_t rhs) noexcept // *NOPAD* +#else + inline bool operator<(const value_t lhs, const value_t rhs) noexcept +#endif { - public: - /*! - @brief create a parse error exception - @param[in] id_ the id of the exception - @param[in] pos the position where the error occurred (or with - chars_read_total=0 if the position cannot be - determined) - @param[in] what_arg the explanatory string - @return parse_error object - */ - static parse_error create(int id_, const position_t& pos, const std::string& what_arg) + static constexpr std::array order = {{ + 0 /* null */, 3 /* object */, 4 /* array */, 5 /* string */, + 1 /* boolean */, 2 /* integer */, 2 /* unsigned */, 2 /* float */, + 6 /* binary */ + } + }; + + const auto l_index = static_cast(lhs); + const auto r_index = static_cast(rhs); +#if JSON_HAS_THREE_WAY_COMPARISON + if (l_index < order.size() && r_index < order.size()) { - std::string w = exception::name("parse_error", id_) + "parse error" + - position_string(pos) + ": " + what_arg; - return parse_error(id_, pos.chars_read_total, w.c_str()); + return order[l_index] <=> order[r_index]; // *NOPAD* } + return std::partial_ordering::unordered; +#else + return l_index < order.size() && r_index < order.size() && order[l_index] < order[r_index]; +#endif +} - static parse_error create(int id_, std::size_t byte_, const std::string& what_arg) - { - std::string w = exception::name("parse_error", id_) + "parse error" + - (byte_ != 0 ? (" at byte " + std::to_string(byte_)) : "") + - ": " + what_arg; - return parse_error(id_, byte_, w.c_str()); - } - - /*! - @brief byte index of the parse error - - The byte index of the last read character in the input file. - - @note For an input with n bytes, 1 is the index of the first character and - n+1 is the index of the terminating null byte or the end of file. - This also holds true when reading a byte vector (CBOR or MessagePack). - */ - const std::size_t byte; - - private: - parse_error(int id_, std::size_t byte_, const char* what_arg) - : exception(id_, what_arg), byte(byte_) {} - - static std::string position_string(const position_t& pos) - { - return " at line " + std::to_string(pos.lines_read + 1) + - ", column " + std::to_string(pos.chars_read_current_line); - } -}; - -/*! -@brief exception indicating errors with iterators - -This exception is thrown if iterators passed to a library function do not match -the expected semantics. - -Exceptions have ids 2xx. - -name / id | example message | description ------------------------------------ | --------------- | ------------------------- -json.exception.invalid_iterator.201 | iterators are not compatible | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.202 | iterator does not fit current value | In an erase or insert function, the passed iterator @a pos does not belong to the JSON value for which the function was called. It hence does not define a valid position for the deletion/insertion. -json.exception.invalid_iterator.203 | iterators do not fit current value | Either iterator passed to function @ref erase(IteratorType first, IteratorType last) does not belong to the JSON value from which values shall be erased. It hence does not define a valid range to delete values from. -json.exception.invalid_iterator.204 | iterators out of range | When an iterator range for a primitive type (number, boolean, or string) is passed to a constructor or an erase function, this range has to be exactly (@ref begin(), @ref end()), because this is the only way the single stored value is expressed. All other ranges are invalid. -json.exception.invalid_iterator.205 | iterator out of range | When an iterator for a primitive type (number, boolean, or string) is passed to an erase function, the iterator has to be the @ref begin() iterator, because it is the only way to address the stored value. All other iterators are invalid. -json.exception.invalid_iterator.206 | cannot construct with iterators from null | The iterators passed to constructor @ref basic_json(InputIT first, InputIT last) belong to a JSON null value and hence to not define a valid range. -json.exception.invalid_iterator.207 | cannot use key() for non-object iterators | The key() member function can only be used on iterators belonging to a JSON object, because other types do not have a concept of a key. -json.exception.invalid_iterator.208 | cannot use operator[] for object iterators | The operator[] to specify a concrete offset cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.209 | cannot use offsets with object iterators | The offset operators (+, -, +=, -=) cannot be used on iterators belonging to a JSON object, because JSON objects are unordered. -json.exception.invalid_iterator.210 | iterators do not fit | The iterator range passed to the insert function are not compatible, meaning they do not belong to the same container. Therefore, the range (@a first, @a last) is invalid. -json.exception.invalid_iterator.211 | passed iterators may not belong to container | The iterator range passed to the insert function must not be a subrange of the container to insert to. -json.exception.invalid_iterator.212 | cannot compare iterators of different containers | When two iterators are compared, they must belong to the same container. -json.exception.invalid_iterator.213 | cannot compare order of object iterators | The order of object iterators cannot be compared, because JSON objects are unordered. -json.exception.invalid_iterator.214 | cannot get value | Cannot get value for iterator: Either the iterator belongs to a null value or it is an iterator to a primitive type (number, boolean, or string), but the iterator is different to @ref begin(). - -@liveexample{The following code shows how an `invalid_iterator` exception can be -caught.,invalid_iterator} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class invalid_iterator : public exception +// GCC selects the built-in operator< over an operator rewritten from +// a user-defined spaceship operator +// Clang, MSVC, and ICC select the rewritten candidate +// (see GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105200) +#if JSON_HAS_THREE_WAY_COMPARISON && defined(__GNUC__) +inline bool operator<(const value_t lhs, const value_t rhs) noexcept { - public: - static invalid_iterator create(int id_, const std::string& what_arg) - { - std::string w = exception::name("invalid_iterator", id_) + what_arg; - return invalid_iterator(id_, w.c_str()); - } + return std::is_lt(lhs <=> rhs); // *NOPAD* +} +#endif - private: - JSON_HEDLEY_NON_NULL(3) - invalid_iterator(int id_, const char* what_arg) - : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating executing a member function with a wrong type - -This exception is thrown in case of a type error; that is, a library function is -executed on a JSON value whose type does not match the expected semantics. - -Exceptions have ids 3xx. - -name / id | example message | description ------------------------------ | --------------- | ------------------------- -json.exception.type_error.301 | cannot create object from initializer list | To create an object from an initializer list, the initializer list must consist only of a list of pairs whose first element is a string. When this constraint is violated, an array is created instead. -json.exception.type_error.302 | type must be object, but is array | During implicit or explicit value conversion, the JSON type must be compatible to the target type. For instance, a JSON string can only be converted into string types, but not into numbers or boolean types. -json.exception.type_error.303 | incompatible ReferenceType for get_ref, actual type is object | To retrieve a reference to a value stored in a @ref basic_json object with @ref get_ref, the type of the reference must match the value type. For instance, for a JSON array, the @a ReferenceType must be @ref array_t &. -json.exception.type_error.304 | cannot use at() with string | The @ref at() member functions can only be executed for certain JSON types. -json.exception.type_error.305 | cannot use operator[] with string | The @ref operator[] member functions can only be executed for certain JSON types. -json.exception.type_error.306 | cannot use value() with string | The @ref value() member functions can only be executed for certain JSON types. -json.exception.type_error.307 | cannot use erase() with string | The @ref erase() member functions can only be executed for certain JSON types. -json.exception.type_error.308 | cannot use push_back() with string | The @ref push_back() and @ref operator+= member functions can only be executed for certain JSON types. -json.exception.type_error.309 | cannot use insert() with | The @ref insert() member functions can only be executed for certain JSON types. -json.exception.type_error.310 | cannot use swap() with number | The @ref swap() member functions can only be executed for certain JSON types. -json.exception.type_error.311 | cannot use emplace_back() with string | The @ref emplace_back() member function can only be executed for certain JSON types. -json.exception.type_error.312 | cannot use update() with string | The @ref update() member functions can only be executed for certain JSON types. -json.exception.type_error.313 | invalid value to unflatten | The @ref unflatten function converts an object whose keys are JSON Pointers back into an arbitrary nested JSON value. The JSON Pointers must not overlap, because then the resulting value would not be well defined. -json.exception.type_error.314 | only objects can be unflattened | The @ref unflatten function only works for an object whose keys are JSON Pointers. -json.exception.type_error.315 | values in object must be primitive | The @ref unflatten function only works for an object whose keys are JSON Pointers and whose values are primitive. -json.exception.type_error.316 | invalid UTF-8 byte at index 10: 0x7E | The @ref dump function only works with UTF-8 encoded strings; that is, if you assign a `std::string` to a JSON value, make sure it is UTF-8 encoded. | -json.exception.type_error.317 | JSON value cannot be serialized to requested format | The dynamic type of the object cannot be represented in the requested serialization format (e.g. a raw `true` or `null` JSON object cannot be serialized to BSON) | - -@liveexample{The following code shows how a `type_error` exception can be -caught.,type_error} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref out_of_range for exceptions indicating access out of the defined range -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class type_error : public exception -{ - public: - static type_error create(int id_, const std::string& what_arg) - { - std::string w = exception::name("type_error", id_) + what_arg; - return type_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - type_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating access out of the defined range - -This exception is thrown in case a library function is called on an input -parameter that exceeds the expected range, for instance in case of array -indices or nonexisting object keys. - -Exceptions have ids 4xx. - -name / id | example message | description -------------------------------- | --------------- | ------------------------- -json.exception.out_of_range.401 | array index 3 is out of range | The provided array index @a i is larger than @a size-1. -json.exception.out_of_range.402 | array index '-' (3) is out of range | The special array index `-` in a JSON Pointer never describes a valid element of the array, but the index past the end. That is, it can only be used to add elements at this position, but not to read it. -json.exception.out_of_range.403 | key 'foo' not found | The provided key was not found in the JSON object. -json.exception.out_of_range.404 | unresolved reference token 'foo' | A reference token in a JSON Pointer could not be resolved. -json.exception.out_of_range.405 | JSON pointer has no parent | The JSON Patch operations 'remove' and 'add' can not be applied to the root element of the JSON value. -json.exception.out_of_range.406 | number overflow parsing '10E1000' | A parsed number could not be stored as without changing it to NaN or INF. -json.exception.out_of_range.407 | number overflow serializing '9223372036854775808' | UBJSON and BSON only support integer numbers up to 9223372036854775807. (until version 3.8.0) | -json.exception.out_of_range.408 | excessive array size: 8658170730974374167 | The size (following `#`) of an UBJSON array or object exceeds the maximal capacity. | -json.exception.out_of_range.409 | BSON key cannot contain code point U+0000 (at byte 2) | Key identifiers to be serialized to BSON cannot contain code point U+0000, since the key is stored as zero-terminated c-string | - -@liveexample{The following code shows how an `out_of_range` exception can be -caught.,out_of_range} - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref other_error for exceptions indicating other library errors - -@since version 3.0.0 -*/ -class out_of_range : public exception -{ - public: - static out_of_range create(int id_, const std::string& what_arg) - { - std::string w = exception::name("out_of_range", id_) + what_arg; - return out_of_range(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - out_of_range(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; - -/*! -@brief exception indicating other library errors - -This exception is thrown in case of errors that cannot be classified with the -other exception types. - -Exceptions have ids 5xx. - -name / id | example message | description ------------------------------- | --------------- | ------------------------- -json.exception.other_error.501 | unsuccessful: {"op":"test","path":"/baz", "value":"bar"} | A JSON Patch operation 'test' failed. The unsuccessful operation is also printed. - -@sa - @ref exception for the base class of the library exceptions -@sa - @ref parse_error for exceptions indicating a parse error -@sa - @ref invalid_iterator for exceptions indicating errors with iterators -@sa - @ref type_error for exceptions indicating executing a member function with - a wrong type -@sa - @ref out_of_range for exceptions indicating access out of the defined range - -@liveexample{The following code shows how an `other_error` exception can be -caught.,other_error} - -@since version 3.0.0 -*/ -class other_error : public exception -{ - public: - static other_error create(int id_, const std::string& what_arg) - { - std::string w = exception::name("other_error", id_) + what_arg; - return other_error(id_, w.c_str()); - } - - private: - JSON_HEDLEY_NON_NULL(3) - other_error(int id_, const char* what_arg) : exception(id_, what_arg) {} -}; } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/*! +@brief replace all occurrences of a substring by another string + +@param[in,out] s the string to manipulate; changed so that all + occurrences of @a f are replaced with @a t +@param[in] f the substring to replace with @a t +@param[in] t the string to replace @a f + +@pre The search string @a f must not be empty. **This precondition is +enforced with an assertion.** + +@since version 2.0.0 +*/ +template +inline void replace_substring(StringType& s, const StringType& f, + const StringType& t) +{ + JSON_ASSERT(!f.empty()); + for (auto pos = s.find(f); // find first occurrence of f + pos != StringType::npos; // make sure f was found + s.replace(pos, f.size(), t), // replace with t, and + pos = s.find(f, pos + t.size())) // find next occurrence of f + {} +} + +/*! + * @brief string escaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to escape + * @return escaped string + * + * Note the order of escaping "~" to "~0" and "/" to "~1" is important. + */ +template +inline StringType escape(StringType s) +{ + replace_substring(s, StringType{"~"}, StringType{"~0"}); + replace_substring(s, StringType{"/"}, StringType{"~1"}); + return s; +} + +/*! + * @brief string unescaping as described in RFC 6901 (Sect. 4) + * @param[in] s string to unescape + * @return unescaped string + * + * Note the order of escaping "~1" to "/" and "~0" to "~" is important. + */ +template +static void unescape(StringType& s) +{ + replace_substring(s, StringType{"~1"}, StringType{"/"}); + replace_substring(s, StringType{"~0"}, StringType{"~"}); +} + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +#include // size_t + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN +namespace detail +{ + +/// struct to capture the start position of the current token +struct position_t +{ + /// the total number of characters read + std::size_t chars_read_total = 0; + /// the number of characters read in the current line + std::size_t chars_read_current_line = 0; + /// the number of lines read + std::size_t lines_read = 0; + + /// conversion to size_t to preserve SAX interface + constexpr operator size_t() const + { + return chars_read_total; + } +}; + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END // #include // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-FileCopyrightText: 2018 The Abseil Authors +// SPDX-License-Identifier: MIT + +#include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type +#include // index_sequence, make_index_sequence, index_sequence_for -namespace nlohmann -{ +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { -// alias templates to reduce boilerplate -template -using enable_if_t = typename std::enable_if::type; template using uncvref_t = typename std::remove_cv::type>::type; -// implementation of C++14 index_sequence and affiliates -// source: https://stackoverflow.com/a/32223343 -template -struct index_sequence +#ifdef JSON_HAS_CPP_14 + +// the following utilities are natively available in C++14 +using std::enable_if_t; +using std::index_sequence; +using std::make_index_sequence; +using std::index_sequence_for; + +#else + +// alias templates to reduce boilerplate +template +using enable_if_t = typename std::enable_if::type; + +// The following code is taken from https://github.com/abseil/abseil-cpp/blob/10cb35e459f5ecca5b2ff107635da0bfa41011b4/absl/utility/utility.h +// which is part of Google Abseil (https://github.com/abseil/abseil-cpp), licensed under the Apache License 2.0. + +//// START OF CODE FROM GOOGLE ABSEIL + +// integer_sequence +// +// Class template representing a compile-time integer sequence. An instantiation +// of `integer_sequence` has a sequence of integers encoded in its +// type through its template arguments (which is a common need when +// working with C++11 variadic templates). `absl::integer_sequence` is designed +// to be a drop-in replacement for C++14's `std::integer_sequence`. +// +// Example: +// +// template< class T, T... Ints > +// void user_function(integer_sequence); +// +// int main() +// { +// // user_function's `T` will be deduced to `int` and `Ints...` +// // will be deduced to `0, 1, 2, 3, 4`. +// user_function(make_integer_sequence()); +// } +template +struct integer_sequence { - using type = index_sequence; - using value_type = std::size_t; + using value_type = T; static constexpr std::size_t size() noexcept { return sizeof...(Ints); } }; -template -struct merge_and_renumber; +// index_sequence +// +// A helper template for an `integer_sequence` of `size_t`, +// `absl::index_sequence` is designed to be a drop-in replacement for C++14's +// `std::index_sequence`. +template +using index_sequence = integer_sequence; -template -struct merge_and_renumber, index_sequence> - : index_sequence < I1..., (sizeof...(I1) + I2)... > {}; +namespace utility_internal +{ -template -struct make_index_sequence - : merge_and_renumber < typename make_index_sequence < N / 2 >::type, - typename make_index_sequence < N - N / 2 >::type > {}; +template +struct Extend; -template<> struct make_index_sequence<0> : index_sequence<> {}; -template<> struct make_index_sequence<1> : index_sequence<0> {}; +// Note that SeqSize == sizeof...(Ints). It's passed explicitly for efficiency. +template +struct Extend, SeqSize, 0> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >; +}; -template +template +struct Extend, SeqSize, 1> +{ + using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >; +}; + +// Recursion helper for 'make_integer_sequence'. +// 'Gen::type' is an alias for 'integer_sequence'. +template +struct Gen +{ + using type = + typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type; +}; + +template +struct Gen +{ + using type = integer_sequence; +}; + +} // namespace utility_internal + +// Compile-time sequences of integers + +// make_integer_sequence +// +// This template alias is equivalent to +// `integer_sequence`, and is designed to be a drop-in +// replacement for C++14's `std::make_integer_sequence`. +template +using make_integer_sequence = typename utility_internal::Gen::type; + +// make_index_sequence +// +// This template alias is equivalent to `index_sequence<0, 1, ..., N-1>`, +// and is designed to be a drop-in replacement for C++14's +// `std::make_index_sequence`. +template +using make_index_sequence = make_integer_sequence; + +// index_sequence_for +// +// Converts a typename pack into an index sequence of the same length, and +// is designed to be a drop-in replacement for C++14's +// `std::index_sequence_for()` +template using index_sequence_for = make_index_sequence; +//// END OF CODE FROM GOOGLE ABSEIL + +#endif + // dispatch utility (taken from ranges-v3) template struct priority_tag : priority_tag < N - 1 > {}; template<> struct priority_tag<0> {}; @@ -2720,48 +3194,63 @@ template<> struct priority_tag<0> {}; template struct static_const { - static constexpr T value{}; + static JSON_INLINE_VARIABLE constexpr T value{}; }; -template -constexpr T static_const::value; +#ifndef JSON_HAS_CPP_17 + template + constexpr T static_const::value; +#endif + +template +inline constexpr std::array make_array(Args&& ... args) +{ + return std::array {{static_cast(std::forward(args))...}}; +} + } // namespace detail -} // namespace nlohmann +NLOHMANN_JSON_NAMESPACE_END // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval +#include // tuple // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #include // random_access_iterator_tag +// #include + // #include - -namespace nlohmann -{ -namespace detail -{ -template struct make_void -{ - using type = void; -}; -template using void_t = typename make_void::type; -} // namespace detail -} // namespace nlohmann - // #include -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN namespace detail { + template struct iterator_types {}; @@ -2800,157 +3289,135 @@ struct iterator_traits::value>> using pointer = T*; using reference = T&; }; -} // namespace detail -} // namespace nlohmann + +} // namespace detail +NLOHMANN_JSON_NAMESPACE_END // #include +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(begin); + +NLOHMANN_JSON_NAMESPACE_END + +// #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + + + +// #include + + +NLOHMANN_JSON_NAMESPACE_BEGIN + +NLOHMANN_CAN_CALL_STD_FUNC_IMPL(end); + +NLOHMANN_JSON_NAMESPACE_END + // #include // #include - -#include - -// #include - - -// https://en.cppreference.com/w/cpp/experimental/is_detected -namespace nlohmann -{ -namespace detail -{ -struct nonesuch -{ - nonesuch() = delete; - ~nonesuch() = delete; - nonesuch(nonesuch const&) = delete; - nonesuch(nonesuch const&&) = delete; - void operator=(nonesuch const&) = delete; - void operator=(nonesuch&&) = delete; -}; - -template class Op, - class... Args> -struct detector -{ - using value_t = std::false_type; - using type = Default; -}; - -template class Op, class... Args> -struct detector>, Op, Args...> -{ - using value_t = std::true_type; - using type = Op; -}; - -template class Op, class... Args> -using is_detected = typename detector::value_t; - -template class Op, class... Args> -using detected_t = typename detector::type; - -template class Op, class... Args> -using detected_or = detector; - -template class Op, class... Args> -using detected_or_t = typename detected_or::type; - -template class Op, class... Args> -using is_detected_exact = std::is_same>; - -template class Op, class... Args> -using is_detected_convertible = - std::is_convertible, To>; -} // namespace detail -} // namespace nlohmann - // #include +// __ _____ _____ _____ +// __| | __| | | | JSON for Modern C++ +// | | |__ | | | | | | version 3.11.2 +// |_____|_____|_____|_|___| https://github.com/nlohmann/json +// +// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann +// SPDX-License-Identifier: MIT + #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#define INCLUDE_NLOHMANN_JSON_FWD_HPP_ + #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ -#include // int64_t, uint64_t -#include // map -#include // allocator -#include // string -#include // vector + #include // int64_t, uint64_t + #include // map + #include // allocator + #include // string + #include // vector -/*! -@brief namespace for Niels Lohmann -@see https://github.com/nlohmann -@since version 1.0.0 -*/ -namespace nlohmann -{ -/*! -@brief default JSONSerializer template argument + // #include -This serializer ignores the template arguments and uses ADL -([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) -for serialization. -*/ -template -struct adl_serializer; -template class ObjectType = - std::map, - template class ArrayType = std::vector, - class StringType = std::string, class BooleanType = bool, - class NumberIntegerType = std::int64_t, - class NumberUnsignedType = std::uint64_t, - class NumberFloatType = double, - template class AllocatorType = std::allocator, - template class JSONSerializer = - adl_serializer, - class BinaryType = std::vector> -class basic_json; + /*! + @brief namespace for Niels Lohmann + @see https://github.com/nlohmann + @since version 1.0.0 + */ + NLOHMANN_JSON_NAMESPACE_BEGIN -/*! -@brief JSON Pointer + /*! + @brief default JSONSerializer template argument -A JSON pointer defines a string syntax for identifying a specific value -within a JSON document. It can be used with functions `at` and -`operator[]`. Furthermore, JSON pointers are the base for JSON patches. + This serializer ignores the template arguments and uses ADL + ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) + for serialization. + */ + template + struct adl_serializer; -@sa [RFC 6901](https://tools.ietf.org/html/rfc6901) + /// a class to store JSON values + /// @sa https://json.nlohmann.me/api/basic_json/ + template class ObjectType = + std::map, + template class ArrayType = std::vector, + class StringType = std::string, class BooleanType = bool, + class NumberIntegerType = std::int64_t, + class NumberUnsignedType = std::uint64_t, + class NumberFloatType = double, + template class AllocatorType = std::allocator, + template class JSONSerializer = + adl_serializer, + class BinaryType = std::vector> + class basic_json; -@since version 2.0.0 -*/ -template -class json_pointer; + /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document + /// @sa https://json.nlohmann.me/api/json_pointer/ + template + class json_pointer; -/*! -@brief default JSON class + /*! + @brief default specialization + @sa https://json.nlohmann.me/api/json/ + */ + using json = basic_json<>; -This type is the default specialization of the @ref basic_json class which -uses the standard template types. + /// @brief a minimal map-like container that preserves insertion order + /// @sa https://json.nlohmann.me/api/ordered_map/ + template + struct ordered_map; -@since version 1.0.0 -*/ -using json = basic_json<>; + /// @brief specialization that maintains the insertion order of object keys + /// @sa https://json.nlohmann.me/api/ordered_json/ + using ordered_json = basic_json; -template -struct ordered_map; - -/*! -@brief ordered JSON class - -This type preserves the insertion order of object keys. - -@since version 3.9.0 -*/ -using ordered_json = basic_json; - -} // namespace nlohmann + NLOHMANN_JSON_NAMESPACE_END #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ -namespace nlohmann -{ +NLOHMANN_JSON_NAMESPACE_BEGIN /*! @brief detail namespace with internal helper functions @@ -2961,6 +3428,7 @@ implementations of some @ref basic_json methods, and meta-programming helpers. */ namespace detail { + ///////////// // helpers // ///////////// @@ -2979,6 +3447,16 @@ template struct is_basic_json : std::false_type {}; NLOHMANN_BASIC_JSON_TPL_DECLARATION struct is_basic_json : std::true_type {}; +// used by exceptions create() member functions +// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t +// false_type otherwise +template +struct is_basic_json_context : + std::integral_constant < bool, + is_basic_json::type>::type>::value + || std::is_same::value > +{}; + ////////////////////// // json_ref helpers // ////////////////////// @@ -3017,9 +3495,6 @@ using reference_t = typename T::reference; template using iterator_category_t = typename T::iterator_category; -template -using iterator_t = typename T::iterator; - template using to_json_function = decltype(T::to_json(std::declval()...)); @@ -3044,8 +3519,7 @@ struct is_getable }; template -struct has_from_json < BasicJsonType, T, - enable_if_t < !is_basic_json::value >> +struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> { using serializer = typename BasicJsonType::template json_serializer; @@ -3084,11 +3558,78 @@ struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json::value >> T>::value; }; +template +using detect_key_compare = typename T::key_compare; + +template +struct has_key_compare : std::integral_constant::value> {}; + +// obtains the actual object key comparator +template +struct actual_object_comparator +{ + using object_t = typename BasicJsonType::object_t; + using object_comparator_t = typename BasicJsonType::default_object_comparator_t; + using type = typename std::conditional < has_key_compare::value, + typename object_t::key_compare, object_comparator_t>::type; +}; + +template +using actual_object_comparator_t = typename actual_object_comparator::type; /////////////////// // is_ functions // /////////////////// +// https://en.cppreference.com/w/cpp/types/conjunction +template struct conjunction : std::true_type { }; +template struct conjunction : B { }; +template +struct conjunction +: std::conditional(B::value), conjunction, B>::type {}; + +// https://en.cppreference.com/w/cpp/types/negation +template struct negation : std::integral_constant < bool, !B::value > { }; + +// Reimplementation of is_constructible and is_default_constructible, due to them being broken for +// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367). +// This causes compile errors in e.g. clang 3.5 or gcc 4.9. +template +struct is_default_constructible : std::is_default_constructible {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction, is_default_constructible> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + +template +struct is_default_constructible> + : conjunction...> {}; + + +template +struct is_constructible : std::is_constructible {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + +template +struct is_constructible> : is_default_constructible> {}; + + template struct is_iterator_traits : std::false_type {}; @@ -3107,7 +3648,34 @@ struct is_iterator_traits> is_detected::value; }; -// source: https://stackoverflow.com/a/37193089/4116453 +template +struct is_range +{ + private: + using t_ref = typename std::add_lvalue_reference::type; + + using iterator = detected_t; + using sentinel = detected_t; + + // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator + // and https://en.cppreference.com/w/cpp/iterator/sentinel_for + // but reimplementing these would be too much work, as a lot of other concepts are used underneath + static constexpr auto is_iterator_begin = + is_iterator_traits>::value; + + public: + static constexpr bool value = !std::is_same::value && !std::is_same::value && is_iterator_begin; +}; + +template +using iterator_t = enable_if_t::value, result_of_begin())>>; + +template +using range_value_t = value_type_t>>; + +// The following implementation of is_complete_type is taken from +// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/ +// and is written by Xiang Fan who agreed to using it in this library. template struct is_complete_type : std::false_type {}; @@ -3125,14 +3693,13 @@ struct is_compatible_object_type_impl < enable_if_t < is_detected::value&& is_detected::value >> { - using object_t = typename BasicJsonType::object_t; // macOS's is_constructible does not play well with nonesuch... static constexpr bool value = - std::is_constructible::value && - std::is_constructible::value; }; @@ -3153,10 +3720,10 @@ struct is_constructible_object_type_impl < using object_t = typename BasicJsonType::object_t; static constexpr bool value = - (std::is_default_constructible::value && + (is_default_constructible::value && (std::is_move_assignable::value || std::is_copy_assignable::value) && - (std::is_constructible::value && std::is_same < typename object_t::mapped_type, @@ -3173,42 +3740,29 @@ struct is_constructible_object_type : is_constructible_object_type_impl {}; -template -struct is_compatible_string_type_impl : std::false_type {}; - template -struct is_compatible_string_type_impl < - BasicJsonType, CompatibleStringType, - enable_if_t::value >> -{ - static constexpr auto value = - std::is_constructible::value; -}; - -template struct is_compatible_string_type - : is_compatible_string_type_impl {}; - -template -struct is_constructible_string_type_impl : std::false_type {}; - -template -struct is_constructible_string_type_impl < - BasicJsonType, ConstructibleStringType, - enable_if_t::value >> { static constexpr auto value = - std::is_constructible::value; + is_constructible::value; }; template struct is_constructible_string_type - : is_constructible_string_type_impl {}; +{ + // launder type through decltype() to fix compilation failure on ICPC +#ifdef __INTEL_COMPILER + using laundered_type = decltype(std::declval()); +#else + using laundered_type = ConstructibleStringType; +#endif + + static constexpr auto value = + conjunction < + is_constructible, + is_detected_exact>::value; +}; template struct is_compatible_array_type_impl : std::false_type {}; @@ -3216,17 +3770,16 @@ struct is_compatible_array_type_impl : std::false_type {}; template struct is_compatible_array_type_impl < BasicJsonType, CompatibleArrayType, - enable_if_t < is_detected::value&& + enable_if_t < is_detected::value&& -// This is needed because json_reverse_iterator has a ::iterator type... -// Therefore it is detected as a CompatibleArrayType. -// The real fix would be to have an Iterable concept. - !is_iterator_traits < - iterator_traits>::value >> + is_iterator_traits>>::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 + !std::is_same>::value >> { static constexpr bool value = - std::is_constructible::value; + is_constructible>::value; }; template @@ -3248,28 +3801,29 @@ struct is_constructible_array_type_impl < BasicJsonType, ConstructibleArrayType, enable_if_t < !std::is_same::value&& - std::is_default_constructible::value&& + !is_compatible_string_type::value&& + is_default_constructible::value&& (std::is_move_assignable::value || std::is_copy_assignable::value)&& -is_detected::value&& is_detected::value&& -is_complete_type < -detected_t>::value >> +is_iterator_traits>>::value&& +is_detected::value&& +// special case for types like std::filesystem::path whose iterator's value_type are themselves +// c.f. https://github.com/nlohmann/json/pull/3073 +!std::is_same>::value&& + is_complete_type < + detected_t>::value >> { - static constexpr bool value = - // This is needed because json_reverse_iterator has a ::iterator type, - // furthermore, std::back_insert_iterator (and other iterators) have a - // base class `iterator`... Therefore it is detected as a - // ConstructibleArrayType. The real fix would be to have an Iterable - // concept. - !is_iterator_traits>::value && + using value_type = range_value_t; - (std::is_same::value || - has_from_json::value || - has_non_default_from_json < - BasicJsonType, typename ConstructibleArrayType::value_type >::value); + static constexpr bool value = + std::is_same::value || + has_from_json::value || + has_non_default_from_json < + BasicJsonType, + value_type >::value; }; template @@ -3292,7 +3846,7 @@ struct is_compatible_integer_type_impl < using CompatibleLimits = std::numeric_limits; static constexpr auto value = - std::is_constructible::value && CompatibleLimits::is_integer && RealLimits::is_signed == CompatibleLimits::is_signed; @@ -3319,115 +3873,728 @@ template struct is_compatible_type : is_compatible_type_impl {}; -// https://en.cppreference.com/w/cpp/types/conjunction -template struct conjunction : std::true_type { }; -template struct conjunction : B1 { }; -template -struct conjunction -: std::conditional, B1>::type {}; - template struct is_constructible_tuple : std::false_type {}; template -struct is_constructible_tuple> : conjunction...> {}; +struct is_constructible_tuple> : conjunction...> {}; + +template +struct is_json_iterator_of : std::false_type {}; + +template +struct is_json_iterator_of : std::true_type {}; + +template +struct is_json_iterator_of : std::true_type +{}; + +// checks if a given type T is a template specialization of Primary +template