diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd15a39..0cdc599 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,7 +129,6 @@ jobs: source $CONDA_EMSDK_DIR/emsdk_env.sh micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32 - mkdir build pushd build diff --git a/CMakeLists.txt b/CMakeLists.txt index 251ab90..ccfa9d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,18 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") set(XEUS_LUA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) + +# PRINT THE COMPILER +message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") + +if(EMSCRIPTEN) + message(STATUS "EMSCRIPTEN") +else() + message(STATUS "NOT EMSCRIPTEN") +endif() + + + # Versionning # =========== @@ -77,28 +89,19 @@ endif() # Dependencies # ============ -set(xtl_REQUIRED_VERSION 0.7.0) -set(xeus_REQUIRED_VERSION 3.0.0) -set(xwidgets_REQUIRED_VERSION 0.27.0) -set(xcanvas_REQUIRED_VERSION 0.3.0) -set(xproperty_REQUIRED_VERSION 0.11.0) + +set(xeus_REQUIRED_VERSION 5.0.0) +set(xwidgets_REQUIRED_VERSION 0.29.0) +set(xcanvas_REQUIRED_VERSION 0.5.0) +set(xproperty_REQUIRED_VERSION 0.12.0) set(Lua_REQUIRED_VERSION 5.3.4) -if (NOT TARGET xtl) - find_package(xtl ${xtl_REQUIRED_VERSION} REQUIRED) -endif () -if (NOT TARGET xeus AND NOT TARGET xeus-static) - find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED) -endif () +find_package(xeus ${xeus_REQUIRED_VERSION} REQUIRED) if(NOT XEUS_LUA_USE_LUAJIT) - if (NOT TARGET Lua) # not sure about these lines - find_package(Lua ${lua_REQUIRED_VERSION} REQUIRED) - endif () + find_package(Lua ${lua_REQUIRED_VERSION} REQUIRED) else() - if (NOT TARGET LuaJIT) # not sure about these lines - find_package(LuaJIT REQUIRED) - endif () + find_package(LuaJIT REQUIRED) endif() # Flags @@ -315,7 +318,7 @@ macro(xeus_lua_create_target target_name linkage output_name) set(XLUA_XCANVAS_TARGET "") endif() - target_link_libraries(${target_name} PUBLIC ${XEUS_LUA_XEUS_TARGET} xtl + target_link_libraries(${target_name} PUBLIC ${XEUS_LUA_XEUS_TARGET} ${XLUA_XWIDGETS_TARGET} ${XLUA_XPROPERTY_TARGET} ${XLUA_XCANVAS_TARGET} @@ -373,12 +376,12 @@ endif() if(EMSCRIPTEN) include(WasmBuildOptions) find_package(xeus-lite REQUIRED) - add_executable(xlua src/main_emscripten_kernel.cpp ) - target_link_libraries(xlua PRIVATE xeus-lite) - target_compile_features(xlua PRIVATE cxx_std_17) - xeus_lua_set_kernel_options(xlua) - xeus_wasm_compile_options(xlua) - xeus_wasm_link_options(xlua "web,worker") + add_executable(xlua_wasm src/main_emscripten_kernel.cpp ) + target_link_libraries(xlua_wasm PRIVATE xeus-lite) + target_compile_features(xlua_wasm PRIVATE cxx_std_17) + xeus_lua_set_kernel_options(xlua_wasm) + xeus_wasm_compile_options(xlua_wasm) + xeus_wasm_link_options(xlua_wasm "web,worker") endif() diff --git a/README.md b/README.md index 165ae67..b6540f3 100644 --- a/README.md +++ b/README.md @@ -117,14 +117,9 @@ the xeus ecosystem like [xwidgets](https://github.com/jupyter-xeus/xwidgets). `xeus-lua` depends on - [xeus](https://github.com/jupyter-xeus/xeus) -- [xtl](https://github.com/xtensor-stack/xtl) - [xwidgets](https://github.com/jupyter-xeus/xwidgets) - [lua](https://www.lua.org/) -| `xeus-lua` | `xeus` | `xwidgets` | `xtl` | `cppzmq` | `nlohmann_json` | `lua` | -| ------------- | ------------- | ------------- | ------------ | -------- | --------------- | ------------ | -| master | >=2.4.0,<3 | >=0.26.1 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<4.0 | >=5.2.0 | -| 0.6.2 | >=2.4.0,<3 | >=0.26.1 | >=0.7.0,<0.8 | ~4.4.1 | >=3.6.1,<4.0 | >=5.2.0 | ## Contributing diff --git a/environment-dev.yml b/environment-dev.yml index 75022bd..92a880d 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -6,13 +6,13 @@ dependencies: - cmake - cxx-compiler # Host dependencies - - xeus-zmq>=1.3.0, <2.0 - - nlohmann_json=3.11.2 + - xeus>=5.0,<=6 + - xeus-zmq + - nlohmann_json - cppzmq - - xtl>=0.7 - lua>=5.2.0 - openlibm # [linux] - - xwidgets <0.29 + - xwidgets >=0.29 - xcanvas>=0.4.2 # to try it out - jupyterlab diff --git a/environment-wasm-host.yml b/environment-wasm-host.yml index b7d014f..b56c6fb 100644 --- a/environment-wasm-host.yml +++ b/environment-wasm-host.yml @@ -5,8 +5,7 @@ channels: dependencies: - lua - nlohmann_json - - xeus-lite <2.0 - - xeus >=3.2.0,<4.0 - - xtl >=0.7,<0.8 - - xcanvas >=0.4,<5.0 - - xwidgets >=0.27.3,<1.0 + - xeus-lite >=2.0 + - xeus>=5.0,<=6 + - xcanvas >=0.5,<5.0 + - xwidgets >=0.28.0,<1.0 \ No newline at end of file diff --git a/include/xeus-lua/xinterpreter.hpp b/include/xeus-lua/xinterpreter.hpp index 14367c8..9fc5d1a 100644 --- a/include/xeus-lua/xinterpreter.hpp +++ b/include/xeus-lua/xinterpreter.hpp @@ -19,7 +19,7 @@ #include "xeus_lua_config.hpp" #include "xeus/xinterpreter.hpp" - +#include "xeus/xrequest_context.hpp" extern "C" { #ifndef XEUS_LUA_USE_LUAJIT @@ -47,12 +47,11 @@ namespace xlua void configure_impl() override; - nl::json execute_request_impl(int execution_counter, - const std::string& code, - bool silent, - bool store_history, - nl::json user_expressions, - bool allow_stdin) override; + void execute_request_impl(send_reply_callback cb, + int execution_counter, + const std::string& code, + xeus::execute_request_config config, + nl::json user_expressions) override; nl::json complete_request_impl(const std::string& code, int cursor_pos) override; diff --git a/src/main.cpp b/src/main.cpp index c0bd63e..5c25f5a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,7 +24,9 @@ #include "xeus/xkernel.hpp" #include "xeus/xkernel_configuration.hpp" #include "xeus/xserver.hpp" -#include "xeus-zmq/xserver_shell_main.hpp" + +#include "xeus-zmq/xserver_zmq_split.hpp" +#include "xeus-zmq/xzmq_context.hpp" #include "xeus-lua/xinterpreter.hpp" @@ -114,9 +116,7 @@ int main(int argc, char* argv[]) - using context_type = xeus::xcontext_impl; - using context_ptr = std::unique_ptr; - context_ptr context = context_ptr(new context_type()); + std::unique_ptr context = xeus::make_zmq_context(); // Instantiating the xeus xinterpreter using interpreter_ptr = std::unique_ptr; diff --git a/src/xdisplay.cpp b/src/xdisplay.cpp index 7aa62bf..287d039 100644 --- a/src/xdisplay.cpp +++ b/src/xdisplay.cpp @@ -23,7 +23,6 @@ namespace xlua - void setup_display( sol::state_view & lua, interpreter & interp diff --git a/src/xinterpreter.cpp b/src/xinterpreter.cpp index 386e14c..45061d3 100644 --- a/src/xinterpreter.cpp +++ b/src/xinterpreter.cpp @@ -176,15 +176,14 @@ namespace xlua { } - nl::json interpreter::execute_request_impl(int /*execution_count*/, + void interpreter::execute_request_impl(send_reply_callback cb, + int execution_count, const std::string& code, - bool silent, - bool /*store_history*/, - nl::json /*user_expressions*/, - bool allow_stdin) + xeus::execute_request_config config, + nl::json user_expressions) { sol::state_view lua(L); - m_allow_stdin = allow_stdin; + m_allow_stdin = config.allow_stdin; // reset payload nl::json kernel_res; @@ -220,7 +219,7 @@ namespace xlua sol::error err = code_result; sol::call_status status = code_result.status(); const auto error_str = err.what(); - if (!silent) + if (!config.silent) { publish_execution_error(error_str,error_str,std::vector(1,error_str)); } @@ -231,7 +230,7 @@ namespace xlua kernel_res["traceback"] = { error_str }; } } - return kernel_res; + cb(kernel_res); } nl::json interpreter::complete_request_impl( @@ -248,7 +247,7 @@ namespace xlua result["matches"] = matches; result["cursor_start"] = cursor_start; result["metadata"] = nl::json::object(); - result["cursor_end"] = cursor_pos; + result["cursor_end"] = cursor_pos; return result; } diff --git a/src/xwidgets.cpp b/src/xwidgets.cpp index 2f8e994..444545e 100644 --- a/src/xwidgets.cpp +++ b/src/xwidgets.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "sol/sol.hpp" #include "xeus/xinterpreter.hpp" @@ -158,7 +159,7 @@ namespace xlua #define XLUA_REGISTER_OPTIONAL_INDEX_OBSERVER(CLS_OBJ, PROPERTY_TYPE, PROPERTY_NAME) \ CLS_OBJ["register_observer"] = [](xwidgets_type & widget, sol::protected_function function){ \ auto callback = [function](const auto& s) { \ - auto res = function.call(xtl::xoptional(s.PROPERTY_NAME).value()+1); \ + auto res = function.call(std::optional(s.PROPERTY_NAME).value()+1); \ if (!res.valid()) \ { \ auto & interpreter = xeus::get_interpreter(); \ diff --git a/xeus-luaConfig.cmake.in b/xeus-luaConfig.cmake.in index 6275b6f..0de39e8 100644 --- a/xeus-luaConfig.cmake.in +++ b/xeus-luaConfig.cmake.in @@ -22,7 +22,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR};${CMAKE_MODULE_PATH}") @XEUS_LUA_CONFIG_CODE@ include(CMakeFindDependencyMacro) -find_dependency(xtl @xtl_REQUIRED_VERSION@) + find_dependency(xeus @xeus_REQUIRED_VERSION@) find_dependency(cppzmq @cppzmq_REQUIRED_VERSION@) find_dependency(Lua @Lua_REQUIRED_VERSION@)