Skip to content

Commit

Permalink
Merge pull request #140 from SylvainCorlay/xwidgets-fixups
Browse files Browse the repository at this point in the history
xwidgets fixups
  • Loading branch information
SylvainCorlay committed Apr 20, 2018
2 parents 5c7b161 + 7637568 commit 72c761a
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 20 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ set(XWIDGETS_HEADERS
${XWIDGETS_INCLUDE_DIR}/xwidgets/xlayout.hpp
${XWIDGETS_INCLUDE_DIR}/xwidgets/xlink.hpp
${XWIDGETS_INCLUDE_DIR}/xwidgets/xmaterialize.hpp
${XWIDGETS_INCLUDE_DIR}/xwidgets/xmaker.hpp
${XWIDGETS_INCLUDE_DIR}/xwidgets/xnumber.hpp
${XWIDGETS_INCLUDE_DIR}/xwidgets/xnumeral.hpp
${XWIDGETS_INCLUDE_DIR}/xwidgets/xobject.hpp
Expand Down
1 change: 1 addition & 0 deletions include/xwidgets/xcontroller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "xeus/xjson.hpp"

#include "xmaterialize.hpp"
#include "xmaker.hpp"
#include "xwidget.hpp"

namespace xw
Expand Down
28 changes: 11 additions & 17 deletions include/xwidgets/xholder.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/***************************************************************************
* Copyright (c) 2017, Sylvain Corlay and Johan Mabille *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XWIDGETS_HOLDER_HPP
#define XWIDGETS_HOLDER_HPP

Expand All @@ -8,12 +16,10 @@
#include "xtl/xany.hpp"
#include "xtl/xclosure.hpp"

#include "xeus/xcomm.hpp"
#include "xeus/xguid.hpp"
#include "xeus/xjson.hpp"

#include "xwidgets_config.hpp"
#include "xmaterialize.hpp"

namespace xw
{
Expand Down Expand Up @@ -481,18 +487,6 @@ namespace xw
return it->second;
}

/*******************
* xmaker template *
*******************/

template <template <class> class CRTP, class... P>
void xmaker(xeus::xcomm&& comm, const xeus::xjson& state, const xeus::buffer_sequence& buffers)
{
auto model = xgenerator<CRTP, P...>(std::move(comm), true);
model.apply_patch(state, buffers);
get_transport_registry().register_owning(reinterpret_cast<xmaterialize<CRTP, P...>&&>(model));
}

namespace detail
{
template <template <class> class CRTP>
Expand Down Expand Up @@ -553,9 +547,9 @@ namespace xw
return xholder<CRTP>(new detail::xholder_id<CRTP>(id));
}

/***********************************************************
* Specialization of cling::printValue for Jupyter Widgets *
***********************************************************/
/**********************************************************
* Specialization of mime_bundle_repr for Jupyter Widgets *
**********************************************************/

template <template <class> class CRTP>
xeus::xjson mime_bundle_repr(const xholder<CRTP>& val)
Expand Down
34 changes: 34 additions & 0 deletions include/xwidgets/xmaker.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/***************************************************************************
* Copyright (c) 2017, Sylvain Corlay and Johan Mabille *
* *
* Distributed under the terms of the BSD 3-Clause License. *
* *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef XWIDGETS_MAKER_HPP
#define XWIDGETS_MAKER_HPP

#include "xeus/xcomm.hpp"
#include "xeus/xjson.hpp"
#include "xeus/xmessage.hpp"

#include "xholder.hpp"
#include "xmaterialize.hpp"

namespace xw
{
/*******************
* xmaker template *
*******************/

template <template <class> class CRTP, class... P>
void xmaker(xeus::xcomm&& comm, const xeus::xjson& state, const xeus::buffer_sequence& buffers)
{
auto model = xgenerator<CRTP, P...>(std::move(comm), true);
model.apply_patch(state, buffers);
get_transport_registry().register_owning(reinterpret_cast<xmaterialize<CRTP, P...>&&>(model));
}
}

#endif
6 changes: 3 additions & 3 deletions include/xwidgets/xmaterialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ namespace xw
template <template <class> class B, class... P>
inline xgenerator<B, P...>& xgenerator<B, P...>::operator=(xgenerator&&) = default;

/***********************************************************
* Specialization of cling::printValue for Jupyter Widgets *
***********************************************************/
/**********************************************************
* Specialization of mime_bundle_repr for Jupyter Widgets *
**********************************************************/

template <template <class> class B, class... P>
xeus::xjson mime_bundle_repr(const xmaterialize<B, P...>& val)
Expand Down

0 comments on commit 72c761a

Please sign in to comment.