156 lines
4.4 KiB
Diff
156 lines
4.4 KiB
Diff
From 1bf5972d7e1413b9910260faf4d3e18fdfb94389 Mon Sep 17 00:00:00 2001
|
|
From: Kreijstal <rainb@tfwno.gf>
|
|
Date: Wed, 21 May 2025 07:55:57 -0400
|
|
Subject: Weird bug where clang requires explicit json definitions
|
|
|
|
Patch updated by Tim Stahlhut
|
|
---
|
|
common/settings/bom_settings.cpp | 2 +-
|
|
common/settings/json_settings.cpp | 1 +
|
|
kicad/tools/kicad_manager_control.cpp | 1 +
|
|
kicad/update_manager.cpp | 2 +-
|
|
libs/core/include/core/json_serializers.h | 62 ++++++++++++++++++++++-
|
|
5 files changed, 65 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/common/settings/bom_settings.cpp b/common/settings/bom_settings.cpp
|
|
index e4d7143903..0015d76efb 100644
|
|
--- a/common/settings/bom_settings.cpp
|
|
+++ b/common/settings/bom_settings.cpp
|
|
@@ -18,9 +18,9 @@
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
+#include <core/json_serializers.h>
|
|
#include <settings/bom_settings.h>
|
|
#include <json_common.h>
|
|
-#include <core/json_serializers.h>
|
|
#include <wx/translation.h>
|
|
|
|
|
|
diff --git a/common/settings/json_settings.cpp b/common/settings/json_settings.cpp
|
|
index 7d946df47d..159e0e09a5 100644
|
|
--- a/common/settings/json_settings.cpp
|
|
+++ b/common/settings/json_settings.cpp
|
|
@@ -26,6 +26,7 @@
|
|
|
|
#include <locale_io.h>
|
|
#include <gal/color4d.h>
|
|
+#include <core/json_serializers.h>
|
|
#include <settings/json_settings.h>
|
|
#include <settings/json_settings_internals.h>
|
|
#include <settings/nested_settings.h>
|
|
diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp
|
|
index 5461ee1e1f..fa0e931afa 100644
|
|
--- a/kicad/tools/kicad_manager_control.cpp
|
|
+++ b/kicad/tools/kicad_manager_control.cpp
|
|
@@ -18,6 +18,7 @@
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
+#include <core/json_serializers.h>
|
|
#include <wildcards_and_files_ext.h>
|
|
#include <env_vars.h>
|
|
#include <executable_names.h>
|
|
diff --git a/kicad/update_manager.cpp b/kicad/update_manager.cpp
|
|
index 932db293f5..4856a9c956 100644
|
|
--- a/kicad/update_manager.cpp
|
|
+++ b/kicad/update_manager.cpp
|
|
@@ -28,6 +28,7 @@
|
|
#include <string>
|
|
#include <sstream>
|
|
|
|
+#include <core/json_serializers.h>
|
|
#include "settings/settings_manager.h"
|
|
#include "settings/kicad_settings.h"
|
|
#include <notifications_manager.h>
|
|
@@ -39,7 +40,6 @@
|
|
#include <dialogs/dialog_update_notice.h>
|
|
|
|
#include <json_common.h>
|
|
-#include <core/json_serializers.h>
|
|
|
|
#include <wx/log.h>
|
|
#include <wx/event.h>
|
|
diff --git a/libs/core/include/core/json_serializers.h b/libs/core/include/core/json_serializers.h
|
|
index 17b1057de9..302cb060f8 100644
|
|
--- a/libs/core/include/core/json_serializers.h
|
|
+++ b/libs/core/include/core/json_serializers.h
|
|
@@ -25,6 +25,7 @@
|
|
#define JSON_SERIALIZERS_H_
|
|
|
|
#include <json_common.h>
|
|
+#include <wx/gdicmn.h>
|
|
#include <wx/string.h>
|
|
#include <optional>
|
|
|
|
@@ -89,7 +90,66 @@ struct adl_serializer<std::optional<T>>
|
|
}
|
|
}
|
|
};
|
|
+
|
|
+// Clang-specific stubs for wxPoint, wxSize, wxRect
|
|
+#ifdef __clang__
|
|
+template <>
|
|
+ struct adl_serializer<wxPoint>
|
|
+ {
|
|
+ static void to_json(json& j, const wxPoint& p)
|
|
+ {
|
|
+ j["x"] = p.x;
|
|
+ j["y"] = p.y;
|
|
+ }
|
|
+
|
|
+ static void from_json(const json& j, wxPoint& p)
|
|
+ {
|
|
+ j.at("x").get_to(p.x);
|
|
+ j.at("y").get_to(p.y);
|
|
+ }
|
|
+ };
|
|
+
|
|
+ template <>
|
|
+ struct adl_serializer<wxSize>
|
|
+ {
|
|
+ static void to_json(json& j, const wxSize& s)
|
|
+ {
|
|
+ j["width"] = s.GetWidth();
|
|
+ j["height"] = s.GetHeight();
|
|
+ }
|
|
+
|
|
+ static void from_json(const json& j, wxSize& s)
|
|
+ {
|
|
+ int w, h;
|
|
+ j.at("width").get_to(w);
|
|
+ j.at("height").get_to(h);
|
|
+ s = wxSize(w, h);
|
|
+ }
|
|
+ };
|
|
+
|
|
+ template <>
|
|
+ struct adl_serializer<wxRect>
|
|
+ {
|
|
+ static void to_json(json& j, const wxRect& r)
|
|
+ {
|
|
+ j["x"] = r.x;
|
|
+ j["y"] = r.y;
|
|
+ j["width"] = r.width;
|
|
+ j["height"] = r.height;
|
|
+ }
|
|
+
|
|
+ static void from_json(const json& j, wxRect& r)
|
|
+ {
|
|
+ int x, y, w, h;
|
|
+ j.at("x").get_to(x);
|
|
+ j.at("y").get_to(y);
|
|
+ j.at("width").get_to(w);
|
|
+ j.at("height").get_to(h);
|
|
+ r = wxRect(x, y, w, h);
|
|
+ }
|
|
+ };
|
|
+#endif // __clang__
|
|
} // namespace nlohmann
|
|
|
|
|
|
-#endif // JSON_SERIALIZERS_H_
|
|
\ No newline at end of file
|
|
+#endif // JSON_SERIALIZERS_H_
|
|
--
|