From 3487e3780cedf9f13589e6da53089ba9e76ec18d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:01:49 -0400 Subject: [PATCH 01/18] initial implementation --- CMakeLists.txt | 44 ++++++++++ README.md | 61 +++++++++++++ cmake/xo_pyreactorConfig.cmake.in | 4 + include/README.md | 1 + src/pyreactor/CMakeLists.txt | 8 ++ src/pyreactor/pyreactor.cpp | 141 ++++++++++++++++++++++++++++++ src/pyreactor/pyreactor.hpp.in | 25 ++++++ 7 files changed, 284 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 README.md create mode 100644 cmake/xo_pyreactorConfig.cmake.in create mode 100644 include/README.md create mode 100644 src/pyreactor/CMakeLists.txt create mode 100644 src/pyreactor/pyreactor.cpp create mode 100644 src/pyreactor/pyreactor.hpp.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..aec8d379 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,44 @@ +# xo-pyreactor/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_pyreactor VERSION 1.0) +enable_language(CXX) + +# common XO cmake macros (see github.com:Rconybea/xo-cmake) +include(xo_macros/xo_cxx) +include(xo_macros/code-coverage) + +# ---------------------------------------------------------------- +# unit test setup + +enable_testing() +# activate code coverage for all executables + libraries (when configured with -DCODE_COVERAGE=ON) +add_code_coverage() +# 1. assuming that /nix/store/ prefixes .hpp files belonging to gcc, catch2 etc. +# we're not interested in code coverage for these sources. +# 2. exclude the utest/ subdir, we don't need coverage on the unit tests themselves; +# rather, want coverage on the code that the unit tests exercise. +# +# NOTE: this seems to work only with the 'ccov-all' target. In particular, doesn't seem to do anything with the 'ccov' target +# +add_code_coverage_all_targets(EXCLUDE /nix/store/* ${PROJECT_SOURCE_DIR}/utest/* ${PROJECT_BINARY_DIR}/local/* ${PROJECT_SOURCE_DIR}/repo/*) + +# ---------------------------------------------------------------- +# c++ settings (usually temporary) + +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +xo_toplevel_compile_options() + +# ---------------------------------------------------------------- +# sources + +add_subdirectory(src/pyreactor) +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# provide find_package() support + +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) diff --git a/README.md b/README.md new file mode 100644 index 00000000..f618c641 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# python bindings for c++ reactor library (xo-reactor) + +## Getting Started + +### build + install dependencies + +- [github/Rconybea/xo-reactor](https://github.com/Rconybea/xo-reactor) +- [github/Rconybea/xo-pyutil](https://github.com/Rconybea/xo-pyutil) +- [github/Rconybea/xo-pyreflect](https://github.com/Rconybea/xo-pyreflect) +- [github/Rconybea/xo-pyprintjson](https://github.com/Rconybea/xo-pyprintjson) + +### build + install + +``` +$ cd xo-pyreactor +$ mkdir build +$ cd build +$ INSTALL_PREFIX=/usr/local # or wherever you prefer, e.g. ~/local +$ cmake \ + -DCMAKE_MODULE_PATH=${INSTALL_PREFIX}/share/cmake \ + -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \ + -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} .. +$ make +$ make install +``` +(also see .github/workflows/main.yml) + +## Development + +### build for unit test coverage +``` +$ cd xo-pyreactor +$ mkdir build-ccov +$ cd build-ccov +$ cmake \ + -DCMAKE_MODULE_PATH=${INSTALL_PREFIX}/share/cmake \ + -DCMAKE_PREFIX_PATH=${INSTALL_PREFIX} \ + -DCODE_COVERAGE=ON \ + -DCMAKE_BUILD_TYPE=Debug .. +``` + +### LSP (language server) support + +LSP looks for compile commands in the root of the source tree; +while Cmake creates them in the root of its build directory. + +``` +$ cd xo-pyreactor +$ ln -s build/compile_commands.json # supply compile commands to LSP +``` + +### display cmake variables + +- `-L` list variables +- `-A` include 'advanced' variables +- `-H` include help text + +``` +$ cd xo-pyreactor/build +$ cmake -LAH +``` diff --git a/cmake/xo_pyreactorConfig.cmake.in b/cmake/xo_pyreactorConfig.cmake.in new file mode 100644 index 00000000..9c15f36a --- /dev/null +++ b/cmake/xo_pyreactorConfig.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/include/README.md b/include/README.md new file mode 100644 index 00000000..4a0ad1c1 --- /dev/null +++ b/include/README.md @@ -0,0 +1 @@ +placeholder for future pyreactor #include files diff --git a/src/pyreactor/CMakeLists.txt b/src/pyreactor/CMakeLists.txt new file mode 100644 index 00000000..ad752e96 --- /dev/null +++ b/src/pyreactor/CMakeLists.txt @@ -0,0 +1,8 @@ +# xo_pyreactor/src/pyreactor/CMakeLists.txt + +set(SELF_LIB pyreactor) +set(SELF_SRCS pyreactor.cpp) + +xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) + +xo_pybind11_dependency(${SELF_LIB} reactor) diff --git a/src/pyreactor/pyreactor.cpp b/src/pyreactor/pyreactor.cpp new file mode 100644 index 00000000..5f8cf77b --- /dev/null +++ b/src/pyreactor/pyreactor.cpp @@ -0,0 +1,141 @@ +/* @file ReactorPy.cpp */ + +#include "pyreactor.hpp" +#include "xo/pyprintjson/pyprintjson.hpp" +#include "xo/pyreflect/pyreflect.hpp" + +#include "xo/reactor/Reactor.hpp" +#include "xo/reactor/ReactorSource.hpp" +#include "xo/reactor/EventStore.hpp" +#include "xo/reactor/Sink.hpp" +#include "xo/webutil/StreamEndpointDescr.hpp" +//#include "time/Time.hpp" + +//#include "xo/pyutil/pytime.hpp" +#include "xo/pyutil/pyutil.hpp" + +//#include +//#include +#include + +namespace xo { + using xo::json::PrintJsonSingleton; + using xo::fn::CallbackId; + using xo::ref::Refcount; + using xo::ref::rp; + using xo::time::utc_nanos; + using xo::tostr; + namespace py = pybind11; + + namespace reactor { + PYBIND11_MODULE(PYREACTOR_MODULE_NAME(), m) { + /* e.g. for TypeDescr */ + PYREFLECT_IMPORT_MODULE(); //py::module_::import("pyreflect"); + PYPRINTJSON_IMPORT_MODULE(); //py::module_::import("pyprintjson"); + + /* module docstring */ + m.doc() = "pybind11 plugin for xo.reactor"; + + m.def("time2str", [](utc_nanos tm) { return tostr(tm); }); + + /* TODO: if we write pycallback/, then CallbackId wrapper belongs there */ + py::class_(m, "CallbackId"); + + py::class_>(m, "AbstractEventProcessor") + .def_property("name", + &AbstractEventProcessor::name, + &AbstractEventProcessor::set_name) + .def("reference_counter", [](AbstractEventProcessor const & x) { return x.reference_counter(); }) + .def("memory_address", [](AbstractEventProcessor const & x) { return (void*)&x; }) + .def("map_network", [](AbstractEventProcessor & x) { return AbstractEventProcessor::map_network(&x); }) + .def("__repr__", &AbstractEventProcessor::display_string); + + py::class_>(m, "AbstractSource") + .def_property_readonly("source_ev_type", &AbstractSource::source_ev_type) + .def_property_readonly("is_volatile", &AbstractSource::is_volatile) + .def_property_readonly("n_out_ev", &AbstractSource::n_out_ev) + .def_property_readonly("n_queued_out_ev", &AbstractSource::n_queued_out_ev) + .def("attach_sink", &AbstractSource::attach_sink) + .def("detach_sink", &AbstractSource::detach_sink) + /* editor bait: websock_endpoint_descr */ + .def("stream_endpoint_descr", &AbstractSource::stream_endpoint_descr) + .def("deliver_one", &AbstractSource::deliver_one) + .def("deliver_n", &AbstractSource::deliver_n, + py::arg("n")); + + py::class_>(m, "AbstractSink") + //.cdef("__repr__", &AbstractSink::display_string) + .def_property_readonly("sink_ev_type", &AbstractSink::sink_ev_type) + .def_property_readonly("n_in_ev", &AbstractSink::n_in_ev) + .def("attach_source", &AbstractSink::attach_source); + + py::class_> + (m, "ReactorSource") + .def_property_readonly("is_empty", &ReactorSource::is_empty) + .def_property_readonly("is_nonempty", &ReactorSource::is_nonempty) + .def_property_readonly("is_exhausted", &ReactorSource::is_exhausted) + .def_property_readonly("sim_current_tm", &ReactorSource::sim_current_tm) + .def_property("debug_sim_flag", + &ReactorSource::debug_sim_flag, + &ReactorSource::set_debug_sim_flag); + + py::class_> + (m, "AbstractEventStore") + .def_property_readonly("empty", &AbstractEventStore::empty) + .def_property_readonly("size", &AbstractEventStore::size) + .def("http_snapshot", + [](AbstractEventStore & self) { + std::stringstream ss; + self.http_snapshot(PrintJsonSingleton::instance(), &ss); + return ss.str(); + }) + .def("http_endpoint_descr", + [](AbstractEventStore & self, std::string const & url_prefix) { + return self.http_endpoint_descr(PrintJsonSingleton::instance(), url_prefix); + }, + py::arg("url_prefix")) + .def("clear", + &AbstractEventStore::clear); + + py::class_> + (m, "Reactor") + .def("add_source", + [](Reactor & self, rp src) { + return self.add_source(src.borrow()); + }) + .def("remove_source", + [](Reactor & self, rp src) { + return self.remove_source(src.borrow()); + }) + .def("run_one", &Reactor::run_one) + .def("run_n", &Reactor::run_n, py::arg("n")); + +#ifdef NOT_IN_USE // trying removed code in ProcessPy.cpp instead for now + /* prints + * std::pair + * pairs + */ + m.def("make_realization_printer", + [] + { + return new SinkToConsole>(); + }); + + py::class_>, + AbstractSink, + xo::ref::rp>>> + (m, "SinkToConsole"); +#endif + } /*pyreactor*/ + } /*namespace reactor*/ +} /*namespace xo*/ + +/* end ReactorPy.cpp */ diff --git a/src/pyreactor/pyreactor.hpp.in b/src/pyreactor/pyreactor.hpp.in new file mode 100644 index 00000000..edbb2e78 --- /dev/null +++ b/src/pyreactor/pyreactor.hpp.in @@ -0,0 +1,25 @@ +/* @file pyreactor.hpp + * + * automatically generated from src/pyreflect/pyreactor.hpp.in + * see src/pyreactor/CMakeLists.txt + */ + +/* python requires module name = library name + * example: + * PYBIND11_MODULE(PYREACTOR_MODULE_NAME(), m) { ... } + */ +#define PYREACTOR_MODULE_NAME() @SELF_LIBRARY_NAME@ + +/* example: + * py::module_::import(PYREACTOR_MODULE_NAME_STR) + */ +#define PYREACTOR_MODULE_NAME_STR "@SELF_LIBRARY_NAME@" + +/* example: + * PYREACTOR_IMPORT_MODULE() + * replaces + * py::module_::import("pyreactor") + */ +#define PYREACTOR_IMPORT_MODULE() py::module_::import("@SELF_LIBRARY_NAME@") + +/* end pyreactor.hpp */ From cc1c42b8c35c3a724d933551d34669e79e67af6c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:02:09 -0400 Subject: [PATCH 02/18] + .gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..f52f1311 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# lsp keeps state here +.cache +# typical build directory +build +# lsp: symlink to file in build directory (established manually) +compile_commands.json From 060366684e54c0dd1a692e2237ffea3c3dbfeb38 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:16:29 -0400 Subject: [PATCH 03/18] github: + workflow --- .github/workflows/main.yml | 234 +++++++++++++++++++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..3bde7ce1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,234 @@ +name: build xo-pyreactor + dependencies + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. + # You can convert this to a matrix build if you need cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - name: checkout source + uses: actions/checkout@v3 + + - name: Install catch2 + # install catch2. see [[https://stackoverflow.com/questions/57982945/how-to-apt-get-install-in-a-github-actions-workflow]] + run: sudo apt-get install -y catch2 + + - name: Install pybind11-dev + run: sudo apt-get install -y pybind11-dev + + # ---------------------------------------------------------------- + + - name: Clone xo-cmake + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-cmake + path: repo/xo-cmake + + - name: Configure xo-cmake + run: cmake -B ${{github.workspace}}/build_xo-cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/xo-cmake + + - name: Build xo-cmake (trivial) + run: cmake --build ${{github.workspace}}/build_xo-cmake --config ${{env.BUILD_TYPE}} + + - name: Install xo-cmake + run: cmake --install ${{github.workspace}}/build_xo-cmake + + # ---------------------------------------------------------------- + + - name: Clone indentlog + uses: actions/checkout@v3 + with: + repository: Rconybea/indentlog + path: repo/indentlog + + - name: Configure indentlog + # configure cmake for indentlog in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_indentlog -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/indentlog + + - name: Build indentlog + run: cmake --build ${{github.workspace}}/build_indentlog --config ${{env.BUILD_TYPE}} + + - name: Install indentlog + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_indentlog + + # ---------------------------------------------------------------- + + - name: Clone subsys + uses: actions/checkout@v3 + with: + repository: Rconybea/subsys + path: repo/subsys + + - name: Configure subsys + # configure cmake for subsys in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_subsys -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/subsys + + - name: Build subsys + run: cmake --build ${{github.workspace}}/build_subsys --config ${{env.BUILD_TYPE}} + + - name: Install subsys + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_subsys + + # ---------------------------------------------------------------- + + - name: Clone refcnt + uses: actions/checkout@v3 + with: + repository: Rconybea/refcnt + path: repo/refcnt + + - name: Configure refcnt + # configure cmake for refcnt in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_refcnt -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/refcnt + + - name: Build refcnt + run: cmake --build ${{github.workspace}}/build_refcnt --config ${{env.BUILD_TYPE}} + + - name: Install refcnt + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_refcnt + + # ---------------------------------------------------------------- + + - name: Clone reflect + uses: actions/checkout@v3 + with: + repository: Rconybea/reflect + path: repo/reflect + + - name: Configure reflect + # configure cmake for reflect in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_reflect -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/reflect + + - name: Build reflect + run: cmake --build ${{github.workspace}}/build_reflect --config ${{env.BUILD_TYPE}} + + - name: Install reflect + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_reflect + + # ---------------------------------------------------------------- + + - name: Clone reactor + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-reactor + path: repo/reactor + + - name: Configure reactor + # configure cmake for reactor in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_reactor -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/reactor + + - name: Build reactor + run: cmake --build ${{github.workspace}}/build_reactor --config ${{env.BUILD_TYPE}} + + - name: Install reactor + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_reactor + + # ---------------------------------------------------------------- + + - name: Clone printjson + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-printjson + path: repo/printjson + + - name: Configure printjson + # configure cmake for printjson in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_printjson -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/printjson + + - name: Build printjson + run: cmake --build ${{github.workspace}}/build_printjson --config ${{env.BUILD_TYPE}} + + - name: Install printjson + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_printjson + + # ---------------------------------------------------------------- + + - name: Clone pyutil + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-pyutil + path: repo/pyutil + + - name: Configure pyutil + # configure cmake for pyutil in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_pyutil -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/pyutil + + - name: Build pyutil + run: cmake --build ${{github.workspace}}/build_pyutil --config ${{env.BUILD_TYPE}} + + - name: Install pyutil + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_pyutil + + # ---------------------------------------------------------------- + + - name: Clone pyreflect + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-pyreflect + path: repo/pyreflect + + - name: Configure pyreflect + # configure cmake for pyreflect in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_pyreflect -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/pyreflect + + - name: Build pyreflect + run: cmake --build ${{github.workspace}}/build_pyreflect --config ${{env.BUILD_TYPE}} + + - name: Install pyreflect + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_pyreflect + + # ---------------------------------------------------------------- + + - name: Clone pyprintjson + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-pyprintjson + path: repo/pyprintjson + + - name: Configure pyprintjson + # configure cmake for pyprintjson in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_pyprintjson -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/pyprintjson + + - name: Build pyprintjson + run: cmake --build ${{github.workspace}}/build_pyprintjson --config ${{env.BUILD_TYPE}} + + - name: Install pyprintjson + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_pyprintjson + + # ---------------------------------------------------------------- + + - name: Configure self (pyreactor) + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + run: cmake -B ${{github.workspace}}/build_pyreactor -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Build self (pyreactor) + # Build your program with the given configuration + run: cmake --build ${{github.workspace}}/build_pyreactor --config ${{env.BUILD_TYPE}} + + - name: Test self (pyreactor) + working-directory: ${{github.workspace}}/build_pyreactor + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C ${{env.BUILD_TYPE}} From 5c4fb100563be70ea675e3b00436c920197720be Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:22:20 -0400 Subject: [PATCH 04/18] github: + missing webutil dep --- .github/workflows/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3bde7ce1..c05316bf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,6 +123,25 @@ jobs: # ---------------------------------------------------------------- + - name: Clone webutil + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-webutil + path: repo/webutil + + - name: Configure webutil + # configure cmake for webutil in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_webutil -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/webutil + + - name: Build webutil + run: cmake --build ${{github.workspace}}/build_webutil --config ${{env.BUILD_TYPE}} + + - name: Install webutil + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_webutil + + # ---------------------------------------------------------------- + - name: Clone reactor uses: actions/checkout@v3 with: From 0653f4f69ed9a8fd2a80850de8292fd0cd9c1be8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:24:36 -0400 Subject: [PATCH 05/18] github: + missing callback dep --- .github/workflows/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c05316bf..ffcf823b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,6 +123,25 @@ jobs: # ---------------------------------------------------------------- + - name: Clone callback + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-callback + path: repo/callback + + - name: Configure callback + # configure cmake for callback in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_callback -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/callback + + - name: Build callback + run: cmake --build ${{github.workspace}}/build_callback --config ${{env.BUILD_TYPE}} + + - name: Install callback + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_callback + + # ---------------------------------------------------------------- + - name: Clone webutil uses: actions/checkout@v3 with: From a97de592dfb37033ad828ced22157049b762c6c0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:29:50 -0400 Subject: [PATCH 06/18] github: fix dep ordering --- .github/workflows/main.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ffcf823b..7f1a931a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -161,25 +161,6 @@ jobs: # ---------------------------------------------------------------- - - name: Clone reactor - uses: actions/checkout@v3 - with: - repository: Rconybea/xo-reactor - path: repo/reactor - - - name: Configure reactor - # configure cmake for reactor in dedicated build directory. - run: cmake -B ${{github.workspace}}/build_reactor -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/reactor - - - name: Build reactor - run: cmake --build ${{github.workspace}}/build_reactor --config ${{env.BUILD_TYPE}} - - - name: Install reactor - # install into ${{github.workspace}}/local - run: cmake --install ${{github.workspace}}/build_reactor - - # ---------------------------------------------------------------- - - name: Clone printjson uses: actions/checkout@v3 with: @@ -199,6 +180,25 @@ jobs: # ---------------------------------------------------------------- + - name: Clone reactor + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-reactor + path: repo/reactor + + - name: Configure reactor + # configure cmake for reactor in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_reactor -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/reactor + + - name: Build reactor + run: cmake --build ${{github.workspace}}/build_reactor --config ${{env.BUILD_TYPE}} + + - name: Install reactor + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_reactor + + # ---------------------------------------------------------------- + - name: Clone pyutil uses: actions/checkout@v3 with: From def29aeb9684836066c9d1f5ed8f67d23620e802 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:36:39 -0400 Subject: [PATCH 07/18] github: + missing dep randomgen --- .github/workflows/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f1a931a..6d8ba190 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -180,6 +180,25 @@ jobs: # ---------------------------------------------------------------- + - name: Clone randomgen + uses: actions/checkout@v3 + with: + repository: Rconybea/randomgen + path: repo/randomgen + + - name: Configure randomgen + # configure cmake for randomgen in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_randomgen -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/randomgen + + - name: Build randomgen + run: cmake --build ${{github.workspace}}/build_randomgen --config ${{env.BUILD_TYPE}} + + - name: Install randomgen + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_randomgen + + # ---------------------------------------------------------------- + - name: Clone reactor uses: actions/checkout@v3 with: From 45d799bd3648a5b507ef5b2598894948aa588837 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Oct 2023 17:42:50 -0400 Subject: [PATCH 08/18] github: + missing xo-ordinaltree dep --- .github/workflows/main.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d8ba190..fb304ec2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -199,6 +199,25 @@ jobs: # ---------------------------------------------------------------- + - name: Clone ordinaltree + uses: actions/checkout@v3 + with: + repository: Rconybea/xo-ordinaltree + path: repo/ordinaltree + + - name: Configure ordinaltree + # configure cmake for ordinaltree in dedicated build directory. + run: cmake -B ${{github.workspace}}/build_ordinaltree -DCMAKE_MODULE_PATH=${{github.workspace}}/local/share/cmake -DCMAKE_PREFIX_PATH=${{github.workspace}}/local -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/local repo/ordinaltree + + - name: Build ordinaltree + run: cmake --build ${{github.workspace}}/build_ordinaltree --config ${{env.BUILD_TYPE}} + + - name: Install ordinaltree + # install into ${{github.workspace}}/local + run: cmake --install ${{github.workspace}}/build_ordinaltree + + # ---------------------------------------------------------------- + - name: Clone reactor uses: actions/checkout@v3 with: From 5553fe5f706eb87bf2af158002720e355dbde910 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 22 Oct 2023 14:55:03 -0400 Subject: [PATCH 09/18] pyreactor: + pyprintjson dep --- src/pyreactor/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pyreactor/CMakeLists.txt b/src/pyreactor/CMakeLists.txt index ad752e96..b7d5695f 100644 --- a/src/pyreactor/CMakeLists.txt +++ b/src/pyreactor/CMakeLists.txt @@ -6,3 +6,4 @@ set(SELF_SRCS pyreactor.cpp) xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) xo_pybind11_dependency(${SELF_LIB} reactor) +xo_pybind11_header_dependency(${SELF_LIB} pyprintjson) From db01f8cefc350e9053f9f01cff9909e966e059a4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 22 Oct 2023 20:26:27 -0400 Subject: [PATCH 10/18] bugfix: varname in .hpp template --- src/pyreactor/pyreactor.hpp.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pyreactor/pyreactor.hpp.in b/src/pyreactor/pyreactor.hpp.in index edbb2e78..140ded1b 100644 --- a/src/pyreactor/pyreactor.hpp.in +++ b/src/pyreactor/pyreactor.hpp.in @@ -8,18 +8,18 @@ * example: * PYBIND11_MODULE(PYREACTOR_MODULE_NAME(), m) { ... } */ -#define PYREACTOR_MODULE_NAME() @SELF_LIBRARY_NAME@ +#define PYREACTOR_MODULE_NAME() @SELF_LIB@ /* example: * py::module_::import(PYREACTOR_MODULE_NAME_STR) */ -#define PYREACTOR_MODULE_NAME_STR "@SELF_LIBRARY_NAME@" +#define PYREACTOR_MODULE_NAME_STR "@SELF_LIB@" /* example: * PYREACTOR_IMPORT_MODULE() * replaces * py::module_::import("pyreactor") */ -#define PYREACTOR_IMPORT_MODULE() py::module_::import("@SELF_LIBRARY_NAME@") +#define PYREACTOR_IMPORT_MODULE() py::module_::import("@SELF_LIB@") /* end pyreactor.hpp */ From 52df00721c19179e9f53a5391cf1c3a4e0cfc350 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Oct 2023 16:39:27 -0400 Subject: [PATCH 11/18] bugfix: SELF_LIBRARY_NAME->SELF_LIB in .hpp.in --- src/pyreactor/pyreactor.cpp | 4 ++-- src/pyreactor/pyreactor.hpp.in | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pyreactor/pyreactor.cpp b/src/pyreactor/pyreactor.cpp index 5f8cf77b..a5120f96 100644 --- a/src/pyreactor/pyreactor.cpp +++ b/src/pyreactor/pyreactor.cpp @@ -1,4 +1,4 @@ -/* @file ReactorPy.cpp */ +/* @file pyreactor.cpp */ #include "pyreactor.hpp" #include "xo/pyprintjson/pyprintjson.hpp" @@ -138,4 +138,4 @@ namespace xo { } /*namespace reactor*/ } /*namespace xo*/ -/* end ReactorPy.cpp */ +/* end pyreactor.cpp */ diff --git a/src/pyreactor/pyreactor.hpp.in b/src/pyreactor/pyreactor.hpp.in index edbb2e78..140ded1b 100644 --- a/src/pyreactor/pyreactor.hpp.in +++ b/src/pyreactor/pyreactor.hpp.in @@ -8,18 +8,18 @@ * example: * PYBIND11_MODULE(PYREACTOR_MODULE_NAME(), m) { ... } */ -#define PYREACTOR_MODULE_NAME() @SELF_LIBRARY_NAME@ +#define PYREACTOR_MODULE_NAME() @SELF_LIB@ /* example: * py::module_::import(PYREACTOR_MODULE_NAME_STR) */ -#define PYREACTOR_MODULE_NAME_STR "@SELF_LIBRARY_NAME@" +#define PYREACTOR_MODULE_NAME_STR "@SELF_LIB@" /* example: * PYREACTOR_IMPORT_MODULE() * replaces * py::module_::import("pyreactor") */ -#define PYREACTOR_IMPORT_MODULE() py::module_::import("@SELF_LIBRARY_NAME@") +#define PYREACTOR_IMPORT_MODULE() py::module_::import("@SELF_LIB@") /* end pyreactor.hpp */ From 5529e36b8136e98af4cba7c58767c88f1dc3c7e2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Oct 2023 17:08:20 -0400 Subject: [PATCH 12/18] build: pyreactor -> xo_pyreactor --- src/pyreactor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyreactor/CMakeLists.txt b/src/pyreactor/CMakeLists.txt index b7d5695f..501a2572 100644 --- a/src/pyreactor/CMakeLists.txt +++ b/src/pyreactor/CMakeLists.txt @@ -1,6 +1,6 @@ # xo_pyreactor/src/pyreactor/CMakeLists.txt -set(SELF_LIB pyreactor) +set(SELF_LIB xo_pyreactor) set(SELF_SRCS pyreactor.cpp) xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) From 037b34d9e903e11ba53b23dcf384527ba7a6b214 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Oct 2023 17:25:44 -0400 Subject: [PATCH 13/18] build: pyprintjson -> xo-pyprintjson --- src/pyreactor/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pyreactor/CMakeLists.txt b/src/pyreactor/CMakeLists.txt index 501a2572..686e0b69 100644 --- a/src/pyreactor/CMakeLists.txt +++ b/src/pyreactor/CMakeLists.txt @@ -6,4 +6,4 @@ set(SELF_SRCS pyreactor.cpp) xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) xo_pybind11_dependency(${SELF_LIB} reactor) -xo_pybind11_header_dependency(${SELF_LIB} pyprintjson) +xo_pybind11_header_dependency(${SELF_LIB} xo_pyprintjson) From 20475c59e194b2fd1a73779cdfd7193273d2d3e4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 15 Mar 2024 19:37:32 -0400 Subject: [PATCH 14/18] build: streamline CMAKE_MODULE_PATH interaction --- .gitignore | 2 +- CMakeLists.txt | 3 +-- EXAMPLES | 12 ++++++++++++ README.md | 11 +++++++++++ cmake/xo-bootstrap-macros.cmake | 12 ++++++++++++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 EXAMPLES create mode 100644 cmake/xo-bootstrap-macros.cmake diff --git a/.gitignore b/.gitignore index f52f1311..53a9c92f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # lsp keeps state here .cache # typical build directory -build +.build* # lsp: symlink to file in build directory (established manually) compile_commands.json diff --git a/CMakeLists.txt b/CMakeLists.txt index aec8d379..773425bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,8 +6,7 @@ project(xo_pyreactor VERSION 1.0) enable_language(CXX) # common XO cmake macros (see github.com:Rconybea/xo-cmake) -include(xo_macros/xo_cxx) -include(xo_macros/code-coverage) +include(cmake/xo-bootstrap-macros.cmake) # ---------------------------------------------------------------- # unit test setup diff --git a/EXAMPLES b/EXAMPLES new file mode 100644 index 00000000..4b67a31a --- /dev/null +++ b/EXAMPLES @@ -0,0 +1,12 @@ +* see ../process_py/README + +>>> import reactor_py +>>> p=reactor_py.make_realization_printer() +>>> p + +>>> + +>>> import inspect +>>> inspect.getmro(reactor_py.SinkToConsole) + +>>> dir(reactor_py) diff --git a/README.md b/README.md index f618c641..bda29b5f 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,17 @@ $ make install ``` (also see .github/workflows/main.yml) +## Examples + +Assumes `xo-pyreactor` installed to `~/local2/lib` +``` +PYTHONPATH=~/local2/lib:$PYTHONPATH python +>>> import xo_pyreactor +>>> dir(xo_pyreactor) +['AbstractEventProcessor', 'AbstractEventStore', 'AbstractSink', 'AbstractSource', 'CallbackId', 'Reactor', 'ReactorSource', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'time2str'] +>>> +``` + ## Development ### build for unit test coverage diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..16644435 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,12 @@ +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + # default to typical install location for xo-project-macros + set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) +endif() + +message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") +message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo-project-macros) From cc5c53d470f943f3db4935f52a1c2a8e7e3af4d3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 29 Mar 2024 14:33:41 -0400 Subject: [PATCH 15/18] build: suppress bootstrap message in submodule build --- cmake/xo-bootstrap-macros.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake index 16644435..96592216 100644 --- a/cmake/xo-bootstrap-macros.cmake +++ b/cmake/xo-bootstrap-macros.cmake @@ -3,8 +3,10 @@ if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "pr set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) endif() -message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") -message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") +if (NOT XO_SUBMODULE_BUILD) + message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") + message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") +endif() # needs to have been installed somewhere on CMAKE_MODULE_PATH, # (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) From a3e3f381c2e091c2a33fbb15fed0c137b8a1061a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 13:57:59 -0500 Subject: [PATCH 16/18] xo-pyreactor: build: update to latest xo-cmake macros --- CMakeLists.txt | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 773425bb..6d47faed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,25 +3,11 @@ cmake_minimum_required(VERSION 3.10) project(xo_pyreactor VERSION 1.0) -enable_language(CXX) -# common XO cmake macros (see github.com:Rconybea/xo-cmake) +include(GNUInstallDirs) include(cmake/xo-bootstrap-macros.cmake) -# ---------------------------------------------------------------- -# unit test setup - -enable_testing() -# activate code coverage for all executables + libraries (when configured with -DCODE_COVERAGE=ON) -add_code_coverage() -# 1. assuming that /nix/store/ prefixes .hpp files belonging to gcc, catch2 etc. -# we're not interested in code coverage for these sources. -# 2. exclude the utest/ subdir, we don't need coverage on the unit tests themselves; -# rather, want coverage on the code that the unit tests exercise. -# -# NOTE: this seems to work only with the 'ccov-all' target. In particular, doesn't seem to do anything with the 'ccov' target -# -add_code_coverage_all_targets(EXCLUDE /nix/store/* ${PROJECT_SOURCE_DIR}/utest/* ${PROJECT_BINARY_DIR}/local/* ${PROJECT_SOURCE_DIR}/repo/*) +xo_cxx_toplevel_options3() # ---------------------------------------------------------------- # c++ settings (usually temporary) @@ -29,8 +15,6 @@ add_code_coverage_all_targets(EXCLUDE /nix/store/* ${PROJECT_SOURCE_DIR}/utest/* set(PROJECT_CXX_FLAGS "") add_definitions(${PROJECT_CXX_FLAGS}) -xo_toplevel_compile_options() - # ---------------------------------------------------------------- # sources From d02fa163246d63954ef783351c456fc5f794452f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 13:58:13 -0500 Subject: [PATCH 17/18] xo-pyreactor: update to latest cmake bootstrap --- cmake/xo-bootstrap-macros.cmake | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake index 96592216..aba31169 100644 --- a/cmake/xo-bootstrap-macros.cmake +++ b/cmake/xo-bootstrap-macros.cmake @@ -1,14 +1,35 @@ -if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) - # default to typical install location for xo-project-macros - set(CMAKE_MODULE_PATH ${CMAKE_INSTALL_PREFIX}/share/cmake) +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if ("${XO_CMAKE_CONFIG_EXECUTABLE}" STREQUAL "XO_CMAKE_CONFIG_EXECUTABLE-NOT_FOUND") + message(FATAL "could not find xo-cmake-config executable") endif() +message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}") + if (NOT XO_SUBMODULE_BUILD) - message("-- CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") - message("-- CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() endif() # needs to have been installed somewhere on CMAKE_MODULE_PATH, # (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) # -include(xo_macros/xo-project-macros) +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() From 50b8d529a764dea6b48f3df33a8de7a1e8412009 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 13:58:36 -0500 Subject: [PATCH 18/18] xo-pyreactor: xo::ref::rp -> xo::rp --- src/pyreactor/CMakeLists.txt | 1 - src/pyreactor/pyreactor.cpp | 11 +++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/pyreactor/CMakeLists.txt b/src/pyreactor/CMakeLists.txt index 686e0b69..fa30e71d 100644 --- a/src/pyreactor/CMakeLists.txt +++ b/src/pyreactor/CMakeLists.txt @@ -4,6 +4,5 @@ set(SELF_LIB xo_pyreactor) set(SELF_SRCS pyreactor.cpp) xo_pybind11_library(${SELF_LIB} ${PROJECT_NAME}Targets ${SELF_SRCS}) - xo_pybind11_dependency(${SELF_LIB} reactor) xo_pybind11_header_dependency(${SELF_LIB} xo_pyprintjson) diff --git a/src/pyreactor/pyreactor.cpp b/src/pyreactor/pyreactor.cpp index a5120f96..f28e610d 100644 --- a/src/pyreactor/pyreactor.cpp +++ b/src/pyreactor/pyreactor.cpp @@ -22,7 +22,6 @@ namespace xo { using xo::json::PrintJsonSingleton; using xo::fn::CallbackId; using xo::ref::Refcount; - using xo::ref::rp; using xo::time::utc_nanos; using xo::tostr; namespace py = pybind11; @@ -42,7 +41,7 @@ namespace xo { py::class_(m, "CallbackId"); py::class_>(m, "AbstractEventProcessor") + xo::rp>(m, "AbstractEventProcessor") .def_property("name", &AbstractEventProcessor::name, &AbstractEventProcessor::set_name) @@ -53,7 +52,7 @@ namespace xo { py::class_>(m, "AbstractSource") + xo::rp>(m, "AbstractSource") .def_property_readonly("source_ev_type", &AbstractSource::source_ev_type) .def_property_readonly("is_volatile", &AbstractSource::is_volatile) .def_property_readonly("n_out_ev", &AbstractSource::n_out_ev) @@ -68,7 +67,7 @@ namespace xo { py::class_>(m, "AbstractSink") + xo::rp>(m, "AbstractSink") //.cdef("__repr__", &AbstractSink::display_string) .def_property_readonly("sink_ev_type", &AbstractSink::sink_ev_type) .def_property_readonly("n_in_ev", &AbstractSink::n_in_ev) @@ -76,7 +75,7 @@ namespace xo { py::class_> + xo::rp> (m, "ReactorSource") .def_property_readonly("is_empty", &ReactorSource::is_empty) .def_property_readonly("is_nonempty", &ReactorSource::is_nonempty) @@ -131,7 +130,7 @@ namespace xo { py::class_>, AbstractSink, - xo::ref::rp>>> + xo::rp>>> (m, "SinkToConsole"); #endif } /*pyreactor*/