From af8b0d4a4675a708678a2c594027b2452b0955b7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Jun 2024 10:55:57 -0400 Subject: [PATCH 1/7] xo-pyreflect: build: streamline cmake --- CMakeLists.txt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d84942e..427a56b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,22 +5,10 @@ cmake_minimum_required(VERSION 3.10) project(xo_pyreflect VERSION 0.1) enable_language(CXX) +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) @@ -28,8 +16,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 00025a66e43416b907dc66c6de0a4c2af4e5ba55 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Jun 2024 10:56:29 -0400 Subject: [PATCH 2/7] xo-pyreflect: + TypeDescr.lookup_by_name() --- src/pyreflect/pyreflect.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index fc6e8fe8..f93b4634 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -28,6 +28,8 @@ namespace xo { //py::class_(m, "TypeDescr"); py::class_>(m, "TypeDescr") + + .def_static("lookup_by_name", &TypeDescrBase::lookup_by_name) .def_static("print_reflected_types", [](){ TypeDescrBase::print_reflected_types(std::cout); }) .def_property_readonly("canonical_name", &TypeDescrBase::canonical_name) From 50d3d32fc3a5900c3c8b516e6a38bb3d2b99f940 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Jun 2024 10:56:53 -0400 Subject: [PATCH 3/7] xo-pyreflect: + TypeDescr.short_name --- src/pyreflect/pyreflect.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index f93b4634..9447a4cd 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -33,6 +33,7 @@ namespace xo { .def_static("print_reflected_types", [](){ TypeDescrBase::print_reflected_types(std::cout); }) .def_property_readonly("canonical_name", &TypeDescrBase::canonical_name) + .def_property_readonly("short_name", &TypeDescrBase::short_name) .def("__repr__", &TypeDescrBase::display_string); /* note: this means python will use From e57ba44ae72b4f2218b1a6fad249479bc5cca521 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Jun 2024 10:57:14 -0400 Subject: [PATCH 4/7] xo-pyreflect: + TypeDescr.complete_flag --- src/pyreflect/pyreflect.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index 9447a4cd..cf65d3d1 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -34,6 +34,7 @@ namespace xo { [](){ TypeDescrBase::print_reflected_types(std::cout); }) .def_property_readonly("canonical_name", &TypeDescrBase::canonical_name) .def_property_readonly("short_name", &TypeDescrBase::short_name) + .def_property_readonly("complete_flag", &TypeDescrBase::complete_flag) .def("__repr__", &TypeDescrBase::display_string); /* note: this means python will use From bd8c2c4e13fa96efd0bfe6a826b42390c0c19d34 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Jun 2024 10:57:40 -0400 Subject: [PATCH 5/7] xo-pyreflect: bind Metatype; + TypeDescr.metatype --- src/pyreflect/pyreflect.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index cf65d3d1..a77993a5 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -22,6 +22,17 @@ namespace xo { namespace reflect { PYBIND11_MODULE(PYREFLECT_MODULE_NAME(), m) { + m.doc() = "pybind11 plugin for xo-reflect"; + + py::enum_(m, "Metatype") + .value("invalid", Metatype::mt_invalid) + .value("atomic", Metatype::mt_atomic) + .value("pointer", Metatype::mt_pointer) + .value("vector", Metatype::mt_vector) + .value("struct", Metatype::mt_struct) + .value("function", Metatype::mt_function) + ; + /* note: possibly move this to pytime/ if/when we provide it */ //py::class_(m, "utc_nanos"); @@ -32,8 +43,10 @@ namespace xo { .def_static("lookup_by_name", &TypeDescrBase::lookup_by_name) .def_static("print_reflected_types", [](){ TypeDescrBase::print_reflected_types(std::cout); }) + .def_property_readonly("canonical_name", &TypeDescrBase::canonical_name) .def_property_readonly("short_name", &TypeDescrBase::short_name) + .def_property_readonly("metatype", &TypeDescrBase::metatype) .def_property_readonly("complete_flag", &TypeDescrBase::complete_flag) .def("__repr__", &TypeDescrBase::display_string); From 76f5e4cacabc26ef72d652f0735cb0a3f1f43904 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Jun 2024 10:58:26 -0400 Subject: [PATCH 6/7] xo-preflect: ++ .gitignore (+ .projectile file) --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 53a9c92f..2d66a655 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +# emacs workspace config +.projectile # lsp keeps state here .cache # typical build directory From c3115779979a08c221ff61cf6bb8f20e94b8b1a9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Sep 2024 11:55:10 -0500 Subject: [PATCH 7/7] xo-pyreflect: bugfix: track ns change xo::ref::rp -> xo::rp --- src/pyreflect/pyreflect.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pyreflect/pyreflect.cpp b/src/pyreflect/pyreflect.cpp index ac5ef86e..846e8cba 100644 --- a/src/pyreflect/pyreflect.cpp +++ b/src/pyreflect/pyreflect.cpp @@ -16,7 +16,6 @@ namespace xo { using xo::time::utc_nanos; using xo::ref::unowned_ptr; - using xo::ref::rp; namespace py = pybind11; namespace reflect {