From 5a5f265d8688e534270f451cbd13cd74b93fd181 Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Tue, 7 May 2024 16:37:15 +0200 Subject: [PATCH] Wraps nlohmann_json include --- CMakeLists.txt | 1 + include/xeus/xcomm.hpp | 7 +++---- include/xeus/xcontrol_messenger.hpp | 3 +-- include/xeus/xdebugger.hpp | 11 +++++------ include/xeus/xeus_context.hpp | 2 +- include/xeus/xguid.hpp | 2 +- include/xeus/xhelper.hpp | 3 +-- include/xeus/xhistory_manager.hpp | 5 ++--- include/xeus/xinterpreter.hpp | 10 +++++----- include/xeus/xjson.hpp | 25 +++++++++++++++++++++++++ include/xeus/xkernel.hpp | 17 +++++++++-------- include/xeus/xkernel_configuration.hpp | 2 +- include/xeus/xlogger.hpp | 7 +++---- include/xeus/xmessage.hpp | 4 ++-- include/xeus/xrequest_context.hpp | 2 +- include/xeus/xserver.hpp | 8 ++++---- include/xeus/xsystem.hpp | 2 +- src/xhistory_manager.cpp | 2 -- src/xin_memory_history_manager.cpp | 2 +- src/xkernel_configuration.cpp | 3 +-- src/xkernel_core.hpp | 1 - src/xlogger_impl.cpp | 3 +-- 22 files changed, 69 insertions(+), 53 deletions(-) create mode 100644 include/xeus/xjson.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index e0be89b4..baa02d13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,7 @@ set(XEUS_HEADERS ${XEUS_INCLUDE_DIR}/xeus/xhistory_manager.hpp ${XEUS_INCLUDE_DIR}/xeus/xinput.hpp ${XEUS_INCLUDE_DIR}/xeus/xinterpreter.hpp + ${XEUS_INCLUDE_DIR}/xeus/xjson.hpp ${XEUS_INCLUDE_DIR}/xeus/xkernel.hpp ${XEUS_INCLUDE_DIR}/xeus/xkernel_configuration.hpp ${XEUS_INCLUDE_DIR}/xeus/xlogger.hpp diff --git a/include/xeus/xcomm.hpp b/include/xeus/xcomm.hpp index 63e6871f..a0d409eb 100644 --- a/include/xeus/xcomm.hpp +++ b/include/xeus/xcomm.hpp @@ -16,10 +16,9 @@ #include #include -#include "nlohmann/json.hpp" - -#include "xguid.hpp" -#include "xmessage.hpp" +#include "xeus/xguid.hpp" +#include "xeus/xjson.hpp" +#include "xeus/xmessage.hpp" namespace nl = nlohmann; diff --git a/include/xeus/xcontrol_messenger.hpp b/include/xeus/xcontrol_messenger.hpp index 32160174..0560e7da 100644 --- a/include/xeus/xcontrol_messenger.hpp +++ b/include/xeus/xcontrol_messenger.hpp @@ -10,9 +10,8 @@ #ifndef XEUS_CONTROL_MESSENGER_HPP #define XEUS_CONTROL_MESSENGER_HPP -#include "nlohmann/json.hpp" - #include "xeus/xeus.hpp" +#include "xeus/xjson.hpp" namespace nl = nlohmann; diff --git a/include/xeus/xdebugger.hpp b/include/xeus/xdebugger.hpp index 637c7e33..aa90ac67 100644 --- a/include/xeus/xdebugger.hpp +++ b/include/xeus/xdebugger.hpp @@ -10,12 +10,11 @@ #ifndef XEUS_DEBUGGER_HPP #define XEUS_DEBUGGER_HPP -#include "nlohmann/json.hpp" - -#include "xeus.hpp" -#include "xeus_context.hpp" -#include "xkernel_configuration.hpp" -#include "xcontrol_messenger.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xeus_context.hpp" +#include "xeus/xjson.hpp" +#include "xeus/xkernel_configuration.hpp" +#include "xeus/xcontrol_messenger.hpp" namespace nl = nlohmann; diff --git a/include/xeus/xeus_context.hpp b/include/xeus/xeus_context.hpp index 75e4004b..c4297851 100644 --- a/include/xeus/xeus_context.hpp +++ b/include/xeus/xeus_context.hpp @@ -12,7 +12,7 @@ #include -#include "xeus.hpp" +#include "xeus/xeus.hpp" namespace xeus { diff --git a/include/xeus/xguid.hpp b/include/xeus/xguid.hpp index d8eb8178..eb752025 100644 --- a/include/xeus/xguid.hpp +++ b/include/xeus/xguid.hpp @@ -12,7 +12,7 @@ #include "xtl/xbasic_fixed_string.hpp" -#include "xeus.hpp" +#include "xeus/xeus.hpp" namespace xeus { diff --git a/include/xeus/xhelper.hpp b/include/xeus/xhelper.hpp index 08be171b..6ff3b692 100644 --- a/include/xeus/xhelper.hpp +++ b/include/xeus/xhelper.hpp @@ -15,10 +15,9 @@ #include #include "xeus/xeus.hpp" +#include "xeus/xjson.hpp" #include "xeus/xkernel_configuration.hpp" -#include "nlohmann/json.hpp" - namespace nl = nlohmann; namespace xeus diff --git a/include/xeus/xhistory_manager.hpp b/include/xeus/xhistory_manager.hpp index 97f58b10..503dbfbd 100644 --- a/include/xeus/xhistory_manager.hpp +++ b/include/xeus/xhistory_manager.hpp @@ -13,9 +13,8 @@ #include #include -#include "nlohmann/json.hpp" - -#include "xeus.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xjson.hpp" namespace nl = nlohmann; diff --git a/include/xeus/xinterpreter.hpp b/include/xeus/xinterpreter.hpp index 619e2dc4..8ebc7afb 100644 --- a/include/xeus/xinterpreter.hpp +++ b/include/xeus/xinterpreter.hpp @@ -14,11 +14,11 @@ #include #include -#include "xcomm.hpp" -#include "xeus.hpp" -#include "xcontrol_messenger.hpp" -#include "xhistory_manager.hpp" -#include "xrequest_context.hpp" +#include "xeus/xcomm.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xcontrol_messenger.hpp" +#include "xeus/xhistory_manager.hpp" +#include "xeus/xrequest_context.hpp" namespace xeus { diff --git a/include/xeus/xjson.hpp b/include/xeus/xjson.hpp new file mode 100644 index 00000000..62690a2f --- /dev/null +++ b/include/xeus/xjson.hpp @@ -0,0 +1,25 @@ +/*************************************************************************** +* Copyright (c) 2016, Johan Mabille, Sylvain Corlay, Martin Renou * +* Copyright (c) 2016, QuantStack * +* * +* Distributed under the terms of the BSD 3-Clause License. * +* * +* The full license is in the file LICENSE, distributed with this software. * +****************************************************************************/ + +#ifndef XEUS_JSON_HPP +#define XEUS_JSON_HPP + +// Remove annoying false positive warning on GCC: json.hpp:1394:23: warning: potential null pointer dereference +// See https://github.com/nlohmann/json/issues/3525 +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wnull-dereference" +# include "nlohmann/json.hpp" +# pragma GCC diagnostic pop +#else +# include "nlohmann/json.hpp" +#endif + +#endif + diff --git a/include/xeus/xkernel.hpp b/include/xeus/xkernel.hpp index 08075155..a0fb52ab 100644 --- a/include/xeus/xkernel.hpp +++ b/include/xeus/xkernel.hpp @@ -10,18 +10,19 @@ #ifndef XEUS_KERNEL_HPP #define XEUS_KERNEL_HPP -#include "xdebugger.hpp" -#include "xeus.hpp" -#include "xeus_context.hpp" -#include "xhistory_manager.hpp" -#include "xinterpreter.hpp" -#include "xkernel_configuration.hpp" -#include "xserver.hpp" -#include "xlogger.hpp" #include #include #include +#include "xeus/xdebugger.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xeus_context.hpp" +#include "xeus/xhistory_manager.hpp" +#include "xeus/xinterpreter.hpp" +#include "xeus/xkernel_configuration.hpp" +#include "xeus/xserver.hpp" +#include "xeus/xlogger.hpp" + namespace xeus { class xkernel_core; diff --git a/include/xeus/xkernel_configuration.hpp b/include/xeus/xkernel_configuration.hpp index d3e79e12..b01375a9 100644 --- a/include/xeus/xkernel_configuration.hpp +++ b/include/xeus/xkernel_configuration.hpp @@ -12,7 +12,7 @@ #include -#include "xeus.hpp" +#include "xeus/xeus.hpp" namespace xeus { diff --git a/include/xeus/xlogger.hpp b/include/xeus/xlogger.hpp index 404dfd04..83b76e22 100644 --- a/include/xeus/xlogger.hpp +++ b/include/xeus/xlogger.hpp @@ -12,10 +12,9 @@ #include -#include "nlohmann/json.hpp" - -#include "xeus.hpp" -#include "xmessage.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xjson.hpp" +#include "xeus/xmessage.hpp" namespace nl = nlohmann; diff --git a/include/xeus/xmessage.hpp b/include/xeus/xmessage.hpp index 010e309e..1119a689 100644 --- a/include/xeus/xmessage.hpp +++ b/include/xeus/xmessage.hpp @@ -13,8 +13,8 @@ #include #include -#include "nlohmann/json.hpp" -#include "xeus.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xjson.hpp" namespace nl = nlohmann; diff --git a/include/xeus/xrequest_context.hpp b/include/xeus/xrequest_context.hpp index 9de54c9a..0aa36b55 100644 --- a/include/xeus/xrequest_context.hpp +++ b/include/xeus/xrequest_context.hpp @@ -12,7 +12,7 @@ #include #include "xeus/xeus.hpp" -#include "nlohmann/json.hpp" +#include "xeus/xjson.hpp" #include "xeus/xmessage.hpp" // for xmessage::guid_list #include "xeus/xserver.hpp" // for channel diff --git a/include/xeus/xserver.hpp b/include/xeus/xserver.hpp index 813743fc..7a1ae20d 100644 --- a/include/xeus/xserver.hpp +++ b/include/xeus/xserver.hpp @@ -12,10 +12,10 @@ #include -#include "xeus.hpp" -#include "xkernel_configuration.hpp" -#include "xcontrol_messenger.hpp" -#include "xmessage.hpp" +#include "xeus/xeus.hpp" +#include "xeus/xkernel_configuration.hpp" +#include "xeus/xcontrol_messenger.hpp" +#include "xeus/xmessage.hpp" namespace xeus { diff --git a/include/xeus/xsystem.hpp b/include/xeus/xsystem.hpp index 5ac62d66..86f0fb12 100644 --- a/include/xeus/xsystem.hpp +++ b/include/xeus/xsystem.hpp @@ -12,7 +12,7 @@ #include -#include "xeus.hpp" +#include "xeus/xeus.hpp" namespace xeus { diff --git a/src/xhistory_manager.cpp b/src/xhistory_manager.cpp index 78090598..73c017ef 100644 --- a/src/xhistory_manager.cpp +++ b/src/xhistory_manager.cpp @@ -10,8 +10,6 @@ #include #include -#include "nlohmann/json.hpp" - #include "xeus/xhistory_manager.hpp" #include "xin_memory_history_manager.hpp" diff --git a/src/xin_memory_history_manager.cpp b/src/xin_memory_history_manager.cpp index aa5613e9..cd2c8374 100644 --- a/src/xin_memory_history_manager.cpp +++ b/src/xin_memory_history_manager.cpp @@ -12,7 +12,7 @@ #include #include -#include "nlohmann/json.hpp" +#include "xeus/xjson.hpp" #include "xin_memory_history_manager.hpp" diff --git a/src/xkernel_configuration.cpp b/src/xkernel_configuration.cpp index 05544014..b3cda80f 100644 --- a/src/xkernel_configuration.cpp +++ b/src/xkernel_configuration.cpp @@ -10,8 +10,7 @@ #include #include -#include "nlohmann/json.hpp" - +#include "xeus/xjson.hpp" #include "xeus/xkernel_configuration.hpp" namespace nl = nlohmann; diff --git a/src/xkernel_core.hpp b/src/xkernel_core.hpp index d7904fe5..6391f47e 100644 --- a/src/xkernel_core.hpp +++ b/src/xkernel_core.hpp @@ -68,7 +68,6 @@ namespace xeus xcomm_manager& comm_manager() & noexcept; const xcomm_manager& comm_manager() const & noexcept; xcomm_manager comm_manager() const && noexcept; - const nl::json& parent_header(channel c) const noexcept; private: diff --git a/src/xlogger_impl.cpp b/src/xlogger_impl.cpp index ff373ac7..0c79dfe6 100644 --- a/src/xlogger_impl.cpp +++ b/src/xlogger_impl.cpp @@ -10,8 +10,7 @@ #include #include -#include "nlohmann/json.hpp" - +#include "xeus/xjson.hpp" #include "xeus/xmessage.hpp" #include "xlogger_impl.hpp"