From 522fbb57fef406b41b8522d2028f911ef1065d1d Mon Sep 17 00:00:00 2001 From: Isabel Paredes Date: Tue, 12 Mar 2024 10:20:01 +0100 Subject: [PATCH] Remove deprecated functions (#386) Remove deprecated APIs --- include/xeus/xeus_context.hpp | 19 --- include/xeus/xhelper.hpp | 5 +- include/xeus/xsystem.hpp | 5 - src/xhelper.cpp | 5 - test/test_unit_kernel.cpp | 6 +- test/xmock_server.cpp | 268 +++++++++++++++++----------------- test/xmock_server.hpp | 17 ++- 7 files changed, 156 insertions(+), 169 deletions(-) diff --git a/include/xeus/xeus_context.hpp b/include/xeus/xeus_context.hpp index 99b9af02..75e4004b 100644 --- a/include/xeus/xeus_context.hpp +++ b/include/xeus/xeus_context.hpp @@ -17,10 +17,6 @@ namespace xeus { - struct [[deprecated]] xempty_context_tag - { - }; - template class xcontext_impl; @@ -68,21 +64,6 @@ namespace xeus return impl->m_context; } - // Deprecated: call the make_xxx_context function from the library providing the - // server implementation - template - std::unique_ptr> make_context(U&&... u) - { - return std::unique_ptr>(new xcontext_impl(std::forward(u)...)); - } - - [[deprecated]] - inline std::unique_ptr> make_empty_context() - { - return std::unique_ptr>( - new xcontext_impl() - ); - } } #endif diff --git a/include/xeus/xhelper.hpp b/include/xeus/xhelper.hpp index 90db251a..f04f8570 100644 --- a/include/xeus/xhelper.hpp +++ b/include/xeus/xhelper.hpp @@ -23,10 +23,7 @@ namespace nl = nlohmann; namespace xeus { - XEUS_API std::string get_started_message(const xconfiguration& config); - - [[deprecated("Use get_started_message instead")]] - XEUS_API std::string print_starting_message(const xconfiguration& config); + XEUS_API std::string get_starting_message(const xconfiguration& config); XEUS_API std::string extract_filename(int argc, char* argv[]); diff --git a/include/xeus/xsystem.hpp b/include/xeus/xsystem.hpp index b2703bf5..5ac62d66 100644 --- a/include/xeus/xsystem.hpp +++ b/include/xeus/xsystem.hpp @@ -25,11 +25,6 @@ namespace xeus XEUS_API int get_current_pid(); - [[deprecated]] XEUS_API - std::string get_cell_tmp_file(const std::string& prefix, - int execution_count, - const std::string& extension); - XEUS_API std::size_t get_tmp_hash_seed(); diff --git a/src/xhelper.cpp b/src/xhelper.cpp index eefc70ab..2a325066 100644 --- a/src/xhelper.cpp +++ b/src/xhelper.cpp @@ -30,11 +30,6 @@ namespace xeus return kernel_info; } - std::string print_starting_message(const xconfiguration& config) - { - return get_starting_message(config); - } - std::string extract_filename(int argc, char* argv[]) { std::string res = ""; diff --git a/test/test_unit_kernel.cpp b/test/test_unit_kernel.cpp index 01c34a43..e8841349 100644 --- a/test/test_unit_kernel.cpp +++ b/test/test_unit_kernel.cpp @@ -28,9 +28,9 @@ namespace xeus { TEST_SUITE("kernel") { - TEST_CASE("print_starting_message") + TEST_CASE("get_starting_message") { - auto context = make_empty_context(); + auto context = make_mock_context(); using interpreter_ptr = std::unique_ptr; interpreter_ptr interpreter = interpreter_ptr(new xmock_interpreter()); @@ -38,7 +38,7 @@ namespace xeus std::move(context), std::move(interpreter), make_mock_server); - std::string kernel_config = print_starting_message(kernel.get_config()); + std::string kernel_config = get_starting_message(kernel.get_config()); std::cout << kernel_config << std::endl; size_t pos = kernel_config.find("Starting kernel...\n" "\n" diff --git a/test/xmock_server.cpp b/test/xmock_server.cpp index 8cfd9ea7..4c60d6e4 100644 --- a/test/xmock_server.cpp +++ b/test/xmock_server.cpp @@ -12,133 +12,141 @@ namespace xeus { -xmock_messenger::xmock_messenger(xmock_server* server) - : p_server(server) -{ -} - -nl::json xmock_messenger::send_to_shell_impl(const nl::json& message) -{ - return p_server->notify_internal_listener(message); -} - -xmock_server::xmock_server() - : m_messenger(this) -{ -} - -void xmock_server::receive_shell(xmessage message) -{ - m_shell_messages.push(std::move(message)); -} - -void xmock_server::receive_control(xmessage message) -{ - m_control_messages.push(std::move(message)); -} - -void xmock_server::receive_stdin(xmessage message) -{ - m_stdin_messages.push(std::move(message)); -} - -std::size_t xmock_server::shell_size() const -{ - return m_shell_messages.size(); -} - -xmessage xmock_server::read_shell() -{ - return read_impl(m_shell_messages); -} - -std::size_t xmock_server::control_size() const -{ - return m_control_messages.size(); -} - -xmessage xmock_server::read_control() -{ - return read_impl(m_control_messages); -} - -std::size_t xmock_server::stdin_size() const -{ - return m_stdin_messages.size(); -} - -xmessage xmock_server::read_stdin() -{ - return read_impl(m_stdin_messages); -} - -std::size_t xmock_server::iopub_size() const -{ - return m_iopub_messages.size(); -} - -xpub_message xmock_server::read_iopub() -{ - xpub_message res = std::move(m_iopub_messages.back()); - m_iopub_messages.pop(); - return res; -} - -xmessage xmock_server::read_impl(message_queue& q) -{ - xmessage res = std::move(q.back()); - q.pop(); - return res; -} - -xcontrol_messenger& xmock_server::get_control_messenger_impl() -{ - return m_messenger; -} - -void xmock_server::send_shell_impl(xmessage message) -{ - m_shell_messages.push(std::move(message)); -} - -void xmock_server::send_control_impl(xmessage message) -{ - m_control_messages.push(std::move(message)); -} - -void xmock_server::send_stdin_impl(xmessage message) -{ - m_stdin_messages.push(std::move(message)); -} - -void xmock_server::publish_impl(xpub_message message, channel) -{ - m_iopub_messages.push(std::move(message)); -} - -void xmock_server::start_impl(xpub_message message) -{ - m_iopub_messages.push(std::move(message)); -} - -void xmock_server::abort_queue_impl(const listener&, long) -{ -} - -void xmock_server::stop_impl() -{ -} - -void xmock_server::update_config_impl(xconfiguration&) const -{ -} - -std::unique_ptr make_mock_server(xcontext&, - const xconfiguration&, - nl::json::error_handler_t) -{ - return std::make_unique(); -} - -} - + xmock_messenger::xmock_messenger(xmock_server* server) + : p_server(server) + { + } + + nl::json xmock_messenger::send_to_shell_impl(const nl::json& message) + { + return p_server->notify_internal_listener(message); + } + + xmock_server::xmock_server() + : m_messenger(this) + { + } + + void xmock_server::receive_shell(xmessage message) + { + m_shell_messages.push(std::move(message)); + } + + void xmock_server::receive_control(xmessage message) + { + m_control_messages.push(std::move(message)); + } + + void xmock_server::receive_stdin(xmessage message) + { + m_stdin_messages.push(std::move(message)); + } + + std::size_t xmock_server::shell_size() const + { + return m_shell_messages.size(); + } + + xmessage xmock_server::read_shell() + { + return read_impl(m_shell_messages); + } + + std::size_t xmock_server::control_size() const + { + return m_control_messages.size(); + } + + xmessage xmock_server::read_control() + { + return read_impl(m_control_messages); + } + + std::size_t xmock_server::stdin_size() const + { + return m_stdin_messages.size(); + } + + xmessage xmock_server::read_stdin() + { + return read_impl(m_stdin_messages); + } + + std::size_t xmock_server::iopub_size() const + { + return m_iopub_messages.size(); + } + + xpub_message xmock_server::read_iopub() + { + xpub_message res = std::move(m_iopub_messages.back()); + m_iopub_messages.pop(); + return res; + } + + xmessage xmock_server::read_impl(message_queue& q) + { + xmessage res = std::move(q.back()); + q.pop(); + return res; + } + + xcontrol_messenger& xmock_server::get_control_messenger_impl() + { + return m_messenger; + } + + void xmock_server::send_shell_impl(xmessage message) + { + m_shell_messages.push(std::move(message)); + } + + void xmock_server::send_control_impl(xmessage message) + { + m_control_messages.push(std::move(message)); + } + + void xmock_server::send_stdin_impl(xmessage message) + { + m_stdin_messages.push(std::move(message)); + } + + void xmock_server::publish_impl(xpub_message message, channel) + { + m_iopub_messages.push(std::move(message)); + } + + void xmock_server::start_impl(xpub_message message) + { + m_iopub_messages.push(std::move(message)); + } + + void xmock_server::abort_queue_impl(const listener&, long) + { + } + + void xmock_server::stop_impl() + { + } + + void xmock_server::update_config_impl(xconfiguration&) const + { + } + + std::unique_ptr make_mock_server(xcontext&, + const xconfiguration&, + nl::json::error_handler_t) + { + return std::make_unique(); + } + + xmock_context::xmock_context() : xcontext() + { + } + + std::unique_ptr make_mock_context() + { + return std::make_unique(); + } + +} // namespace xeus diff --git a/test/xmock_server.hpp b/test/xmock_server.hpp index d7f56d43..09090d2d 100644 --- a/test/xmock_server.hpp +++ b/test/xmock_server.hpp @@ -42,10 +42,10 @@ namespace xeus xmock_server(); virtual ~xmock_server() = default; - + xmock_server(const xmock_server&) = delete; xmock_server& operator=(const xmock_server&) = delete; - + xmock_server(xmock_server&&) = delete; xmock_server& operator=(xmock_server&&) = delete; @@ -58,7 +58,7 @@ namespace xeus std::size_t control_size() const; xmessage read_control(); - + std::size_t stdin_size() const; xmessage read_stdin(); @@ -95,6 +95,17 @@ namespace xeus std::unique_ptr make_mock_server(xcontext& context, const xconfiguration& config, nl::json::error_handler_t eh); + + class xmock_context : public xcontext + { + public: + + xmock_context(); + ~xmock_context() = default; + + }; + + std::unique_ptr make_mock_context(); } #endif