Skip to content

Commit

Permalink
Merge pull request #177 from JohanMabille/api
Browse files Browse the repository at this point in the history
Moved xdebugger.hpp to include folder
  • Loading branch information
JohanMabille authored Nov 19, 2019
2 parents 8716492 + 46b89b0 commit 33e3f43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib; ${CMAKE_INSTALL_PREFIX}/${
set(XEUS_PYTHON_SRC
src/xcomm.cpp
src/xcomm.hpp
src/xdebugger.hpp
src/xdebugger.cpp
src/xdisplay.cpp
src/xdisplay.hpp
Expand All @@ -116,8 +115,9 @@ set(XEUS_PYTHON_SRC
)

set(XEUS_PYTHON_HEADERS
include/xeus-python/xinterpreter.hpp
include/xeus-python/xdebugger.hpp
include/xeus-python/xeus_python_config.hpp
include/xeus-python/xinterpreter.hpp
include/xeus-python/xpythonhome.hpp
)

Expand Down
9 changes: 5 additions & 4 deletions src/xdebugger.hpp → include/xeus-python/xdebugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
#include "zmq.hpp"
#include "nlohmann/json.hpp"
#include "xeus/xdebugger.hpp"
#include "xptvsd_client.hpp"

#include "xeus-python/xeus_python_config.hpp"
#include "xeus_python_config.hpp"

namespace xpyt
{

class xptvsd_client;

class XEUS_PYTHON_API debugger : public xeus::xdebugger
{
public:
Expand All @@ -33,7 +34,7 @@ namespace xpyt
const std::string& user_name,
const std::string& session_id);

virtual ~debugger() = default;
virtual ~debugger();

private:

Expand All @@ -52,7 +53,7 @@ namespace xpyt
void stop();
void handle_event(const nl::json& message);

xptvsd_client m_ptvsd_client;
xptvsd_client* p_ptvsd_client;
zmq::socket_t m_ptvsd_socket;
zmq::socket_t m_ptvsd_header;
// PTVSD cannot be started on different ports in a same process
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "xeus-python/xinterpreter.hpp"
#include "xeus-python/xpythonhome.hpp"
#include "xdebugger.hpp"
#include "xeus-python/xdebugger.hpp"

namespace py = pybind11;

Expand Down
15 changes: 11 additions & 4 deletions src/xdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
#include "xeus/xmiddleware.hpp"
#include "xeus/xsystem.hpp"

#include "xdebugger.hpp"
#include "xeus-python/xdebugger.hpp"
#include "xptvsd_client.hpp"
#include "xutils.hpp"

namespace nl = nlohmann;
Expand All @@ -41,8 +42,8 @@ namespace xpyt
const xeus::xconfiguration& config,
const std::string& user_name,
const std::string& session_id)
: m_ptvsd_client(context, config, xeus::get_socket_linger(), user_name, session_id,
std::bind(&debugger::handle_event, this, _1))
: p_ptvsd_client(new xptvsd_client(context, config, xeus::get_socket_linger(), user_name, session_id,
std::bind(&debugger::handle_event, this, _1)))
, m_ptvsd_socket(context, zmq::socket_type::req)
, m_ptvsd_header(context, zmq::socket_type::req)
, m_ptvsd_port("")
Expand All @@ -53,6 +54,12 @@ namespace xpyt
m_ptvsd_port = xeus::find_free_port(100, 5678, 5900);
}

debugger::~debugger()
{
delete p_ptvsd_client;
p_ptvsd_client = nullptr;
}

nl::json debugger::process_request_impl(const nl::json& header,
const nl::json& message)
{
Expand Down Expand Up @@ -345,7 +352,7 @@ namespace xpyt

std::string ptvsd_end_point = "tcp://" + host + ':' + m_ptvsd_port;
std::thread client(&xptvsd_client::start_debugger,
&m_ptvsd_client,
p_ptvsd_client,
ptvsd_end_point,
publisher_end_point,
controller_end_point,
Expand Down

0 comments on commit 33e3f43

Please sign in to comment.